mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge pull request #10804 from creative-commoners/pulls/5/unit-test-buildtask
MNT Add BuildTaskTest
This commit is contained in:
commit
fd57f06755
43
tests/php/Dev/BuildTaskTest.php
Normal file
43
tests/php/Dev/BuildTaskTest.php
Normal file
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\Dev\Tests;
|
||||
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
use SilverStripe\Dev\BuildTask;
|
||||
|
||||
class BuildTaskTest extends SapphireTest
|
||||
{
|
||||
/**
|
||||
* Test that the default `$enabled` property is used when the new `is_enabled` config is not used
|
||||
* Test that the `is_enabled` config overrides `$enabled` property
|
||||
*
|
||||
* This test should be removed in CMS 6 as the default $enabled property is now deprecated
|
||||
*/
|
||||
public function testIsEnabled(): void
|
||||
{
|
||||
// enabledTask
|
||||
$enabledTask = new class extends BuildTask
|
||||
{
|
||||
protected $enabled = true;
|
||||
public function run($request)
|
||||
{
|
||||
// noop
|
||||
}
|
||||
};
|
||||
$this->assertTrue($enabledTask->isEnabled());
|
||||
$enabledTask->config()->set('is_enabled', false);
|
||||
$this->assertFalse($enabledTask->isEnabled());
|
||||
// disabledTask
|
||||
$disabledTask = new class extends BuildTask
|
||||
{
|
||||
protected $enabled = false;
|
||||
public function run($request)
|
||||
{
|
||||
// noop
|
||||
}
|
||||
};
|
||||
$this->assertFalse($disabledTask->isEnabled());
|
||||
$disabledTask->config()->set('is_enabled', true);
|
||||
$this->assertTrue($disabledTask->isEnabled());
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user