Welcome To Our Shell

Mister Spy & Souheyl Bypass Shell

Current Path : /var/www/html/dataninja.cn/core/modules/views/tests/src/Unit/Plugin/

Linux ift1.ift-informatik.de 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
Upload File :
Current File : /var/www/html/dataninja.cn/core/modules/views/tests/src/Unit/Plugin/HandlerBaseTest.php

<?php

/**
 * @file
 * Contains \Drupal\Tests\views\Unit\Plugin\HandlerBaseTest.
 */

namespace Drupal\Tests\views\Unit\Plugin;

use Drupal\Tests\UnitTestCase;
use Drupal\views\Plugin\views\HandlerBase;

/**
 * @coversDefaultClass \Drupal\views\Plugin\views\HandlerBase
 * @group Views
 */
class HandlerBaseTest extends UnitTestCase {

  use HandlerTestTrait;

  /**
   * {@inheritdoc}
   */
  protected function setUp() {
    parent::setUp();

    $this->setupViewsData();
    $this->setupExecutableAndView();
    $this->setupDisplay();
  }

  /**
   * @covers ::getEntityType
   */
  public function testGetEntityTypeForFieldOnBaseTable() {
    $handler = new TestHandler([], 'test_handler', []);
    $handler->init($this->executable, $this->display);

    $this->view->expects($this->any())
      ->method('get')
      ->with('base_table')
      ->willReturn('test_entity_type_table');
    $this->viewsData->expects($this->any())
      ->method('get')
      ->with('test_entity_type_table')
      ->willReturn([
        'table' => ['entity type' => 'test_entity_type'],
      ]);
    $handler->setViewsData($this->viewsData);

    $this->assertEquals('test_entity_type', $handler->getEntityType());
  }

  /**
   * @covers ::getEntityType
   */
  public function testGetEntityTypeForFieldWithRelationship() {
    $handler = new TestHandler([], 'test_handler', []);

    $options = ['relationship' => 'test_relationship'];
    $handler->init($this->executable, $this->display, $options);

    $this->display->expects($this->atLeastOnce())
      ->method('getOption')
      ->with('relationships')
      ->willReturn(['test_relationship' => ['table' => 'test_entity_type_table', 'id' => 'test_relationship', 'field' => 'test_relationship']]);

    $this->view->expects($this->any())
      ->method('get')
      ->with('base_table')
      ->willReturn('test_entity_type_table');

    $this->viewsData->expects($this->any())
      ->method('get')
      ->willReturnMap([
        [
          'test_entity_type_table',
          [
            'table' => ['entity type' => 'test_entity_type'],
            'test_relationship' => [
              'relationship' => [
                'base' => 'test_other_entity_type_table',
                'base field' => 'id',
              ],
            ],
          ],
        ],
        [
          'test_other_entity_type_table',
          ['table' => ['entity type' => 'test_other_entity_type']],
        ],
      ]);
    $handler->setViewsData($this->viewsData);

    $this->assertEquals('test_other_entity_type', $handler->getEntityType());
  }

}

/**
 * Allow testing base handler implementation by extending the abstract class.
 */
class TestHandler extends HandlerBase {

}

bypass 1.0, Devloped By El Moujahidin (the source has been moved and devloped)
Email: contact@elmoujehidin.net bypass 1.0, Devloped By El Moujahidin (the source has been moved and devloped) Email: contact@elmoujehidin.net