Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
Signed-off-by: Nathanael Esayeas <[email protected]>
  • Loading branch information
ghostwriter committed Feb 24, 2022
1 parent 33755a5 commit 0d4f8c7
Showing 1 changed file with 27 additions and 20 deletions.
47 changes: 27 additions & 20 deletions test/Command/InspectCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@
use Laminas\ServiceManager\Inspector\EventReporter\NullEventReporter;
use Laminas\ServiceManager\Inspector\Scanner\DependencyScannerInterface;
use Laminas\ServiceManager\Inspector\Traverser\TraverserInterface;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Prophecy\Argument;
use Prophecy\PhpUnit\ProphecyTrait;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

Expand All @@ -23,7 +22,6 @@
*/
class InspectCommandTest extends TestCase
{
use ProphecyTrait;

public function testBeginsAnalysisWhenScannableDependenciesAreProvided(): void
{
Expand All @@ -33,24 +31,29 @@ public function testBeginsAnalysisWhenScannableDependenciesAreProvided(): void
'service2' => LaminasDependecyConfigFactory::class,
],
]);
/** @var DependencyScannerInterface|MockObject $scanner */
$scanner = $this->createMock(DependencyScannerInterface::class);
$scanner->method('canScan')
->withAnyParameters()
->willReturn(true);

$scanner = $this->prophesize(DependencyScannerInterface::class);
$scanner->canScan(Argument::any())->willReturn(true);

$traverser = $this->prophesize(TraverserInterface::class);
$traverser->__invoke(Argument::type(Dependency::class))->shouldBeCalled(2);
/** @var TraverserInterface|MockObject $traverser */
$traverser = $this->createMock(TraverserInterface::class);
$traverser->expects($this->exactly(2))
->method('__invoke')
->with($this->isInstanceOf(Dependency::class));

$command = new InspectCommand(
$config,
$scanner->reveal(),
$traverser->reveal(),
$scanner,
$traverser,
new NullEventCollector(),
new NullEventReporter(),
);

$command->run(
$this->prophesize(InputInterface::class)->reveal(),
$this->prophesize(OutputInterface::class)->reveal(),
$this->createMock(InputInterface::class),
$this->createMock(OutputInterface::class),
);
}

Expand All @@ -63,23 +66,27 @@ public function testSkipAnalysisWhenNonScannableDependenciesAreProvided(): void
],
]);

$scanner = $this->prophesize(DependencyScannerInterface::class);
$scanner->canScan(Argument::any())->willReturn(false);
/** @var DependencyScannerInterface|MockObject $scanner */
$scanner = $this->createMock(DependencyScannerInterface::class);
$scanner->method('canScan')->withAnyParameters()->willReturn(false);

$traverser = $this->prophesize(TraverserInterface::class);
$traverser->__invoke(Argument::type(Dependency::class))->shouldNotBeCalled();
/** @var TraverserInterface|MockObject $traverser */
$traverser = $this->createMock(TraverserInterface::class);
$traverser->expects($this->never())
->method('__invoke')
->with($this->isInstanceOf(Dependency::class));

$command = new InspectCommand(
$config,
$scanner->reveal(),
$traverser->reveal(),
$scanner,
$traverser,
new NullEventCollector(),
new NullEventReporter(),
);

$command->run(
$this->prophesize(InputInterface::class)->reveal(),
$this->prophesize(OutputInterface::class)->reveal(),
$this->createMock(InputInterface::class),
$this->createMock(OutputInterface::class),
);
}
}

0 comments on commit 0d4f8c7

Please sign in to comment.