From 67ae27874a169140f3c535ef403f7f6eb47f8502 Mon Sep 17 00:00:00 2001 From: Steve Boyd Date: Thu, 4 Nov 2021 13:47:42 +1300 Subject: [PATCH] API phpunit 9 support --- composer.json | 5 +++-- tests/GridFieldConfigurablePaginatorTest.php | 8 +++----- tests/GridFieldEditableColumnsTest.php | 6 +++--- tests/GridFieldOrderableRowsTest.php | 8 ++++---- tests/OrderableRowsThroughVersionedTest.php | 4 ++-- 5 files changed, 15 insertions(+), 16 deletions(-) diff --git a/composer.json b/composer.json index db4d73bb..241d7eaf 100644 --- a/composer.json +++ b/composer.json @@ -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" }, diff --git a/tests/GridFieldConfigurablePaginatorTest.php b/tests/GridFieldConfigurablePaginatorTest.php index fdc74931..969d8897 100644 --- a/tests/GridFieldConfigurablePaginatorTest.php +++ b/tests/GridFieldConfigurablePaginatorTest.php @@ -16,7 +16,7 @@ class GridFieldConfigurablePaginatorTest extends SapphireTest */ protected $gridField; - public function setUp() + protected function setUp(): void { parent::setUp(); @@ -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->expectExceptionMessageMatches('No GridField available yet for this request!'); $paginator = new GridFieldConfigurablePaginator; $paginator->getGridField(); } diff --git a/tests/GridFieldEditableColumnsTest.php b/tests/GridFieldEditableColumnsTest.php index 7cb6af3e..fc9a9b9c 100644 --- a/tests/GridFieldEditableColumnsTest.php +++ b/tests/GridFieldEditableColumnsTest.php @@ -48,7 +48,7 @@ public function testProvidesEditableFieldsInColumns() $column = $component->getColumnContent($grid, $record, 'Title'); $this->assertInstanceOf(DBHTMLText::class, $column); - $this->assertRegExp( + $this->assertMatchesRegularExpression( '/]*>/', $column->getValue() ); @@ -64,7 +64,7 @@ public function testProvidesReadonlyColumnsForNoneditableRecords() $column = $component->getColumnContent($grid, $record, 'Title'); $this->assertInstanceOf(DBHTMLText::class, $column); - $this->assertRegExp( + $this->assertMatchesRegularExpression( '/]*>\s*testval\s*<\/span>/', $column->getValue() ); @@ -86,7 +86,7 @@ public function testProvidesReadonlyColumnsForReadonlyGrids() $column = $component->getColumnContent($grid, $record, 'Title'); $this->assertInstanceOf(DBHTMLText::class, $column); - $this->assertRegExp( + $this->assertMatchesRegularExpression( '/]*>\s*testval\s*<\/span>/', $column->getValue() ); diff --git a/tests/GridFieldOrderableRowsTest.php b/tests/GridFieldOrderableRowsTest.php index e9ce1d4e..44e9f1b6 100644 --- a/tests/GridFieldOrderableRowsTest.php +++ b/tests/GridFieldOrderableRowsTest.php @@ -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' @@ -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' diff --git a/tests/OrderableRowsThroughVersionedTest.php b/tests/OrderableRowsThroughVersionedTest.php index e7e3cb1e..473e0335 100644 --- a/tests/OrderableRowsThroughVersionedTest.php +++ b/tests/OrderableRowsThroughVersionedTest.php @@ -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);