本文整理汇总了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);
}