createMock(Connection::class); $loggerMock = $this->createMock(LoggerInterface::class); $schemaMock = $this->createMock(Schema::class); $upReportMock = $this->createMock(Report::class); $upReportMock->method('getMessage') ->willReturn($expectedUpReportMessage); $upReportMock->method('getType') ->willReturn(Report::TYPE_INFO); $upReportMock->method('getIterator') ->willReturn($this->createMock(\ArrayIterator::class)); $downReportMock = $this->createMock(Report::class); $downReportMock->method('getMessage') ->willReturn($expectedDownReportMessage); $downReportMock->method('getType') ->willReturn(Report::TYPE_ERROR); $downReportMock->method('getIterator') ->willReturn($this->createMock(\ArrayIterator::class)); $migration = new class($connectionMock, $loggerMock, $upReportMock, $downReportMock) extends AbstractMigration { private $upReportMock; private $downReportMock; public function __construct(Connection $connection, LoggerInterface $logger, Report $upReportMock, Report $downReportMock) { parent::__construct($connection, $logger); $this->upReportMock = $upReportMock; $this->downReportMock = $downReportMock; } public function up(Schema $schema): void { $this->addReport($this->upReportMock); } public function down(Schema $schema): void { $this->addReport($this->downReportMock); } }; $expectedUpReportMessage .= PHP_EOL; $expectedDownReportMessage .= PHP_EOL; $loggerMock->expects($this->exactly(2)) ->method('notice') ->withConsecutive( [$this->equalTo($expectedUpReportMessage)], [$this->equalTo($expectedDownReportMessage)] ); $migration->up($schemaMock); $migration->down($schemaMock); } }