Unverified Commit 3655e082 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3079788 by Spokje, mondrake: Remove phpunit4 polyfills from 8.8.x

parent f0e91159
Loading
Loading
Loading
Loading
+0 −12
Changes for core/tests/Drupal/Tests/Component/Bridge/ZfExtensionManagerSfContainerTest.php: 0 added lines, 12 removed lines.
Original line number Diff line number Diff line
@@ -58,14 +58,8 @@ public function testHas() {
   * @covers ::setStandalone
   */
  public function testSetStandaloneException() {
    if (method_exists($this, 'expectException')) {
    $this->expectException(\RuntimeException::class);
    $this->expectExceptionMessage('Drupal\Tests\Component\Bridge\ZfExtensionManagerSfContainerTest must implement Zend\Feed\Reader\ExtensionManagerInterface or Zend\Feed\Writer\ExtensionManagerInterface');
    }
    else {
      $this->expectException(\RuntimeException::class);
      $this->expectExceptionMessage('Drupal\Tests\Component\Bridge\ZfExtensionManagerSfContainerTest must implement Zend\Feed\Reader\ExtensionManagerInterface or Zend\Feed\Writer\ExtensionManagerInterface');
    }
    $bridge = new ZfExtensionManagerSfContainer();
    $bridge->setStandalone(static::class);
  }
@@ -74,14 +68,8 @@ public function testSetStandaloneException() {
   * @covers ::get
   */
  public function testGetContainerException() {
    if (method_exists($this, 'expectException')) {
    $this->expectException(ServiceNotFoundException::class);
    $this->expectExceptionMessage('You have requested a non-existent service "test.foo".');
    }
    else {
      $this->expectException(ServiceNotFoundException::class);
      $this->expectExceptionMessage('You have requested a non-existent service "test.foo".');
    }
    $container = new ContainerBuilder();
    $bridge = new ZfExtensionManagerSfContainer('test.');
    $bridge->setContainer($container);
+0 −27
Changes for core/tests/Drupal/Tests/Component/Datetime/DateTimePlusTest.php: 0 added lines, 27 removed lines.
Original line number Diff line number Diff line
@@ -87,14 +87,8 @@ public function testDateDiff($input1, $input2, $absolute, \DateInterval $expecte
   * @dataProvider providerTestInvalidDateDiff
   */
  public function testInvalidDateDiff($input1, $input2, $absolute) {
    if (method_exists($this, 'expectException')) {
    $this->expectException(\BadMethodCallException::class);
    $this->expectExceptionMessage('Method Drupal\Component\Datetime\DateTimePlus::diff expects parameter 1 to be a \DateTime or \Drupal\Component\Datetime\DateTimePlus object');
    }
    else {
      $this->expectException(\BadMethodCallException::class);
      $this->expectExceptionMessage('Method Drupal\Component\Datetime\DateTimePlus::diff expects parameter 1 to be a \DateTime or \Drupal\Component\Datetime\DateTimePlus object');
    }
    $interval = $input1->diff($input2, $absolute);
  }

@@ -111,12 +105,7 @@ public function testInvalidDateDiff($input1, $input2, $absolute) {
   * @dataProvider providerTestInvalidDateArrays
   */
  public function testInvalidDateArrays($input, $timezone, $class) {
    if (method_exists($this, 'expectException')) {
    $this->expectException($class);
    }
    else {
      $this->expectException($class);
    }
    $this->assertInstanceOf(
      '\Drupal\Component\DateTimePlus',
      DateTimePlus::createFromArray($input, $timezone)
@@ -254,12 +243,7 @@ public function testDateFormat($input, $timezone, $format, $format_date, $expect
   * @dataProvider providerTestInvalidDates
   */
  public function testInvalidDates($input, $timezone, $format, $message, $class) {
    if (method_exists($this, 'expectException')) {
      $this->expectException($class);
    }
    else {
    $this->expectException($class);
    }
    DateTimePlus::createFromFormat($format, $input, $timezone);
  }

@@ -817,12 +801,7 @@ public function testValidateFormat() {

    // Parse the same date with ['validate_format' => TRUE] and make sure we
    // get the expected exception.
    if (method_exists($this, 'expectException')) {
      $this->expectException(\UnexpectedValueException::class);
    }
    else {
    $this->expectException(\UnexpectedValueException::class);
    }
    $date = DateTimePlus::createFromFormat('Y-m-d H:i:s', '11-03-31 17:44:00', 'UTC', ['validate_format' => TRUE]);
  }

@@ -881,14 +860,8 @@ public function testChainableNonChainable() {
   * @covers ::__call
   */
  public function testChainableNonCallable() {
    if (method_exists($this, 'expectException')) {
    $this->expectException(\BadMethodCallException::class);
    $this->expectExceptionMessage('Call to undefined method Drupal\Component\Datetime\DateTimePlus::nonexistent()');
    }
    else {
      $this->expectException(\BadMethodCallException::class);
      $this->expectExceptionMessage('Call to undefined method Drupal\Component\Datetime\DateTimePlus::nonexistent()');
    }
    $date = new DateTimePlus('now', 'Australia/Sydney');
    $date->setTimezone(new \DateTimeZone('America/New_York'))->nonexistent();
  }
+0 −80
Changes for core/tests/Drupal/Tests/Component/DependencyInjection/ContainerTest.php: 0 added lines, 80 removed lines.
Original line number Diff line number Diff line
@@ -70,12 +70,7 @@ protected function setUp() {
  public function testConstruct() {
    $container_definition = $this->getMockContainerDefinition();
    $container_definition['machine_format'] = !$this->machineFormat;
    if (method_exists($this, 'expectException')) {
    $this->expectException(InvalidArgumentException::class);
    }
    else {
      $this->expectException(InvalidArgumentException::class);
    }
    $container = new $this->containerClass($container_definition);
  }

@@ -98,12 +93,7 @@ public function testGetParameter() {
   * @covers ::getAlternatives
   */
  public function testGetParameterIfNotFound() {
    if (method_exists($this, 'expectException')) {
    $this->expectException(ParameterNotFoundException::class);
    }
    else {
      $this->expectException(ParameterNotFoundException::class);
    }
    $this->container->getParameter('parameter_that_does_not_exist');
  }

@@ -113,12 +103,7 @@ public function testGetParameterIfNotFound() {
   * @covers ::getParameter
   */
  public function testGetParameterIfNotFoundBecauseNull() {
    if (method_exists($this, 'expectException')) {
    $this->expectException(ParameterNotFoundException::class);
    }
    else {
      $this->expectException(ParameterNotFoundException::class);
    }
    $this->container->getParameter(NULL);
  }

@@ -152,12 +137,7 @@ public function testSetParameterWithUnfrozenContainer() {
   */
  public function testSetParameterWithFrozenContainer() {
    $this->container = new $this->containerClass($this->containerDefinition);
    if (method_exists($this, 'expectException')) {
    $this->expectException(LogicException::class);
    }
    else {
      $this->expectException(LogicException::class);
    }
    $this->container->setParameter('some_config', 'new_value');
  }

@@ -262,12 +242,7 @@ public function testHasForAliasedService() {
   * @covers ::createService
   */
  public function testGetForCircularServices() {
    if (method_exists($this, 'expectException')) {
    $this->expectException(ServiceCircularReferenceException::class);
    }
    else {
      $this->expectException(ServiceCircularReferenceException::class);
    }
    $this->container->get('circular_dependency');
  }

@@ -280,12 +255,7 @@ public function testGetForCircularServices() {
   * @covers ::getServiceAlternatives
   */
  public function testGetForNonExistantService() {
    if (method_exists($this, 'expectException')) {
    $this->expectException(ServiceNotFoundException::class);
    }
    else {
      $this->expectException(ServiceNotFoundException::class);
    }
    $this->container->get('service_not_exists');
  }

@@ -334,12 +304,7 @@ public function testGetForParameterDependencyWithExceptionOnSecondCall() {

    // Reset the service.
    $this->container->set('service_parameter_not_exists', NULL);
    if (method_exists($this, 'expectException')) {
    $this->expectException(InvalidArgumentException::class);
    }
    else {
      $this->expectException(InvalidArgumentException::class);
    }
    $this->container->get('service_parameter_not_exists');
  }

@@ -351,12 +316,7 @@ public function testGetForParameterDependencyWithExceptionOnSecondCall() {
   * @covers ::resolveServicesAndParameters
   */
  public function testGetForNonExistantParameterDependencyWithException() {
    if (method_exists($this, 'expectException')) {
    $this->expectException(InvalidArgumentException::class);
    }
    else {
      $this->expectException(InvalidArgumentException::class);
    }
    $this->container->get('service_parameter_not_exists');
  }

@@ -381,12 +341,7 @@ public function testGetForNonExistantServiceDependency() {
   * @covers ::getAlternatives
   */
  public function testGetForNonExistantServiceDependencyWithException() {
    if (method_exists($this, 'expectException')) {
    $this->expectException(ServiceNotFoundException::class);
    }
    else {
      $this->expectException(ServiceNotFoundException::class);
    }
    $this->container->get('service_dependency_not_exists');
  }

@@ -406,12 +361,7 @@ public function testGetForNonExistantServiceWhenUsingNull() {
   * @covers ::createService
   */
  public function testGetForNonExistantNULLService() {
    if (method_exists($this, 'expectException')) {
    $this->expectException(ServiceNotFoundException::class);
    }
    else {
      $this->expectException(ServiceNotFoundException::class);
    }
    $this->container->get(NULL);
  }

@@ -437,12 +387,7 @@ public function testGetForNonExistantServiceMultipleTimes() {
   */
  public function testGetForNonExistantServiceWithExceptionOnSecondCall() {
    $this->assertNull($this->container->get('service_not_exists', ContainerInterface::NULL_ON_INVALID_REFERENCE), 'Not found service does nto throw exception.');
    if (method_exists($this, 'expectException')) {
    $this->expectException(ServiceNotFoundException::class);
    }
    else {
      $this->expectException(ServiceNotFoundException::class);
    }
    $this->container->get('service_not_exists');
  }

@@ -478,12 +423,7 @@ public function testGetForSyntheticService() {
   * @covers ::createService
   */
  public function testGetForSyntheticServiceWithException() {
    if (method_exists($this, 'expectException')) {
    $this->expectException(RuntimeException::class);
    }
    else {
      $this->expectException(RuntimeException::class);
    }
    $this->container->get('synthetic');
  }

@@ -522,12 +462,7 @@ public function testGetForInstantiationWithVariousArgumentLengths() {
   * @covers ::createService
   */
  public function testGetForWrongFactory() {
    if (method_exists($this, 'expectException')) {
    $this->expectException(RuntimeException::class);
    }
    else {
      $this->expectException(RuntimeException::class);
    }
    $this->container->get('wrong_factory');
  }

@@ -565,12 +500,7 @@ public function testGetForFactoryClass() {
   * @covers ::createService
   */
  public function testGetForConfiguratorWithException() {
    if (method_exists($this, 'expectException')) {
    $this->expectException(InvalidArgumentException::class);
    }
    else {
      $this->expectException(InvalidArgumentException::class);
    }
    $this->container->get('configurable_service_exception');
  }

@@ -668,12 +598,7 @@ public function testResolveServicesAndParametersForOptionalServiceDependencies()
   * @covers ::resolveServicesAndParameters
   */
  public function testResolveServicesAndParametersForInvalidArgument() {
    if (method_exists($this, 'expectException')) {
    $this->expectException(InvalidArgumentException::class);
    }
    else {
      $this->expectException(InvalidArgumentException::class);
    }
    $this->container->get('invalid_argument_service');
  }

@@ -687,12 +612,7 @@ public function testResolveServicesAndParametersForInvalidArgument() {
  public function testResolveServicesAndParametersForInvalidArguments() {
    // In case the machine-optimized format is not used, we need to simulate the
    // test failure.
    if (method_exists($this, 'expectException')) {
    $this->expectException(InvalidArgumentException::class);
    }
    else {
      $this->expectException(InvalidArgumentException::class);
    }
    if (!$this->machineFormat) {
      throw new InvalidArgumentException('Simulating the test failure.');
    }
+0 −20
Changes for core/tests/Drupal/Tests/Component/DependencyInjection/Dumper/OptimizedPhpArrayDumperTest.php: 0 added lines, 20 removed lines.
Original line number Diff line number Diff line
@@ -545,12 +545,7 @@ public function testGetServiceDefinitionForDecoratedService() {
      $services['bar'] = $bar_definition;

      $this->containerBuilder->getDefinitions()->willReturn($services);
      if (method_exists($this, 'expectException')) {
      $this->expectException(InvalidArgumentException::class);
      }
      else {
        $this->expectException(InvalidArgumentException::class);
      }
      $this->dumper->getArray();
    }

@@ -567,12 +562,7 @@ public function testGetServiceDefinitionForExpression() {
      $services['bar'] = $bar_definition;

      $this->containerBuilder->getDefinitions()->willReturn($services);
      if (method_exists($this, 'expectException')) {
      $this->expectException(RuntimeException::class);
      }
      else {
        $this->expectException(RuntimeException::class);
      }
      $this->dumper->getArray();
    }

@@ -589,12 +579,7 @@ public function testGetServiceDefinitionForObject() {
      $services['bar'] = $bar_definition;

      $this->containerBuilder->getDefinitions()->willReturn($services);
      if (method_exists($this, 'expectException')) {
      $this->expectException(RuntimeException::class);
      }
      else {
        $this->expectException(RuntimeException::class);
      }
      $this->dumper->getArray();
    }

@@ -611,12 +596,7 @@ public function testGetServiceDefinitionForResource() {
      $services['bar'] = $bar_definition;

      $this->containerBuilder->getDefinitions()->willReturn($services);
      if (method_exists($this, 'expectException')) {
      $this->expectException(RuntimeException::class);
      }
      else {
        $this->expectException(RuntimeException::class);
      }
      $this->dumper->getArray();
    }

+0 −12
Changes for core/tests/Drupal/Tests/Component/Discovery/YamlDirectoryDiscoveryTest.php: 0 added lines, 12 removed lines.
Original line number Diff line number Diff line
@@ -124,14 +124,8 @@ public function testDiscoveryAlternateId() {
   * @covers ::getIdentifier
   */
  public function testDiscoveryNoIdException() {
    if (method_exists($this, 'expectException')) {
    $this->expectException(DiscoveryException::class);
    $this->expectExceptionMessage('The vfs://modules/test_1/item_1.test.yml contains no data in the identifier key \'id\'');
    }
    else {
      $this->expectException(DiscoveryException::class);
      $this->expectExceptionMessage('The vfs://modules/test_1/item_1.test.yml contains no data in the identifier key \'id\'');
    }
    vfsStream::setup('modules', NULL, [
      'test_1' => [
        'item_1.test.yml' => "",
@@ -151,14 +145,8 @@ public function testDiscoveryNoIdException() {
   * @covers ::findAll
   */
  public function testDiscoveryInvalidYamlException() {
    if (method_exists($this, 'expectException')) {
    $this->expectException(DiscoveryException::class);
    $this->expectExceptionMessage('The vfs://modules/test_1/item_1.test.yml contains invalid YAML');
    }
    else {
      $this->expectException(DiscoveryException::class);
      $this->expectExceptionMessage('The vfs://modules/test_1/item_1.test.yml contains invalid YAML');
    }
    vfsStream::setup('modules', NULL, [
      'test_1' => [
        'item_1.test.yml' => "id: invalid\nfoo : [bar}",
Loading