You are here

class DeprecatedModuleHandlerTest in Drupal 8

@coversDefaultClass \Drupal\Core\Extension\ModuleHandler @runTestsInSeparateProcesses

@group Extension @group legacy

Hierarchy

Expanded class hierarchy of DeprecatedModuleHandlerTest

File

core/tests/Drupal/Tests/Core/Extension/DeprecatedModuleHandlerTest.php, line 15

Namespace

Drupal\Tests\Core\Extension
View source
class DeprecatedModuleHandlerTest extends UnitTestCase {

  /**
   * @dataProvider dependencyProvider
   * @covers ::parseDependency
   * @expectedDeprecation Drupal\Core\Extension\ModuleHandler::parseDependency is deprecated. Use \Drupal\Core\Extension\Dependency::createFromString() instead. See https://www.drupal.org/node/2756875
   * @expectedDeprecation Array access to the Drupal\Core\Extension\Dependency original_version property is deprecated. Use Drupal\Core\Extension\Dependency::getConstraintString() instead. See https://www.drupal.org/node/2756875
   * @expectedDeprecation Array access to the Drupal\Core\Extension\Dependency versions property is deprecated. See https://www.drupal.org/node/2756875
   * @expectedDeprecation Drupal\Component\Version\Constraint::toArray() only exists to provide a backwards compatibility layer. See https://www.drupal.org/node/2756875
   */
  public function testDependencyParsing($dependency, $expected) {
    $version = ModuleHandler::parseDependency($dependency);
    $this
      ->assertEquals($expected, $version);
  }

  /**
   * Provider for testing dependency parsing.
   */
  public function dependencyProvider() {
    return [
      [
        'system',
        [
          'name' => 'system',
        ],
      ],
      [
        'taxonomy',
        [
          'name' => 'taxonomy',
        ],
      ],
      [
        'views',
        [
          'name' => 'views',
        ],
      ],
      [
        'views_ui(8.x-1.0)',
        [
          'name' => 'views_ui',
          'original_version' => ' (8.x-1.0)',
          'versions' => [
            [
              'op' => '=',
              'version' => '1.0',
            ],
          ],
        ],
      ],
      /* @todo Not supported? Fix this in
            https://www.drupal.org/project/drupal/issues/3001344.
         [
           'views_ui(8.x-1.1-beta)',
           [
             'name' => 'views_ui',
             'original_version' => ' (8.x-1.1-beta)',
             'versions' => [['op' => '=', 'version' => '1.1-beta']],
           ],
         ],*/
      [
        'views_ui(8.x-1.1-alpha12)',
        [
          'name' => 'views_ui',
          'original_version' => ' (8.x-1.1-alpha12)',
          'versions' => [
            [
              'op' => '=',
              'version' => '1.1-alpha12',
            ],
          ],
        ],
      ],
      [
        'views_ui(8.x-1.1-beta8)',
        [
          'name' => 'views_ui',
          'original_version' => ' (8.x-1.1-beta8)',
          'versions' => [
            [
              'op' => '=',
              'version' => '1.1-beta8',
            ],
          ],
        ],
      ],
      [
        'views_ui(8.x-1.1-rc11)',
        [
          'name' => 'views_ui',
          'original_version' => ' (8.x-1.1-rc11)',
          'versions' => [
            [
              'op' => '=',
              'version' => '1.1-rc11',
            ],
          ],
        ],
      ],
      [
        'views_ui(8.x-1.12)',
        [
          'name' => 'views_ui',
          'original_version' => ' (8.x-1.12)',
          'versions' => [
            [
              'op' => '=',
              'version' => '1.12',
            ],
          ],
        ],
      ],
      [
        'views_ui(8.x-1.x)',
        [
          'name' => 'views_ui',
          'original_version' => ' (8.x-1.x)',
          'versions' => [
            [
              'op' => '<',
              'version' => '2.x',
            ],
            [
              'op' => '>=',
              'version' => '1.x',
            ],
          ],
        ],
      ],
      [
        'views_ui( <= 8.x-1.x)',
        [
          'name' => 'views_ui',
          'original_version' => ' ( <= 8.x-1.x)',
          'versions' => [
            [
              'op' => '<=',
              'version' => '2.x',
            ],
          ],
        ],
      ],
      [
        'views_ui(<= 8.x-1.x)',
        [
          'name' => 'views_ui',
          'original_version' => ' (<= 8.x-1.x)',
          'versions' => [
            [
              'op' => '<=',
              'version' => '2.x',
            ],
          ],
        ],
      ],
      [
        'views_ui( <=8.x-1.x)',
        [
          'name' => 'views_ui',
          'original_version' => ' ( <=8.x-1.x)',
          'versions' => [
            [
              'op' => '<=',
              'version' => '2.x',
            ],
          ],
        ],
      ],
      [
        'views_ui(>8.x-1.x)',
        [
          'name' => 'views_ui',
          'original_version' => ' (>8.x-1.x)',
          'versions' => [
            [
              'op' => '>',
              'version' => '2.x',
            ],
          ],
        ],
      ],
      [
        'drupal:views_ui(>8.x-1.x)',
        [
          'project' => 'drupal',
          'name' => 'views_ui',
          'original_version' => ' (>8.x-1.x)',
          'versions' => [
            [
              'op' => '>',
              'version' => '2.x',
            ],
          ],
        ],
      ],
    ];
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DeprecatedModuleHandlerTest::dependencyProvider public function Provider for testing dependency parsing.
DeprecatedModuleHandlerTest::testDependencyParsing public function @dataProvider dependencyProvider @covers ::parseDependency @expectedDeprecation Drupal\Core\Extension\ModuleHandler::parseDependency is deprecated. Use \Drupal\Core\Extension\Dependency::createFromString() instead. See…
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.
UnitTestCase::setUp protected function 340