View source
<?php
namespace Drupal\Tests\onlyone\Unit;
use Drupal\Tests\UnitTestCase;
use Drupal\onlyone\OnlyOnePrintDrush;
use Drupal\Tests\onlyone\Traits\OnlyOneUnitTestTrait;
class OnlyOnePrintDrushTest extends UnitTestCase {
use OnlyOneUnitTestTrait;
public function testGetContentTypesListForPrint(array $expected, array $content_types) {
$onlyOnePrintDrush = new OnlyOnePrintDrush();
$onlyOnePrintDrush
->setStringTranslation($this
->getStringTranslationStub());
$this
->assertEquals($expected, $onlyOnePrintDrush
->getContentTypesListForPrint($content_types));
}
public function providerGetContentTypesListForPrint() {
$content_types = $this
->getContentTypesObjectList();
$configured = sprintf(OnlyOnePrintDrush::GREEN_OUTPUT, 'Configured');
$expected = [
[
'page' => 'Basic Page (En: 1 Node, Es: 1 Node) ' . $configured,
'blog' => 'Blog Post (0 Nodes) ' . $configured,
'car' => 'Car (Not specified: 1 Node, Not applicable: 2 Nodes, En: 1 Node)',
'article' => 'Article (Not specified: 1 Node, En: 2 Nodes, Es: 1 Node)',
],
[
'blog' => 'Blog Post (En: 1 Node) ' . $configured,
'car' => 'Car (0 Nodes)',
],
[
'page' => 'Basic Page (En: 1 Node, Es: 1 Node) ' . $configured,
'car' => 'Car (0 Nodes) ' . $configured,
'article' => 'Article (Es: 3 Nodes)',
],
[
'page' => 'Basic Page (1 Node) ' . $configured,
'blog' => 'Blog Post (2 Nodes) ' . $configured,
'car' => 'Car (0 Nodes)',
'article' => 'Article (5 Nodes)',
],
[
'blog' => 'Blog Post (0 Nodes) ' . $configured,
'car' => 'Car (1 Node)',
],
[
'page' => 'Basic Page (1 Node) ' . $configured,
'car' => 'Car (5 Nodes) ' . $configured,
'article' => 'Article (3 Nodes)',
],
];
$tests['multilingual 1'] = [
$expected[0],
$content_types[0],
];
$tests['multilingual 2'] = [
$expected[1],
$content_types[1],
];
$tests['multilingual 3'] = [
$expected[2],
$content_types[2],
];
$tests['non-multilingual 1'] = [
$expected[3],
$content_types[3],
];
$tests['non-multilingual 2'] = [
$expected[4],
$content_types[4],
];
$tests['non-multilingual 3'] = [
$expected[5],
$content_types[5],
];
return $tests;
}
}