class LingotekModerationFactoryTest in Lingotek Translation 8.2
Same name and namespace in other branches
- 4.0.x tests/src/Unit/Moderation/LingotekModerationFactoryTest.php \Drupal\Tests\lingotek\Unit\Moderation\LingotekModerationFactoryTest
- 3.0.x tests/src/Unit/Moderation/LingotekModerationFactoryTest.php \Drupal\Tests\lingotek\Unit\Moderation\LingotekModerationFactoryTest
- 3.1.x tests/src/Unit/Moderation/LingotekModerationFactoryTest.php \Drupal\Tests\lingotek\Unit\Moderation\LingotekModerationFactoryTest
- 3.2.x tests/src/Unit/Moderation/LingotekModerationFactoryTest.php \Drupal\Tests\lingotek\Unit\Moderation\LingotekModerationFactoryTest
- 3.3.x tests/src/Unit/Moderation/LingotekModerationFactoryTest.php \Drupal\Tests\lingotek\Unit\Moderation\LingotekModerationFactoryTest
- 3.4.x tests/src/Unit/Moderation/LingotekModerationFactoryTest.php \Drupal\Tests\lingotek\Unit\Moderation\LingotekModerationFactoryTest
- 3.5.x tests/src/Unit/Moderation/LingotekModerationFactoryTest.php \Drupal\Tests\lingotek\Unit\Moderation\LingotekModerationFactoryTest
- 3.6.x tests/src/Unit/Moderation/LingotekModerationFactoryTest.php \Drupal\Tests\lingotek\Unit\Moderation\LingotekModerationFactoryTest
- 3.7.x tests/src/Unit/Moderation/LingotekModerationFactoryTest.php \Drupal\Tests\lingotek\Unit\Moderation\LingotekModerationFactoryTest
- 3.8.x tests/src/Unit/Moderation/LingotekModerationFactoryTest.php \Drupal\Tests\lingotek\Unit\Moderation\LingotekModerationFactoryTest
Unit test for the moderation factory.
@coversDefaultClass \Drupal\lingotek\Moderation\LingotekModerationFactory @group lingotek @preserveGlobalState disabled
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \PHPUnit\Framework\TestCase uses PhpunitCompatibilityTrait
- class \Drupal\Tests\lingotek\Unit\Moderation\LingotekModerationFactoryTest
Expanded class hierarchy of LingotekModerationFactoryTest
File
- tests/
src/ Unit/ Moderation/ LingotekModerationFactoryTest.php, line 18
Namespace
Drupal\Tests\lingotek\Unit\ModerationView source
class LingotekModerationFactoryTest extends UnitTestCase {
/**
* @var \Drupal\lingotek\Moderation\LingotekModerationFactoryInterface
*/
protected $factory;
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->factory = new LingotekModerationFactory();
}
/**
* @covers ::addModerationConfiguration
* @covers ::getModerationConfigurationService
*/
public function testAddModerationConfiguration() {
$configServiceLast = $this
->createMock(LingotekModerationConfigurationServiceInterface::class);
$configServiceLast
->expects($this
->any())
->method('applies')
->willReturn(TRUE);
$configServiceFirst = $this
->createMock(LingotekModerationConfigurationServiceInterface::class);
$configServiceFirst
->expects($this
->any())
->method('applies')
->willReturn(TRUE);
$this->factory
->addModerationConfiguration($configServiceLast, 'last', 10);
$this->factory
->addModerationConfiguration($configServiceFirst, 'first', 100);
$configService = $this->factory
->getModerationConfigurationService();
$this
->assertEquals($configService, $configServiceFirst, 'Priority is respected if all services apply.');
}
/**
* @covers ::addModerationConfiguration
* @covers ::getModerationConfigurationService
*/
public function testAddModerationConfigurationWithANonApplyingService() {
$configServiceLast = $this
->createMock(LingotekModerationConfigurationServiceInterface::class);
$configServiceLast
->expects($this
->any())
->method('applies')
->willReturn(TRUE);
$configServiceFirst = $this
->createMock(LingotekModerationConfigurationServiceInterface::class);
$configServiceFirst
->expects($this
->any())
->method('applies')
->willReturn(FALSE);
$this->factory
->addModerationConfiguration($configServiceLast, 'last', 10);
$this->factory
->addModerationConfiguration($configServiceFirst, 'first', 100);
$configService = $this->factory
->getModerationConfigurationService();
$this
->assertEquals($configService, $configServiceLast, 'Priority is respected, but we return a services that applies.');
}
/**
* @covers ::addModerationForm
* @covers ::getModerationSettingsForm
*/
public function testAddModerationSettingsForm() {
$configServiceLast = $this
->createMock(LingotekModerationSettingsFormInterface::class);
$configServiceLast
->expects($this
->any())
->method('applies')
->willReturn(TRUE);
$configServiceFirst = $this
->createMock(LingotekModerationSettingsFormInterface::class);
$configServiceFirst
->expects($this
->any())
->method('applies')
->willReturn(TRUE);
$this->factory
->addModerationForm($configServiceLast, 'last', 10);
$this->factory
->addModerationForm($configServiceFirst, 'first', 100);
$configService = $this->factory
->getModerationSettingsForm();
$this
->assertEquals($configService, $configServiceFirst, 'Priority is respected if all services apply.');
}
/**
* @covers ::addModerationForm
* @covers ::getModerationSettingsForm
*/
public function testAddModerationSettingsFormWithANonApplyingService() {
$configServiceLast = $this
->createMock(LingotekModerationSettingsFormInterface::class);
$configServiceLast
->expects($this
->any())
->method('applies')
->willReturn(TRUE);
$configServiceFirst = $this
->createMock(LingotekModerationSettingsFormInterface::class);
$configServiceFirst
->expects($this
->any())
->method('applies')
->willReturn(FALSE);
$this->factory
->addModerationForm($configServiceLast, 'last', 10);
$this->factory
->addModerationForm($configServiceFirst, 'first', 100);
$configService = $this->factory
->getModerationSettingsForm();
$this
->assertEquals($configService, $configServiceLast, 'Priority is respected, but we return a services that applies.');
}
/**
* @covers ::addModerationHandler
* @covers ::getModerationHandler
*/
public function testAddModerationHandler() {
$configServiceLast = $this
->createMock(LingotekModerationHandlerInterface::class);
$configServiceLast
->expects($this
->any())
->method('applies')
->willReturn(TRUE);
$configServiceFirst = $this
->createMock(LingotekModerationHandlerInterface::class);
$configServiceFirst
->expects($this
->any())
->method('applies')
->willReturn(TRUE);
$this->factory
->addModerationHandler($configServiceLast, 'last', 10);
$this->factory
->addModerationHandler($configServiceFirst, 'first', 100);
$configService = $this->factory
->getModerationHandler();
$this
->assertEquals($configService, $configServiceFirst, 'Priority is respected if all services apply.');
}
/**
* @covers ::addModerationHandler
* @covers ::getModerationHandler
*/
public function testAddModerationHandlerWithANonApplyingService() {
$configServiceLast = $this
->createMock(LingotekModerationHandlerInterface::class);
$configServiceLast
->expects($this
->any())
->method('applies')
->willReturn(TRUE);
$configServiceFirst = $this
->createMock(LingotekModerationHandlerInterface::class);
$configServiceFirst
->expects($this
->any())
->method('applies')
->willReturn(FALSE);
$this->factory
->addModerationHandler($configServiceLast, 'last', 10);
$this->factory
->addModerationHandler($configServiceFirst, 'first', 100);
$configService = $this->factory
->getModerationHandler();
$this
->assertEquals($configService, $configServiceLast, 'Priority is respected, but we return a services that applies.');
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
LingotekModerationFactoryTest:: |
protected | property | ||
LingotekModerationFactoryTest:: |
protected | function |
Overrides UnitTestCase:: |
|
LingotekModerationFactoryTest:: |
public | function | @covers ::addModerationConfiguration @covers ::getModerationConfigurationService | |
LingotekModerationFactoryTest:: |
public | function | @covers ::addModerationConfiguration @covers ::getModerationConfigurationService | |
LingotekModerationFactoryTest:: |
public | function | @covers ::addModerationHandler @covers ::getModerationHandler | |
LingotekModerationFactoryTest:: |
public | function | @covers ::addModerationHandler @covers ::getModerationHandler | |
LingotekModerationFactoryTest:: |
public | function | @covers ::addModerationForm @covers ::getModerationSettingsForm | |
LingotekModerationFactoryTest:: |
public | function | @covers ::addModerationForm @covers ::getModerationSettingsForm | |
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. |