当前位置: 首页>>代码示例>>PHP>>正文


PHP Mockery::instanceMock方法代码示例

本文整理汇总了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);
 }
开发者ID:comporu,项目名称:migrations,代码行数:26,代码来源:MigrationTest.php

示例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);
 }
开发者ID:robertfausk,项目名称:migrations,代码行数:25,代码来源:VersionTest.php


注:本文中的Mockery::instanceMock方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。