From df29f93518a976f988026a496b35f5bbf5768fd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20Mo=CC=88ller?= Date: Tue, 18 Aug 2015 14:00:29 +0200 Subject: [PATCH 1/3] Enhancement: Assert that OutputWriter can be injected --- .../Tests/Configuration/ConfigurationTest.php | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 tests/Doctrine/DBAL/Migrations/Tests/Configuration/ConfigurationTest.php 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..2f432a4b5b --- /dev/null +++ b/tests/Doctrine/DBAL/Migrations/Tests/Configuration/ConfigurationTest.php @@ -0,0 +1,43 @@ +getOutputWriterMock(); + + $configuration = new Configuration( + $this->getConnectionMock(), + $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() + ; + } +} From 90b4220697b6185d5bcf959331384f67eea09d7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20Mo=CC=88ller?= Date: Tue, 18 Aug 2015 14:05:22 +0200 Subject: [PATCH 2/3] Enhancement: Assert that OutputWriter is created if not injected --- .../Migrations/Tests/Configuration/ConfigurationTest.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/Doctrine/DBAL/Migrations/Tests/Configuration/ConfigurationTest.php b/tests/Doctrine/DBAL/Migrations/Tests/Configuration/ConfigurationTest.php index 2f432a4b5b..ec2fb01c61 100644 --- a/tests/Doctrine/DBAL/Migrations/Tests/Configuration/ConfigurationTest.php +++ b/tests/Doctrine/DBAL/Migrations/Tests/Configuration/ConfigurationTest.php @@ -20,6 +20,13 @@ public function testConstructorSetsOutputWriter() $this->assertSame($outputWriter, $configuration->getOutputWriter()); } + public function testOutputWriterIsCreatedIfNotInjected() + { + $configuration = new Configuration($this->getConnectionMock()); + + $this->assertInstanceOf('Doctrine\DBAL\Migrations\OutputWriter', $configuration->getOutputWriter()); + } + /** * @return \PHPUnit_Framework_MockObject_MockObject|Connection */ From fd3f50fa4298cd70554abb7317d61492d2f5c11e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20Mo=CC=88ller?= Date: Tue, 18 Aug 2015 14:06:23 +0200 Subject: [PATCH 3/3] Enhancement: Allow to set OutputWriter --- .../DBAL/Migrations/Configuration/Configuration.php | 10 ++++++++++ .../Tests/Configuration/ConfigurationTest.php | 10 ++++++++++ 2 files changed, 20 insertions(+) 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 index ec2fb01c61..ef45149f58 100644 --- a/tests/Doctrine/DBAL/Migrations/Tests/Configuration/ConfigurationTest.php +++ b/tests/Doctrine/DBAL/Migrations/Tests/Configuration/ConfigurationTest.php @@ -27,6 +27,16 @@ public function testOutputWriterIsCreatedIfNotInjected() $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 */