本文整理汇总了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);
}
示例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');
}
示例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);
}
示例5: testHandleThrowPass
public function testHandleThrowPass()
{
$middleware = new AuthoriseRole();
$this->assertTrue($middleware->handle(Mockery::mock('\\Illuminate\\Http\\Request'), function () {
return true;
}, 'su'));
}
示例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();
}
示例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();
}
示例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();
}
示例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');
}
示例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>'));
}
示例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'));
}
示例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();
}
示例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);
}
示例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);
}
示例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'));
}