public function RenderStackTest::test_drupal_add_library in Render cache 7.2
@covers ::drupal_add_library()
File
- tests/
src/ Cache/ RenderStackTest.php, line 746 - 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_add_library() {
$this->renderStack
->shouldReceive('callOriginalFunction')
->twice()
->andReturn(FALSE, TRUE);
$this->renderStack
->shouldReceive('collectAttached')
->twice()
->andReturnUsing(array(
$this,
'helperCollectAttached',
));
$elements_found = array(
'#attached' => array(
'library' => array(
array(
'contextual',
'contextual-links',
),
),
),
);
$this
->assertFalse($this->renderStack
->drupal_add_library('not_exist', 'foo'), 'Original function returns FALSE and is called one time.');
$this->renderStack
->increaseRecursion();
$this
->assertTrue($this->renderStack
->drupal_add_library('contextual', 'contextual-links'), 'Dynamic call path returns TRUE when found.');
// @todo Fix this test.
// $this->assertFalse($this->renderStack->drupal_add_library('not_exist', 'foo'), 'Dynamic call 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('contextual', 'contextual-links'), 'Original function returns TRUE and is called one time.');
}