/** * Test that migrating by date chooses the correct * migration to point to. * * @dataProvider migrateDateDataProvider */ public function testMigrationsByDate($availableMigrations, $dateString, $expectedMigration) { // stub environment $envStub = $this->getMock('\\Phinx\\Migration\\Manager\\Environment', array(), array('mockenv', array())); $envStub->expects($this->once())->method('getVersions')->will($this->returnValue($availableMigrations)); $this->manager->setEnvironments(array('mockenv' => $envStub)); $this->manager->migrateToDateTime('mockenv', new \DateTime($dateString)); rewind($this->manager->getOutput()->getStream()); $output = stream_get_contents($this->manager->getOutput()->getStream()); if (is_null($expectedMigration)) { $this->assertEmpty($output); } else { $this->assertContains($expectedMigration, $output); } }