class LingotekSettingsTabUtilitiesFormTest in Lingotek Translation 8.2
Same name and namespace in other branches
- 8 tests/src/Unit/Form/LingotekSettingsTabUtilitiesFormTest.php \Drupal\Tests\lingotek\Unit\Form\LingotekSettingsTabUtilitiesFormTest
- 4.0.x tests/src/Unit/Form/LingotekSettingsTabUtilitiesFormTest.php \Drupal\Tests\lingotek\Unit\Form\LingotekSettingsTabUtilitiesFormTest
- 3.0.x tests/src/Unit/Form/LingotekSettingsTabUtilitiesFormTest.php \Drupal\Tests\lingotek\Unit\Form\LingotekSettingsTabUtilitiesFormTest
- 3.1.x tests/src/Unit/Form/LingotekSettingsTabUtilitiesFormTest.php \Drupal\Tests\lingotek\Unit\Form\LingotekSettingsTabUtilitiesFormTest
- 3.2.x tests/src/Unit/Form/LingotekSettingsTabUtilitiesFormTest.php \Drupal\Tests\lingotek\Unit\Form\LingotekSettingsTabUtilitiesFormTest
- 3.3.x tests/src/Unit/Form/LingotekSettingsTabUtilitiesFormTest.php \Drupal\Tests\lingotek\Unit\Form\LingotekSettingsTabUtilitiesFormTest
- 3.4.x tests/src/Unit/Form/LingotekSettingsTabUtilitiesFormTest.php \Drupal\Tests\lingotek\Unit\Form\LingotekSettingsTabUtilitiesFormTest
- 3.5.x tests/src/Unit/Form/LingotekSettingsTabUtilitiesFormTest.php \Drupal\Tests\lingotek\Unit\Form\LingotekSettingsTabUtilitiesFormTest
- 3.6.x tests/src/Unit/Form/LingotekSettingsTabUtilitiesFormTest.php \Drupal\Tests\lingotek\Unit\Form\LingotekSettingsTabUtilitiesFormTest
- 3.7.x tests/src/Unit/Form/LingotekSettingsTabUtilitiesFormTest.php \Drupal\Tests\lingotek\Unit\Form\LingotekSettingsTabUtilitiesFormTest
- 3.8.x tests/src/Unit/Form/LingotekSettingsTabUtilitiesFormTest.php \Drupal\Tests\lingotek\Unit\Form\LingotekSettingsTabUtilitiesFormTest
@coversDefaultClass \Drupal\lingotek\Form\LingotekSettingsTabUtilitiesForm @group lingotek @preserveGlobalState disabled
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \PHPUnit\Framework\TestCase uses PhpunitCompatibilityTrait
- class \Drupal\Tests\lingotek\Unit\Form\LingotekSettingsTabUtilitiesFormTest
Expanded class hierarchy of LingotekSettingsTabUtilitiesFormTest
File
- tests/
src/ Unit/ Form/ LingotekSettingsTabUtilitiesFormTest.php, line 21
Namespace
Drupal\Tests\lingotek\Unit\FormView source
class LingotekSettingsTabUtilitiesFormTest extends UnitTestCase {
/**
* The Lingotek service
*
* @var \Drupal\lingotek\LingotekInterface|\PHPUnit_Framework_MockObject_MockObject
*/
protected $lingotek;
/**
* The config factory.
*
* @var \Drupal\Core\Config\ConfigFactoryInterface|\PHPUnit_Framework_MockObject_MockObject
*/
protected $configFactory;
/**
* @var \Drupal\Core\State\StateInterface|\PHPUnit_Framework_MockObject_MockObject
*/
protected $state;
/**
* @var \Drupal\Core\Routing\RouteBuilderInterface|\PHPUnit_Framework_MockObject_MockObject
*/
protected $routeBuilder;
/**
* @var LingotekSettingsTabUtilitiesForm
*/
protected $form;
/**
* The url generator.
*
* @var \Drupal\Core\Routing\UrlGeneratorInterface|\PHPUnit_Framework_MockObject_MockObject
*/
protected $urlGenerator;
/**
* The link generator.
*
* @var \Drupal\Core\Utility\LinkGeneratorInterface|\PHPUnit_Framework_MockObject_MockObject
*/
protected $linkGenerator;
protected function setUp() {
parent::setUp();
$this->lingotek = $this
->createMock(LingotekInterface::class);
$this->configFactory = $this
->createMock(ConfigFactoryInterface::class);
$this->state = $this
->createMock(StateInterface::class);
$this->routeBuilder = $this
->createMock(RouteBuilderInterface::class);
$this->urlGenerator = $this
->createMock(UrlGeneratorInterface::class);
$this->linkGenerator = $this
->createMock(LinkGeneratorInterface::class);
$messenger = $this
->createMock(MessengerInterface::class);
$this->form = new LingotekSettingsTabUtilitiesForm($this->lingotek, $this->configFactory, $this->state, $this->routeBuilder, $this->urlGenerator, $this->linkGenerator);
$this->form
->setStringTranslation($this
->getStringTranslationStub());
$this->form
->setMessenger($messenger);
}
/**
* @covers ::getFormId
*/
public function testGetFormId() {
$form_id = $this->form
->getFormID();
$this
->assertSame('lingotek.settings_tab_utilities_form', $form_id);
}
/**
* @covers ::buildForm
*/
public function testFormDebugUtilityWithDebugDisabled() {
$this->state
->expects($this
->any())
->method('get')
->with('lingotek.enable_debug_utilities')
->will($this
->returnValue(FALSE));
$build = [];
$form_state = $this
->createMock(FormStateInterface::class);
$build = $this->form
->buildForm($build, $form_state);
$this
->assertSame($build['utilities']['lingotek_table']['enable_debug_utilities']['actions']['submit']['#value']
->getUntranslatedString(), 'Enable debug operations');
}
/**
* @covers ::buildForm
*/
public function testFormDebugUtilityWithDebugEnabled() {
$this->state
->expects($this
->any())
->method('get')
->with('lingotek.enable_debug_utilities')
->will($this
->returnValue(TRUE));
$build = [];
$form_state = $this
->createMock(FormStateInterface::class);
$build = $this->form
->buildForm($build, $form_state);
$this
->assertSame($build['utilities']['lingotek_table']['enable_debug_utilities']['actions']['submit']['#value']
->getUntranslatedString(), 'Disable debug operations');
}
/**
* @covers ::switchDebugUtilities
*/
public function testSwitchDebugWithDebugEnabled() {
$this->state
->expects($this
->any())
->method('get')
->with('lingotek.enable_debug_utilities')
->will($this
->returnValue(TRUE));
$this->state
->expects($this
->once())
->method('set')
->with('lingotek.enable_debug_utilities', FALSE);
$this->routeBuilder
->expects($this
->once())
->method('rebuild');
$this->form
->switchDebugUtilities();
}
/**
* @covers ::switchDebugUtilities
*/
public function testSwitchDebugWithDebugDisabled() {
$this->state
->expects($this
->any())
->method('get')
->with('lingotek.enable_debug_utilities')
->will($this
->returnValue(FALSE));
$this->state
->expects($this
->once())
->method('set')
->with('lingotek.enable_debug_utilities', TRUE);
$this->routeBuilder
->expects($this
->once())
->method('rebuild');
$this->form
->switchDebugUtilities();
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
LingotekSettingsTabUtilitiesFormTest:: |
protected | property | The config factory. | |
LingotekSettingsTabUtilitiesFormTest:: |
protected | property | ||
LingotekSettingsTabUtilitiesFormTest:: |
protected | property | The Lingotek service | |
LingotekSettingsTabUtilitiesFormTest:: |
protected | property | The link generator. | |
LingotekSettingsTabUtilitiesFormTest:: |
protected | property | ||
LingotekSettingsTabUtilitiesFormTest:: |
protected | property | ||
LingotekSettingsTabUtilitiesFormTest:: |
protected | property | The url generator. | |
LingotekSettingsTabUtilitiesFormTest:: |
protected | function |
Overrides UnitTestCase:: |
|
LingotekSettingsTabUtilitiesFormTest:: |
public | function | @covers ::buildForm | |
LingotekSettingsTabUtilitiesFormTest:: |
public | function | @covers ::buildForm | |
LingotekSettingsTabUtilitiesFormTest:: |
public | function | @covers ::getFormId | |
LingotekSettingsTabUtilitiesFormTest:: |
public | function | @covers ::switchDebugUtilities | |
LingotekSettingsTabUtilitiesFormTest:: |
public | function | @covers ::switchDebugUtilities | |
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. |