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 1, 2021
1 parent 6031869 commit c4f5077
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 32 deletions.
13 changes: 0 additions & 13 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,4 @@ import:

env:
global:
# Require at least recipe 4.7.x-dev to satisfy the silverstripe/admin:1.7@dev requirement
- REQUIRE_RECIPE="4.x-dev || "
- BEHAT_SUITE="elemental-bannerblock"

before_script:
# Allow the installation of 4.x-dev which is graphql 4 compatible for when running a job that requires graphql 4
# Also set the minimum version of elemental to 4.5.0 which is graphql 3 compatible only
# Otherwise elemental 4.4.1 will be installed which has no graphql contraint and is not graphql 4 compatible
# Doing this in before_script instead of REQUIRE_EXTRA above because the || would not work in conjuction with the
# unquoted $REQUIRE_EXTRA in travis-shared-config base.yml
- composer require --no-update "dnadesign/silverstripe-elemental:^4.5@dev || 4.x-dev"
# requiring via --no-update and the running update to bypass the php check on the php8 builds
# this can be reduced to a regular composer require once silverstripe-elemental supports php8 in composer.json
- composer update dnadesign/silverstripe-elemental
11 changes: 5 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,19 @@
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
"php": ">=7.1.0",
"php": ">=7.3.0",
"silverstripe/vendor-plugin": "^1.0",
"dnadesign/silverstripe-elemental": "^4.7",
"silverstripe/elemental-fileblock": "^2@dev",
"silverstripe/cms": "^4.3",
"silverstripe/admin": "^1.7@dev"
"silverstripe/admin": "^1.7@dev",
"silverstripe/framework": "^4.10"
},
"require-dev": {
"sminnee/phpunit": "^5.7",
"phpunit/phpunit": "^9.5",
"squizlabs/php_codesniffer": "^3.0"
},
"extra": {
"branch-alias": {
"dev-master": "2.x-dev"
},
"expose": [
"client/dist"
]
Expand Down
8 changes: 5 additions & 3 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<phpunit bootstrap="vendor/silverstripe/cms/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
13 changes: 7 additions & 6 deletions tests/Behat/Context/FeatureContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

use Behat\Mink\Element\NodeElement;
use DNADesign\Elemental\Tests\Behat\Context\FeatureContext as BaseFeatureContext;
use PHPUnit\Framework\Assert;
use SilverStripe\BehatExtension\Context\MainContextAwareTrait;

if (!class_exists(BaseFeatureContext::class)) {
Expand All @@ -27,9 +28,9 @@ public function iShouldSeeTheThumbnailImageForBlock($negative, $position)
$thumbnailImage = $this->findThumbnailImage($position);

if ($iShouldNotSee) {
assertNull($thumbnailImage, 'Thumbnail image displayed (but shouldn\'t)');
Assert::assertNull($thumbnailImage, 'Thumbnail image displayed (but shouldn\'t)');
} else {
assertNotNull($thumbnailImage, 'Thumbnail image not displayed (but should be)');
Assert::assertNotNull($thumbnailImage, 'Thumbnail image not displayed (but should be)');
}
}

Expand All @@ -43,7 +44,7 @@ public function iShouldSeeTheThumbnailImageForBlock($negative, $position)
protected function findThumbnailImage($position)
{
$block = $this->getSpecificBlock($position);
assertNotNull($block, 'Block ' . $position . ' was not found in the page.');
Assert::assertNotNull($block, 'Block ' . $position . ' was not found in the page.');

$thumbnail = $block->find(
'css',
Expand All @@ -68,7 +69,7 @@ public function stepIPressTheButtonInTheActionMenuForCallToActionLink($buttonNam

$button = $popover->find('xpath', sprintf('/button[contains(text(), \'%s\')]', $buttonName));

assertNotNull($button, sprintf('Could not find button labelled "%s"', $buttonName));
Assert::assertNotNull($button, sprintf('Could not find button labelled "%s"', $buttonName));

$button->click();
}
Expand All @@ -81,7 +82,7 @@ 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);
}
}
3 changes: 2 additions & 1 deletion tests/Behat/Context/FixtureContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

use Behat\Mink\Element\DocumentElement;
use Behat\Mink\Element\NodeElement;
use PHPUnit\Framework\Assert;
use SilverStripe\Assets\Image;
use SilverStripe\BehatExtension\Context\FixtureContext as BaseFixtureContext;
use SilverStripe\ElementalBannerBlock\Block\BannerBlock;
Expand Down Expand Up @@ -92,7 +93,7 @@ public function contentBlocksAreNotInLineEditable()
public function stepISelectGalleryItem($name)
{
$item = $this->getGalleryItem($name);
assertNotNull($item, "File named $name could not be found");
Assert::assertNotNull($item, "File named $name could not be found");
$item->click();
}

Expand Down
4 changes: 2 additions & 2 deletions tests/Form/BlockLinkFieldTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ class BlockLinkFieldTest extends SapphireTest
*/
protected $field;

protected function setUp()
protected function setUp(): void
{
parent::setUp();
$this->field = new BlockLinkField('test');
}

public function testHasUniqueFormFieldSelector()
{
$this->assertContains('block-link-field', $this->field->Type());
$this->assertStringContainsString('block-link-field', $this->field->Type());
}

public function testGetParsedValue()
Expand Down
2 changes: 1 addition & 1 deletion tests/Form/BlockLinkField_ReadonlyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class BlockLinkField_ReadonlyTest extends SapphireTest
*/
protected $field;

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

Expand Down

0 comments on commit c4f5077

Please sign in to comment.