Skip to content

Commit d9f404d

Browse files
bechtoldtorenware
authored andcommitted
Issue #2601486 by navneet0693, Mile23, bechtold, minakshiPh: List action in config entity example defined wrong
1 parent 0f00a74 commit d9f404d

File tree

2 files changed

+38
-2
lines changed

2 files changed

+38
-2
lines changed

config_entity_example/config_entity_example.links.action.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,4 @@ config_entity_example.list_action:
1111
title: 'List Robots'
1212
appears_on:
1313
- entity.robot.add_form
14-
- entity.robot.edit
15-
- entity.robot.delete
14+
- entity.robot.edit_form

config_entity_example/src/Tests/ConfigEntityExampleTest.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,43 @@ public function testConfigEntityExample() {
139139
$this->drupalGet('/examples/config-entity-example');
140140
$this->assertText($robby_label);
141141
$this->assertText($robby_machine_name);
142+
143+
// 6) Verify that required links are present on respective paths.
144+
$this->assertLinkByHref('/examples/config-entity-example/add');
145+
$this->assertLinkByHref('/examples/config-entity-example/manage/robby_machine_name');
146+
$this->assertLinkByHref('/examples/config-entity-example/manage/robby_machine_name/delete');
147+
148+
// Verify links on Add Robot.
149+
$this->drupalGet('/examples/config-entity-example/add');
150+
$this->assertActionButton('examples/config-entity-example');
151+
152+
// Verify links on Edit Robot.
153+
$this->drupalGet('/examples/config-entity-example/manage/robby_machine_name');
154+
$this->assertLinkByHref('/examples/config-entity-example/manage/robby_machine_name/delete');
155+
$this->assertActionButton('examples/config-entity-example');
156+
157+
// Verify links on Delete Robot.
158+
$this->drupalGet('/examples/config-entity-example/manage/robby_machine_name/delete');
159+
// List page will be the destination of the cancel link.
160+
$cancel_button = $this->xpath(
161+
'//a[@id="edit-cancel" and contains(@href, :path)]',
162+
[':path' => '/examples/config-entity-example']
163+
);
164+
$this->assertEqual(count($cancel_button), 1, 'Found cancel button linking to list page.');
165+
}
166+
167+
/**
168+
* Wrap an assertion for the action button.
169+
*
170+
* @param string $path
171+
* Drupal path to a page.
172+
*/
173+
protected function assertActionButton($path) {
174+
$button_element = $this->xpath(
175+
'//a[contains(@class, "button-action") and contains(@data-drupal-link-system-path, :path)]',
176+
[':path' => $path]
177+
);
178+
$this->assertEqual(count($button_element), 1, 'Found action button for path: ' . $path);
142179
}
143180

144181
}

0 commit comments

Comments
 (0)