diff --git a/composer.json b/composer.json index 4990dd29c..7db9426c2 100755 --- a/composer.json +++ b/composer.json @@ -8,6 +8,7 @@ ], "type": "silverstripe-vendormodule", "require": { + "php": "^7.3 || ^8.0", "silverstripe/cms": "^4.0", "silverstripe/lumberjack": "^2.0", "silverstripe/tagfield": "^2.0", @@ -15,7 +16,7 @@ "silverstripe/asset-admin": "^1.0" }, "require-dev": { - "sminnee/phpunit": "^5.7", + "phpunit/phpunit": "^9.5", "squizlabs/php_codesniffer": "^3.0" }, "extra": { diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 052f7c360..6a309c412 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,8 +1,9 @@ - - tests/ - - + + + tests/ + + src/ diff --git a/tests/BlogCategoryTest.php b/tests/BlogCategoryTest.php index 1cc4aa089..321bec552 100755 --- a/tests/BlogCategoryTest.php +++ b/tests/BlogCategoryTest.php @@ -13,9 +13,6 @@ use SilverStripe\Security\Member; use SilverStripe\Security\Security; -/** - * @mixin PHPUnit_Framework_TestCase - */ class BlogCategoryTest extends FunctionalTest { /** @@ -26,7 +23,7 @@ class BlogCategoryTest extends FunctionalTest /** * {@inheritdoc} */ - public function setUp() + protected function setUp(): void { parent::setUp(); @@ -36,7 +33,7 @@ public function setUp() /** * {@inheritdoc} */ - public function tearDown() + protected function tearDown(): void { DBDatetime::clear_mock_now(); diff --git a/tests/BlogFunctionalTest.php b/tests/BlogFunctionalTest.php index aae2ddbd4..505486a23 100644 --- a/tests/BlogFunctionalTest.php +++ b/tests/BlogFunctionalTest.php @@ -13,7 +13,7 @@ class BlogFunctionalTest extends FunctionalTest protected static $use_draft_site = true; - protected function setUp() + protected function setUp(): void { Config::modify()->set(URLSegmentFilter::class, 'default_allow_multibyte', true); i18n::set_locale('fa_IR'); @@ -33,7 +33,7 @@ public function testMemberProfileWithMultibyteUrlAndName() $result = $this->get(rawurlencode('آبید') . '/profile/' . rawurlencode('عبّاس-آبان')); $this->assertEquals(200, $result->getStatusCode()); - $this->assertContains('My Blog Post', $result->getBody()); + $this->assertStringContainsString('My Blog Post', $result->getBody()); } public function testMemberProfileWithMultibyteUrlAndEnglishName() @@ -41,6 +41,6 @@ public function testMemberProfileWithMultibyteUrlAndEnglishName() $result = $this->get(rawurlencode('آبید') . '/profile/bob-jones'); $this->assertEquals(200, $result->getStatusCode()); - $this->assertContains('My Blog Post', $result->getBody()); + $this->assertStringContainsString('My Blog Post', $result->getBody()); } } diff --git a/tests/BlogPostFilterTest.php b/tests/BlogPostFilterTest.php index 708c68095..d9eb19149 100755 --- a/tests/BlogPostFilterTest.php +++ b/tests/BlogPostFilterTest.php @@ -8,7 +8,6 @@ use SilverStripe\Security\Security; /** - * @mixin PHPUnit_Framework_TestCase * @coversDefaultClass \SilverStripe\Blog\Model\BlogPostFilter */ class BlogPostFilterTest extends SapphireTest @@ -18,14 +17,14 @@ class BlogPostFilterTest extends SapphireTest */ protected static $fixture_file = 'blog.yml'; - public function setUp() + protected function setUp(): void { parent::setUp(); DBDatetime::set_mock_now('2013-10-10 20:00:00'); } - public function tearDown() + protected function tearDown(): void { DBDatetime::clear_mock_now(); diff --git a/tests/BlogPostTest.php b/tests/BlogPostTest.php index 44391948e..90e6333da 100644 --- a/tests/BlogPostTest.php +++ b/tests/BlogPostTest.php @@ -13,7 +13,7 @@ class BlogPostTest extends SapphireTest { protected static $fixture_file = 'blog.yml'; - protected function tearDown() + protected function tearDown(): void { DBDatetime::clear_mock_now(); parent::tearDown(); @@ -159,7 +159,7 @@ public function testGetMonthlyArchiveLink($type, $expected) $blogPost = $this->objFromFixture(BlogPost::class, 'FirstBlogPost'); $archiveLink = $blogPost->getMonthlyArchiveLink($type); - $this->assertContains('archive/', $archiveLink); + $this->assertStringContainsString('archive/', $archiveLink); $this->assertStringEndsWith($expected, $archiveLink); } @@ -181,7 +181,7 @@ public function testGetYearlyArchiveLink() $blogPost = $this->objFromFixture(BlogPost::class, 'FirstBlogPost'); $archiveLink = $blogPost->getYearlyArchiveLink(); - $this->assertContains('archive/', $archiveLink); + $this->assertStringContainsString('archive/', $archiveLink); $this->assertStringEndsWith('/2013', $archiveLink); } } diff --git a/tests/BlogTagTest.php b/tests/BlogTagTest.php index 88a48ff29..ca024813b 100755 --- a/tests/BlogTagTest.php +++ b/tests/BlogTagTest.php @@ -2,7 +2,6 @@ namespace SilverStripe\Blog\Tests; -use PHPUnit_Framework_TestCase; use SilverStripe\Blog\Model\Blog; use SilverStripe\Blog\Model\BlogPost; use SilverStripe\Blog\Model\BlogTag; @@ -13,21 +12,18 @@ use SilverStripe\Security\Member; use SilverStripe\Security\Security; -/** - * @mixin PHPUnit_Framework_TestCase - */ class BlogTagTest extends FunctionalTest { protected static $fixture_file = 'blog.yml'; - protected function setUp() + protected function setUp(): void { parent::setUp(); DBDatetime::set_mock_now('2013-10-10 20:00:00'); } - protected function tearDown() + protected function tearDown(): void { DBDatetime::clear_mock_now(); diff --git a/tests/BlogTest.php b/tests/BlogTest.php index 4792f5977..a02f65e12 100755 --- a/tests/BlogTest.php +++ b/tests/BlogTest.php @@ -2,7 +2,7 @@ namespace SilverStripe\Blog\Tests; -use PHPUnit_Framework_TestCase; +use SilverStripe\Control\HTTPResponse_Exception; use SilverStripe\Blog\Model\Blog; use SilverStripe\Blog\Model\BlogController; use SilverStripe\Blog\Model\BlogPost; @@ -17,14 +17,11 @@ use SilverStripe\ORM\SS_List; use SilverStripe\Security\Member; -/** - * @mixin PHPUnit_Framework_TestCase - */ class BlogTest extends SapphireTest { protected static $fixture_file = 'blog.yml'; - protected function setUp() + protected function setUp(): void { parent::setUp(); @@ -37,7 +34,7 @@ protected function setUp() $blog->publishRecursive(); } - protected function tearDown() + protected function tearDown(): void { DBDatetime::clear_mock_now(); @@ -327,12 +324,10 @@ public function testFilteredCategoriesArchive() ); } - /** - * @expectedException \SilverStripe\Control\HTTPResponse_Exception - * @expectedExceptionCode 404 - */ public function testDisabledProfiles() { + $this->expectException(HTTPResponse_Exception::class); + $this->expectExceptionCode(404); Config::modify()->set(BlogController::class, 'disable_profiles', true); $controller = BlogController::create(); diff --git a/tests/Model/BlogControllerFunctionalTest.php b/tests/Model/BlogControllerFunctionalTest.php index c188bcbd2..39385a652 100644 --- a/tests/Model/BlogControllerFunctionalTest.php +++ b/tests/Model/BlogControllerFunctionalTest.php @@ -13,7 +13,7 @@ class BlogControllerFunctionalTest extends FunctionalTest protected static $use_draft_site = true; - protected function setUp() + protected function setUp(): void { Config::modify()->set(URLSegmentFilter::class, 'default_allow_multibyte', true); i18n::set_locale('fa_IR'); @@ -26,7 +26,7 @@ public function testGetCategoriesWithMultibyteUrl() $result = $this->get('my-blog/category/' . rawurlencode('آبید')); $this->assertEquals(200, $result->getStatusCode()); - $this->assertContains('آبید', $result->getBody()); + $this->assertStringContainsString('آبید', $result->getBody()); } public function testGetTagsWithMultibyteUrl() @@ -34,6 +34,6 @@ public function testGetTagsWithMultibyteUrl() $result = $this->get('my-blog/tag/' . rawurlencode('برتراند')); $this->assertEquals(200, $result->getStatusCode()); - $this->assertContains('برتراند', $result->getBody()); + $this->assertStringContainsString('برتراند', $result->getBody()); } } diff --git a/tests/Widgets/BlogArchiveWidgetTest.php b/tests/Widgets/BlogArchiveWidgetTest.php index 767d18f6a..6e4f79391 100644 --- a/tests/Widgets/BlogArchiveWidgetTest.php +++ b/tests/Widgets/BlogArchiveWidgetTest.php @@ -15,7 +15,7 @@ class BlogArchiveWidgetTest extends SapphireTest { protected static $fixture_file = 'BlogArchiveWidgetTest.yml'; - protected function setUp() + protected function setUp(): void { if (!class_exists(Widget::class)) { self::$fixture_file = null; @@ -28,7 +28,7 @@ protected function setUp() parent::setUp(); } - protected function tearDown() + protected function tearDown(): void { parent::tearDown();