function CounterTest::setUp

Same name in other branches
  1. 9 core/modules/views/tests/src/Unit/Plugin/field/CounterTest.php \Drupal\Tests\views\Unit\Plugin\field\CounterTest::setUp()
  2. 10 core/modules/views/tests/src/Unit/Plugin/field/CounterTest.php \Drupal\Tests\views\Unit\Plugin\field\CounterTest::setUp()
  3. 11.x core/modules/views/tests/src/Unit/Plugin/field/CounterTest.php \Drupal\Tests\views\Unit\Plugin\field\CounterTest::setUp()

Overrides UnitTestCase::setUp

File

core/modules/views/tests/src/Unit/Plugin/field/CounterTest.php, line 57

Class

CounterTest
@coversDefaultClass \Drupal\views\Plugin\views\field\Counter @group views

Namespace

Drupal\Tests\views\Unit\Plugin\field

Code

protected function setUp() {
    parent::setUp();
    // Setup basic stuff like the view and the display.
    $config = [];
    $config['display']['default'] = [
        'id' => 'default',
        'display_plugin' => 'default',
        'display_title' => 'Default',
    ];
    $storage = new View($config, 'view');
    $user = $this->createMock('Drupal\\Core\\Session\\AccountInterface');
    $views_data = $this->getMockBuilder('Drupal\\views\\ViewsData')
        ->disableOriginalConstructor()
        ->getMock();
    $route_provider = $this->createMock('Drupal\\Core\\Routing\\RouteProviderInterface');
    $this->view = new ViewExecutable($storage, $user, $views_data, $route_provider);
    $this->display = $this->getMockBuilder('Drupal\\views\\Plugin\\views\\display\\DisplayPluginBase')
        ->disableOriginalConstructor()
        ->getMock();
    $this->pager = $this->getMockBuilder('Drupal\\views\\Plugin\\views\\pager\\Full')
        ->disableOriginalConstructor()
        ->setMethods(NULL)
        ->getMock();
    $this->view->display_handler = $this->display;
    $this->view->pager = $this->pager;
    foreach (ViewTestData::dataSet() as $index => $set) {
        $this->testData[] = new ResultRow($set + [
            'index' => $index,
        ]);
    }
    $this->definition = [
        'title' => 'counter field',
        'plugin_type' => 'field',
    ];
}

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