class ViewTest

Same name in this branch
  1. 10 core/modules/jsonapi/tests/src/Functional/ViewTest.php \Drupal\Tests\jsonapi\Functional\ViewTest
Same name in other branches
  1. 9 core/modules/jsonapi/tests/src/Functional/ViewTest.php \Drupal\Tests\jsonapi\Functional\ViewTest
  2. 9 core/modules/views/tests/src/Unit/Plugin/area/ViewTest.php \Drupal\Tests\views\Unit\Plugin\area\ViewTest
  3. 8.9.x core/modules/jsonapi/tests/src/Functional/ViewTest.php \Drupal\Tests\jsonapi\Functional\ViewTest
  4. 8.9.x core/modules/views/tests/src/Unit/Plugin/area/ViewTest.php \Drupal\Tests\views\Unit\Plugin\area\ViewTest
  5. 11.x core/modules/jsonapi/tests/src/Functional/ViewTest.php \Drupal\Tests\jsonapi\Functional\ViewTest
  6. 11.x 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

Expanded class hierarchy of ViewTest

File

core/modules/views/tests/src/Unit/Plugin/area/ViewTest.php, line 14

Namespace

Drupal\Tests\views\Unit\Plugin\area
View 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() : void {
        parent::setUp();
        $this->entityStorage = $this->createMock('Drupal\\Core\\Entity\\EntityStorageInterface');
        $this->viewHandler = new ViewAreaPlugin([], 'view', [], $this->entityStorage);
        $this->viewHandler->view = $this->getMockBuilder('Drupal\\views\\ViewExecutable')
            ->disableOriginalConstructor()
            ->getMock();
    }
    
    /**
     * @covers ::calculateDependencies
     */
    public function testCalculateDependencies() : void {
        
        /** @var \Drupal\views\Entity\View $view_this */
        
        /** @var \Drupal\views\Entity\View $view_other */
        $view_this = $this->createMock('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->createMock('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->assertEquals([
            'config' => [
                'view.other',
            ],
        ], $this->viewHandler
            ->calculateDependencies());
        $this->viewHandler->options['view_to_insert'] = 'this:default';
        $this->assertSame([], $this->viewHandler
            ->calculateDependencies());
    }

}

Members

Title Sort descending Deprecated Modifiers Object type Summary Overriden Title Overrides
PhpUnitWarnings::$deprecationWarnings private static property Deprecation warnings from PHPUnit to raise with @trigger_error().
PhpUnitWarnings::addWarning public function Converts PHPUnit deprecation warnings to E_USER_DEPRECATED.
RandomGeneratorTrait::getRandomGenerator protected function Gets the random generator for the utility methods.
RandomGeneratorTrait::randomMachineName protected function Generates a unique random string containing letters and numbers.
RandomGeneratorTrait::randomObject public function Generates a random PHP object.
RandomGeneratorTrait::randomString public function Generates a pseudo-random string of ASCII characters of codes 32 to 126.
RandomGeneratorTrait::randomStringValidate Deprecated public function Callback for random string validation.
UnitTestCase::$root protected property The app root. 1
UnitTestCase::getClassResolverStub protected function Returns a stub class resolver.
UnitTestCase::getConfigFactoryStub public function Returns a stub config factory that behaves according to the passed array.
UnitTestCase::getConfigStorageStub public function Returns a stub config storage that returns the supplied configuration.
UnitTestCase::getContainerWithCacheTagsInvalidator protected function Sets up a container with a cache tags invalidator.
UnitTestCase::getStringTranslationStub public function Returns a stub translation manager that just returns the passed string.
UnitTestCase::setUpBeforeClass public static function
UnitTestCase::__get public function
ViewTest::$entityStorage protected property The mocked entity storage.
ViewTest::$viewHandler protected property The view handler.
ViewTest::setUp protected function Overrides UnitTestCase::setUp
ViewTest::testCalculateDependencies public function @covers ::calculateDependencies

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.