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


PHP Mockery类代码示例

本文整理汇总了PHP中Mockery的典型用法代码示例。如果您正苦于以下问题:PHP Mockery类的具体用法?PHP Mockery怎么用?PHP Mockery使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Mockery类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _before

 public function _before()
 {
     $this->pheanstalkJob = \Mockery::mock('Pheanstalk\\Job');
     $this->pheanstalkJob->shouldReceive('getData')->andReturn(json_encode([]));
     $this->connector = \Mockery::mock('Indigo\\Queue\\Connector\\BeanstalkdConnector');
     $this->manager = new BeanstalkdManager('test', $this->pheanstalkJob, $this->connector);
 }
开发者ID:indigophp,项目名称:queue,代码行数:7,代码来源:BeanstalkdManagerTest.php

示例2: setUp

 /**
  * {@inheritdoc}
  */
 public function setUp()
 {
     parent::setUp();
     $this->factory = new ProcessFactory('pwd');
     $this->directory = \Mockery::mock(\SplFileInfo::class);
     $this->directory->shouldReceive('__toString')->andReturn('/tmp');
 }
开发者ID:epfremmer,项目名称:process-queue,代码行数:10,代码来源:ProcessManagerTest.php

示例3: setUp

 protected function setUp()
 {
     $this->outputInterface = new InMemoryOutputInterface();
     $this->preCommitConfig = new InMemoryHookConfig();
     $this->codeSnifferHandler = \Mockery::mock('PhpGitHooks\\Infrastructure\\CodeSniffer\\CodeSnifferHandler');
     $this->checkCodeStyleCodeSnifferPreCommitExecuter = new CheckCodeStyleCodeSnifferPreCommitExecuter($this->preCommitConfig, $this->codeSnifferHandler);
 }
开发者ID:raphaelcarles,项目名称:php-git-hooks,代码行数:7,代码来源:CheckCodeStyleCodeSnifferPreCommitExecuterTest.php

示例4: testRotate

 public function testRotate()
 {
     $newProfile = $this->getFaker()->word;
     $encryptor = \Mockery::mock('Giftcards\\Encryption\\Encryptor');
     $observer = \Mockery::mock('Giftcards\\Encryption\\CipherText\\Rotator\\ObserverInterface');
     $fields = $this->fields;
     $fields[] = $this->idField;
     $faker = $this->getFaker();
     $row1 = array_combine($fields, array_map(function () use($faker) {
         return $faker->unique()->word;
     }, $fields));
     $row2 = array_combine($fields, array_map(function () use($faker) {
         return $faker->unique()->word;
     }, $fields));
     $row3 = array_combine($fields, array_map(function () use($faker) {
         return $faker->unique()->word;
     }, $fields));
     $this->pdo->shouldReceive('prepare')->once()->with(sprintf('SELECT %s FROM %s', implode(', ', $fields), $this->table))->andReturn(\Mockery::mock()->shouldReceive('execute')->once()->getMock()->shouldReceive('fetch')->times(4)->with(\PDO::FETCH_ASSOC)->andReturn($row1, $row2, $row3, false)->getMock());
     $observer->shouldReceive('rotating')->once()->ordered()->with($row1[$this->idField])->getMock()->shouldReceive('rotated')->once()->ordered()->with($row1[$this->idField])->getMock()->shouldReceive('rotating')->once()->ordered()->with($row2[$this->idField])->getMock()->shouldReceive('rotated')->once()->ordered()->with($row2[$this->idField])->getMock()->shouldReceive('rotating')->once()->ordered()->with($row3[$this->idField])->getMock()->shouldReceive('rotated')->once()->ordered()->with($row3[$this->idField])->getMock();
     foreach (array($row1, $row2, $row3) as $row) {
         $parameters = array();
         $setFields = array();
         foreach ($row as $field => $value) {
             if ($field == $this->idField) {
                 continue;
             }
             $encryptor->shouldReceive('decrypt')->once()->with($value)->andReturn($decrypted = $this->getFaker()->unique()->word)->getMock()->shouldReceive('encrypt')->once()->with($decrypted, $newProfile)->andReturn($parameters[] = $this->getFaker()->unique()->word)->getMock();
             $setFields[] = sprintf('%s = ?', $field);
         }
         $parameters[] = $row[$this->idField];
         $this->pdo->shouldReceive('prepare')->once()->with(sprintf('UPDATE %s SET %s WHERE %s = ?', $this->table, implode(',', $setFields), $this->idField))->andReturn(\Mockery::mock()->shouldReceive('execute')->once()->with($parameters)->getMock());
     }
     $this->rotator->rotate($observer, $encryptor, $newProfile);
 }
