Skip to content

Commit

Permalink
[Tests] Streamline
Browse files Browse the repository at this point in the history
  • Loading branch information
OskarStark authored and nicolas-grekas committed Oct 31, 2023
1 parent 338638e commit eb1bcaf
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions Tests/Compiler/CheckTypeDeclarationsPassTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -265,17 +265,15 @@ public function testProcessSuccessWhenPassingNullToOptionalThatDoesNotAcceptNull

public function testProcessFailsWhenPassingBadTypeToOptional()
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('Invalid definition for service "bar": argument 1 of "Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\CheckTypeDeclarationsPass\\BarOptionalArgument::__construct()" accepts "stdClass", "string" passed.');

$container = new ContainerBuilder();

$container->register('bar', BarOptionalArgument::class)
->addArgument('string instead of stdClass');

(new CheckTypeDeclarationsPass(true))->process($container);
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('Invalid definition for service "bar": argument 1 of "Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\CheckTypeDeclarationsPass\\BarOptionalArgument::__construct()" accepts "stdClass", "string" passed.');

$this->assertNull($container->get('bar')->foo);
(new CheckTypeDeclarationsPass(true))->process($container);
}

public function testProcessSuccessScalarType()
Expand Down Expand Up @@ -604,17 +602,15 @@ public function testProcessDoesNotThrowsExceptionOnValidTypes()

public function testProcessThrowsOnIterableTypeWhenScalarPassed()
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('Invalid definition for service "bar_call": argument 1 of "Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\CheckTypeDeclarationsPass\\BarMethodCall::setIterable()" accepts "iterable", "int" passed.');

$container = new ContainerBuilder();

$container->register('bar_call', BarMethodCall::class)
->addMethodCall('setIterable', [2]);

(new CheckTypeDeclarationsPass(true))->process($container);
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('Invalid definition for service "bar_call": argument 1 of "Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\CheckTypeDeclarationsPass\\BarMethodCall::setIterable()" accepts "iterable", "int" passed.');

$this->assertInstanceOf(\stdClass::class, $container->get('bar')->foo);
(new CheckTypeDeclarationsPass(true))->process($container);
}

public function testProcessResolveExpressions()
Expand Down

0 comments on commit eb1bcaf

Please sign in to comment.