Skip to content

Commit

Permalink
API phpunit 9 support
Browse files Browse the repository at this point in the history
  • Loading branch information
emteknetnz committed Oct 27, 2021
1 parent 90d4812 commit b92616e
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 19 deletions.
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
8 changes: 5 additions & 3 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -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">
Expand Down
8 changes: 4 additions & 4 deletions tests/FileTextExtractableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class FileTextExtractableTest extends SapphireTest
],
];

protected function setUp()
protected function setUp(): void
{
parent::setUp();

Expand All @@ -33,7 +33,7 @@ protected function setUp()
);
}

protected function tearDown()
protected function tearDown(): void
{
if (file_exists(dirname(__FILE__) . '/fixtures/test1-copy.html')) {
unlink(dirname(__FILE__) . '/fixtures/test1-copy.html');
Expand All @@ -53,8 +53,8 @@ public function testExtractFileAsText()

$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);
}
}
10 changes: 5 additions & 5 deletions tests/HTMLTextExtractorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class HTMLTextExtractorTest extends SapphireTest
{
protected $usesDatabase = true;

protected function setUp()
protected function setUp(): void
{
parent::setUp();

Expand All @@ -28,9 +28,9 @@ public function testExtraction()

$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');
}
}
2 changes: 1 addition & 1 deletion tests/PDFTextExtractorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ public function testExtraction()
$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);
}
}
6 changes: 3 additions & 3 deletions tests/TikaServerTextExtractorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -28,7 +28,7 @@ public function testServerExtraction()
$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'));
Expand All @@ -43,7 +43,7 @@ public function testServerExtraction()
*/
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();
Expand Down
2 changes: 1 addition & 1 deletion tests/TikaTextExtractorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function testExtraction()
$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'));
Expand Down

0 comments on commit b92616e

Please sign in to comment.