API phpunit 9 support

This commit is contained in:
Steve Boyd 2021-10-27 18:16:05 +13:00
parent 90d4812aa8
commit b92616eb4e
7 changed files with 22 additions and 19 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -28,7 +28,7 @@ class TikaTextExtractorTest extends SapphireTest
$file->write(); $file->write();
$content = $extractor->getContent($file); $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 // Check mime validation
$this->assertTrue($extractor->supportsMime('application/pdf')); $this->assertTrue($extractor->supportsMime('application/pdf'));