Merge pull request #65 from creative-commoners/pulls/3/sapphire-test-nine

API phpunit 9 support
This commit is contained in:
Maxime Rainville 2021-11-01 22:37:19 +13:00 committed by GitHub
commit eb36dcf5fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 22 additions and 19 deletions

View File

@ -20,14 +20,15 @@
}
],
"require": {
"silverstripe/framework": "^4",
"php": "^7.3 || ^8.0",
"silverstripe/framework": "^4.10",
"silverstripe/assets": "^1",
"silverstripe/versioned": "^1",
"guzzlehttp/guzzle": "~6.3.0"
},
"require-dev": {
"squizlabs/php_codesniffer": "^3",
"sminnee/phpunit": "^5.7"
"phpunit/phpunit": "^9.5"
},
"autoload": {
"psr-4": {

View File

@ -1,7 +1,9 @@
<phpunit bootstrap="vendor/silverstripe/framework/tests/bootstrap.php" colors="true">
<testsuite name="Default">
<directory>tests/</directory>
</testsuite>
<testsuites>
<testsuite name="Default">
<directory>tests/</directory>
</testsuite>
</testsuites>
<filter>
<whitelist addUncoveredFilesFromWhitelist="true">

View File

@ -18,7 +18,7 @@ class FileTextExtractableTest extends SapphireTest
],
];
protected function setUp()
protected function setUp(): void
{
parent::setUp();
@ -33,7 +33,7 @@ class FileTextExtractableTest extends SapphireTest
);
}
protected function tearDown()
protected function tearDown(): void
{
if (file_exists(dirname(__FILE__) . '/fixtures/test1-copy.html')) {
unlink(dirname(__FILE__) . '/fixtures/test1-copy.html');
@ -53,8 +53,8 @@ class FileTextExtractableTest extends SapphireTest
$content = $file->extractFileAsText();
$this->assertNotNull($content);
$this->assertContains('Test Headline', $content);
$this->assertContains('Test Text', $content);
$this->assertStringContainsString('Test Headline', $content);
$this->assertStringContainsString('Test Text', $content);
$this->assertEquals($content, $file->FileContentCache);
}
}

View File

@ -11,7 +11,7 @@ class HTMLTextExtractorTest extends SapphireTest
{
protected $usesDatabase = true;
protected function setUp()
protected function setUp(): void
{
parent::setUp();
@ -28,9 +28,9 @@ class HTMLTextExtractorTest extends SapphireTest
$content = $extractor->getContent($file);
$this->assertContains('Test Headline', $content);
$this->assertNotContains('Test Comment', $content, 'Strips HTML comments');
$this->assertNotContains('Test Style', $content, 'Strips non-content style tags');
$this->assertNotContains('Test Script', $content, 'Strips non-content script tags');
$this->assertStringContainsString('Test Headline', $content);
$this->assertStringNotContainsString('Test Comment', $content, 'Strips HTML comments');
$this->assertStringNotContainsString('Test Style', $content, 'Strips non-content style tags');
$this->assertStringNotContainsString('Test Script', $content, 'Strips non-content script tags');
}
}

View File

@ -24,6 +24,6 @@ class PDFTextExtractorTest extends SapphireTest
$file->write();
$content = $extractor->getContent($file);
$this->assertContains('This is a test file with a link', $content);
$this->assertStringContainsString('This is a test file with a link', $content);
}
}

View File

@ -2,7 +2,7 @@
namespace SilverStripe\TextExtraction\Tests;
use PHPUnit_Framework_MockObject_MockObject;
use PHPUnit\Framework\MockObject\MockObject;
use SilverStripe\Assets\File;
use SilverStripe\Dev\SapphireTest;
use SilverStripe\TextExtraction\Extractor\TikaServerTextExtractor;
@ -28,7 +28,7 @@ class TikaServerTextExtractorTest extends SapphireTest
$file->write();
$content = $extractor->getContent($file);
$this->assertContains('This is a test file with a link', $content);
$this->assertStringContainsString('This is a test file with a link', $content);
// Check mime validation
$this->assertTrue($extractor->supportsMime('application/pdf'));
@ -43,7 +43,7 @@ class TikaServerTextExtractorTest extends SapphireTest
*/
public function testIsAvailable($version, $expected)
{
/** @var PHPUnit_Framework_MockObject_MockObject|TikaServerTextExtractor $extractor */
/** @var MockObject|TikaServerTextExtractor $extractor */
$extractor = $this->getMockBuilder(TikaServerTextExtractor::class)
->setMethods(['getClient', 'getServerEndpoint'])
->getMock();

View File

@ -28,7 +28,7 @@ class TikaTextExtractorTest extends SapphireTest
$file->write();
$content = $extractor->getContent($file);
$this->assertContains('This is a test file with a link', $content);
$this->assertStringContainsString('This is a test file with a link', $content);
// Check mime validation
$this->assertTrue($extractor->supportsMime('application/pdf'));