开发者ID:SaveYa,项目名称:Encryption,代码行数:34,代码来源:DatabaseTableRotatorTest.php

示例5: testHandleThrowPass

 public function testHandleThrowPass()
 {
     $middleware = new AuthoriseRole();
     $this->assertTrue($middleware->handle(Mockery::mock('\\Illuminate\\Http\\Request'), function () {
         return true;
     }, 'su'));
 }
开发者ID:paybreak,项目名称:basket,代码行数:7,代码来源:AuthoriseRoleTest.php

示例6: setup

 /**
  * Setup method
  * @return void
  */
 public function setup()
 {
     $targetClass = DefinedTargetClass::factory('Mockery\\Test\\Generator\\StringManipulation\\Pass\\MagicDummy');
     $this->pass = new MagicMethodTypeHintsPass();
     $this->mockedConfiguration = m::mock('Mockery\\Generator\\MockConfiguration');
     $this->mockedConfiguration->shouldReceive('getTargetClass')->andReturn($targetClass)->byDefault();
 }
开发者ID:mockery,项目名称:mockery,代码行数:11,代码来源:MagicMethodTypeHintsPassTest.php

示例7: testGetCustomersInvalidCustomer

 public function testGetCustomersInvalidCustomer()
 {
     $this->setExpectedException('\\DomainException');
     $jsonProvider = \Mockery::mock('\\KieranBamforth\\CustomerInviter\\CustomerProvider\\JsonProvider[isCustomerValid]', [$this->json]);
     $jsonProvider->shouldReceive('isCustomerValid')->andReturn(false);
     $jsonProvider->getCustomers();
 }
开发者ID:kieran-bamforth,项目名称:customer-inviter,代码行数:7,代码来源:JsonProviderTest.php

示例8: testFormatObjectsWithMockCalledInGetterDoesNotLeadToRecursion

 /**
  * @expectedException Mockery\Exception\NoMatchingExpectationException
  *
  * Note that without the patch checked in with this test, rather than throwing
  * an exception, the program will go into an infinite recursive loop
  */
 public function testFormatObjectsWithMockCalledInGetterDoesNotLeadToRecursion()
 {
     $mock = Mockery::mock('stdClass');
     $mock->shouldReceive('doBar')->with('foo');
     $obj = new ClassWithGetter($mock);
     $obj->getFoo();
 }
开发者ID:tamboer,项目名称:LaravelOctober,代码行数:13,代码来源:WithFormatterExpectationTest.php

示例9: testConstrainQuery

 public function testConstrainQuery()
 {
     $query = m::mock('Illuminate\\Database\\Eloquent\\Builder');
     $query->shouldReceive('where')->once();
     $this->field->shouldReceive('getOption')->once();
     $this->field->constrainQuery($query, m::mock(array()), 'foo');
 }
开发者ID:hifone,项目名称:dashboard,代码行数:7,代码来源:HasOneOrManyTest.php

示例10: testShowFolderTreeWithContent

 public function testShowFolderTreeWithContent()
 {
     $res = $this->prepareShowFolderTree($parentFolderId = 'foo');
     $this->dbManager->shouldReceive('fetchArray')->with($res)->andReturn($rowTop = array('folder_pk' => 1, 'folder_name' => 'Top', 'folder_desc' => '', 'depth' => 0), $rowA = array('folder_pk' => 2, 'folder_name' => 'B', 'folder_desc' => '/A', 'depth' => 1), $rowB = array('folder_pk' => 3, 'folder_name' => 'B', 'folder_desc' => '/A/B', 'depth' => 2), $rowC = array('folder_pk' => 4, 'folder_name' => 'C', 'folder_desc' => '/C', 'depth' => 1), false);
     $out = $this->folderNav->showFolderTree($parentFolderId);
     assertThat(str_replace("\n", '', $out), equalTo('<ul id="tree"><li>' . $this->getFormattedItem($rowTop) . '<ul><li>' . $this->getFormattedItem($rowA) . '<ul><li>' . $this->getFormattedItem($rowB) . '</li></ul></li><li>' . $this->getFormattedItem($rowC) . '</li></ul></li></ul>'));
 }
