Skip to content

Commit

Permalink
Merge pull request #57 from creative-commoners/pulls/2/sapphire-test-…
Browse files Browse the repository at this point in the history
…nine

API phpunit 9 support
  • Loading branch information
Maxime Rainville authored Nov 2, 2021
2 parents 4ccabdf + c35df1c commit a29de58
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@
"license": "BSD-3-Clause",
"minimum-stability": "dev",
"require": {
"php": "^7.3 || ^8.0",
"league/csv": "^8 || ^9",
"silverstripe/framework": "^4",
"silverstripe/framework": "^4.10",
"symbiote/silverstripe-queuedjobs": "^4"
},
"require-dev": {
"sminnee/phpunit": "^5.7",
"phpunit/phpunit": "^9.5",
"squizlabs/php_codesniffer": "^3.0"
},
"extra": {
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
16 changes: 8 additions & 8 deletions tests/GenerateCSVJobTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class GenerateCSVJobTest extends SapphireTest

protected static $extra_controllers = [GenerateCSVJobTestController::class];

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

Expand All @@ -32,7 +32,7 @@ protected function setUp()

protected $paths = [];

protected function tearDown()
protected function tearDown(): void
{
foreach ($this->paths as $path) {
Filesystem::removeFolder(dirname($path));
Expand All @@ -57,7 +57,7 @@ public function testGenerateExport()
$this->paths[] = $path; // Mark for cleanup later

// Test that the job runs
$this->assertFileNotExists($path);
$this->assertFileDoesNotExist($path);
$job->setup();
$job->process();
$job->afterComplete();
Expand All @@ -72,8 +72,8 @@ public function testGenerateExport()
];
$actual = file_get_contents($path);
// Note: strtolower() is for case insensitive comparison, since field label casing changed in SS 4.3
$this->assertContains('title,content,"publish on"', strtolower($actual));
$this->assertContains(implode("\r\n", $expected), $actual);
$this->assertStringContainsString('title,content,"publish on"', strtolower($actual));
$this->assertStringContainsString(implode("\r\n", $expected), $actual);
}

public function testGenerateExportOverMultipleSteps()
Expand All @@ -96,7 +96,7 @@ public function testGenerateExportOverMultipleSteps()
$this->paths[] = $path; // Mark for cleanup later

// Test that the job runs
$this->assertFileNotExists($path);
$this->assertFileDoesNotExist($path);
$count = 0;
while (!$job->jobFinished()) {
++$count;
Expand All @@ -120,8 +120,8 @@ public function testGenerateExportOverMultipleSteps()
];
$actual = file_get_contents($path);
// Note: strtolower() is for case insensitive comparison, since field label casing changed in SS 4.3
$this->assertContains('title,content,"publish on"', strtolower($actual));
$this->assertContains(implode("\r\n", $expected), $actual);
$this->assertStringContainsString('title,content,"publish on"', strtolower($actual));
$this->assertStringContainsString(implode("\r\n", $expected), $actual);
}

/**
Expand Down

0 comments on commit a29de58

Please sign in to comment.