Updated to Drupal 8.6.4, which is PHP 7.3 friendly. Also updated HTMLaw library....
[yaffs-website] / web / core / modules / field_ui / tests / src / Unit / FieldUiTest.php
1 <?php
2
3 namespace Drupal\Tests\field_ui\Unit;
4
5 use Drupal\Core\DependencyInjection\ContainerBuilder;
6 use Drupal\field_ui\FieldUI;
7 use Drupal\Tests\UnitTestCase;
8
9 /**
10  * @coversDefaultClass \Drupal\field_ui\FieldUI
11  *
12  * @group field_ui
13  */
14 class FieldUiTest extends UnitTestCase {
15
16   /**
17    * The path validator.
18    *
19    * @var \Drupal\Core\Path\PathValidatorInterface|\PHPUnit_Framework_MockObject_MockObject
20    */
21   protected $pathValidator;
22
23   /**
24    * {@inheritdoc}
25    */
26   protected function setUp() {
27     parent::setUp();
28
29     $this->pathValidator = $this->getMock('Drupal\Core\Path\PathValidatorInterface');
30     $container = new ContainerBuilder();
31     $container->set('path.validator', $this->pathValidator);
32     \Drupal::setContainer($container);
33   }
34
35   /**
36    * @covers ::getNextDestination
37    */
38   public function testGetNextDestination() {
39     $destinations = ['admin', 'admin/content'];
40     $expected_uri = 'base:admin';
41     $expected_query = [
42       'destinations' => ['admin/content'],
43     ];
44     $actual = FieldUI::getNextDestination($destinations);
45     $this->assertSame($expected_uri, $actual->getUri());
46     $this->assertSame($expected_query, $actual->getOption('query'));
47   }
48
49   /**
50    * @covers ::getNextDestination
51    */
52   public function testGetNextDestinationEmpty() {
53     $destinations = [];
54     $actual = FieldUI::getNextDestination($destinations);
55     $this->assertNull($actual);
56   }
57
58   /**
59    * @covers ::getNextDestination
60    */
61   public function testGetNextDestinationRouteName() {
62     $destinations = [['route_name' => 'system.admin'], ['route_name' => 'system.admin_content']];
63     $expected_route_name = 'system.admin';
64     $expected_query = [
65       'destinations' => [['route_name' => 'system.admin_content']],
66     ];
67     $actual = FieldUI::getNextDestination($destinations);
68     $this->assertSame($expected_route_name, $actual->getRouteName());
69     $this->assertSame($expected_query, $actual->getOption('query'));
70   }
71
72 }