开发者ID:DanielDobre,项目名称:fossology,代码行数:7,代码来源:FolderNavTest.php

示例11: testGetIncludedColumn

 public function testGetIncludedColumn()
 {
     $model = m::mock(array('getTable' => 'table', 'method' => m::mock(array('getRelated' => m::mock(array('getKeyName' => 'fk'))))));
     $this->config->shouldReceive('getDataModel')->once()->andReturn($model);
     $this->column->shouldReceive('getOption')->once()->andReturn('method');
     $this->assertEquals($this->column->getIncludedColumn(), array('fk' => 'table.fk'));
 }
开发者ID:hifone,项目名称:dashboard,代码行数:7,代码来源:BelongsToManyTest.php

示例12: testBuild

 public function testBuild()
 {
     $url = m::mock('Illuminate\\Routing\\UrlGenerator');
     $url->shouldReceive('route')->once();
     $this->validator->shouldReceive('arrayGet')->times(3)->shouldReceive('getUrlInstance')->once()->andReturn($url);
     $this->config->shouldReceive('getType')->once()->shouldReceive('getOption')->once();
     $this->field->build();
 }
开发者ID:hifone,项目名称:dashboard,代码行数:8,代码来源:FileTest.php

示例13: testFilterQueryWithoutValue

 public function testFilterQueryWithoutValue()
 {
     $query = m::mock('Illuminate\\Database\\Query\\Builder');
     $query->shouldReceive('where')->never();
     $this->config->shouldReceive('getDataModel')->once()->andReturn(m::mock(array('getTable' => 'table')));
     $this->field->shouldReceive('getOption')->twice()->andReturn(false);
     $this->field->filterQuery($query);
 }
开发者ID:dmitriyuch,项目名称:Laravel-Administrator,代码行数:8,代码来源:TextTest.php

示例14: testServiceGetLogged

 /**
  * Tests if the service get admin
  * method interacts correctly.
  */
 public function testServiceGetLogged()
 {
     $fakeUser = m::mock('App\\Models\\User');
     $fakeAdmin = m::mock('App\\Mdodels\\Administrator');
     \Auth::shouldReceive('user')->once()->andReturn($fakeUser);
     $this->fakeAdministratorsRepo->shouldReceive('getAdministrator')->withArgs([m::type('App\\Models\\User')])->once()->andReturn($fakeAdmin);
     $admin = $this->service->getLogged();
     $this->assertEquals($fakeAdmin, $admin);
 }
开发者ID:TiagoMaiaL,项目名称:Tournament-Manager,代码行数:13,代码来源:AdministratorsServiceUnitTest.php

示例15: testFilterQuery

 public function testFilterQuery()
 {
     $relationship = m::mock(array('getPlainForeignKey' => '', 'getRelated' => m::mock(array('getTable' => 'table'))));
     $model = m::mock(array('getTable' => 'table', 'getKeyName' => '', 'method' => $relationship));
     $grammar = m::mock('Illuminate\\Database\\Query\\Grammars');
     $grammar->shouldReceive('wrap')->once()->andReturn('');
     $this->config->shouldReceive('getDataModel')->once()->andReturn($model);
     $this->column->shouldReceive('getOption')->times(3)->andReturn('column_name', 'method', 'select')->shouldReceive('getRelationshipWheres')->once()->andReturn('');
     $this->db->shouldReceive('raw')->once()->andReturn('foo')->shouldReceive('getQueryGrammar')->once()->andReturn($grammar);
     $selects = array();
     $this->column->filterQuery($selects);
     $this->assertEquals($selects, array('foo'));
 }
开发者ID:EmersonStone,项目名称:Laravel-Administrator,代码行数:13,代码来源:HasOneOrManyTest.php


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