mirror of
https://github.com/joomla/joomla-cms.git
synced 2024-06-25 23:02:55 +00:00
[4.3] Activate all unit tests as default (#38421)
This commit is contained in:
parent
2aef1693f6
commit
0805889bfb
|
@ -2,10 +2,10 @@
|
|||
<phpunit bootstrap="tests/Unit/bootstrap.php" colors="false">
|
||||
<testsuites>
|
||||
<testsuite name="Unit">
|
||||
<directory suffix="Test.php">./tests/Unit/Libraries</directory>
|
||||
<directory suffix="Test.php">./tests/Unit</directory>
|
||||
</testsuite>
|
||||
<testsuite name="Integration">
|
||||
<directory suffix="Test.php">./tests/Integration/Libraries</directory>
|
||||
<directory suffix="Test.php">./tests/Integration</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
<php>
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
<phpunit bootstrap="tests/Unit/bootstrap.php" colors="false">
|
||||
<testsuites>
|
||||
<testsuite name="Unit">
|
||||
<directory suffix="Test.php">./tests/Unit/Libraries</directory>
|
||||
<directory suffix="Test.php">./tests/Unit</directory>
|
||||
</testsuite>
|
||||
<testsuite name="Integration">
|
||||
<directory suffix="Test.php">./tests/Integration/Libraries</directory>
|
||||
<directory suffix="Test.php">./tests/Integration</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
<php>
|
||||
|
|
|
@ -330,7 +330,8 @@ class AtomParserTest extends UnitTestCase
|
|||
{
|
||||
$dummyXml = '<?xml version="1.0" encoding="utf-8" ?>
|
||||
<feed xmlns="http://www.w3.org/2005/Atom" />';
|
||||
$reader = \XMLReader::XML($dummyXml);
|
||||
$reader = new XMLReader();
|
||||
$reader->xml($dummyXml);
|
||||
$atomParser = new AtomParser($reader);
|
||||
$atomParser->parse();
|
||||
|
||||
|
@ -356,7 +357,8 @@ class AtomParserTest extends UnitTestCase
|
|||
<feed xmlns="http://www.w3.org/2005/Atom">
|
||||
<title type="text">Joomla! Unit test</title>
|
||||
</feed>';
|
||||
$reader = \XMLReader::XML($dummyXml);
|
||||
$reader = new XMLReader();
|
||||
$reader->xml($dummyXml);
|
||||
$atomParser = new AtomParser($reader);
|
||||
|
||||
// same logic as FeedFactory.php : skip head record
|
||||
|
@ -395,7 +397,8 @@ class AtomParserTest extends UnitTestCase
|
|||
<feed version="0.3" xmlns="http://www.w3.org/2005/Atom">
|
||||
<title type="text">Joomla! Unit test</title>
|
||||
</feed>';
|
||||
$reader = \XMLReader::XML($dummyXml);
|
||||
$reader = new XMLReader();
|
||||
$reader->xml($dummyXml);
|
||||
$atomParser = new AtomParser($reader);
|
||||
|
||||
// same logic as FeedFactory.php : skip head record
|
||||
|
|
|
@ -589,7 +589,8 @@ class RssParserTest extends UnitTestCase
|
|||
<title>Test Channel</title>
|
||||
</channel>
|
||||
</rss>';
|
||||
$reader = \XMLReader::XML($dummyXml);
|
||||
$reader = new XMLReader();
|
||||
$reader->xml($dummyXml);
|
||||
$rssParser = new RssParser($reader);
|
||||
|
||||
// same logic as FeedFactory.php : skip head record
|
||||
|
|
|
@ -32,6 +32,15 @@ use Joomla\Tests\Unit\UnitTestCase;
|
|||
*/
|
||||
class CheckfilesPluginTest extends UnitTestCase
|
||||
{
|
||||
/**
|
||||
* The temporary folder.
|
||||
*
|
||||
* @var string
|
||||
*
|
||||
* @since __DEPLOY_VERSION__
|
||||
*/
|
||||
private $tmpFolder;
|
||||
|
||||
/**
|
||||
* Setup
|
||||
*
|
||||
|
@ -41,13 +50,16 @@ class CheckfilesPluginTest extends UnitTestCase
|
|||
*/
|
||||
public function setUp(): void
|
||||
{
|
||||
if (!is_dir(__DIR__ . '/tmp')) {
|
||||
mkdir(__DIR__ . '/tmp');
|
||||
// Dir must be random for parallel automated tests
|
||||
$this->tmpFolder = JPATH_ROOT . '/tmp/' . rand();
|
||||
|
||||
if (!is_dir($this->tmpFolder)) {
|
||||
mkdir($this->tmpFolder);
|
||||
}
|
||||
|
||||
$image = imagecreate(200, 200);
|
||||
imagecolorallocate($image, 255, 255, 0);
|
||||
imagepng($image, __DIR__ . '/tmp/test.png');
|
||||
imagepng($image, $this->tmpFolder . '/test.png');
|
||||
imagedestroy($image);
|
||||
}
|
||||
|
||||
|
@ -60,8 +72,8 @@ class CheckfilesPluginTest extends UnitTestCase
|
|||
*/
|
||||
public function tearDown(): void
|
||||
{
|
||||
if (is_dir(__DIR__ . '/tmp')) {
|
||||
Folder::delete(__DIR__ . '/tmp');
|
||||
if (is_dir($this->tmpFolder)) {
|
||||
Folder::delete($this->tmpFolder);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -80,7 +92,7 @@ class CheckfilesPluginTest extends UnitTestCase
|
|||
$app = $this->createStub(CMSApplicationInterface::class);
|
||||
$app->method('getLanguage')->willReturn($language);
|
||||
|
||||
$plugin = new Checkfiles(new Dispatcher(), [], __DIR__);
|
||||
$plugin = new Checkfiles(new Dispatcher(), [], $this->tmpFolder);
|
||||
$plugin->setApplication($app);
|
||||
|
||||
$task = $this->createStub(Task::class);
|
||||
|
@ -90,14 +102,14 @@ class CheckfilesPluginTest extends UnitTestCase
|
|||
'test',
|
||||
[
|
||||
'subject' => $task,
|
||||
'params' => (object)['path' => '/tmp', 'dimension' => 'width', 'limit' => 20, 'numImages' => 1]
|
||||
'params' => (object)['path' => '/', 'dimension' => 'width', 'limit' => 20, 'numImages' => 1]
|
||||
]
|
||||
);
|
||||
$plugin->standardRoutineHandler($event);
|
||||
|
||||
$this->assertEquals(Status::OK, $event->getResultSnapshot()['status']);
|
||||
|
||||
list($width, $height) = getimagesize(__DIR__ . '/tmp/test.png');
|
||||
list($width, $height) = getimagesize($this->tmpFolder . '/test.png');
|
||||
$this->assertEquals(20, $width);
|
||||
$this->assertEquals(20, $height);
|
||||
}
|
||||
|
@ -111,7 +123,7 @@ class CheckfilesPluginTest extends UnitTestCase
|
|||
*/
|
||||
public function testResizeWithLimit()
|
||||
{
|
||||
copy(__DIR__ . '/tmp/test.png', __DIR__ . '/tmp/test1.png');
|
||||
copy($this->tmpFolder . '/test.png', $this->tmpFolder . '/test1.png');
|
||||
|
||||
$language = $this->createStub(Language::class);
|
||||
$language->method('_')->willReturn('test');
|
||||
|
@ -119,7 +131,7 @@ class CheckfilesPluginTest extends UnitTestCase
|
|||
$app = $this->createStub(CMSApplicationInterface::class);
|
||||
$app->method('getLanguage')->willReturn($language);
|
||||
|
||||
$plugin = new Checkfiles(new Dispatcher(), [], __DIR__);
|
||||
$plugin = new Checkfiles(new Dispatcher(), [], $this->tmpFolder);
|
||||
$plugin->setApplication($app);
|
||||
|
||||
$task = $this->createStub(Task::class);
|
||||
|
@ -129,18 +141,18 @@ class CheckfilesPluginTest extends UnitTestCase
|
|||
'test',
|
||||
[
|
||||
'subject' => $task,
|
||||
'params' => (object)['path' => '/tmp', 'dimension' => 'width', 'limit' => 20, 'numImages' => 1]
|
||||
'params' => (object)['path' => '/', 'dimension' => 'width', 'limit' => 20, 'numImages' => 1]
|
||||
]
|
||||
);
|
||||
$plugin->standardRoutineHandler($event);
|
||||
|
||||
$this->assertEquals(Status::OK, $event->getResultSnapshot()['status']);
|
||||
|
||||
list($width, $height) = getimagesize(__DIR__ . '/tmp/test.png');
|
||||
list($width, $height) = getimagesize($this->tmpFolder . '/test.png');
|
||||
$this->assertEquals(20, $width);
|
||||
$this->assertEquals(20, $height);
|
||||
|
||||
list($width, $height) = getimagesize(__DIR__ . '/tmp/test1.png');
|
||||
list($width, $height) = getimagesize($this->tmpFolder . '/test1.png');
|
||||
$this->assertEquals(200, $width);
|
||||
$this->assertEquals(200, $height);
|
||||
}
|
||||
|
@ -160,7 +172,7 @@ class CheckfilesPluginTest extends UnitTestCase
|
|||
$app = $this->createStub(CMSApplicationInterface::class);
|
||||
$app->method('getLanguage')->willReturn($language);
|
||||
|
||||
$plugin = new Checkfiles(new Dispatcher(), [], __DIR__);
|
||||
$plugin = new Checkfiles(new Dispatcher(), [], $this->tmpFolder);
|
||||
$plugin->setApplication($app);
|
||||
|
||||
$task = $this->createStub(Task::class);
|
||||
|
@ -170,14 +182,14 @@ class CheckfilesPluginTest extends UnitTestCase
|
|||
'test',
|
||||
[
|
||||
'subject' => $task,
|
||||
'params' => (object)['path' => '/tmp', 'dimension' => 'width', 'limit' => 2000, 'numImages' => 1]
|
||||
'params' => (object)['path' => '/', 'dimension' => 'width', 'limit' => 2000, 'numImages' => 1]
|
||||
]
|
||||
);
|
||||
$plugin->standardRoutineHandler($event);
|
||||
|
||||
$this->assertEquals(Status::OK, $event->getResultSnapshot()['status']);
|
||||
|
||||
list($width, $height) = getimagesize(__DIR__ . '/tmp/test.png');
|
||||
list($width, $height) = getimagesize($this->tmpFolder . '/test.png');
|
||||
$this->assertEquals(200, $width);
|
||||
$this->assertEquals(200, $height);
|
||||
}
|
||||
|
@ -197,7 +209,7 @@ class CheckfilesPluginTest extends UnitTestCase
|
|||
$app = $this->createStub(CMSApplicationInterface::class);
|
||||
$app->method('getLanguage')->willReturn($language);
|
||||
|
||||
$plugin = new Checkfiles(new Dispatcher(), [], __DIR__);
|
||||
$plugin = new Checkfiles(new Dispatcher(), [], $this->tmpFolder);
|
||||
$plugin->setApplication($app);
|
||||
|
||||
$task = $this->createStub(Task::class);
|
||||
|
@ -212,7 +224,7 @@ class CheckfilesPluginTest extends UnitTestCase
|
|||
);
|
||||
$plugin->standardRoutineHandler($event);
|
||||
|
||||
list($width, $height) = getimagesize(__DIR__ . '/tmp/test.png');
|
||||
list($width, $height) = getimagesize($this->tmpFolder . '/test.png');
|
||||
$this->assertEquals(Status::NO_RUN, $event->getResultSnapshot()['status']);
|
||||
$this->assertEquals(200, $width);
|
||||
$this->assertEquals(200, $height);
|
||||
|
|
|
@ -37,6 +37,15 @@ use Joomla\Uri\UriInterface;
|
|||
*/
|
||||
class RequestsPluginTest extends UnitTestCase
|
||||
{
|
||||
/**
|
||||
* The temporary folder.
|
||||
*
|
||||
* @var string
|
||||
*
|
||||
* @since __DEPLOY_VERSION__
|
||||
*/
|
||||
private $tmpFolder;
|
||||
|
||||
/**
|
||||
* Setup
|
||||
*
|
||||
|
@ -46,8 +55,11 @@ class RequestsPluginTest extends UnitTestCase
|
|||
*/
|
||||
public function setUp(): void
|
||||
{
|
||||
if (is_dir(__DIR__ . '/tmp')) {
|
||||
Folder::delete(__DIR__ . '/tmp');
|
||||
// Dir must be random for parallel automated tests
|
||||
$this->tmpFolder = JPATH_ROOT . '/tmp/' . rand();
|
||||
|
||||
if (is_dir($this->tmpFolder)) {
|
||||
Folder::delete($this->tmpFolder);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -60,8 +72,8 @@ class RequestsPluginTest extends UnitTestCase
|
|||
*/
|
||||
public function tearDown(): void
|
||||
{
|
||||
if (is_dir(__DIR__ . '/tmp')) {
|
||||
Folder::delete(__DIR__ . '/tmp');
|
||||
if (is_dir($this->tmpFolder)) {
|
||||
Folder::delete($this->tmpFolder);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -95,10 +107,13 @@ class RequestsPluginTest extends UnitTestCase
|
|||
$factory = $this->createStub(HttpFactory::class);
|
||||
$factory->method('getHttp')->willReturn($http);
|
||||
|
||||
$app = $this->createStub(CMSApplicationInterface::class);
|
||||
$app->method('getLanguage')->willReturn($this->createStub(Language::class));
|
||||
$language = $this->createStub(Language::class);
|
||||
$language->method('_')->willReturn('test');
|
||||
|
||||
$plugin = new Requests(new Dispatcher(), [], $factory, __DIR__ . '/tmp');
|
||||
$app = $this->createStub(CMSApplicationInterface::class);
|
||||
$app->method('getLanguage')->willReturn($language);
|
||||
|
||||
$plugin = new Requests(new Dispatcher(), [], $factory, $this->tmpFolder);
|
||||
$plugin->setApplication($app);
|
||||
|
||||
$task = $this->createStub(Task::class);
|
||||
|
@ -116,7 +131,7 @@ class RequestsPluginTest extends UnitTestCase
|
|||
$this->assertEquals(Status::OK, $event->getResultSnapshot()['status']);
|
||||
$this->assertStringContainsString('SAVED', $event->getResultSnapshot()['output']);
|
||||
$this->assertEquals('http://example.com', $transport->url);
|
||||
$this->assertStringEqualsFile(__DIR__ . '/tmp/task_1_response.html', 'test');
|
||||
$this->assertStringEqualsFile($this->tmpFolder . '/task_1_response.html', 'test');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -149,10 +164,13 @@ class RequestsPluginTest extends UnitTestCase
|
|||
$factory = $this->createStub(HttpFactory::class);
|
||||
$factory->method('getHttp')->willReturn($http);
|
||||
|
||||
$app = $this->createStub(CMSApplicationInterface::class);
|
||||
$app->method('getLanguage')->willReturn($this->createStub(Language::class));
|
||||
$language = $this->createStub(Language::class);
|
||||
$language->method('_')->willReturn('test');
|
||||
|
||||
$plugin = new Requests(new Dispatcher(), [], $factory, __DIR__ . '/tmp');
|
||||
$app = $this->createStub(CMSApplicationInterface::class);
|
||||
$app->method('getLanguage')->willReturn($language);
|
||||
|
||||
$plugin = new Requests(new Dispatcher(), [], $factory, $this->tmpFolder);
|
||||
$plugin->setApplication($app);
|
||||
|
||||
$task = $this->createStub(Task::class);
|
||||
|
@ -170,7 +188,7 @@ class RequestsPluginTest extends UnitTestCase
|
|||
$this->assertEquals(Status::KNOCKOUT, $event->getResultSnapshot()['status']);
|
||||
$this->assertStringContainsString('SAVED', $event->getResultSnapshot()['output']);
|
||||
$this->assertEquals('http://example.com', $transport->url);
|
||||
$this->assertStringEqualsFile(__DIR__ . '/tmp/task_1_response.html', 'test');
|
||||
$this->assertStringEqualsFile($this->tmpFolder . '/task_1_response.html', 'test');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -203,10 +221,13 @@ class RequestsPluginTest extends UnitTestCase
|
|||
$factory = $this->createStub(HttpFactory::class);
|
||||
$factory->method('getHttp')->willReturn($http);
|
||||
|
||||
$app = $this->createStub(CMSApplicationInterface::class);
|
||||
$app->method('getLanguage')->willReturn($this->createStub(Language::class));
|
||||
$language = $this->createStub(Language::class);
|
||||
$language->method('_')->willReturn('test');
|
||||
|
||||
$plugin = new Requests(new Dispatcher(), [], $factory, __DIR__ . '/tmp');
|
||||
$app = $this->createStub(CMSApplicationInterface::class);
|
||||
$app->method('getLanguage')->willReturn($language);
|
||||
|
||||
$plugin = new Requests(new Dispatcher(), [], $factory, $this->tmpFolder);
|
||||
$plugin->setApplication($app);
|
||||
|
||||
$task = $this->createStub(Task::class);
|
||||
|
@ -256,7 +277,7 @@ class RequestsPluginTest extends UnitTestCase
|
|||
$app = $this->createStub(CMSApplicationInterface::class);
|
||||
$app->method('getLanguage')->willReturn($language);
|
||||
|
||||
$plugin = new Requests(new Dispatcher(), [], $factory, __DIR__ . '/tmp');
|
||||
$plugin = new Requests(new Dispatcher(), [], $factory, $this->tmpFolder);
|
||||
$plugin->setApplication($app);
|
||||
|
||||
$task = $this->createStub(Task::class);
|
||||
|
@ -305,7 +326,7 @@ class RequestsPluginTest extends UnitTestCase
|
|||
$app = $this->createStub(CMSApplicationInterface::class);
|
||||
$app->method('getLanguage')->willReturn($language);
|
||||
|
||||
$plugin = new Requests(new Dispatcher(), [], $factory, '/invalid');
|
||||
$plugin = new Requests(new Dispatcher(), [], $factory, '/proc/invalid');
|
||||
$plugin->setApplication($app);
|
||||
|
||||
$task = $this->createStub(Task::class);
|
||||
|
|
|
@ -32,6 +32,15 @@ use Joomla\Tests\Unit\UnitTestCase;
|
|||
*/
|
||||
class SiteStatusPluginTest extends UnitTestCase
|
||||
{
|
||||
/**
|
||||
* The temporary folder.
|
||||
*
|
||||
* @var string
|
||||
*
|
||||
* @since __DEPLOY_VERSION__
|
||||
*/
|
||||
private $tmpFolder;
|
||||
|
||||
/**
|
||||
* Setup
|
||||
*
|
||||
|
@ -41,11 +50,14 @@ class SiteStatusPluginTest extends UnitTestCase
|
|||
*/
|
||||
public function setUp(): void
|
||||
{
|
||||
if (!is_dir(__DIR__ . '/tmp')) {
|
||||
mkdir(__DIR__ . '/tmp');
|
||||
// Dir must be random for parallel automated tests
|
||||
$this->tmpFolder = JPATH_ROOT . '/tmp/' . rand();
|
||||
|
||||
if (!is_dir($this->tmpFolder)) {
|
||||
mkdir($this->tmpFolder);
|
||||
}
|
||||
|
||||
touch(__DIR__ . '/tmp/config.php');
|
||||
touch($this->tmpFolder . '/config.php');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -57,8 +69,8 @@ class SiteStatusPluginTest extends UnitTestCase
|
|||
*/
|
||||
public function tearDown(): void
|
||||
{
|
||||
if (is_dir(__DIR__ . '/tmp')) {
|
||||
Folder::delete(__DIR__ . '/tmp');
|
||||
if (is_dir($this->tmpFolder)) {
|
||||
Folder::delete($this->tmpFolder);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -71,10 +83,13 @@ class SiteStatusPluginTest extends UnitTestCase
|
|||
*/
|
||||
public function testSetOnlineWhenOffline()
|
||||
{
|
||||
$app = $this->createStub(CMSApplicationInterface::class);
|
||||
$app->method('getLanguage')->willReturn($this->createStub(Language::class));
|
||||
$language = $this->createStub(Language::class);
|
||||
$language->method('_')->willReturn('test');
|
||||
|
||||
$plugin = new SiteStatus(new Dispatcher(), [], ['offline' => true], __DIR__ . '/tmp/config.php');
|
||||
$app = $this->createStub(CMSApplicationInterface::class);
|
||||
$app->method('getLanguage')->willReturn($language);
|
||||
|
||||
$plugin = new SiteStatus(new Dispatcher(), [], ['offline' => true], $this->tmpFolder . '/config.php');
|
||||
$plugin->setApplication($app);
|
||||
|
||||
$task = $this->createStub(Task::class);
|
||||
|
@ -84,7 +99,7 @@ class SiteStatusPluginTest extends UnitTestCase
|
|||
$plugin->alterSiteStatus($event);
|
||||
|
||||
$this->assertEquals(Status::OK, $event->getResultSnapshot()['status']);
|
||||
$this->assertStringContainsString('$offline = false;', file_get_contents(__DIR__ . '/tmp/config.php'));
|
||||
$this->assertStringContainsString('$offline = false;', file_get_contents($this->tmpFolder . '/config.php'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -96,10 +111,13 @@ class SiteStatusPluginTest extends UnitTestCase
|
|||
*/
|
||||
public function testSetOnlineWhenOnline()
|
||||
{
|
||||
$app = $this->createStub(CMSApplicationInterface::class);
|
||||
$app->method('getLanguage')->willReturn($this->createStub(Language::class));
|
||||
$language = $this->createStub(Language::class);
|
||||
$language->method('_')->willReturn('test');
|
||||
|
||||
$plugin = new SiteStatus(new Dispatcher(), [], ['offline' => false], __DIR__ . '/tmp/config.php');
|
||||
$app = $this->createStub(CMSApplicationInterface::class);
|
||||
$app->method('getLanguage')->willReturn($language);
|
||||
|
||||
$plugin = new SiteStatus(new Dispatcher(), [], ['offline' => false], $this->tmpFolder . '/config.php');
|
||||
$plugin->setApplication($app);
|
||||
|
||||
$task = $this->createStub(Task::class);
|
||||
|
@ -109,7 +127,7 @@ class SiteStatusPluginTest extends UnitTestCase
|
|||
$plugin->alterSiteStatus($event);
|
||||
|
||||
$this->assertEquals(Status::OK, $event->getResultSnapshot()['status']);
|
||||
$this->assertStringContainsString('$offline = false;', file_get_contents(__DIR__ . '/tmp/config.php'));
|
||||
$this->assertStringContainsString('$offline = false;', file_get_contents($this->tmpFolder . '/config.php'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -121,10 +139,13 @@ class SiteStatusPluginTest extends UnitTestCase
|
|||
*/
|
||||
public function testSetOfflineWhenOnline()
|
||||
{
|
||||
$app = $this->createStub(CMSApplicationInterface::class);
|
||||
$app->method('getLanguage')->willReturn($this->createStub(Language::class));
|
||||
$language = $this->createStub(Language::class);
|
||||
$language->method('_')->willReturn('test');
|
||||
|
||||
$plugin = new SiteStatus(new Dispatcher(), [], ['offline' => false], __DIR__ . '/tmp/config.php');
|
||||
$app = $this->createStub(CMSApplicationInterface::class);
|
||||
$app->method('getLanguage')->willReturn($language);
|
||||
|
||||
$plugin = new SiteStatus(new Dispatcher(), [], ['offline' => false], $this->tmpFolder . '/config.php');
|
||||
$plugin->setApplication($app);
|
||||
|
||||
$task = $this->createStub(Task::class);
|
||||
|
@ -134,7 +155,7 @@ class SiteStatusPluginTest extends UnitTestCase
|
|||
$plugin->alterSiteStatus($event);
|
||||
|
||||
$this->assertEquals(Status::OK, $event->getResultSnapshot()['status']);
|
||||
$this->assertStringContainsString('$offline = true;', file_get_contents(__DIR__ . '/tmp/config.php'));
|
||||
$this->assertStringContainsString('$offline = true;', file_get_contents($this->tmpFolder . '/config.php'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -146,10 +167,13 @@ class SiteStatusPluginTest extends UnitTestCase
|
|||
*/
|
||||
public function testSetOfflineWhenOffline()
|
||||
{
|
||||
$app = $this->createStub(CMSApplicationInterface::class);
|
||||
$app->method('getLanguage')->willReturn($this->createStub(Language::class));
|
||||
$language = $this->createStub(Language::class);
|
||||
$language->method('_')->willReturn('test');
|
||||
|
||||
$plugin = new SiteStatus(new Dispatcher(), [], ['offline' => true], __DIR__ . '/tmp/config.php');
|
||||
$app = $this->createStub(CMSApplicationInterface::class);
|
||||
$app->method('getLanguage')->willReturn($language);
|
||||
|
||||
$plugin = new SiteStatus(new Dispatcher(), [], ['offline' => true], $this->tmpFolder . '/config.php');
|
||||
$plugin->setApplication($app);
|
||||
|
||||
$task = $this->createStub(Task::class);
|
||||
|
@ -159,7 +183,7 @@ class SiteStatusPluginTest extends UnitTestCase
|
|||
$plugin->alterSiteStatus($event);
|
||||
|
||||
$this->assertEquals(Status::OK, $event->getResultSnapshot()['status']);
|
||||
$this->assertStringContainsString('$offline = true;', file_get_contents(__DIR__ . '/tmp/config.php'));
|
||||
$this->assertStringContainsString('$offline = true;', file_get_contents($this->tmpFolder . '/config.php'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -171,10 +195,13 @@ class SiteStatusPluginTest extends UnitTestCase
|
|||
*/
|
||||
public function testToggleOffline()
|
||||
{
|
||||
$app = $this->createStub(CMSApplicationInterface::class);
|
||||
$app->method('getLanguage')->willReturn($this->createStub(Language::class));
|
||||
$language = $this->createStub(Language::class);
|
||||
$language->method('_')->willReturn('test');
|
||||
|
||||
$plugin = new SiteStatus(new Dispatcher(), [], ['offline' => false], __DIR__ . '/tmp/config.php');
|
||||
$app = $this->createStub(CMSApplicationInterface::class);
|
||||
$app->method('getLanguage')->willReturn($language);
|
||||
|
||||
$plugin = new SiteStatus(new Dispatcher(), [], ['offline' => false], $this->tmpFolder . '/config.php');
|
||||
$plugin->setApplication($app);
|
||||
|
||||
$task = $this->createStub(Task::class);
|
||||
|
@ -184,7 +211,7 @@ class SiteStatusPluginTest extends UnitTestCase
|
|||
$plugin->alterSiteStatus($event);
|
||||
|
||||
$this->assertEquals(Status::OK, $event->getResultSnapshot()['status']);
|
||||
$this->assertStringContainsString('$offline = true;', file_get_contents(__DIR__ . '/tmp/config.php'));
|
||||
$this->assertStringContainsString('$offline = true;', file_get_contents($this->tmpFolder . '/config.php'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -196,10 +223,13 @@ class SiteStatusPluginTest extends UnitTestCase
|
|||
*/
|
||||
public function testToggleOnline()
|
||||
{
|
||||
$app = $this->createStub(CMSApplicationInterface::class);
|
||||
$app->method('getLanguage')->willReturn($this->createStub(Language::class));
|
||||
$language = $this->createStub(Language::class);
|
||||
$language->method('_')->willReturn('test');
|
||||
|
||||
$plugin = new SiteStatus(new Dispatcher(), [], ['offline' => true], __DIR__ . '/tmp/config.php');
|
||||
$app = $this->createStub(CMSApplicationInterface::class);
|
||||
$app->method('getLanguage')->willReturn($language);
|
||||
|
||||
$plugin = new SiteStatus(new Dispatcher(), [], ['offline' => true], $this->tmpFolder . '/config.php');
|
||||
$plugin->setApplication($app);
|
||||
|
||||
$task = $this->createStub(Task::class);
|
||||
|
@ -209,7 +239,7 @@ class SiteStatusPluginTest extends UnitTestCase
|
|||
$plugin->alterSiteStatus($event);
|
||||
|
||||
$this->assertEquals(Status::OK, $event->getResultSnapshot()['status']);
|
||||
$this->assertStringContainsString('$offline = false;', file_get_contents(__DIR__ . '/tmp/config.php'));
|
||||
$this->assertStringContainsString('$offline = false;', file_get_contents($this->tmpFolder . '/config.php'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -227,7 +257,7 @@ class SiteStatusPluginTest extends UnitTestCase
|
|||
$app = $this->createStub(CMSApplicationInterface::class);
|
||||
$app->method('getLanguage')->willReturn($language);
|
||||
|
||||
$plugin = new SiteStatus(new Dispatcher(), [], ['offline' => true], '/invalid/config.php');
|
||||
$plugin = new SiteStatus(new Dispatcher(), [], ['offline' => true], '/proc/invalid/config.php');
|
||||
$plugin->setApplication($app);
|
||||
|
||||
$task = $this->createStub(Task::class);
|
||||
|
@ -237,6 +267,6 @@ class SiteStatusPluginTest extends UnitTestCase
|
|||
$plugin->alterSiteStatus($event);
|
||||
|
||||
$this->assertEquals(Status::KNOCKOUT, $event->getResultSnapshot()['status']);
|
||||
$this->assertFileNotExists('/invalid/config.php');
|
||||
$this->assertFileNotExists('/proc/invalid/config.php');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,15 +37,11 @@ if (!defined('JPATH_ROOT')) {
|
|||
}
|
||||
|
||||
if (!defined('JPATH_PLATFORM')) {
|
||||
define('JPATH_PLATFORM', JPATH_BASE . '/libraries');
|
||||
define('JPATH_PLATFORM', JPATH_BASE . DIRECTORY_SEPARATOR . 'libraries');
|
||||
}
|
||||
|
||||
if (!defined('JPATH_LIBRARIES')) {
|
||||
define('JPATH_LIBRARIES', JPATH_BASE . '/libraries');
|
||||
}
|
||||
|
||||
if (!defined('JPATH_CACHE')) {
|
||||
define('JPATH_CACHE', JPATH_BASE . '/cache');
|
||||
define('JPATH_LIBRARIES', JPATH_BASE . DIRECTORY_SEPARATOR . 'libraries');
|
||||
}
|
||||
|
||||
if (!defined('JPATH_CONFIGURATION')) {
|
||||
|
@ -57,27 +53,31 @@ if (!defined('JPATH_SITE')) {
|
|||
}
|
||||
|
||||
if (!defined('JPATH_ADMINISTRATOR')) {
|
||||
define('JPATH_ADMINISTRATOR', JPATH_ROOT . '/administrator');
|
||||
define('JPATH_ADMINISTRATOR', JPATH_ROOT . DIRECTORY_SEPARATOR . 'administrator');
|
||||
}
|
||||
|
||||
if (!defined('JPATH_CACHE')) {
|
||||
define('JPATH_CACHE', JPATH_ADMINISTRATOR . DIRECTORY_SEPARATOR . 'cache');
|
||||
}
|
||||
|
||||
if (!defined('JPATH_API')) {
|
||||
define('JPATH_API', JPATH_ROOT . '/api');
|
||||
define('JPATH_API', JPATH_ROOT . DIRECTORY_SEPARATOR . 'api');
|
||||
}
|
||||
|
||||
if (!defined('JPATH_INSTALLATION')) {
|
||||
define('JPATH_INSTALLATION', JPATH_ROOT . '/installation');
|
||||
define('JPATH_INSTALLATION', JPATH_ROOT . DIRECTORY_SEPARATOR . 'installation');
|
||||
}
|
||||
|
||||
if (!defined('JPATH_MANIFESTS')) {
|
||||
define('JPATH_MANIFESTS', JPATH_ADMINISTRATOR . '/manifests');
|
||||
define('JPATH_MANIFESTS', JPATH_ADMINISTRATOR . DIRECTORY_SEPARATOR . 'manifests');
|
||||
}
|
||||
|
||||
if (!defined('JPATH_PLUGINS')) {
|
||||
define('JPATH_PLUGINS', JPATH_BASE . '/plugins');
|
||||
define('JPATH_PLUGINS', JPATH_BASE . DIRECTORY_SEPARATOR . 'plugins');
|
||||
}
|
||||
|
||||
if (!defined('JPATH_THEMES')) {
|
||||
define('JPATH_THEMES', JPATH_BASE . '/templates');
|
||||
define('JPATH_THEMES', JPATH_BASE . DIRECTORY_SEPARATOR . 'templates');
|
||||
}
|
||||
|
||||
if (!defined('JDEBUG')) {
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
<phpunit bootstrap="Unit/bootstrap.php" colors="false">
|
||||
<testsuites>
|
||||
<testsuite name="Unit">
|
||||
<directory suffix="Test.php">./Unit/Libraries</directory>
|
||||
<directory suffix="Test.php">./Unit</directory>
|
||||
</testsuite>
|
||||
<testsuite name="Integration">
|
||||
<directory suffix="Test.php">./Integration/Libraries</directory>
|
||||
<directory suffix="Test.php">./Integration</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
<php>
|
||||
|
|
Loading…
Reference in New Issue
Block a user