class ContentHubImportQueueBaseTest in Acquia Content Hub 8
Test for Content Hub Import Queue Base.
@coversDefaultClass \Drupal\acquia_contenthub\Plugin\QueueWorker\ContentHubImportQueueBase
@group acquia_contenthub
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \PHPUnit\Framework\TestCase uses PhpunitCompatibilityTrait
- class \Drupal\Tests\acquia_contenthub\Unit\Plugin\QueueWorker\ContentHubImportQueueBaseTest
Expanded class hierarchy of ContentHubImportQueueBaseTest
File
- tests/
src/ Unit/ Plugin/ QueueWorker/ ContentHubImportQueueBaseTest.php, line 17
Namespace
Drupal\Tests\acquia_contenthub\Unit\Plugin\QueueWorkerView source
class ContentHubImportQueueBaseTest extends UnitTestCase {
/**
* Provide QueueItems for the queue process.
*/
public function provideQueueItems() {
$data = [];
$data[] = [
[
new ImportQueueItem('00000000-0000-0000-0000-000000000000'),
],
[
[
'00000000-0000-0000-0000-000000000000',
TRUE,
TRUE,
0,
],
],
];
$data[] = [
[
new ImportQueueItem('00000000-0000-0000-0000-000000000000'),
new ImportQueueItem('00000000-0001-0000-0000-000000000000', FALSE),
new ImportQueueItem('00000000-0002-0000-0000-000000000000', TRUE, TRUE, 1),
],
[
[
'00000000-0000-0000-0000-000000000000',
TRUE,
TRUE,
0,
],
[
'00000000-0001-0000-0000-000000000000',
FALSE,
TRUE,
0,
],
[
'00000000-0002-0000-0000-000000000000',
TRUE,
TRUE,
1,
],
],
];
$data[] = [
(object) [
'data' => [
new ImportQueueItem('00000000-0000-0000-0000-000000000000'),
],
],
[
[
'00000000-0000-0000-0000-000000000000',
TRUE,
TRUE,
0,
],
],
];
return $data;
}
/**
* Ensure that the queue can process given entities.
*
* @param mixed $item
* Some items to test.
* @param array $expected
* An array of expected items.
*
* @dataProvider provideQueueItems
*/
public function testProcessItem($item = [], array $expected = []) {
$import_entity_manager = $this
->getMockBuilder(ImportEntityManager::class)
->disableOriginalConstructor()
->setMethods([
'importRemoteEntity',
])
->getMock();
foreach ($expected as $index => $values) {
// @codingStandardsIgnoreStart
/**
* @var string $uuid
* @var bool $deps
* @var bool $author
* @var int $status
*/
// @codingStandardsIgnoreEnd
$values = array_combine([
'uuid',
'deps',
'author',
'status',
], $values);
extract($values);
$import_entity_manager
->expects($this
->at($index))
->method('importRemoteEntity')
->with($uuid, $deps, $author, $status);
}
$worker = $this
->getMockBuilder(ContentHubImportQueue::class)
->disableOriginalConstructor()
->setMethods([
'getEntityManager',
])
->getMock();
$worker
->expects($this
->any())
->method('getEntityManager')
->willReturn($import_entity_manager);
$worker
->processItem($item);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ContentHubImportQueueBaseTest:: |
public | function | Provide QueueItems for the queue process. | |
ContentHubImportQueueBaseTest:: |
public | function | Ensure that the queue can process given entities. | |
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. | |
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 |