You are here

abstract class ViewsXmlBackendTestBase in Views XML Backend 8

Base testing class.

Hierarchy

Expanded class hierarchy of ViewsXmlBackendTestBase

13 files declare their use of ViewsXmlBackendTestBase
DateTest.php in tests/src/Unit/Plugin/views/sort/DateTest.php
Contains \Drupal\Tests\views_xml_backend\Unit\Plugin\views\sort\DateTest.
DateTest.php in tests/src/Unit/Plugin/views/field/DateTest.php
Contains \Drupal\Tests\views_xml_backend\Unit\Plugin\views\field\DateTest.
MarkupTest.php in tests/src/Unit/Plugin/views/field/MarkupTest.php
Contains \Drupal\Tests\views_xml_backend\Unit\Plugin\views\field\MarkupTest.
NumericTest.php in tests/src/Unit/Plugin/views/filter/NumericTest.php
Contains \Drupal\Tests\views_xml_backend\Unit\Plugin\views\filter\NumericTest.
NumericTest.php in tests/src/Unit/Plugin/views/sort/NumericTest.php
Contains \Drupal\Tests\views_xml_backend\Unit\Plugin\views\sort\NumericTest.

... See full list

File

tests/src/Unit/ViewsXmlBackendTestBase.php, line 19
Contains \Drupal\Tests\views_xml_backend\Unit\ViewsXmlBackendTestBase.

Namespace

Drupal\Tests\views_xml_backend\Unit
View source
abstract class ViewsXmlBackendTestBase extends UnitTestCase {
  protected $display;
  protected $view;
  public function setUp() {
    parent::setUp();
    if (!defined('REQUEST_TIME')) {
      define('REQUEST_TIME', time());
    }
    require_once dirname(dirname(dirname(__DIR__))) . '/views_xml_backend.module';
  }
  protected function getMockedView() {
    if (isset($this->view)) {
      return $this->view
        ->reveal();
    }
    $this->view = $this
      ->prophesize(ViewExecutable::class);
    $this->view->display_handler = $this
      ->getMockedDisplay();
    $this->view
      ->getDisplay()
      ->willReturn($this
      ->getMockedDisplay());
    $this->view
      ->initPager()
      ->willReturn(TRUE);
    $this->view
      ->getStyle()
      ->willReturn(new DefaultStyle([], '', []));
    $this->view->pager = new None([], '', []);
    $this->view->field = [];
    return $this->view
      ->reveal();
  }
  protected function getMockedDisplay() {
    if (isset($this->display)) {
      return $this->display
        ->reveal();
    }
    $this->display = $this
      ->prophesize(DisplayPluginBase::class);
    $this->display
      ->getArgumentsTokens()
      ->willReturn([]);
    $this->display
      ->getOption('relationships')
      ->willReturn(FALSE);
    return $this->display
      ->reveal();
  }

}

Members

Namesort descending Modifiers Type Description Overrides
PhpunitCompatibilityTrait::getMock Deprecated public function Returns a mock object for the specified class using the available method.
PhpunitCompatibilityTrait::setExpectedException Deprecated public function Compatibility layer for PHPUnit 6 to support PHPUnit 4 code.
UnitTestCase::$randomGenerator protected property The random generator.
UnitTestCase::$root protected property The app root. 1
UnitTestCase::assertArrayEquals protected function Asserts if two arrays are equal by sorting them first.
UnitTestCase::getBlockMockWithMachineName Deprecated protected function Mocks a block with a block plugin. 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::getRandomGenerator protected function Gets the random generator for the utility methods.
UnitTestCase::getStringTranslationStub public function Returns a stub translation manager that just returns the passed string.
UnitTestCase::randomMachineName public function Generates a unique random string containing letters and numbers.
ViewsXmlBackendTestBase::$display protected property
ViewsXmlBackendTestBase::$view protected property
ViewsXmlBackendTestBase::getMockedDisplay protected function
ViewsXmlBackendTestBase::getMockedView protected function
ViewsXmlBackendTestBase::setUp public function Overrides UnitTestCase::setUp 1