class ViewTest in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/views/tests/src/Unit/Plugin/area/ViewTest.php \Drupal\Tests\views\Unit\Plugin\area\ViewTest
@coversDefaultClass \Drupal\views\Plugin\views\area\View @group views
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \Drupal\Tests\PHPUnit_Framework_TestCase
- class \Drupal\Tests\views\Unit\Plugin\area\ViewTest
Expanded class hierarchy of ViewTest
File
- core/
modules/ views/ tests/ src/ Unit/ Plugin/ area/ ViewTest.php, line 17 - Contains \Drupal\Tests\views\Unit\Plugin\area\ViewTest.
Namespace
Drupal\Tests\views\Unit\Plugin\areaView source
class ViewTest extends UnitTestCase {
/**
* The mocked entity storage.
*
* @var \Drupal\Core\Entity\EntityStorageInterface|\PHPUnit_Framework_MockObject_MockObject
*/
protected $entityStorage;
/**
* The view handler.
*
* @var \Drupal\views\Plugin\views\area\View
*/
protected $viewHandler;
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->entityStorage = $this
->getMock('Drupal\\Core\\Entity\\EntityStorageInterface');
$this->viewHandler = new ViewAreaPlugin(array(), 'view', array(), $this->entityStorage);
$this->viewHandler->view = $this
->getMockBuilder('Drupal\\views\\ViewExecutable')
->disableOriginalConstructor()
->getMock();
}
/**
* @covers ::calculateDependencies
*/
public function testCalculateDependencies() {
/* @var $view_this \Drupal\views\Entity\View */
/* @var $view_other \Drupal\views\Entity\View */
$view_this = $this
->getMock('Drupal\\views\\ViewEntityInterface');
$view_this
->expects($this
->any())
->method('getConfigDependencyKey')
->willReturn('config');
$view_this
->expects($this
->any())
->method('getConfigDependencyName')
->willReturn('view.this');
$view_this
->expects($this
->any())
->method('id')
->willReturn('this');
$view_other = $this
->getMock('Drupal\\views\\ViewEntityInterface');
$view_other
->expects($this
->any())
->method('getConfigDependencyKey')
->willReturn('config');
$view_other
->expects($this
->any())
->method('getConfigDependencyName')
->willReturn('view.other');
$this->entityStorage
->expects($this
->any())
->method('load')
->willReturnMap([
[
'this',
$view_this,
],
[
'other',
$view_other,
],
]);
$this->viewHandler->view->storage = $view_this;
$this->viewHandler->options['view_to_insert'] = 'other:default';
$this
->assertArrayEquals(array(
'config' => array(
'view.other',
),
), $this->viewHandler
->calculateDependencies());
$this->viewHandler->options['view_to_insert'] = 'this:default';
$this
->assertArrayEquals(array(), $this->viewHandler
->calculateDependencies());
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
UnitTestCase:: |
protected | property | The random generator. | |
UnitTestCase:: |
protected | property | The app root. | |
UnitTestCase:: |
protected | function | Asserts if two arrays are equal by sorting them first. | |
UnitTestCase:: |
protected | function | Mocks a block with a block plugin. | |
UnitTestCase:: |
protected | function | Returns a stub class resolver. | |
UnitTestCase:: |
public | function | Returns a stub config factory that behaves according to the passed in array. | |
UnitTestCase:: |
public | function | Returns a stub config storage that returns the supplied configuration. | |
UnitTestCase:: |
protected | function | Sets up a container with a cache tags invalidator. | |
UnitTestCase:: |
protected | function | Gets the random generator for the utility methods. | |
UnitTestCase:: |
public | function | Returns a stub translation manager that just returns the passed string. | |
UnitTestCase:: |
public | function | Generates a unique random string containing letters and numbers. | |
ViewTest:: |
protected | property | The mocked entity storage. | |
ViewTest:: |
protected | property | The view handler. | |
ViewTest:: |
protected | function |
Overrides UnitTestCase:: |
|
ViewTest:: |
public | function | @covers ::calculateDependencies |