public function RenderStackTest::test_drupal_add_assets in Render cache 7.2
@covers ::drupal_add_assets()
File
- tests/
src/ Cache/ RenderStackTest.php, line 691 - 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_assets() {
$this->renderStack
->shouldReceive('callOriginalFunction')
->twice()
->with('drupal_add_css', Mockery::any(), Mockery::any())
->andReturn(NULL);
$this->renderStack
->shouldReceive('callOriginalFunction')
->twice()
->with('drupal_add_js', Mockery::any(), Mockery::any())
->andReturn(NULL);
$this->renderStack
->shouldReceive('collectAttached')
->times(4)
->andReturnUsing(array(
$this,
'helperCollectAttached',
));
$elements_found = array(
'#attached' => array(
'js' => array(
array(
'data' => 'foo.js',
),
array(
'data' => array(
'bar' => 'baz',
),
'type' => 'setting',
),
),
'css' => array(
array(
'data' => 'foo.css',
),
),
),
);
$this
->assertNull($this->renderStack
->drupal_add_assets('js', 'foo.js'), 'Original function returns NULL and is called one time.');
$this
->assertNull($this->renderStack
->drupal_add_assets('css', 'foo.css'), 'Original function returns NULL and is called one time.');
$this->renderStack
->increaseRecursion();
$this
->assertNull($this->renderStack
->drupal_add_assets('js', 'foo.js'), 'Original function returns NULL and is called one time.');
$this
->assertNull($this->renderStack
->drupal_add_assets('css', 'foo.css'), 'Original function returns NULL and is called one time.');
$this
->assertNull($this->renderStack
->drupal_add_assets('js', array(
'bar' => 'baz',
), 'setting'), 'Original function returns NULL and is called one time.');
$storage = $this->renderStack
->decreaseRecursion();
$this
->assertEquals($elements_found, $storage, 'Storage matches what was pushed via drupal_add_assets.');
$this
->assertNull($this->renderStack
->drupal_add_assets('js', 'bar.js'), 'Original function returns NULL and is called one time.');
$this
->assertNull($this->renderStack
->drupal_add_assets('css', 'bar.css'), 'Original function returns NULL and is called one time.');
}