class ViewExecutableFactoryTest in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/views/tests/src/Unit/ViewExecutableFactoryTest.php \Drupal\Tests\views\Unit\ViewExecutableFactoryTest
@coversDefaultClass \Drupal\views\ViewExecutableFactory @group views
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \Drupal\Tests\PHPUnit_Framework_TestCase
- class \Drupal\Tests\views\Unit\ViewExecutableFactoryTest
Expanded class hierarchy of ViewExecutableFactoryTest
File
- core/
modules/ views/ tests/ src/ Unit/ ViewExecutableFactoryTest.php, line 19 - Contains \Drupal\Tests\views\Unit\ViewExecutableFactoryTest.
Namespace
Drupal\Tests\views\UnitView source
class ViewExecutableFactoryTest extends UnitTestCase {
/**
* The mock user object.
*
* @var \Drupal\Core\Session\AccountInterface|\PHPUnit_Framework_MockObject_MockObject
*/
protected $user;
/**
* The mock request stack object.
*
* @var \Symfony\Component\HttpFoundation\RequestStack
*/
protected $requestStack;
/**
* The mock view entity.
*
* @var \Drupal\Core\Config\Entity\ConfigEntityInterface|\PHPUnit_Framework_MockObject_MockObject
*/
protected $view;
/**
* The ViewExecutableFactory class under test.
*
* @var \Drupal\views\ViewExecutableFactory
*/
protected $viewExecutableFactory;
/**
* The mocked views data.
*
* @var \Drupal\views\ViewsData|\PHPUnit_Framework_MockObject_MockObject
*/
protected $viewsData;
/**
* The mocked route provider.
*
* @var \Drupal\Core\Routing\RouteProviderInterface|\PHPUnit_Framework_MockObject_MockObject
*/
protected $routeProvider;
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->user = $this
->getMock('Drupal\\Core\\Session\\AccountInterface');
$this->requestStack = new RequestStack();
$this->view = $this
->getMock('Drupal\\views\\ViewEntityInterface');
$this->viewsData = $this
->getMockBuilder('Drupal\\views\\ViewsData')
->disableOriginalConstructor()
->getMock();
$this->routeProvider = $this
->getMock('Drupal\\Core\\Routing\\RouteProviderInterface');
$this->viewExecutableFactory = new ViewExecutableFactory($this->user, $this->requestStack, $this->viewsData, $this->routeProvider);
}
/**
* Tests the get method.
*
* @covers ::get
*/
public function testGet() {
$request_1 = new Request();
$request_2 = new Request();
$this->requestStack
->push($request_1);
$executable = $this->viewExecutableFactory
->get($this->view);
$this
->assertInstanceOf('Drupal\\views\\ViewExecutable', $executable);
$this
->assertSame($executable
->getRequest(), $request_1);
$this
->assertSame($executable
->getUser(), $this->user);
// Call get() again to ensure a new executable is created with the other
// request object.
$this->requestStack
->push($request_2);
$executable = $this->viewExecutableFactory
->get($this->view);
$this
->assertInstanceOf('Drupal\\views\\ViewExecutable', $executable);
$this
->assertSame($executable
->getRequest(), $request_2);
$this
->assertSame($executable
->getUser(), $this->user);
}
}
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. | |
ViewExecutableFactoryTest:: |
protected | property | The mock request stack object. | |
ViewExecutableFactoryTest:: |
protected | property | The mocked route provider. | |
ViewExecutableFactoryTest:: |
protected | property | The mock user object. | |
ViewExecutableFactoryTest:: |
protected | property | The mock view entity. | |
ViewExecutableFactoryTest:: |
protected | property | The ViewExecutableFactory class under test. | |
ViewExecutableFactoryTest:: |
protected | property | The mocked views data. | |
ViewExecutableFactoryTest:: |
protected | function |
Overrides UnitTestCase:: |
|
ViewExecutableFactoryTest:: |
public | function | Tests the get method. |