API phpunit 9 support

This commit is contained in:
Steve Boyd 2021-10-27 18:09:34 +13:00
parent 3f8b3d1eda
commit 1b3496d66e
3 changed files with 15 additions and 12 deletions

View File

@ -11,10 +11,11 @@
} }
], ],
"require": { "require": {
"php": "^7.3 || ^8.0",
"silverstripe/cms": "^4.0" "silverstripe/cms": "^4.0"
}, },
"require-dev": { "require-dev": {
"sminnee/phpunit": "^5.7", "phpunit/phpunit": "^9.5",
"squizlabs/php_codesniffer": "^3.0" "squizlabs/php_codesniffer": "^3.0"
}, },
"autoload": { "autoload": {

View File

@ -1,7 +1,9 @@
<phpunit bootstrap="vendor/silverstripe/cms/tests/bootstrap.php" colors="true"> <phpunit bootstrap="vendor/silverstripe/cms/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">
<directory suffix=".php">src/</directory> <directory suffix=".php">src/</directory>

View File

@ -19,12 +19,12 @@ class IFramePageTest extends SapphireTest
$iframe->AutoHeight = 1; $iframe->AutoHeight = 1;
$iframe->getClass(); $iframe->getClass();
$this->assertContains('iframepage-height-auto', $iframe->getClass()); $this->assertStringContainsString('iframepage-height-auto', $iframe->getClass());
$iframe->AutoHeight = 0; $iframe->AutoHeight = 0;
$iframe->getClass(); $iframe->getClass();
$this->assertNotContains('iframepage-height-auto', $iframe->getClass()); $this->assertStringNotContainsString('iframepage-height-auto', $iframe->getClass());
} }
public function testGetStyle() public function testGetStyle()
@ -33,19 +33,19 @@ class IFramePageTest extends SapphireTest
$iframe->FixedHeight = 0; $iframe->FixedHeight = 0;
$iframe->getStyle(); $iframe->getStyle();
$this->assertContains('height: 800px', $iframe->getStyle(), 'Height defaults to 800 if not set.'); $this->assertStringContainsString('height: 800px', $iframe->getStyle(), 'Height defaults to 800 if not set.');
$iframe->FixedHeight = 100; $iframe->FixedHeight = 100;
$iframe->getStyle(); $iframe->getStyle();
$this->assertContains('height: 100px', $iframe->getStyle(), 'Fixed height is settable'); $this->assertStringContainsString('height: 100px', $iframe->getStyle(), 'Fixed height is settable');
$iframe->AutoWidth = 1; $iframe->AutoWidth = 1;
$iframe->FixedWidth = '200'; $iframe->FixedWidth = '200';
$this->assertContains('width: 100%', $iframe->getStyle(), 'Auto width overrides fixed width'); $this->assertStringContainsString('width: 100%', $iframe->getStyle(), 'Auto width overrides fixed width');
$iframe->AutoWidth = 0; $iframe->AutoWidth = 0;
$iframe->FixedWidth = '200'; $iframe->FixedWidth = '200';
$this->assertContains('width: 200px', $iframe->getStyle(), 'Fixed width is settable'); $this->assertStringContainsString('width: 200px', $iframe->getStyle(), 'Fixed width is settable');
} }
public function testAllowedUrls() public function testAllowedUrls()
@ -80,12 +80,12 @@ class IFramePageTest extends SapphireTest
foreach ($tests['allowed'] as $url) { foreach ($tests['allowed'] as $url) {
$iframe->IFrameURL = $url; $iframe->IFrameURL = $url;
$iframe->write(); $iframe->write();
$this->assertContains($iframe->IFrameURL, $url); $this->assertStringContainsString($iframe->IFrameURL, $url);
} }
foreach ($tests['banned'] as $url) { foreach ($tests['banned'] as $url) {
$iframe->IFrameURL = $url; $iframe->IFrameURL = $url;
$this->setExpectedException(ValidationException::class); $this->expectException(ValidationException::class);
$iframe->write(); $iframe->write();
} }
} }