當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。