mirror of
https://github.com/silverstripe/silverstripe-blog
synced 2024-10-22 11:05:58 +02:00
Merge pull request #661 from creative-commoners/pulls/3/sapphire-test-nine
API phpunit9 support
This commit is contained in:
commit
363a115300
@ -8,6 +8,7 @@
|
|||||||
],
|
],
|
||||||
"type": "silverstripe-vendormodule",
|
"type": "silverstripe-vendormodule",
|
||||||
"require": {
|
"require": {
|
||||||
|
"php": "^7.3 || ^8.0",
|
||||||
"silverstripe/cms": "^4.0",
|
"silverstripe/cms": "^4.0",
|
||||||
"silverstripe/lumberjack": "^2.0",
|
"silverstripe/lumberjack": "^2.0",
|
||||||
"silverstripe/tagfield": "^2.0",
|
"silverstripe/tagfield": "^2.0",
|
||||||
@ -15,7 +16,7 @@
|
|||||||
"silverstripe/asset-admin": "^1.0"
|
"silverstripe/asset-admin": "^1.0"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"sminnee/phpunit": "^5.7",
|
"phpunit/phpunit": "^9.5",
|
||||||
"squizlabs/php_codesniffer": "^3.0"
|
"squizlabs/php_codesniffer": "^3.0"
|
||||||
},
|
},
|
||||||
"extra": {
|
"extra": {
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
<phpunit bootstrap="vendor/silverstripe/cms/tests/bootstrap.php" colors="true">
|
<phpunit bootstrap="vendor/silverstripe/cms/tests/bootstrap.php" colors="true">
|
||||||
<testsuite name="blog">
|
<testsuites>
|
||||||
<directory>tests/</directory>
|
<testsuite name="blog">
|
||||||
</testsuite>
|
<directory>tests/</directory>
|
||||||
|
</testsuite>
|
||||||
|
</testsuites>
|
||||||
<filter>
|
<filter>
|
||||||
<whitelist addUncoveredFilesFromWhitelist="true">
|
<whitelist addUncoveredFilesFromWhitelist="true">
|
||||||
<directory suffix=".php">src/</directory>
|
<directory suffix=".php">src/</directory>
|
||||||
|
@ -13,9 +13,6 @@ use SilverStripe\ORM\ValidationException;
|
|||||||
use SilverStripe\Security\Member;
|
use SilverStripe\Security\Member;
|
||||||
use SilverStripe\Security\Security;
|
use SilverStripe\Security\Security;
|
||||||
|
|
||||||
/**
|
|
||||||
* @mixin PHPUnit_Framework_TestCase
|
|
||||||
*/
|
|
||||||
class BlogCategoryTest extends FunctionalTest
|
class BlogCategoryTest extends FunctionalTest
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
@ -26,7 +23,7 @@ class BlogCategoryTest extends FunctionalTest
|
|||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function setUp()
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
@ -36,7 +33,7 @@ class BlogCategoryTest extends FunctionalTest
|
|||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function tearDown()
|
protected function tearDown(): void
|
||||||
{
|
{
|
||||||
DBDatetime::clear_mock_now();
|
DBDatetime::clear_mock_now();
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ class BlogFunctionalTest extends FunctionalTest
|
|||||||
|
|
||||||
protected static $use_draft_site = true;
|
protected static $use_draft_site = true;
|
||||||
|
|
||||||
protected function setUp()
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
Config::modify()->set(URLSegmentFilter::class, 'default_allow_multibyte', true);
|
Config::modify()->set(URLSegmentFilter::class, 'default_allow_multibyte', true);
|
||||||
i18n::set_locale('fa_IR');
|
i18n::set_locale('fa_IR');
|
||||||
@ -33,7 +33,7 @@ class BlogFunctionalTest extends FunctionalTest
|
|||||||
$result = $this->get(rawurlencode('آبید') . '/profile/' . rawurlencode('عبّاس-آبان'));
|
$result = $this->get(rawurlencode('آبید') . '/profile/' . rawurlencode('عبّاس-آبان'));
|
||||||
|
|
||||||
$this->assertEquals(200, $result->getStatusCode());
|
$this->assertEquals(200, $result->getStatusCode());
|
||||||
$this->assertContains('My Blog Post', $result->getBody());
|
$this->assertStringContainsString('My Blog Post', $result->getBody());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testMemberProfileWithMultibyteUrlAndEnglishName()
|
public function testMemberProfileWithMultibyteUrlAndEnglishName()
|
||||||
@ -41,6 +41,6 @@ class BlogFunctionalTest extends FunctionalTest
|
|||||||
$result = $this->get(rawurlencode('آبید') . '/profile/bob-jones');
|
$result = $this->get(rawurlencode('آبید') . '/profile/bob-jones');
|
||||||
|
|
||||||
$this->assertEquals(200, $result->getStatusCode());
|
$this->assertEquals(200, $result->getStatusCode());
|
||||||
$this->assertContains('My Blog Post', $result->getBody());
|
$this->assertStringContainsString('My Blog Post', $result->getBody());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,6 @@ use SilverStripe\ORM\FieldType\DBDatetime;
|
|||||||
use SilverStripe\Security\Security;
|
use SilverStripe\Security\Security;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @mixin PHPUnit_Framework_TestCase
|
|
||||||
* @coversDefaultClass \SilverStripe\Blog\Model\BlogPostFilter
|
* @coversDefaultClass \SilverStripe\Blog\Model\BlogPostFilter
|
||||||
*/
|
*/
|
||||||
class BlogPostFilterTest extends SapphireTest
|
class BlogPostFilterTest extends SapphireTest
|
||||||
@ -18,14 +17,14 @@ class BlogPostFilterTest extends SapphireTest
|
|||||||
*/
|
*/
|
||||||
protected static $fixture_file = 'blog.yml';
|
protected static $fixture_file = 'blog.yml';
|
||||||
|
|
||||||
public function setUp()
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
DBDatetime::set_mock_now('2013-10-10 20:00:00');
|
DBDatetime::set_mock_now('2013-10-10 20:00:00');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function tearDown()
|
protected function tearDown(): void
|
||||||
{
|
{
|
||||||
DBDatetime::clear_mock_now();
|
DBDatetime::clear_mock_now();
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ class BlogPostTest extends SapphireTest
|
|||||||
{
|
{
|
||||||
protected static $fixture_file = 'blog.yml';
|
protected static $fixture_file = 'blog.yml';
|
||||||
|
|
||||||
protected function tearDown()
|
protected function tearDown(): void
|
||||||
{
|
{
|
||||||
DBDatetime::clear_mock_now();
|
DBDatetime::clear_mock_now();
|
||||||
parent::tearDown();
|
parent::tearDown();
|
||||||
@ -159,7 +159,7 @@ class BlogPostTest extends SapphireTest
|
|||||||
$blogPost = $this->objFromFixture(BlogPost::class, 'FirstBlogPost');
|
$blogPost = $this->objFromFixture(BlogPost::class, 'FirstBlogPost');
|
||||||
|
|
||||||
$archiveLink = $blogPost->getMonthlyArchiveLink($type);
|
$archiveLink = $blogPost->getMonthlyArchiveLink($type);
|
||||||
$this->assertContains('archive/', $archiveLink);
|
$this->assertStringContainsString('archive/', $archiveLink);
|
||||||
$this->assertStringEndsWith($expected, $archiveLink);
|
$this->assertStringEndsWith($expected, $archiveLink);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -181,7 +181,7 @@ class BlogPostTest extends SapphireTest
|
|||||||
$blogPost = $this->objFromFixture(BlogPost::class, 'FirstBlogPost');
|
$blogPost = $this->objFromFixture(BlogPost::class, 'FirstBlogPost');
|
||||||
|
|
||||||
$archiveLink = $blogPost->getYearlyArchiveLink();
|
$archiveLink = $blogPost->getYearlyArchiveLink();
|
||||||
$this->assertContains('archive/', $archiveLink);
|
$this->assertStringContainsString('archive/', $archiveLink);
|
||||||
$this->assertStringEndsWith('/2013', $archiveLink);
|
$this->assertStringEndsWith('/2013', $archiveLink);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
namespace SilverStripe\Blog\Tests;
|
namespace SilverStripe\Blog\Tests;
|
||||||
|
|
||||||
use PHPUnit_Framework_TestCase;
|
|
||||||
use SilverStripe\Blog\Model\Blog;
|
use SilverStripe\Blog\Model\Blog;
|
||||||
use SilverStripe\Blog\Model\BlogPost;
|
use SilverStripe\Blog\Model\BlogPost;
|
||||||
use SilverStripe\Blog\Model\BlogTag;
|
use SilverStripe\Blog\Model\BlogTag;
|
||||||
@ -13,21 +12,18 @@ use SilverStripe\ORM\ValidationException;
|
|||||||
use SilverStripe\Security\Member;
|
use SilverStripe\Security\Member;
|
||||||
use SilverStripe\Security\Security;
|
use SilverStripe\Security\Security;
|
||||||
|
|
||||||
/**
|
|
||||||
* @mixin PHPUnit_Framework_TestCase
|
|
||||||
*/
|
|
||||||
class BlogTagTest extends FunctionalTest
|
class BlogTagTest extends FunctionalTest
|
||||||
{
|
{
|
||||||
protected static $fixture_file = 'blog.yml';
|
protected static $fixture_file = 'blog.yml';
|
||||||
|
|
||||||
protected function setUp()
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
DBDatetime::set_mock_now('2013-10-10 20:00:00');
|
DBDatetime::set_mock_now('2013-10-10 20:00:00');
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function tearDown()
|
protected function tearDown(): void
|
||||||
{
|
{
|
||||||
DBDatetime::clear_mock_now();
|
DBDatetime::clear_mock_now();
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace SilverStripe\Blog\Tests;
|
namespace SilverStripe\Blog\Tests;
|
||||||
|
|
||||||
use PHPUnit_Framework_TestCase;
|
use SilverStripe\Control\HTTPResponse_Exception;
|
||||||
use SilverStripe\Blog\Model\Blog;
|
use SilverStripe\Blog\Model\Blog;
|
||||||
use SilverStripe\Blog\Model\BlogController;
|
use SilverStripe\Blog\Model\BlogController;
|
||||||
use SilverStripe\Blog\Model\BlogPost;
|
use SilverStripe\Blog\Model\BlogPost;
|
||||||
@ -17,14 +17,11 @@ use SilverStripe\ORM\FieldType\DBDatetime;
|
|||||||
use SilverStripe\ORM\SS_List;
|
use SilverStripe\ORM\SS_List;
|
||||||
use SilverStripe\Security\Member;
|
use SilverStripe\Security\Member;
|
||||||
|
|
||||||
/**
|
|
||||||
* @mixin PHPUnit_Framework_TestCase
|
|
||||||
*/
|
|
||||||
class BlogTest extends SapphireTest
|
class BlogTest extends SapphireTest
|
||||||
{
|
{
|
||||||
protected static $fixture_file = 'blog.yml';
|
protected static $fixture_file = 'blog.yml';
|
||||||
|
|
||||||
protected function setUp()
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
@ -37,7 +34,7 @@ class BlogTest extends SapphireTest
|
|||||||
$blog->publishRecursive();
|
$blog->publishRecursive();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function tearDown()
|
protected function tearDown(): void
|
||||||
{
|
{
|
||||||
DBDatetime::clear_mock_now();
|
DBDatetime::clear_mock_now();
|
||||||
|
|
||||||
@ -327,12 +324,10 @@ class BlogTest extends SapphireTest
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException \SilverStripe\Control\HTTPResponse_Exception
|
|
||||||
* @expectedExceptionCode 404
|
|
||||||
*/
|
|
||||||
public function testDisabledProfiles()
|
public function testDisabledProfiles()
|
||||||
{
|
{
|
||||||
|
$this->expectException(HTTPResponse_Exception::class);
|
||||||
|
$this->expectExceptionCode(404);
|
||||||
Config::modify()->set(BlogController::class, 'disable_profiles', true);
|
Config::modify()->set(BlogController::class, 'disable_profiles', true);
|
||||||
|
|
||||||
$controller = BlogController::create();
|
$controller = BlogController::create();
|
||||||
|
@ -13,7 +13,7 @@ class BlogControllerFunctionalTest extends FunctionalTest
|
|||||||
|
|
||||||
protected static $use_draft_site = true;
|
protected static $use_draft_site = true;
|
||||||
|
|
||||||
protected function setUp()
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
Config::modify()->set(URLSegmentFilter::class, 'default_allow_multibyte', true);
|
Config::modify()->set(URLSegmentFilter::class, 'default_allow_multibyte', true);
|
||||||
i18n::set_locale('fa_IR');
|
i18n::set_locale('fa_IR');
|
||||||
@ -26,7 +26,7 @@ class BlogControllerFunctionalTest extends FunctionalTest
|
|||||||
$result = $this->get('my-blog/category/' . rawurlencode('آبید'));
|
$result = $this->get('my-blog/category/' . rawurlencode('آبید'));
|
||||||
|
|
||||||
$this->assertEquals(200, $result->getStatusCode());
|
$this->assertEquals(200, $result->getStatusCode());
|
||||||
$this->assertContains('آبید', $result->getBody());
|
$this->assertStringContainsString('آبید', $result->getBody());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetTagsWithMultibyteUrl()
|
public function testGetTagsWithMultibyteUrl()
|
||||||
@ -34,6 +34,6 @@ class BlogControllerFunctionalTest extends FunctionalTest
|
|||||||
$result = $this->get('my-blog/tag/' . rawurlencode('برتراند'));
|
$result = $this->get('my-blog/tag/' . rawurlencode('برتراند'));
|
||||||
|
|
||||||
$this->assertEquals(200, $result->getStatusCode());
|
$this->assertEquals(200, $result->getStatusCode());
|
||||||
$this->assertContains('برتراند', $result->getBody());
|
$this->assertStringContainsString('برتراند', $result->getBody());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ class BlogArchiveWidgetTest extends SapphireTest
|
|||||||
{
|
{
|
||||||
protected static $fixture_file = 'BlogArchiveWidgetTest.yml';
|
protected static $fixture_file = 'BlogArchiveWidgetTest.yml';
|
||||||
|
|
||||||
protected function setUp()
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
if (!class_exists(Widget::class)) {
|
if (!class_exists(Widget::class)) {
|
||||||
self::$fixture_file = null;
|
self::$fixture_file = null;
|
||||||
@ -28,7 +28,7 @@ class BlogArchiveWidgetTest extends SapphireTest
|
|||||||
parent::setUp();
|
parent::setUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function tearDown()
|
protected function tearDown(): void
|
||||||
{
|
{
|
||||||
parent::tearDown();
|
parent::tearDown();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user