public function RenderStackTest::test_drupal_process_attached in Render cache 7.2
@covers ::drupal_process_attached()
File
- tests/
src/ Cache/ RenderStackTest.php, line 779 - Contains \Drupal\render_cache\Tests\Cache\RenderStackTest
Class
- RenderStackTest
- @coversDefaultClass \Drupal\render_cache\Cache\RenderStack @group cache
Namespace
Drupal\render_cache\Tests\CacheCode
public function test_drupal_process_attached() {
$this->renderStack
->shouldReceive('callOriginalFunction')
->twice()
->andReturn(FALSE, TRUE);
$this->renderStack
->shouldReceive('collectAttached')
->twice()
->andReturnUsing(array(
$this,
'helperCollectAttached',
));
$elements_not_found = array(
'#attached' => array(
'library' => array(
'not_exist',
'foo',
),
),
);
$elements_found = array(
'#attached' => array(
'library' => array(
array(
'contextual',
'contextual-links',
),
),
'js' => array(
'foo.js',
),
'css' => array(
'bar.css',
),
'drupal_set_html_head' => array(
'X-Foo' => 'Baz',
),
),
);
$this
->assertFalse($this->renderStack
->drupal_process_attached($elements_not_found), 'Original function returns FALSE and is called one time.');
$this->renderStack
->increaseRecursion();
$this
->assertTrue($this->renderStack
->drupal_process_attached($elements_found), 'Dynamic call path returns TRUE when found.');
// @todo Fix this test.
// $this->assertFalse($this->renderStack->drupal_process_attached($elements_not_found), 'Lazy function path returns FALSE when not found.');
$storage = $this->renderStack
->decreaseRecursion();
$this
->assertEquals($elements_found, $storage, 'Storage matches what was pushed via drupal_process_attached.');
$this
->assertTrue($this->renderStack
->drupal_process_attached($elements_found), 'Original function returns TRUE and is called one time.');
}