Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix deprecated use of getMock() on tests (II) #941

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions tests/Phinx/Console/Command/CreateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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',
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
12 changes: 9 additions & 3 deletions tests/Phinx/Console/Command/MigrateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand All @@ -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');

Expand All @@ -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');

Expand Down
12 changes: 9 additions & 3 deletions tests/Phinx/Console/Command/RollbackTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(array($this->config, $this->input, $this->output))
->getMock();
$managerStub->expects($this->once())
->method('rollback');

Expand All @@ -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(array($this->config, $this->input, $this->output))
->getMock();
$managerStub->expects($this->once())
->method('rollback');

Expand All @@ -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(array($this->config, $this->input, $this->output))
->getMock();
$managerStub->expects($this->once())
->method('rollback');

Expand Down
8 changes: 6 additions & 2 deletions tests/Phinx/Console/Command/SeedCreateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(array($this->config, $this->input, $this->output))
->getMock();

$command->setConfig($this->config);
$command->setManager($managerStub);
Expand All @@ -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(array($this->config, $this->input, $this->output))
->getMock();

$command->setConfig($this->config);
$command->setManager($managerStub);
Expand Down
16 changes: 12 additions & 4 deletions tests/Phinx/Console/Command/SeedRunTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(array($this->config, $this->input, $this->output))
->getMock();
$managerStub->expects($this->once())
->method('seed')->with($this->identicalTo('development'), $this->identicalTo(null));

Expand All @@ -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(array($this->config, $this->input, $this->output))
->getMock();
$managerStub->expects($this->any())
->method('migrate');

Expand All @@ -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(array($this->config, $this->input, $this->output))
->getMock();
$managerStub->expects($this->once())
->method('seed');

Expand All @@ -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(array($this->config, $this->input, $this->output))
->getMock();
$managerStub->expects($this->exactly(3))
->method('seed')->withConsecutive(
array($this->identicalTo('development'), $this->identicalTo('One')),
Expand Down
12 changes: 9 additions & 3 deletions tests/Phinx/Console/Command/StatusTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(array($this->config, $this->input, $this->output))
->getMock();
$managerStub->expects($this->once())
->method('printStatus')
->will($this->returnValue(0));
Expand All @@ -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(array($this->config, $this->input, $this->output))
->getMock();
$managerStub->expects($this->once())
->method('printStatus')
->will($this->returnValue(0));
Expand All @@ -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(array($this->config, $this->input, $this->output))
->getMock();
$managerStub->expects($this->once())
->method('printStatus')
->will($this->returnValue(0));
Expand Down
4 changes: 3 additions & 1 deletion tests/Phinx/Db/Adapter/AdapterFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ public function testRegisterWrapperFailure()

private function getAdapterMock()
{
return $this->getMock('Phinx\Db\Adapter\AdapterInterface', array());
return $this->getMockBuilder('Phinx\Db\Adapter\AdapterInterface')
->setConstructorArgs(array(array()))
->getMock();
}

public function testGetWrapper()
Expand Down
4 changes: 3 additions & 1 deletion tests/Phinx/Db/Adapter/ProxyAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(array(array()))
->getMock();

$this->adapter = new ProxyAdapter($stub);
}
Expand Down
4 changes: 3 additions & 1 deletion tests/Phinx/Db/Adapter/TablePrefixAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(array(array()))
->getMock();

$this->mock
->expects($this->any())
Expand Down
44 changes: 33 additions & 11 deletions tests/Phinx/Db/TableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(array(array()))
->getMock();
$adapterStub->expects($this->once())
->method('changeColumn');
$newColumn = new \Phinx\Db\Table\Column();
Expand All @@ -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(array(array()))
->getMock();
$adapterStub->expects($this->once())
->method('changeColumn');
$table = new \Phinx\Db\Table('ntable', [], $adapterStub);
Expand All @@ -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(array(array()))
->getMock();
$adapterStub->expects($this->once())
->method('dropForeignKey');
$table = new \Phinx\Db\Table('ntable', [], $adapterStub);
Expand All @@ -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(array(array()))
->getMock();
$adapterStub->expects($this->once())
->method('getColumns');

Expand All @@ -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(array(array()))
->getMock();
$table = new \Phinx\Db\Table('ntable', [], $adapterStub);
$data = [
'column1' => 'value1',
Expand All @@ -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(array(array()))
->getMock();
$table = new \Phinx\Db\Table('ntable', [], $adapterStub);
$data = [
[
Expand Down Expand Up @@ -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(array(array()))
->getMock();
$adapterStub->expects($this->once())
->method('dropColumn');
$table = new \Phinx\Db\Table('ntable', [], $adapterStub);
Expand All @@ -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(array(array()))
->getMock();
$adapterStub->expects($this->once())
->method('dropIndex');
$table = new \Phinx\Db\Table('ntable', [], $adapterStub);
Expand All @@ -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(array(array()))
->getMock();
$adapterStub->expects($this->once())
->method('dropIndexByName');
$table = new \Phinx\Db\Table('ntable', [], $adapterStub);
Expand All @@ -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(array(array()))
->getMock();
$adapterStub->expects($this->once())
->method('renameColumn');
$table = new \Phinx\Db\Table('ntable', [], $adapterStub);
Expand All @@ -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(array(array()))
->getMock();
$table = new \Phinx\Db\Table('ntable', [], $adapterStub);
$columns = ["column1"];
$data = [["value1"]];
Expand Down
Loading