public function NumberPatternTest::testEdit in Commerce Core 8.2
Tests editing a number pattern.
File
- modules/
number_pattern/ tests/ src/ FunctionalJavascript/ NumberPatternTest.php, line 61
Class
- NumberPatternTest
- Tests the number pattern admin UI.
Namespace
Drupal\Tests\commerce_number_pattern\FunctionalJavascriptCode
public function testEdit() {
$number_pattern = NumberPattern::create([
'id' => 'foo',
'label' => 'Foo',
'targetEntityType' => 'entity_test_with_store',
'plugin' => 'yearly',
'configuration' => [
'initial_number' => 10,
'padding' => 2,
],
]);
$number_pattern
->save();
$this
->drupalGet($number_pattern
->toUrl('edit-form'));
$this
->assertSession()
->fieldNotExists('configuration[yearly][per_store_sequence');
$edit = [
'label' => 'Foo!',
'configuration[yearly][initial_number]' => 2,
'configuration[yearly][padding]' => 5,
];
$this
->submitForm($edit, 'Save');
$this
->assertSession()
->pageTextContains('Saved the Foo! number pattern.');
$number_pattern = NumberPattern::load('foo');
$this
->assertNotEmpty($number_pattern);
$this
->assertEquals($edit['label'], $number_pattern
->label());
$configuration = $number_pattern
->getPluginConfiguration();
$this
->assertEquals($edit['configuration[yearly][initial_number]'], $configuration['initial_number']);
$this
->assertEquals($edit['configuration[yearly][padding]'], $configuration['padding']);
}