diff --git a/composer.json b/composer.json index 76843b7f..4e0133e5 100644 --- a/composer.json +++ b/composer.json @@ -22,12 +22,12 @@ ], "require": { "silverstripe/admin": "^1.5", - "silverstripe/framework": "^4.5", + "silverstripe/framework": "^4.10", "silverstripe/versioned": "^1.5", "silverstripe/vendor-plugin": "^1.0" }, "require-dev": { - "sminnee/phpunit": "^5.7", + "phpunit/phpunit": "^9", "squizlabs/php_codesniffer": "^3", "silverstripe/asset-admin": "^1.5", "silverstripe/cms": "^4.5" diff --git a/phpunit.xml.dist b/phpunit.xml.dist index b46289aa..8d159c07 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,12 +1,9 @@ - - - tests/php - - + + + tests/php + + src/ diff --git a/tests/behat/src/FixtureContext.php b/tests/behat/src/FixtureContext.php index 871bac76..e332c677 100644 --- a/tests/behat/src/FixtureContext.php +++ b/tests/behat/src/FixtureContext.php @@ -4,6 +4,7 @@ use Behat\Mink\Element\DocumentElement; use Behat\Mink\Element\NodeElement; +use PHPUnit\Framework\Assert; use SilverStripe\BehatExtension\Context\FixtureContext as BaseFixtureContext; use SilverStripe\BehatExtension\Utility\StepHelper; use SilverStripe\MinkFacebookWebDriver\FacebookWebDriver; @@ -24,7 +25,7 @@ public function iShouldSeeTheCampaign($name) { $item = $this->getCampaign($name); - assertNotNull($item, "Could not find campaign \"$name\" in the list"); + Assert::assertNotNull($item, "Could not find campaign \"$name\" in the list"); } /** @@ -35,7 +36,7 @@ public function iShouldNotSeeTheCampaign($name) { $item = $this->getCampaign($name); - assertNull($item, "Found campaign \"$name\" in the list"); + Assert::assertNull($item, "Found campaign \"$name\" in the list"); } /** @@ -47,11 +48,11 @@ public function iShouldNotSeeTheCampaign($name) public function iShouldSeeInTheCampaignColumn($text, $column, $name) { $campaignRow = $this->getCampaign($name); - assertNotNull($campaignRow, sprintf('Could not find campaign "%s"', $name)); + Assert::assertNotNull($campaignRow, sprintf('Could not find campaign "%s"', $name)); $cell = $campaignRow->find('xpath', "/td[{$column}][contains(text(), '{$text}')]"); - assertNotNull($cell, sprintf('Could not find "%s" in column %d of "%s"', $text, $column, $name)); + Assert::assertNotNull($cell, sprintf('Could not find "%s" in column %d of "%s"', $text, $column, $name)); } /** @@ -61,7 +62,7 @@ public function iShouldSeeInTheCampaignColumn($text, $column, $name) public function iViewTheCampaign($name) { $item = $this->getCampaign($name); - assertNotNull($item, sprintf('Campaign %s not found', $name)); + Assert::assertNotNull($item, sprintf('Campaign %s not found', $name)); $item->find('css', 'td')->click(); } @@ -73,10 +74,10 @@ public function iViewTheCampaign($name) public function iEditTheCampaign($name) { $item = $this->getCampaign($name); - assertNotNull($item, sprintf('Campaign %s not found', $name)); + Assert::assertNotNull($item, sprintf('Campaign %s not found', $name)); $button = $item->find('css', '.font-icon-cog'); - assertNotNull($button, sprintf('Campaign %s has no edit button', $name)); + Assert::assertNotNull($button, sprintf('Campaign %s has no edit button', $name)); $button->click(); } @@ -87,10 +88,10 @@ public function iEditTheCampaign($name) public function iDeleteTheCampaign($name) { $item = $this->getCampaign($name); - assertNotNull($item, sprintf('Campaign %s not found', $name)); + Assert::assertNotNull($item, sprintf('Campaign %s not found', $name)); $button = $item->find('css', '.font-icon-cancel'); - assertNotNull($button, sprintf('Campaign %s has no delete button', $name)); + Assert::assertNotNull($button, sprintf('Campaign %s has no delete button', $name)); $button->click(); /** @var FacebookWebDriver $driver */ @@ -108,8 +109,8 @@ public function iShouldSeeTheForm($id) /** @var DocumentElement $page */ $page = $this->getMainContext()->getSession()->getPage(); $form = $page->find('css', "form#{$id}"); - assertNotNull($form, "form with id $id could not be found"); - assertTrue($form->isVisible(), "form with id $id is not visible"); + Assert::assertNotNull($form, "form with id $id could not be found"); + Assert::assertTrue($form->isVisible(), "form with id $id is not visible"); } /** @@ -135,8 +136,8 @@ public function iShouldSeeAModalTitled($title) { $page = $this->getMainContext()->getSession()->getPage(); $modalTitle = $page->find('css', '[role=dialog] .modal-header > .modal-title'); - assertNotNull($modalTitle, 'No modal on the page'); - assertTrue($modalTitle->getText() == $title); + Assert::assertNotNull($modalTitle, 'No modal on the page'); + Assert::assertTrue($modalTitle->getText() == $title); } /** @@ -147,7 +148,7 @@ public function iCloseTheModal() /** @var DocumentElement $page */ $page = $this->getMainContext()->getSession()->getPage(); $button = $page->find('css', '.modal-header .close'); - assertNotNull($button, 'Close button not found'); + Assert::assertNotNull($button, 'Close button not found'); $button->click(); } @@ -166,7 +167,7 @@ public function iClickTheGalleryItem($name) "//div[contains(@class, 'gallery-item')]//div[contains(text(), '{$name}')]" ); - assertNotNull($cell, sprintf('Gallery item "%s" could not be found', $name)); + Assert::assertNotNull($cell, sprintf('Gallery item "%s" could not be found', $name)); $cell->click(); } @@ -182,12 +183,12 @@ public function iSeeTheCampaignItem($negate, $name) $shouldSee = !trim($negate); if ($shouldSee) { - assertNotNull($item, sprintf('Item "%s" could not be found', $name)); - assertTrue($item->isVisible(), sprintf('Item "%s" is not visible', $name)); + Assert::assertNotNull($item, sprintf('Item "%s" could not be found', $name)); + Assert::assertTrue($item->isVisible(), sprintf('Item "%s" is not visible', $name)); } elseif ($item) { - assertFalse($item->isVisible(), sprintf('Item "%s" is visible', $name)); + Assert::assertFalse($item->isVisible(), sprintf('Item "%s" is visible', $name)); } else { - assertNull($item, sprintf('Item "%s" exists', $name)); + Assert::assertNull($item, sprintf('Item "%s" exists', $name)); } } @@ -198,7 +199,7 @@ public function iSeeTheCampaignItem($negate, $name) public function iSelectTheCampaignItem($name) { $item = $this->getCampaignItem($name); - assertNotNull($item, sprintf('Item "%s" could not be found', $name)); + Assert::assertNotNull($item, sprintf('Item "%s" could not be found', $name)); $item->click(); } diff --git a/tests/php/AddToCampaignValidatorTest.php b/tests/php/AddToCampaignValidatorTest.php index cae8dfc3..6d0f29f9 100644 --- a/tests/php/AddToCampaignValidatorTest.php +++ b/tests/php/AddToCampaignValidatorTest.php @@ -20,7 +20,7 @@ class AddToCampaignValidatorTest extends SapphireTest */ protected $validator = null; - protected function setUp() + protected function setUp(): void { parent::setUp(); $this->logInWithPermission('ADMIN'); diff --git a/tests/php/CampaignAdminTest.php b/tests/php/CampaignAdminTest.php index 0b048c4b..e781dad7 100644 --- a/tests/php/CampaignAdminTest.php +++ b/tests/php/CampaignAdminTest.php @@ -17,7 +17,7 @@ class CampaignAdminTest extends SapphireTest protected static $fixture_file = 'CampaignAdminTest.yml'; - protected function setUp() + protected function setUp(): void { parent::setUp(); DBDatetime::set_mock_now('2011-09-24 11:11:00');