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 Nov 5, 2021
1 parent cf63ba9 commit b696fb6
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 26 deletions.
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
"cwp"
],
"require": {
"php": ">=7.1.0",
"silverstripe/framework": "^4.7",
"php": "^7.3 || ^8.0",
"silverstripe/framework": "^4.10",
"silverstripe/admin": "^1.7",
"silverstripe/hybridsessions": "^2",
"silverstripe/environmentcheck": "^2",
"silverstripe/auditor": "^2"
},
"require-dev": {
"sminnee/phpunit": "^5.7",
"phpunit/phpunit": "^9.5",
"squizlabs/php_codesniffer": "^3"
},
"autoload": {
Expand Down
30 changes: 15 additions & 15 deletions tests/AtomFeedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,36 +32,36 @@ public function testAtomFeed()
$content = $atomFeed->outputToBrowser();

//Debug::message($content);
$this->assertContains('<link href="http://www.example.org/item-a/" />', $content);
$this->assertContains('<link href="http://www.example.com/item-b.html" />', $content);
$this->assertContains('<link href="http://www.example.com/item-c.html" />', $content);
$this->assertStringContainsString('<link href="http://www.example.org/item-a/" />', $content);
$this->assertStringContainsString('<link href="http://www.example.com/item-b.html" />', $content);
$this->assertStringContainsString('<link href="http://www.example.com/item-c.html" />', $content);

$this->assertContains('<title type="html">ItemA</title>', $content);
$this->assertContains('<title type="html">ItemB</title>', $content);
$this->assertContains('<title type="html">ItemC</title>', $content);
$this->assertStringContainsString('<title type="html">ItemA</title>', $content);
$this->assertStringContainsString('<title type="html">ItemB</title>', $content);
$this->assertStringContainsString('<title type="html">ItemC</title>', $content);

$this->assertContains("\tItemA Content\n", $content);
$this->assertContains("\tItemB Content\n", $content);
$this->assertContains("\tItemC Content\n", $content);
$this->assertStringContainsString("\tItemA Content\n", $content);
$this->assertStringContainsString("\tItemB Content\n", $content);
$this->assertStringContainsString("\tItemC Content\n", $content);
}

public function testRenderWithTemplate()
{
$atomFeed = new CwpAtomFeed(new ArrayList(), "", "", "");
$content = $atomFeed->outputToBrowser();
// test we have switched from a RSS feed test template tot he AtomFeed template
$this->assertNotContains('<title>Test Custom Template</title>', $content);
$this->assertStringNotContainsString('<title>Test Custom Template</title>', $content);
}

public function testLinkToFeed()
{
$link = AtomTagsStub::linkToFeed('atomLinkUrl', 'Atom feed of this blog');
$this->assertContains('atomLinkUrl', $link);
$this->assertContains('Atom feed of this blog', $link);
$this->assertContains('application/atom+xml', $link);
$this->assertStringContainsString('atomLinkUrl', $link);
$this->assertStringContainsString('Atom feed of this blog', $link);
$this->assertStringContainsString('application/atom+xml', $link);
}

protected function setUp()
protected function setUp(): void
{
parent::setUp();
Config::modify()->set(Director::class, 'alternate_base_url', '/');
Expand All @@ -71,7 +71,7 @@ protected function setUp()
$_SERVER['HTTP_HOST'] = 'www.example.org';
}

protected function tearDown()
protected function tearDown(): void
{
parent::tearDown();
Config::modify()->set(Director::class, 'alternate_base_url', null);
Expand Down
4 changes: 2 additions & 2 deletions tests/Control/CwpBasicAuthMiddlewareTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class CwpBasicAuthMiddlewareTest extends SapphireTest
*/
protected $originalServersVars = [];

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

Expand All @@ -33,7 +33,7 @@ protected function setUp()
Config::modify()->set(BasicAuth::class, 'ignore_cli', false);
}

protected function tearDown()
protected function tearDown(): void
{
$_SERVER = $this->originalServersVars;

Expand Down
2 changes: 1 addition & 1 deletion tests/Control/InitialisationMiddlewareTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class InitialisationMiddlewareTest extends FunctionalTest

protected $usesDatabase = true;

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

Expand Down
2 changes: 1 addition & 1 deletion tests/Extension/CWPVersionExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class CWPVersionExtensionTest extends SapphireTest
*/
protected $leftAndMain;

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

Expand Down
6 changes: 2 additions & 4 deletions tests/PasswordEncryptor/PBKDF2Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,10 @@ public function testEncrypt()
);
}

/**
* @expectedException Exception
* @expectedExceptionMessage Hash algorithm "foobar" not found
*/
public function testThrowsExceptionWhenInvalidAlgorithmIsProvided()
{
$this->expectException(\Exception::class);
$this->expectExceptionMessage('');
new PBKDF2('foobar');
}
}

0 comments on commit b696fb6

Please sign in to comment.