diff --git a/lib/Doctrine/DBAL/Migrations/Configuration/Configuration.php b/lib/Doctrine/DBAL/Migrations/Configuration/Configuration.php index 67240a3d66..e8b4186ce3 100644 --- a/lib/Doctrine/DBAL/Migrations/Configuration/Configuration.php +++ b/lib/Doctrine/DBAL/Migrations/Configuration/Configuration.php @@ -203,6 +203,16 @@ public function getName() return $this->name; } + /** + * Sets the output writer. + * + * @param OutputWriter $outputWriter + */ + public function setOutputWriter(OutputWriter $outputWriter) + { + $this->outputWriter = $outputWriter; + } + /** * Returns the OutputWriter instance * diff --git a/tests/Doctrine/DBAL/Migrations/Tests/Configuration/ConfigurationTest.php b/tests/Doctrine/DBAL/Migrations/Tests/Configuration/ConfigurationTest.php new file mode 100644 index 0000000000..ef45149f58 --- /dev/null +++ b/tests/Doctrine/DBAL/Migrations/Tests/Configuration/ConfigurationTest.php @@ -0,0 +1,60 @@ +getOutputWriterMock(); + + $configuration = new Configuration( + $this->getConnectionMock(), + $outputWriter + ); + + $this->assertSame($outputWriter, $configuration->getOutputWriter()); + } + + public function testOutputWriterIsCreatedIfNotInjected() + { + $configuration = new Configuration($this->getConnectionMock()); + + $this->assertInstanceOf('Doctrine\DBAL\Migrations\OutputWriter', $configuration->getOutputWriter()); + } + + public function testOutputWriterCanBeSet() + { + $outputWriter = $this->getOutputWriterMock(); + + $configuration = new Configuration($this->getConnectionMock()); + $configuration->setOutputWriter($outputWriter); + + $this->assertSame($outputWriter, $configuration->getOutputWriter()); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|Connection + */ + private function getConnectionMock() + { + return $this->getMockBuilder('Doctrine\DBAL\Connection') + ->disableOriginalConstructor() + ->getMock() + ; + } + /** + * @return \PHPUnit_Framework_MockObject_MockObject|OutputWriter + */ + private function getOutputWriterMock() + { + return $this->getMockBuilder('Doctrine\DBAL\Migrations\OutputWriter') + ->disableOriginalConstructor() + ->getMock() + ; + } +}