class ScheduledTransitionsCronUnitTest in Scheduled Transitions 8
Same name and namespace in other branches
- 2.x tests/src/Unit/ScheduledTransitionsCronUnitTest.php \Drupal\Tests\scheduled_transitions\Unit\ScheduledTransitionsCronUnitTest
Tests cron hooks.
@coversDefaultClass \Drupal\scheduled_transitions\ScheduledTransitionsHooks @group scheduled_transitions
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \PHPUnit\Framework\TestCase uses PhpunitCompatibilityTrait
- class \Drupal\Tests\scheduled_transitions\Unit\ScheduledTransitionsCronUnitTest
Expanded class hierarchy of ScheduledTransitionsCronUnitTest
File
- tests/
src/ Unit/ ScheduledTransitionsCronUnitTest.php, line 19
Namespace
Drupal\Tests\scheduled_transitions\UnitView source
class ScheduledTransitionsCronUnitTest extends UnitTestCase {
/**
* A test config factory.
*
* @var \Drupal\Core\Config\ConfigFactoryInterface
*/
protected $testConfigFactory;
/**
* Test jobs.
*
* @var \Drupal\scheduled_transitions\ScheduledTransitionsJobsInterface
*/
protected $testJobs;
/**
* ScheduledTransitionsCronUnitTest constructor.
*/
public function __construct() {
parent::__construct();
$this->testConfigFactory = $this
->createMock(ConfigFactoryInterface::class);
$this->testJobs = $this
->createMock(ScheduledTransitionsJobsInterface::class);
}
/**
* Tests creating queue items during cron.
*
* @covers ::cron
*/
public function testCronOn() : void {
$testConfig = $this
->createMock(ImmutableConfig::class);
$testConfig
->expects($this
->once())
->method('get')
->with('automation.cron_create_queue_items')
->willReturn(TRUE);
$this->testConfigFactory
->expects($this
->once())
->method('get')
->with('scheduled_transitions.settings')
->willReturn($testConfig);
$this->testJobs
->expects($this
->once())
->method('jobCreator');
$hooksService = new ScheduledTransitionsHooks($this->testConfigFactory, $this->testJobs);
$hooksService
->cron();
}
/**
* Tests not creating queue items during cron.
*
* @covers ::cron
*/
public function testCronOff() : void {
$testConfig = $this
->createMock(ImmutableConfig::class);
$testConfig
->expects($this
->once())
->method('get')
->with('automation.cron_create_queue_items')
->willReturn(FALSE);
$this->testConfigFactory
->expects($this
->once())
->method('get')
->with('scheduled_transitions.settings')
->willReturn($testConfig);
$this->testJobs
->expects($this
->never())
->method('jobCreator');
$hooksService = new ScheduledTransitionsHooks($this->testConfigFactory, $this->testJobs);
$hooksService
->cron();
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
PhpunitCompatibilityTrait:: |
public | function | Returns a mock object for the specified class using the available method. | |
PhpunitCompatibilityTrait:: |
public | function | Compatibility layer for PHPUnit 6 to support PHPUnit 4 code. | |
ScheduledTransitionsCronUnitTest:: |
protected | property | A test config factory. | |
ScheduledTransitionsCronUnitTest:: |
protected | property | Test jobs. | |
ScheduledTransitionsCronUnitTest:: |
public | function | Tests not creating queue items during cron. | |
ScheduledTransitionsCronUnitTest:: |
public | function | Tests creating queue items during cron. | |
ScheduledTransitionsCronUnitTest:: |
public | function | ScheduledTransitionsCronUnitTest constructor. | |
UnitTestCase:: |
protected | property | The random generator. | |
UnitTestCase:: |
protected | property | The app root. | 1 |
UnitTestCase:: |
protected | function | Asserts if two arrays are equal by sorting them first. | |
UnitTestCase:: |
protected | function | Mocks a block with a block plugin. | 1 |
UnitTestCase:: |
protected | function | Returns a stub class resolver. | |
UnitTestCase:: |
public | function | Returns a stub config factory that behaves according to the passed array. | |
UnitTestCase:: |
public | function | Returns a stub config storage that returns the supplied configuration. | |
UnitTestCase:: |
protected | function | Sets up a container with a cache tags invalidator. | |
UnitTestCase:: |
protected | function | Gets the random generator for the utility methods. | |
UnitTestCase:: |
public | function | Returns a stub translation manager that just returns the passed string. | |
UnitTestCase:: |
public | function | Generates a unique random string containing letters and numbers. | |
UnitTestCase:: |
protected | function | 340 |