diff --git a/tests/Phinx/Console/Command/CreateTest.php b/tests/Phinx/Console/Command/CreateTest.php index 49fcf4f4a..d41db24b9 100644 --- a/tests/Phinx/Console/Command/CreateTest.php +++ b/tests/Phinx/Console/Command/CreateTest.php @@ -81,7 +81,9 @@ public function testExecuteWithDuplicateMigrationNames() $command = $application->find('create'); /** @var Manager $managerStub mock the manager class */ - $managerStub = $this->getMock('\Phinx\Migration\Manager', array(), array($this->config, $this->input, $this->output)); + $managerStub = $this->getMockBuilder('\Phinx\Migration\Manager') + ->setConstructorArgs(array($this->config, $this->input, $this->output)) + ->getMock(); $command->setConfig($this->config); $command->setManager($managerStub); @@ -106,7 +108,9 @@ public function testSupplyingBothClassAndTemplateAtCommandLineThrowsException() $command = $application->find('create'); /** @var Manager $managerStub mock the manager class */ - $managerStub = $this->getMock('\Phinx\Migration\Manager', array(), array($this->config, $this->input, $this->output)); + $managerStub = $this->getMockBuilder('\Phinx\Migration\Manager') + ->setConstructorArgs(array($this->config, $this->input, $this->output)) + ->getMock(); $command->setConfig($this->config); $command->setManager($managerStub); @@ -128,7 +132,9 @@ public function testSupplyingBothClassAndTemplateInConfigThrowsException() $command = $application->find('create'); /** @var Manager $managerStub mock the manager class */ - $managerStub = $this->getMock('\Phinx\Migration\Manager', array(), array($this->config, $this->input, $this->output)); + $managerStub = $this->getMockBuilder('\Phinx\Migration\Manager') + ->setConstructorArgs(array($this->config, $this->input, $this->output)) + ->getMock(); $this->config['templates'] = array( 'file' => 'MyTemplate', @@ -188,7 +194,9 @@ public function testTemplateGeneratorsWithoutCorrectInterfaceThrowsException(arr $command = $application->find('create'); /** @var Manager $managerStub mock the manager class */ - $managerStub = $this->getMock('\Phinx\Migration\Manager', array(), array($this->config, $this->input, $this->output)); + $managerStub = $this->getMockBuilder('\Phinx\Migration\Manager') + ->setConstructorArgs(array($this->config, $this->input, $this->output)) + ->getMock(); foreach ($config as $key => $value) { $this->config[$key] = $value; @@ -250,7 +258,9 @@ public function testNullTemplateGeneratorsDoNotFail(array $config, array $comman $command = $application->find('create'); /** @var Manager $managerStub mock the manager class */ - $managerStub = $this->getMock('\Phinx\Migration\Manager', array(), array($this->config, $this->input, $this->output)); + $managerStub = $this->getMockBuilder('\Phinx\Migration\Manager') + ->setConstructorArgs(array($this->config, $this->input, $this->output)) + ->getMock(); foreach ($config as $key => $value) { $this->config[$key] = $value; @@ -311,7 +321,9 @@ public function testSimpleTemplateGeneratorsIsCorrectlyPopulated(array $config, $command = $application->find('create'); /** @var Manager $managerStub mock the manager class */ - $managerStub = $this->getMock('\Phinx\Migration\Manager', array(), array($this->config, $this->input, $this->output)); + $managerStub = $this->getMockBuilder('\Phinx\Migration\Manager') + ->setConstructorArgs(array($this->config, $this->input, $this->output)) + ->getMock(); foreach ($config as $key => $value) { $this->config[$key] = $value; diff --git a/tests/Phinx/Console/Command/MigrateTest.php b/tests/Phinx/Console/Command/MigrateTest.php index ee946d8cb..f31d9f2d8 100644 --- a/tests/Phinx/Console/Command/MigrateTest.php +++ b/tests/Phinx/Console/Command/MigrateTest.php @@ -65,7 +65,9 @@ public function testExecute() // mock the manager class /** @var Manager|PHPUnit_Framework_MockObject_MockObject $managerStub */ - $managerStub = $this->getMock('\Phinx\Migration\Manager', [], [$this->config, $this->input, $this->output]); + $managerStub = $this->getMockBuilder('\Phinx\Migration\Manager') + ->setConstructorArgs([$this->config, $this->input, $this->output]) + ->getMock(); $managerStub->expects($this->once()) ->method('migrate'); @@ -89,7 +91,9 @@ public function testExecuteWithEnvironmentOption() // mock the manager class /** @var Manager|PHPUnit_Framework_MockObject_MockObject $managerStub */ - $managerStub = $this->getMock('\Phinx\Migration\Manager', [], [$this->config, $this->input, $this->output]); + $managerStub = $this->getMockBuilder('\Phinx\Migration\Manager') + ->setConstructorArgs([$this->config, $this->input, $this->output]) + ->getMock(); $managerStub->expects($this->any()) ->method('migrate'); @@ -113,7 +117,9 @@ public function testDatabaseNameSpecified() // mock the manager class /** @var Manager|PHPUnit_Framework_MockObject_MockObject $managerStub */ - $managerStub = $this->getMock('\Phinx\Migration\Manager', [], [$this->config, $this->input, $this->output]); + $managerStub = $this->getMockBuilder('\Phinx\Migration\Manager') + ->setConstructorArgs([$this->config, $this->input, $this->output]) + ->getMock(); $managerStub->expects($this->once()) ->method('migrate'); diff --git a/tests/Phinx/Console/Command/RollbackTest.php b/tests/Phinx/Console/Command/RollbackTest.php index ba142c4b3..997ae9a5d 100644 --- a/tests/Phinx/Console/Command/RollbackTest.php +++ b/tests/Phinx/Console/Command/RollbackTest.php @@ -65,7 +65,9 @@ public function testExecute() // mock the manager class /** @var Manager|PHPUnit_Framework_MockObject_MockObject $managerStub */ - $managerStub = $this->getMock('\Phinx\Migration\Manager', array(), array($this->config, $this->input, $this->output)); + $managerStub = $this->getMockBuilder('\Phinx\Migration\Manager') + ->setConstructorArgs([$this->config, $this->input, $this->output]) + ->getMock(); $managerStub->expects($this->once()) ->method('rollback'); @@ -88,7 +90,9 @@ public function testExecuteWithEnvironmentOption() // mock the manager class /** @var Manager|PHPUnit_Framework_MockObject_MockObject $managerStub */ - $managerStub = $this->getMock('\Phinx\Migration\Manager', array(), array($this->config, $this->input, $this->output)); + $managerStub = $this->getMockBuilder('\Phinx\Migration\Manager') + ->setConstructorArgs([$this->config, $this->input, $this->output]) + ->getMock(); $managerStub->expects($this->once()) ->method('rollback'); @@ -110,7 +114,9 @@ public function testDatabaseNameSpecified() // mock the manager class /** @var Manager|PHPUnit_Framework_MockObject_MockObject $managerStub */ - $managerStub = $this->getMock('\Phinx\Migration\Manager', array(), array($this->config, $this->input, $this->output)); + $managerStub = $this->getMockBuilder('\Phinx\Migration\Manager') + ->setConstructorArgs([$this->config, $this->input, $this->output]) + ->getMock(); $managerStub->expects($this->once()) ->method('rollback'); diff --git a/tests/Phinx/Console/Command/SeedCreateTest.php b/tests/Phinx/Console/Command/SeedCreateTest.php index 607bf6fac..df0ce0f01 100644 --- a/tests/Phinx/Console/Command/SeedCreateTest.php +++ b/tests/Phinx/Console/Command/SeedCreateTest.php @@ -70,7 +70,9 @@ public function testExecute() // mock the manager class /** @var Manager|PHPUnit_Framework_MockObject_MockObject $managerStub */ - $managerStub = $this->getMock('\Phinx\Migration\Manager', array(), array($this->config, $this->input, $this->output)); + $managerStub = $this->getMockBuilder('\Phinx\Migration\Manager') + ->setConstructorArgs([$this->config, $this->input, $this->output]) + ->getMock(); $command->setConfig($this->config); $command->setManager($managerStub); @@ -94,7 +96,9 @@ public function testExecuteWithInvalidClassName() // mock the manager class /** @var Manager|PHPUnit_Framework_MockObject_MockObject $managerStub */ - $managerStub = $this->getMock('\Phinx\Migration\Manager', array(), array($this->config, $this->input, $this->output)); + $managerStub = $this->getMockBuilder('\Phinx\Migration\Manager') + ->setConstructorArgs([$this->config, $this->input, $this->output]) + ->getMock(); $command->setConfig($this->config); $command->setManager($managerStub); diff --git a/tests/Phinx/Console/Command/SeedRunTest.php b/tests/Phinx/Console/Command/SeedRunTest.php index bef1a4455..82597e4f0 100644 --- a/tests/Phinx/Console/Command/SeedRunTest.php +++ b/tests/Phinx/Console/Command/SeedRunTest.php @@ -66,7 +66,9 @@ public function testExecute() // mock the manager class /** @var Manager|PHPUnit_Framework_MockObject_MockObject $managerStub */ - $managerStub = $this->getMock('\Phinx\Migration\Manager', array(), array($this->config, $this->input, $this->output)); + $managerStub = $this->getMockBuilder('\Phinx\Migration\Manager') + ->setConstructorArgs([$this->config, $this->input, $this->output]) + ->getMock(); $managerStub->expects($this->once()) ->method('seed')->with($this->identicalTo('development'), $this->identicalTo(null)); @@ -89,7 +91,9 @@ public function testExecuteWithEnvironmentOption() // mock the manager class /** @var Manager|PHPUnit_Framework_MockObject_MockObject $managerStub */ - $managerStub = $this->getMock('\Phinx\Migration\Manager', array(), array($this->config, $this->input, $this->output)); + $managerStub = $this->getMockBuilder('\Phinx\Migration\Manager') + ->setConstructorArgs([$this->config, $this->input, $this->output]) + ->getMock(); $managerStub->expects($this->any()) ->method('migrate'); @@ -111,7 +115,9 @@ public function testDatabaseNameSpecified() // mock the manager class /** @var Manager|PHPUnit_Framework_MockObject_MockObject $managerStub */ - $managerStub = $this->getMock('\Phinx\Migration\Manager', array(), array($this->config, $this->input, $this->output)); + $managerStub = $this->getMockBuilder('\Phinx\Migration\Manager') + ->setConstructorArgs([$this->config, $this->input, $this->output]) + ->getMock(); $managerStub->expects($this->once()) ->method('seed'); @@ -133,7 +139,9 @@ public function testExecuteMultipleSeeders() // mock the manager class /** @var Manager|PHPUnit_Framework_MockObject_MockObject $managerStub */ - $managerStub = $this->getMock('\Phinx\Migration\Manager', array(), array($this->config, $this->input, $this->output)); + $managerStub = $this->getMockBuilder('\Phinx\Migration\Manager') + ->setConstructorArgs([$this->config, $this->input, $this->output]) + ->getMock(); $managerStub->expects($this->exactly(3)) ->method('seed')->withConsecutive( array($this->identicalTo('development'), $this->identicalTo('One')), diff --git a/tests/Phinx/Console/Command/StatusTest.php b/tests/Phinx/Console/Command/StatusTest.php index 26748b840..e2fdd66fe 100644 --- a/tests/Phinx/Console/Command/StatusTest.php +++ b/tests/Phinx/Console/Command/StatusTest.php @@ -65,7 +65,9 @@ public function testExecute() // mock the manager class /** @var Manager|PHPUnit_Framework_MockObject_MockObject $managerStub */ - $managerStub = $this->getMock('\Phinx\Migration\Manager', array(), array($this->config, $this->input, $this->output)); + $managerStub = $this->getMockBuilder('\Phinx\Migration\Manager') + ->setConstructorArgs([$this->config, $this->input, $this->output]) + ->getMock(); $managerStub->expects($this->once()) ->method('printStatus') ->will($this->returnValue(0)); @@ -90,7 +92,9 @@ public function testExecuteWithEnvironmentOption() // mock the manager class /** @var Manager|PHPUnit_Framework_MockObject_MockObject $managerStub */ - $managerStub = $this->getMock('\Phinx\Migration\Manager', array(), array($this->config, $this->input, $this->output)); + $managerStub = $this->getMockBuilder('\Phinx\Migration\Manager') + ->setConstructorArgs([$this->config, $this->input, $this->output]) + ->getMock(); $managerStub->expects($this->once()) ->method('printStatus') ->will($this->returnValue(0)); @@ -114,7 +118,9 @@ public function testFormatSpecified() // mock the manager class /** @var Manager|PHPUnit_Framework_MockObject_MockObject $managerStub */ - $managerStub = $this->getMock('\Phinx\Migration\Manager', array(), array($this->config, $this->input, $this->output)); + $managerStub = $this->getMockBuilder('\Phinx\Migration\Manager') + ->setConstructorArgs([$this->config, $this->input, $this->output]) + ->getMock(); $managerStub->expects($this->once()) ->method('printStatus') ->will($this->returnValue(0)); diff --git a/tests/Phinx/Db/Adapter/AdapterFactoryTest.php b/tests/Phinx/Db/Adapter/AdapterFactoryTest.php index 4a0f6fad3..1aa47892a 100644 --- a/tests/Phinx/Db/Adapter/AdapterFactoryTest.php +++ b/tests/Phinx/Db/Adapter/AdapterFactoryTest.php @@ -90,7 +90,7 @@ public function testRegisterWrapperFailure() private function getAdapterMock() { - return $this->getMock('Phinx\Db\Adapter\AdapterInterface', array()); + return $this->getMockBuilder('Phinx\Db\Adapter\AdapterInterface')->getMock(); } public function testGetWrapper() diff --git a/tests/Phinx/Db/Adapter/ProxyAdapterTest.php b/tests/Phinx/Db/Adapter/ProxyAdapterTest.php index 24299aab9..373f273be 100644 --- a/tests/Phinx/Db/Adapter/ProxyAdapterTest.php +++ b/tests/Phinx/Db/Adapter/ProxyAdapterTest.php @@ -18,7 +18,9 @@ class ProxyAdapterTest extends \PHPUnit_Framework_TestCase public function setUp() { - $stub = $this->getMock('\Phinx\Db\Adapter\PdoAdapter', array(), array(array())); + $stub = $this->getMockBuilder('\Phinx\Db\Adapter\PdoAdapter') + ->setConstructorArgs([[]]) + ->getMock(); $this->adapter = new ProxyAdapter($stub); } diff --git a/tests/Phinx/Db/Adapter/TablePrefixAdapterTest.php b/tests/Phinx/Db/Adapter/TablePrefixAdapterTest.php index 1f8482fce..bc3b5d91d 100644 --- a/tests/Phinx/Db/Adapter/TablePrefixAdapterTest.php +++ b/tests/Phinx/Db/Adapter/TablePrefixAdapterTest.php @@ -26,7 +26,9 @@ public function setUp() 'table_suffix' => '_suf', ); - $this->mock = $this->getMock('\Phinx\Db\Adapter\PdoAdapter', array(), array(array())); + $this->mock = $this->getMockBuilder('\Phinx\Db\Adapter\PdoAdapter') + ->setConstructorArgs([[]]) + ->getMock(); $this->mock ->expects($this->any()) diff --git a/tests/Phinx/Db/TableTest.php b/tests/Phinx/Db/TableTest.php index 04f36a103..7ae4cdb78 100644 --- a/tests/Phinx/Db/TableTest.php +++ b/tests/Phinx/Db/TableTest.php @@ -169,7 +169,9 @@ public function testAddTimestamps(AdapterInterface $adapter, $createdAtColumnNam public function testChangeColumn() { // stub adapter - $adapterStub = $this->getMock('\Phinx\Db\Adapter\MysqlAdapter', [], [[]]); + $adapterStub = $this->getMockBuilder('\Phinx\Db\Adapter\MysqlAdapter') + ->setConstructorArgs([[]]) + ->getMock(); $adapterStub->expects($this->once()) ->method('changeColumn'); $newColumn = new \Phinx\Db\Table\Column(); @@ -180,7 +182,9 @@ public function testChangeColumn() public function testChangeColumnWithoutAColumnObject() { // stub adapter - $adapterStub = $this->getMock('\Phinx\Db\Adapter\MysqlAdapter', [], [[]]); + $adapterStub = $this->getMockBuilder('\Phinx\Db\Adapter\MysqlAdapter') + ->setConstructorArgs([[]]) + ->getMock(); $adapterStub->expects($this->once()) ->method('changeColumn'); $table = new \Phinx\Db\Table('ntable', [], $adapterStub); @@ -190,7 +194,9 @@ public function testChangeColumnWithoutAColumnObject() public function testDropForeignKey() { // stub adapter - $adapterStub = $this->getMock('\Phinx\Db\Adapter\MysqlAdapter', [], [[]]); + $adapterStub = $this->getMockBuilder('\Phinx\Db\Adapter\MysqlAdapter') + ->setConstructorArgs([[]]) + ->getMock(); $adapterStub->expects($this->once()) ->method('dropForeignKey'); $table = new \Phinx\Db\Table('ntable', [], $adapterStub); @@ -200,7 +206,9 @@ public function testDropForeignKey() public function testGetColumns() { // stub adapter - $adapterStub = $this->getMock('\Phinx\Db\Adapter\MysqlAdapter', [], [[]]); + $adapterStub = $this->getMockBuilder('\Phinx\Db\Adapter\MysqlAdapter') + ->setConstructorArgs([[]]) + ->getMock(); $adapterStub->expects($this->once()) ->method('getColumns'); @@ -210,7 +218,9 @@ public function testGetColumns() public function testInsert() { - $adapterStub = $this->getMock('\Phinx\Db\Adapter\MysqlAdapter', [], [[]]); + $adapterStub = $this->getMockBuilder('\Phinx\Db\Adapter\MysqlAdapter') + ->setConstructorArgs([[]]) + ->getMock(); $table = new \Phinx\Db\Table('ntable', [], $adapterStub); $data = [ 'column1' => 'value1', @@ -225,7 +235,9 @@ public function testInsert() public function testInsertSaveData() { - $adapterStub = $this->getMock('\Phinx\Db\Adapter\MysqlAdapter', [], [[]]); + $adapterStub = $this->getMockBuilder('\Phinx\Db\Adapter\MysqlAdapter') + ->setConstructorArgs([[]]) + ->getMock(); $table = new \Phinx\Db\Table('ntable', [], $adapterStub); $data = [ [ @@ -257,7 +269,9 @@ public function testInsertSaveData() public function testRemoveColumn() { // stub adapter - $adapterStub = $this->getMock('\Phinx\Db\Adapter\MysqlAdapter', [], [[]]); + $adapterStub = $this->getMockBuilder('\Phinx\Db\Adapter\MysqlAdapter') + ->setConstructorArgs([[]]) + ->getMock(); $adapterStub->expects($this->once()) ->method('dropColumn'); $table = new \Phinx\Db\Table('ntable', [], $adapterStub); @@ -267,7 +281,9 @@ public function testRemoveColumn() public function testRemoveIndex() { // stub adapter - $adapterStub = $this->getMock('\Phinx\Db\Adapter\MysqlAdapter', [], [[]]); + $adapterStub = $this->getMockBuilder('\Phinx\Db\Adapter\MysqlAdapter') + ->setConstructorArgs([[]]) + ->getMock(); $adapterStub->expects($this->once()) ->method('dropIndex'); $table = new \Phinx\Db\Table('ntable', [], $adapterStub); @@ -277,7 +293,9 @@ public function testRemoveIndex() public function testRemoveIndexByName() { // stub adapter - $adapterStub = $this->getMock('\Phinx\Db\Adapter\MysqlAdapter', [], [[]]); + $adapterStub = $this->getMockBuilder('\Phinx\Db\Adapter\MysqlAdapter') + ->setConstructorArgs([[]]) + ->getMock(); $adapterStub->expects($this->once()) ->method('dropIndexByName'); $table = new \Phinx\Db\Table('ntable', [], $adapterStub); @@ -287,7 +305,9 @@ public function testRemoveIndexByName() public function testRenameColumn() { // stub adapter - $adapterStub = $this->getMock('\Phinx\Db\Adapter\MysqlAdapter', [], [[]]); + $adapterStub = $this->getMockBuilder('\Phinx\Db\Adapter\MysqlAdapter') + ->setConstructorArgs([[]]) + ->getMock(); $adapterStub->expects($this->once()) ->method('renameColumn'); $table = new \Phinx\Db\Table('ntable', [], $adapterStub); @@ -296,7 +316,9 @@ public function testRenameColumn() public function testResetAfterAddingData() { - $adapterStub = $this->getMock('\Phinx\Db\Adapter\MysqlAdapter', [], [[]]); + $adapterStub = $this->getMockBuilder('\Phinx\Db\Adapter\MysqlAdapter') + ->setConstructorArgs([[]]) + ->getMock(); $table = new \Phinx\Db\Table('ntable', [], $adapterStub); $columns = ["column1"]; $data = [["value1"]]; diff --git a/tests/Phinx/Migration/AbstractMigrationTest.php b/tests/Phinx/Migration/AbstractMigrationTest.php index 3c86321d8..e17204600 100644 --- a/tests/Phinx/Migration/AbstractMigrationTest.php +++ b/tests/Phinx/Migration/AbstractMigrationTest.php @@ -27,7 +27,9 @@ public function testAdapterMethods() $migrationStub = $this->getMockForAbstractClass('\Phinx\Migration\AbstractMigration', array(0)); // stub adapter - $adapterStub = $this->getMock('\Phinx\Db\Adapter\PdoAdapter', array(), array(array())); + $adapterStub = $this->getMockBuilder('\Phinx\Db\Adapter\PdoAdapter') + ->setConstructorArgs([[]]) + ->getMock(); // test methods $this->assertNull($migrationStub->getAdapter()); @@ -41,7 +43,9 @@ public function testSetOutputMethods() $migrationStub = $this->getMockForAbstractClass('\Phinx\Migration\AbstractMigration', array(0)); // stub output - $outputStub = $this->getMock('\Symfony\Component\Console\Output\OutputInterface', array(), array(array())); + $outputStub = $this->getMockBuilder('\Symfony\Component\Console\Output\OutputInterface') + ->setConstructorArgs([[]]) + ->getMock(); // test methods $this->assertNull($migrationStub->getOutput()); @@ -52,7 +56,9 @@ public function testSetOutputMethods() public function testGetInputMethodWithInjectedInput() { // stub input - $inputStub = $this->getMock('\Symfony\Component\Console\Input\InputInterface', array(), array(array())); + $inputStub = $this->getMockBuilder('\Symfony\Component\Console\Input\InputInterface') + ->setConstructorArgs([[]]) + ->getMock(); // stub migration $migrationStub = $this->getMockForAbstractClass('\Phinx\Migration\AbstractMigration', array(0, $inputStub, null)); @@ -65,7 +71,9 @@ public function testGetInputMethodWithInjectedInput() public function testGetOutputMethodWithInjectedOutput() { // stub output - $outputStub = $this->getMock('\Symfony\Component\Console\Output\OutputInterface', array(), array(array())); + $outputStub = $this->getMockBuilder('\Symfony\Component\Console\Output\OutputInterface') + ->setConstructorArgs([[]]) + ->getMock(); // stub migration $migrationStub = $this->getMockForAbstractClass('\Phinx\Migration\AbstractMigration', array(0, null, $outputStub)); @@ -95,7 +103,9 @@ public function testExecute() $migrationStub = $this->getMockForAbstractClass('\Phinx\Migration\AbstractMigration', array(0)); // stub adapter - $adapterStub = $this->getMock('\Phinx\Db\Adapter\PdoAdapter', array(), array(array())); + $adapterStub = $this->getMockBuilder('\Phinx\Db\Adapter\PdoAdapter') + ->setConstructorArgs([[]]) + ->getMock(); $adapterStub->expects($this->once()) ->method('execute') ->will($this->returnValue(2)); @@ -110,7 +120,9 @@ public function testQuery() $migrationStub = $this->getMockForAbstractClass('\Phinx\Migration\AbstractMigration', array(0)); // stub adapter - $adapterStub = $this->getMock('\Phinx\Db\Adapter\PdoAdapter', array(), array(array())); + $adapterStub = $this->getMockBuilder('\Phinx\Db\Adapter\PdoAdapter') + ->setConstructorArgs([[]]) + ->getMock(); $adapterStub->expects($this->once()) ->method('query') ->will($this->returnValue(array(array('0' => 'bar', 'foo' => 'bar')))); @@ -125,7 +137,9 @@ public function testFetchRow() $migrationStub = $this->getMockForAbstractClass('\Phinx\Migration\AbstractMigration', array(0)); // stub adapter - $adapterStub = $this->getMock('\Phinx\Db\Adapter\PdoAdapter', array(), array(array())); + $adapterStub = $this->getMockBuilder('\Phinx\Db\Adapter\PdoAdapter') + ->setConstructorArgs([[]]) + ->getMock(); $adapterStub->expects($this->once()) ->method('fetchRow') ->will($this->returnValue(array('0' => 'bar', 'foo' => 'bar'))); @@ -140,7 +154,9 @@ public function testFetchAll() $migrationStub = $this->getMockForAbstractClass('\Phinx\Migration\AbstractMigration', array(0)); // stub adapter - $adapterStub = $this->getMock('\Phinx\Db\Adapter\PdoAdapter', array(), array(array())); + $adapterStub = $this->getMockBuilder('\Phinx\Db\Adapter\PdoAdapter') + ->setConstructorArgs([[]]) + ->getMock(); $adapterStub->expects($this->once()) ->method('fetchAll') ->will($this->returnValue(array(array('0' => 'bar', 'foo' => 'bar')))); @@ -155,7 +171,9 @@ public function testInsert() $migrationStub = $this->getMockForAbstractClass('\Phinx\Migration\AbstractMigration', array(0)); // stub adapter - $adapterStub = $this->getMock('\Phinx\Db\Adapter\PdoAdapter', array(), array(array())); + $adapterStub = $this->getMockBuilder('\Phinx\Db\Adapter\PdoAdapter') + ->setConstructorArgs([[]]) + ->getMock(); $adapterStub->expects($this->once()) ->method('insert'); @@ -171,7 +189,9 @@ public function testCreateDatabase() $migrationStub = $this->getMockForAbstractClass('\Phinx\Migration\AbstractMigration', array(0)); // stub adapter - $adapterStub = $this->getMock('\Phinx\Db\Adapter\PdoAdapter', array(), array(array())); + $adapterStub = $this->getMockBuilder('\Phinx\Db\Adapter\PdoAdapter') + ->setConstructorArgs([[]]) + ->getMock(); $adapterStub->expects($this->once()) ->method('createDatabase') ->will($this->returnValue(array(array('0' => 'bar', 'foo' => 'bar')))); @@ -186,7 +206,9 @@ public function testDropDatabase() $migrationStub = $this->getMockForAbstractClass('\Phinx\Migration\AbstractMigration', array(0)); // stub adapter - $adapterStub = $this->getMock('\Phinx\Db\Adapter\PdoAdapter', array(), array(array())); + $adapterStub = $this->getMockBuilder('\Phinx\Db\Adapter\PdoAdapter') + ->setConstructorArgs([[]]) + ->getMock(); $adapterStub->expects($this->once()) ->method('dropDatabase') ->will($this->returnValue(array(array('0' => 'bar', 'foo' => 'bar')))); @@ -201,7 +223,9 @@ public function testHasTable() $migrationStub = $this->getMockForAbstractClass('\Phinx\Migration\AbstractMigration', array(0)); // stub adapter - $adapterStub = $this->getMock('\Phinx\Db\Adapter\PdoAdapter', array(), array(array())); + $adapterStub = $this->getMockBuilder('\Phinx\Db\Adapter\PdoAdapter') + ->setConstructorArgs([[]]) + ->getMock(); $adapterStub->expects($this->once()) ->method('hasTable') ->will($this->returnValue(true)); @@ -216,7 +240,9 @@ public function testTableMethod() $migrationStub = $this->getMockForAbstractClass('\Phinx\Migration\AbstractMigration', array(0)); // stub adapter - $adapterStub = $this->getMock('\Phinx\Db\Adapter\PdoAdapter', array(), array(array())); + $adapterStub = $this->getMockBuilder('\Phinx\Db\Adapter\PdoAdapter') + ->setConstructorArgs([[]]) + ->getMock(); $migrationStub->setAdapter($adapterStub); $this->assertTrue($migrationStub->table('test_table') instanceof Table); @@ -228,7 +254,9 @@ public function testDropTableMethod() $migrationStub = $this->getMockForAbstractClass('\Phinx\Migration\AbstractMigration', array(0)); // stub adapter - $adapterStub = $this->getMock('\Phinx\Db\Adapter\PdoAdapter', array(), array(array())); + $adapterStub = $this->getMockBuilder('\Phinx\Db\Adapter\PdoAdapter') + ->setConstructorArgs([[]]) + ->getMock(); $adapterStub->expects($this->once()) ->method('dropTable'); diff --git a/tests/Phinx/Migration/Manager/EnvironmentTest.php b/tests/Phinx/Migration/Manager/EnvironmentTest.php index 01a3f990f..72a5e7968 100644 --- a/tests/Phinx/Migration/Manager/EnvironmentTest.php +++ b/tests/Phinx/Migration/Manager/EnvironmentTest.php @@ -106,7 +106,9 @@ public function testSchemaName() public function testCurrentVersion() { - $stub = $this->getMock('\Phinx\Db\Adapter\PdoAdapter', array(), array(array())); + $stub = $this->getMockBuilder('\Phinx\Db\Adapter\PdoAdapter') + ->setConstructorArgs([[]]) + ->getMock(); $stub->expects($this->any()) ->method('getVersions') ->will($this->returnValue(array('20110301080000'))); @@ -119,7 +121,9 @@ public function testCurrentVersion() public function testExecutingAMigrationUp() { // stub adapter - $adapterStub = $this->getMock('\Phinx\Db\Adapter\PdoAdapter', array(), array(array())); + $adapterStub = $this->getMockBuilder('\Phinx\Db\Adapter\PdoAdapter') + ->setConstructorArgs([[]]) + ->getMock(); $adapterStub->expects($this->once()) ->method('migrated') ->will($this->returnArgument(0)); @@ -127,7 +131,10 @@ public function testExecutingAMigrationUp() $this->environment->setAdapter($adapterStub); // up - $upMigration = $this->getMock('\Phinx\Migration\AbstractMigration', array('up'), array('20110301080000')); + $upMigration = $this->getMockBuilder('\Phinx\Migration\AbstractMigration') + ->setConstructorArgs(['20110301080000']) + ->setMethods(['up']) + ->getMock(); $upMigration->expects($this->once()) ->method('up'); @@ -137,7 +144,9 @@ public function testExecutingAMigrationUp() public function testExecutingAMigrationDown() { // stub adapter - $adapterStub = $this->getMock('\Phinx\Db\Adapter\PdoAdapter', array(), array(array())); + $adapterStub = $this->getMockBuilder('\Phinx\Db\Adapter\PdoAdapter') + ->setConstructorArgs([[]]) + ->getMock(); $adapterStub->expects($this->once()) ->method('migrated') ->will($this->returnArgument(0)); @@ -145,7 +154,10 @@ public function testExecutingAMigrationDown() $this->environment->setAdapter($adapterStub); // down - $downMigration = $this->getMock('\Phinx\Migration\AbstractMigration', array('down'), array('20110301080000')); + $downMigration = $this->getMockBuilder('\Phinx\Migration\AbstractMigration') + ->setConstructorArgs(['20110301080000']) + ->setMethods(['down']) + ->getMock(); $downMigration->expects($this->once()) ->method('down'); @@ -155,7 +167,9 @@ public function testExecutingAMigrationDown() public function testExecutingAMigrationWithTransactions() { // stub adapter - $adapterStub = $this->getMock('\Phinx\Db\Adapter\PdoAdapter', array(), array(array())); + $adapterStub = $this->getMockBuilder('\Phinx\Db\Adapter\PdoAdapter') + ->setConstructorArgs([[]]) + ->getMock(); $adapterStub->expects($this->once()) ->method('beginTransaction'); @@ -169,7 +183,10 @@ public function testExecutingAMigrationWithTransactions() $this->environment->setAdapter($adapterStub); // migrate - $migration = $this->getMock('\Phinx\Migration\AbstractMigration', array('up'), array('20110301080000')); + $migration = $this->getMockBuilder('\Phinx\Migration\AbstractMigration') + ->setConstructorArgs(['20110301080000']) + ->setMethods(['up']) + ->getMock(); $migration->expects($this->once()) ->method('up'); @@ -179,7 +196,9 @@ public function testExecutingAMigrationWithTransactions() public function testExecutingAChangeMigrationUp() { // stub adapter - $adapterStub = $this->getMock('\Phinx\Db\Adapter\PdoAdapter', array(), array(array())); + $adapterStub = $this->getMockBuilder('\Phinx\Db\Adapter\PdoAdapter') + ->setConstructorArgs([[]]) + ->getMock(); $adapterStub->expects($this->once()) ->method('migrated') ->will($this->returnArgument(0)); @@ -187,7 +206,10 @@ public function testExecutingAChangeMigrationUp() $this->environment->setAdapter($adapterStub); // migration - $migration = $this->getMock('\Phinx\Migration\AbstractMigration', array('change'), array('20130301080000')); + $migration = $this->getMockBuilder('\Phinx\Migration\AbstractMigration') + ->setConstructorArgs(['20130301080000']) + ->setMethods(['change']) + ->getMock(); $migration->expects($this->once()) ->method('change'); @@ -197,7 +219,9 @@ public function testExecutingAChangeMigrationUp() public function testExecutingAChangeMigrationDown() { // stub adapter - $adapterStub = $this->getMock('\Phinx\Db\Adapter\PdoAdapter', array(), array(array())); + $adapterStub = $this->getMockBuilder('\Phinx\Db\Adapter\PdoAdapter') + ->setConstructorArgs([[]]) + ->getMock(); $adapterStub->expects($this->once()) ->method('migrated') ->will($this->returnArgument(0)); @@ -205,7 +229,10 @@ public function testExecutingAChangeMigrationDown() $this->environment->setAdapter($adapterStub); // migration - $migration = $this->getMock('\Phinx\Migration\AbstractMigration', array('change'), array('20130301080000')); + $migration = $this->getMockBuilder('\Phinx\Migration\AbstractMigration') + ->setConstructorArgs(['20130301080000']) + ->setMethods(['change']) + ->getMock(); $migration->expects($this->once()) ->method('change'); diff --git a/tests/Phinx/Migration/ManagerTest.php b/tests/Phinx/Migration/ManagerTest.php index 3f1bd8c9a..3b42e5ee6 100644 --- a/tests/Phinx/Migration/ManagerTest.php +++ b/tests/Phinx/Migration/ManagerTest.php @@ -81,7 +81,9 @@ public function testInstantiation() public function testPrintStatusMethod() { // stub environment - $envStub = $this->getMock('\Phinx\Migration\Manager\Environment', array(), array('mockenv', array())); + $envStub = $this->getMockBuilder('\Phinx\Migration\Manager\Environment') + ->setConstructorArgs(['mockenv', []]) + ->getMock(); $envStub->expects($this->once()) ->method('getVersionLog') ->will($this->returnValue( @@ -119,7 +121,9 @@ public function testPrintStatusMethod() public function testPrintStatusMethodWithBreakpointSet() { // stub environment - $envStub = $this->getMock('\Phinx\Migration\Manager\Environment', array(), array('mockenv', array())); + $envStub = $this->getMockBuilder('\Phinx\Migration\Manager\Environment') + ->setConstructorArgs(['mockenv', []]) + ->getMock(); $envStub->expects($this->once()) ->method('getVersionLog') ->will($this->returnValue( @@ -156,7 +160,9 @@ public function testPrintStatusMethodWithBreakpointSet() public function testPrintStatusMethodWithNoMigrations() { // stub environment - $envStub = $this->getMock('\Phinx\Migration\Manager\Environment', array(), array('mockenv', array())); + $envStub = $this->getMockBuilder('\Phinx\Migration\Manager\Environment') + ->setConstructorArgs(['mockenv', []]) + ->getMock(); // override the migrations directory to an empty one $configArray = $this->getConfigArray(); @@ -177,7 +183,9 @@ public function testPrintStatusMethodWithNoMigrations() public function testPrintStatusMethodWithMissingMigrations() { // stub environment - $envStub = $this->getMock('\Phinx\Migration\Manager\Environment', array(), array('mockenv', array())); + $envStub = $this->getMockBuilder('\Phinx\Migration\Manager\Environment') + ->setConstructorArgs(['mockenv', []]) + ->getMock(); $envStub->expects($this->once()) ->method('getVersionLog') ->will($this->returnValue( @@ -215,7 +223,9 @@ public function testPrintStatusMethodWithMissingMigrations() public function testPrintStatusMethodWithMissingMigrationsAndBreakpointSet() { // stub environment - $envStub = $this->getMock('\Phinx\Migration\Manager\Environment', array(), array('mockenv', array())); + $envStub = $this->getMockBuilder('\Phinx\Migration\Manager\Environment') + ->setConstructorArgs(['mockenv', []]) + ->getMock(); $envStub->expects($this->once()) ->method('getVersionLog') ->will($this->returnValue( @@ -254,7 +264,9 @@ public function testPrintStatusMethodWithMissingMigrationsAndBreakpointSet() public function testPrintStatusMethodWithDownMigrations() { // stub environment - $envStub = $this->getMock('\Phinx\Migration\Manager\Environment', array(), array('mockenv', array())); + $envStub = $this->getMockBuilder('\Phinx\Migration\Manager\Environment') + ->setConstructorArgs(['mockenv', []]) + ->getMock(); $envStub->expects($this->once()) ->method('getVersionLog') ->will($this->returnValue(array( @@ -340,7 +352,9 @@ public function testGettingAValidEnvironment() public function testMigrationsByDate(array $availableMigrations, $dateString, $expectedMigration, $message) { // stub environment - $envStub = $this->getMock('\Phinx\Migration\Manager\Environment', array(), array('mockenv', array())); + $envStub = $this->getMockBuilder('\Phinx\Migration\Manager\Environment') + ->setConstructorArgs(['mockenv', []]) + ->getMock(); if (is_null($expectedMigration)) { $envStub->expects($this->never()) ->method('getVersions'); @@ -368,7 +382,9 @@ public function testMigrationsByDate(array $availableMigrations, $dateString, $e public function testRollbacksByDate(array $availableRollbacks, $dateString, $expectedRollback, $message) { // stub environment - $envStub = $this->getMock('\Phinx\Migration\Manager\Environment', array(), array('mockenv', array())); + $envStub = $this->getMockBuilder('\Phinx\Migration\Manager\Environment') + ->setConstructorArgs(['mockenv', []]) + ->getMock(); $envStub->expects($this->any()) ->method('getVersionLog') ->will($this->returnValue($availableRollbacks)); @@ -390,7 +406,9 @@ public function testRollbacksByDate(array $availableRollbacks, $dateString, $exp public function testRollbackWithSingleMigrationDoesNotFail() { // stub environment - $envStub = $this->getMock('\Phinx\Migration\Manager\Environment', array(), array('mockenv', array())); + $envStub = $this->getMockBuilder('\Phinx\Migration\Manager\Environment') + ->setConstructorArgs(['mockenv', []]) + ->getMock(); $envStub->expects($this->any()) ->method('getVersionLog') ->will($this->returnValue([ @@ -410,7 +428,9 @@ public function testRollbackWithSingleMigrationDoesNotFail() public function testRollbackWithTwoMigrationsDoesNotRollbackBothMigrations() { // stub environment - $envStub = $this->getMock('\Phinx\Migration\Manager\Environment', array(), array('mockenv', array())); + $envStub = $this->getMockBuilder('\Phinx\Migration\Manager\Environment') + ->setConstructorArgs(['mockenv', []]) + ->getMock(); $envStub->expects($this->any()) ->method('getVersionLog') ->will( @@ -660,7 +680,9 @@ public function rollbackDateDataProvider() public function testExecuteSeedWorksAsExpected() { // stub environment - $envStub = $this->getMock('\Phinx\Migration\Manager\Environment', array(), array('mockenv', array())); + $envStub = $this->getMockBuilder('\Phinx\Migration\Manager\Environment') + ->setConstructorArgs(['mockenv', []]) + ->getMock(); $this->manager->setEnvironments(array('mockenv' => $envStub)); $this->manager->seed('mockenv'); rewind($this->manager->getOutput()->getStream()); @@ -673,7 +695,9 @@ public function testExecuteSeedWorksAsExpected() public function testExecuteASingleSeedWorksAsExpected() { // stub environment - $envStub = $this->getMock('\Phinx\Migration\Manager\Environment', array(), array('mockenv', array())); + $envStub = $this->getMockBuilder('\Phinx\Migration\Manager\Environment') + ->setConstructorArgs(['mockenv', []]) + ->getMock(); $this->manager->setEnvironments(array('mockenv' => $envStub)); $this->manager->seed('mockenv', 'UserSeeder'); rewind($this->manager->getOutput()->getStream()); @@ -688,7 +712,9 @@ public function testExecuteASingleSeedWorksAsExpected() public function testExecuteANonExistentSeedWorksAsExpected() { // stub environment - $envStub = $this->getMock('\Phinx\Migration\Manager\Environment', array(), array('mockenv', array())); + $envStub = $this->getMockBuilder('\Phinx\Migration\Manager\Environment') + ->setConstructorArgs(['mockenv', []]) + ->getMock(); $this->manager->setEnvironments(array('mockenv' => $envStub)); $this->manager->seed('mockenv', 'NonExistentSeeder'); rewind($this->manager->getOutput()->getStream());