Skip to content

Commit

Permalink
Merge pull request #327 from creative-commoners/pulls/3/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 9, 2021
2 parents b52fd75 + 5e3037b commit baa6a8d
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 16 deletions.
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@
"issues": "http://github.com/symbiote/silverstripe-gridfieldextensions/issues"
},
"require": {
"php": "^7.3 || ^8.0",
"silverstripe/vendor-plugin": "^1.0",
"silverstripe/framework": "~4.0"
"silverstripe/framework": "^4.10"
},
"require-dev": {
"sminnee/phpunit": "^5.7",
"phpunit/phpunit": "^9.5",
"squizlabs/php_codesniffer": "^3.0",
"silverstripe/versioned": "^1"
},
Expand Down
8 changes: 3 additions & 5 deletions tests/GridFieldConfigurablePaginatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class GridFieldConfigurablePaginatorTest extends SapphireTest
*/
protected $gridField;

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

Expand Down Expand Up @@ -172,12 +172,10 @@ public function testGetPageSizesAsList()
), $paginator->getPageSizesAsList());
}

/**
* @expectedException Exception
* @expectedExceptionMessage No GridField available yet for this request!
*/
public function testGetGridFieldThrowsExceptionWhenNotSet()
{
$this->expectException(\Exception::class);
$this->expectExceptionMessage('No GridField available yet for this request!');
$paginator = new GridFieldConfigurablePaginator;
$paginator->getGridField();
}
Expand Down
6 changes: 3 additions & 3 deletions tests/GridFieldEditableColumnsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function testProvidesEditableFieldsInColumns()
$column = $component->getColumnContent($grid, $record, 'Title');

$this->assertInstanceOf(DBHTMLText::class, $column);
$this->assertRegExp(
$this->assertMatchesRegularExpression(
'/<input type="text" name="TestGridField\[GridFieldEditableColumns\]\[100\]\[Title\]" value="foo"[^>]*>/',
$column->getValue()
);
Expand All @@ -64,7 +64,7 @@ public function testProvidesReadonlyColumnsForNoneditableRecords()
$column = $component->getColumnContent($grid, $record, 'Title');

$this->assertInstanceOf(DBHTMLText::class, $column);
$this->assertRegExp(
$this->assertMatchesRegularExpression(
'/<span[^>]*>\s*testval\s*<\/span>/',
$column->getValue()
);
Expand All @@ -86,7 +86,7 @@ public function testProvidesReadonlyColumnsForReadonlyGrids()
$column = $component->getColumnContent($grid, $record, 'Title');

$this->assertInstanceOf(DBHTMLText::class, $column);
$this->assertRegExp(
$this->assertMatchesRegularExpression(
'/<span[^>]*>\s*testval\s*<\/span>/',
$column->getValue()
);
Expand Down
8 changes: 4 additions & 4 deletions tests/GridFieldOrderableRowsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,12 @@ public function testManyManyThroughListSortOrdersAreUsedForInitialRender()

$result = $orderable->getColumnContent($grid, $record, 'irrelevant');

$this->assertContains(
$this->assertStringContainsString(
'Belongings[GridFieldEditableColumns][' . $record->ID . '][Sort]',
$result,
'The field name is indexed under the record\'s ID'
);
$this->assertContains(
$this->assertStringContainsString(
'value="' . $intermediary->Sort . '"',
$result,
'The value comes from the MMTL intermediary Sort value'
Expand Down Expand Up @@ -152,12 +152,12 @@ public function testPolymorphicManyManyListSortOrdersAreUsedForInitialRender()

$result = $orderable->getColumnContent($grid, $record, 'irrelevant');

$this->assertContains(
$this->assertStringContainsString(
'Children[GridFieldEditableColumns][' . $record->ID . '][Sort]',
$result,
'The field name is indexed under the record\'s ID'
);
$this->assertContains(
$this->assertStringContainsString(
'value="' . $intermediary->Sort . '"',
$result,
'The value comes from the MMTL intermediary Sort value'
Expand Down
4 changes: 2 additions & 2 deletions tests/OrderableRowsThroughVersionedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ class OrderableRowsThroughVersionedTest extends SapphireTest

protected $originalReadingMode;

protected function setUp()
protected function setUp(): void
{
parent::setUp();
$this->orignalReadingMode = Versioned::get_reading_mode();
}

protected function tearDown()
protected function tearDown(): void
{
Versioned::set_reading_mode($this->originalReadingMode);
unset($this->originalReadingMode);
Expand Down

0 comments on commit baa6a8d

Please sign in to comment.