本文整理汇总了PHP中Mockery::shouldReceive方法的典型用法代码示例。如果您正苦于以下问题:PHP Mockery::shouldReceive方法的具体用法?PHP Mockery::shouldReceive怎么用?PHP Mockery::shouldReceive使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mockery
的用法示例。
在下文中一共展示了Mockery::shouldReceive方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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'));
}
示例2: testOverrideSetsDataRulesAndMessages
public function testOverrideSetsDataRulesAndMessages()
{
$this->validator->shouldReceive('setData')->once()
->shouldReceive('setRules')->once()
->shouldReceive('setCustomMessages')->once();
$this->validator->override(array(), array());
}
示例3: 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>'));
}
示例4: 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');
}
示例5: 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();
}
示例6: 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);
}
示例7: 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);
}
示例8: 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'));
}
示例9: testFilterQueryNoValue
public function testFilterQueryNoValue()
{
$query = m::mock('Illuminate\\Database\\Query\\Builder');
$query->shouldReceive('where')->never();
$this->field->shouldReceive('getOption')->once()->andReturn('');
$this->field->filterQuery($query);
}
示例10: testGetIncludedColumn
public function testGetIncludedColumn()
{
$this->config->shouldReceive('getDataModel')->once()->andReturn(m::mock(array('getTable' => 'table')));
$nested = array('pieces' => array('foo'), 'models' => array(m::mock(array('foo' => m::mock(array('getForeignKey' => 'fk'))))));
$this->column->shouldReceive('getOption')->once()->andReturn($nested);
$this->assertEquals($this->column->getIncludedColumn(), array('fk' => 'table.fk'));
}
示例11: testGetMenuDeepNestedWithoutPermission
public function testGetMenuDeepNestedWithoutPermission()
{
$this->config->shouldReceive('get')->once()->andReturn(array('Header' => array('Header2' => array('test_name'))));
$itemconfig = m::mock('Frozennode\\Administrator\\Config\\Config');
$itemconfig->shouldReceive('getOption')->once()->andReturn(false);
$this->configFactory->shouldReceive('make')->once()->andReturn($itemconfig);
$this->assertEquals($this->menu->getMenu(), array());
}
示例12: testSetRowsPerPageDefaultsToUserChoice
public function testSetRowsPerPageDefaultsToUserChoice()
{
$session = m::mock('Illuminate\\Session\\Store');
$session->shouldReceive('get')->once()->andReturn(23);
$this->config->shouldReceive('getOption')->once();
$this->dataTable->setRowsPerPage($session, 54);
$this->assertEquals($this->dataTable->getRowsPerPage(), 23);
}
示例13: testGetRelationshipWheres
public function testGetRelationshipWheres()
{
$connection = m::mock('Illuminate\\Database\\Connection');
$connection->shouldReceive('prepareBindings')->once()->andReturn(array());
$query = m::mock('Illuminate\\Database\\Query\\Builder');
$query->shouldReceive('getConnection')->once()->andReturn($connection)->shouldReceive('getBindings')->once()->andReturn(array())->shouldReceive('toSql')->once()->andReturn('');
$query->wheres = array(array(), array('column' => 'bar'));
$eloquentQuery = m::mock('Illuminate\\Database\\Eloquent\\Builder');
$eloquentQuery->shouldReceive('getQuery')->once()->andReturn($query);
$relatedModel = m::mock('Illuminate\\Database\\Eloquent\\Model');
$relatedModel->shouldReceive('isSoftDeleting')->once();
$relationship = m::mock('Illuminate\\Database\\Eloquent\\Relations\\Relation');
$relationship->shouldReceive('getQuery')->once()->andReturn($eloquentQuery)->shouldReceive('getRelated')->once()->andReturn($relatedModel);
$this->column->shouldReceive('interpolateQuery')->once()->andReturn('foo where test')->shouldReceive('aliasRelationshipWhere')->once()->andReturn('foo');
$result = $this->column->getRelationshipWheres($relationship, 'fooalias');
$this->assertEquals($result, 'test');
}
示例14: testConstrainQueryAlreadyJoined
public function testConstrainQueryAlreadyJoined()
{
$query = m::mock('Illuminate\\Database\\Eloquent\\Builder');
$query->shouldReceive('join')->never()->shouldReceive('where')->once();
$this->validator->shouldReceive('isJoined')->once()->andReturn(true);
$model = m::mock(array('getTable' => 'table', 'getKeyName' => 'id'));
$this->field->shouldReceive('getOption')->twice();
$this->field->constrainQuery($query, $model, 'foo');
}
示例15: testServiceRemoveMatchInteractsCorrectly
/**
* Tests if the delete match method
* Interacts and works as expected.
*/
public function testServiceRemoveMatchInteractsCorrectly()
{
$matchID = 1;
$fakeAdmin = m::mock('App\\Models\\Administrator');
\Admin::shouldReceive('getLogged')->once()->andReturn($fakeAdmin);
$this->fakeMatchesRepo->shouldReceive('removeMatch')->withArgs([m::type('App\\Models\\Administrator'), $matchID])->once()->andReturn(true);
$result = $this->service->removeMatch($matchID);
$this->assertTrue($result);
}