- <?php
- * @file
- * Test for the render example module.
- */
-
- * Functional tests for the Render Example module.
- *
- * @ingroup render_example
- */
- class RenderExampleTestCase extends BackdropWebTestCase {
-
-
- * Enable modules and create user with specific permissions.
- */
- public function setUp() {
- parent::setUp('devel', 'render_example');
- }
-
-
-
- * Asserts that the string value of the result is the same as the passed text.
- *
- * @param array $xpath_array
- * Array of keyed arrays of tests to be made. Each child array consists of
- * $xpath => $expected_text
- */
- public function assertRenderedText($xpath_array) {
- foreach ($xpath_array as $xpath => $text) {
- $result = $this->xpath($xpath);
- $this->assertTrue((string) $result[0][0] == $text, format_string('%ary selects text %text', array('%ary' => $xpath, '%text' => $text)));
- }
- }
-
-
-
- * Basic test of rendering through user interaction.
- *
- * Login user, create an example node, and test blog functionality through
- * the admin and user interfaces.
- */
- public function testRenderExampleBasic() {
-
-
- $web_user = $this->backdropCreateUser(array('access devel information', 'access content'));
- $this->backdropLogin($web_user);
-
-
-
- $this->backdropGet('examples/render_example/arrays');
- $content = $this->xpath('//*[@class="render-array"][1]');
-
- $xpath_array = array(
- '//div[@class="rendered"][starts-with(.,"Some basic text in a #markup")]' => 'Some basic text in a #markup (shows basic markup and how it is rendered)',
- '//div[@class="rendered"][starts-with(.,"This is some text that should be put to")]' => 'This is some text that should be put together | This is some more text that we need | ',
- '//div[@class="rendered"][starts-with(.,"The current time was")]' => 'The current time was when this was cached. Updated every seconds',
- '//div[@class="rendered"]/div[text()][starts-with(.,"(prefix)This one")]' => '(prefix)This one adds a prefix and suffix, which put a div around the item(suffix)',
- '//div[@class="rendered"]/div[text()][starts-with(.,"markup for pre_")]' => 'markup for pre_render and post_render example',
- '//div[@class="rendered"]/div[text()][starts-with(.,"This markup was added")]' => 'This markup was added after rendering by a #post_render',
- '//div[@class="rendered"]/div[text()][starts-with(.,"This #suffix")]' => 'This #suffix was added by a #pre_render',
- );
- $this->assertRenderedText($xpath_array);
-
- }
- }