本文整理匯總了PHP中Mockery::instanceMock方法的典型用法代碼示例。如果您正苦於以下問題:PHP Mockery::instanceMock方法的具體用法?PHP Mockery::instanceMock怎麽用?PHP Mockery::instanceMock使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Mockery
的用法示例。
在下文中一共展示了Mockery::instanceMock方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testWriteSqlFile
/**
* @param $path
* @param $to
* @param $getSqlReturn
*
* @dataProvider writeSqlFileProvider
*/
public function testWriteSqlFile($path, $from, $to, $getSqlReturn)
{
$expectedReturn = 123;
$sqlWriter = m::instanceMock('overload:Doctrine\\DBAL\\Migrations\\SqlFileWriter');
$sqlWriter->shouldReceive('write')->with(m::type('array'), m::anyOf('up', 'down'))->andReturn($expectedReturn);
$outputWriter = m::mock('Doctrine\\DBAL\\Migrations\\OutputWriter');
$outputWriter->shouldReceive('write');
$config = m::mock('Doctrine\\DBAL\\Migrations\\Configuration\\Configuration')->makePartial();
$config->shouldReceive('getCurrentVersion')->andReturn($from);
$config->shouldReceive('getOutputWriter')->andReturn($outputWriter);
if ($to == null) {
// this will always just test the "up" direction
$config->shouldReceive('getLatestVersion')->andReturn($from + 1);
}
$migration = m::mock('Doctrine\\DBAL\\Migrations\\Migration[getSql]', [$config])->makePartial();
$migration->shouldReceive('getSql')->with($to)->andReturn($getSqlReturn);
$result = $migration->writeSqlFile($path, $to);
$this->assertEquals($expectedReturn, $result);
}
示例2: testWriteSqlFile
/**
* @param $path
* @param $to
* @param $getSqlReturn
*
* @dataProvider writeSqlFileProvider
*/
public function testWriteSqlFile($path, $direction, $getSqlReturn)
{
$version = 1;
$outputWriter = m::mock('Doctrine\\DBAL\\Migrations\\OutputWriter');
$outputWriter->shouldReceive('write');
$connection = m::mock('Doctrine\\DBAL\\Connection');
$connection->shouldReceive(array('getSchemaManager' => 'something', 'getDatabasePlatform' => 'something else'));
$config = m::mock('Doctrine\\DBAL\\Migrations\\Configuration\\Configuration')->makePartial();
$config->shouldReceive('getOutputWriter')->andReturn($outputWriter);
$config->shouldReceive('getConnection')->andReturn($connection);
$migration = m::mock('Doctrine\\DBAL\\Migrations\\Version[execute]', array($config, $version, 'stdClass'))->makePartial();
$migration->shouldReceive('execute')->with($direction, true)->andReturn($getSqlReturn);
$expectedReturn = 123;
$sqlWriter = m::instanceMock('overload:Doctrine\\DBAL\\Migrations\\SqlFileWriter');
$sqlWriter->shouldReceive('write')->with(m::type('array'), m::anyOf('up', 'down'))->andReturn($expectedReturn);
$result = $migration->writeSqlFile($path, $direction);
$this->assertEquals($expectedReturn, $result);
}