本文整理汇总了PHP中Mockery\MockInterface类的典型用法代码示例。如果您正苦于以下问题:PHP MockInterface类的具体用法?PHP MockInterface怎么用?PHP MockInterface使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MockInterface类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: it_should_not_call_remove_from_indices_if_afterUpdate_is_set_to_false
/** @test */
public function it_should_not_call_remove_from_indices_if_afterUpdate_is_set_to_false()
{
$dummyModel = new DummyActiveRecordModel();
$dummyModel->attachBehavior('test', ['class' => SynchronousAutoIndexBehavior::class, 'afterUpdate' => false]);
$this->dummyAlgoliaManager->shouldNotReceive('updateInIndices');
$dummyModel->trigger(ActiveRecord::EVENT_AFTER_UPDATE);
}
示例2: it_responds_internal_error_when_something_bad_happens
/** @test */
public function it_responds_internal_error_when_something_bad_happens()
{
$this->speakers->shouldReceive('findProfile')->andThrow(new Exception('Zomgz it blew up somehow.'));
$response = $this->sut->handleShowSpeakerProfile($this->getRequest());
$this->assertEquals(500, $response->getStatusCode());
$this->assertContains('Zomgz it blew up somehow', $response->getContent());
}
示例3: test_calc
public function test_calc()
{
/** === Test Data === */
$CUST_1 = 1;
$PARENT_1 = 101;
$ORDR_1 = 10;
$PV_1 = 100;
$RANK_1 = 2;
$PERCENT_1 = 0.01;
$BONUS_1 = 'bonus';
$TREE = 'tree';
$TREE_EXP = [$CUST_1 => [Snap::ATTR_PATH => 'path1']];
$MAP_RANKS = [$PARENT_1 => $RANK_1];
$ORDERS = [[Cfg::E_SALE_ORDER_A_CUSTOMER_ID => $CUST_1, PvSale::ATTR_SALE_ID => $ORDR_1, PvSale::ATTR_TOTAL => $PV_1]];
$PARAMS = [];
$PERCENTS = [$RANK_1 => [1 => $PERCENT_1]];
$PARENTS = [$PARENT_1];
/** === Setup Mocks === */
// $mapTreeExp = $this->_expandTree($tree);
// $resp = $this->_callDownlineSnap->expandMinimal($req);
$this->mCallDownlineSnap->shouldReceive('expandMinimal')->once()->andReturn(new DataObject(['SnapData' => $TREE_EXP]));
// $mapRankById = $this->_rankQualifier->qualifyCustomers($tree, $params);
$this->mRankQualifier->shouldReceive('qualifyCustomers')->once()->andReturn($MAP_RANKS);
// $parents = $this->_toolDownlineTree->getParentsFromPathReversed($path);
$this->mToolDownlineTree->shouldReceive('getParentsFromPathReversed')->once()->andReturn($PARENTS);
// $bonus = $this->_toolFormat->roundBonus($bonus);
$this->mToolFormat->shouldReceive('roundBonus')->once()->with($PV_1 * $PERCENT_1)->andReturn($BONUS_1);
/** === Call and asserts === */
$resp = $this->sub->calc($TREE, $ORDERS, $PARAMS, $PERCENTS);
$this->assertEquals($BONUS_1, $resp[$PARENT_1][$ORDR_1]);
}
示例4: testListUsersNoResults
/**
* @covers \Ilios\CliBundle\Command\ListRootUsersCommand::execute
*/
public function testListUsersNoResults()
{
$this->userManager->shouldReceive('findDTOsBy')->with(['root' => true])->andReturn([]);
$this->commandTester->execute(['command' => ListRootUsersCommand::COMMAND_NAME]);
$output = $this->commandTester->getDisplay();
$this->assertEquals('No users with root-level privileges found.', trim($output));
}
示例5: testDestroy
public function testDestroy()
{
$redirect = $this->app['config']->get('laravel-sentry-backend::logout_redirect');
$this->auth->shouldReceive('logout')->once()->withNoArgs();
$this->route('delete', 'session.destroy');
$this->assertRedirectedToRoute($redirect);
}
示例6: test_request_false
/**
* @expectedException \Exception
*/
public function test_request_false()
{
/** === Test Data === */
$PARAMS = 'params';
$PARAMS_JSON = 'JSON encoded params';
$ROUTE = 'route';
$SESS_ID = 'session id';
$CONTEXT_OPTS_JSON = 'JSON encoded context options';
$RESULT = 'result';
/** === Setup Mocks === */
// $sessId = $this->_login->getSessionId();
$this->mLogin->shouldReceive('getSessionId')->once()->andReturn($SESS_ID);
// $request = $this->_adapter->encodeJson($params);
$this->mAdapter->shouldReceive('encodeJson')->once()->with($PARAMS)->andReturn($PARAMS_JSON);
// $context = $this->_adapter->createContext($contextOpts);
$this->mAdapter->shouldReceive('createContext')->once()->andReturn($PARAMS_JSON);
// this->_logger->debug("Request URI:\t$uri");
$this->mLogger->shouldReceive('debug');
// $jsonContextOpt = $this->_adapter->encodeJson($contextOpts);
$this->mAdapter->shouldReceive('encodeJson')->once()->andReturn($CONTEXT_OPTS_JSON);
// $contents = $this->_adapter->getContents($uri, $context);
$this->mAdapter->shouldReceive('getContents')->once()->andReturn(false);
// $this->_logger->critical($msg);
$this->mLogger->shouldReceive('critical')->once();
/** === Call and asserts === */
$res = $this->obj->request($PARAMS, $ROUTE);
$this->assertEquals($RESULT, $res);
}
示例7: testTransform
/**
* @covers phpDocumentor\Plugin\Core\Transformer\Writer\CheckStyle::transform
*/
public function testTransform()
{
$transformer = m::mock('phpDocumentor\\Transformer\\Transformation');
$transformer->shouldReceive('getTransformer->getTarget')->andReturn(vfsStream::url('CheckStyleTest'));
$transformer->shouldReceive('getArtifact')->andReturn('artifact.xml');
$fileDescriptor = m::mock('phpDocumentor\\Descriptor\\FileDescriptor');
$projectDescriptor = m::mock('phpDocumentor\\Descriptor\\ProjectDescriptor');
$projectDescriptor->shouldReceive('getFiles->getAll')->andReturn(array($fileDescriptor));
$error = m::mock('phpDocumentor\\Descriptor\\Validator\\Error');
$fileDescriptor->shouldReceive('getPath')->andReturn('/foo/bar/baz');
$fileDescriptor->shouldReceive('getAllErrors->getAll')->andReturn(array($error));
$error->shouldReceive('getLine')->andReturn(1234);
$error->shouldReceive('getCode')->andReturn(5678);
$error->shouldReceive('getSeverity')->andReturn('error');
$error->shouldReceive('getContext')->andReturn('myContext');
$this->translator->shouldReceive('translate')->with('5678')->andReturn('5678 %s');
// Call the actual method
$this->checkStyle->transform($projectDescriptor, $transformer);
// Assert file exists
$this->assertTrue($this->fs->hasChild('artifact.xml'));
// Inspect XML
$xml = <<<XML
<?xml version="1.0"?>
<checkstyle version="1.3.0">
<file name="/foo/bar/baz">
<error line="1234" severity="error" message="5678 myContext" source="phpDocumentor.file.5678"/>
</file>
</checkstyle>
XML;
$expectedXml = new \DOMDocument();
$expectedXml->loadXML($xml);
$actualXml = new \DOMDocument();
$actualXml->load(vfsStream::url('CheckStyleTest/artifact.xml'));
$this->assertEqualXMLStructure($expectedXml->firstChild, $actualXml->firstChild, true);
}
示例8: testParseLine
public function testParseLine()
{
$this->line['34:39'] = 'seeya';
$this->line['40:42'] = 'ho';
$this->formatter->shouldReceive('formatFromFile')->once()->with($this->spec->getFieldSpec('field2'), 'ho')->andReturn('ha')->getMock()->shouldReceive('formatFromFile')->once()->with($this->spec->getFieldSpec('field1'), 'seeya')->andReturn('booya')->getMock();
$this->assertEquals(array('field1' => 'booya', 'field2' => 'ha'), $this->reader->getFields());
}
示例9: testUpdate
public function testUpdate()
{
$this->users->shouldReceive('findById')->once()->andReturn(false);
$this->route('put', 'password-reset.update');
$this->assertRedirectedToRoute('password-reset.create');
$this->users->shouldReceive('findById')->once()->andReturn(false);
$this->route('put', 'password-reset.update', null, array('code' => '123456789'));
$this->assertRedirectedToRoute('password-reset.create');
$this->users->shouldReceive('findById')->once()->andReturn(true);
$this->route('put', 'password-reset.update', null, array('id' => '1'));
$this->assertRedirectedToRoute('password-reset.create');
$user = m::mock();
$user->id = 1;
$this->users->shouldReceive('findById')->with(1)->once()->andReturn($user);
$this->validator->shouldReceive('validate')->once()->andReturn(false);
$this->validator->shouldReceive('getErrors')->once()->andReturn(array());
$this->route('put', 'password-reset.update', null, array('id' => '1', 'code' => '123456789'));
$this->assertRedirectedToRoute('password-reset.edit', array(1, '123456789'));
$this->assertSessionHasErrors();
$this->users->shouldReceive('findById')->with(1)->once()->andReturn($user);
$this->validator->shouldReceive('validate')->once()->andReturn(true);
$user->shouldReceive('checkResetPasswordCode')->with('123456789')->once()->andReturn(false);
$this->route('put', 'password-reset.update', null, array('id' => '1', 'code' => '123456789'));
$this->assertRedirectedToRoute('password-reset.create');
$this->users->shouldReceive('findById')->with(1)->once()->andReturn($user);
$this->validator->shouldReceive('validate')->once()->andReturn(true);
$user->shouldReceive('checkResetPasswordCode')->with('123456789')->once()->andReturn(true);
$user->shouldReceive('attemptResetPassword')->with('123456789', 'newPassword')->once()->andReturn(true);
$this->route('put', 'password-reset.update', null, array('id' => '1', 'code' => '123456789', 'password' => 'newPassword'));
$this->assertRedirectedToRoute('session.create');
$this->assertSessionHas('success_password_reset', true);
}
示例10: it_should_respond_unauthorized_when_no_authentication_provided
/** @test */
public function it_should_respond_unauthorized_when_no_authentication_provided()
{
$this->speakers->shouldReceive('getTalks')->andThrow(\OpenCFP\Domain\Services\NotAuthenticatedException::class);
$response = $this->sut->handleViewAllTalks($this->getValidRequest());
$this->assertEquals(401, $response->getStatusCode());
$this->assertContains('Unauthorized', $response->getContent());
}
示例11: testExecuteWithoutViolations
public function testExecuteWithoutViolations()
{
$list = new ConstraintViolationList([]);
$this->validator->shouldReceive('validate')->once()->andReturn($list);
$this->middleware->execute(new FakeCommand(), function () {
});
}
示例12: testHighlightLastQueryIsEmpty
public function testHighlightLastQueryIsEmpty()
{
$this->queryRunner->shouldReceive('getLastQuery')->andReturn(false);
$this->analyzerConfig->shouldReceive('setHighlighterAnalyzer')->never();
$this->analyzerConfig->shouldReceive('setDefaultAnalyzer')->never();
$this->assertEquals('test', $this->html->highlight('test'));
}
示例13: test_getItemsByOrderId
public function test_getItemsByOrderId()
{
/** === Test Data === */
$ORDER_ID = 32;
$ITEM_ID = 64;
$TBL_ORDER = 'sale order item';
$TBL_PV_ITEM = 'pv item';
/** === Setup Mocks === */
// $tblOrder = [$asOrder => $this->_resource->getTableName(Cfg::ENTITY_MAGE_SALES_ORDER_ITEM)];
$this->mResource->shouldReceive('getTableName')->once()->andReturn($TBL_ORDER);
// $tblPvItem = [$asPvItem => $this->_resource->getTableName(Entity::ENTITY_NAME)];
$this->mResource->shouldReceive('getTableName')->once()->andReturn($TBL_PV_ITEM);
// $query = $conn->select();
$mQuery = $this->_mockDbSelect();
$this->mConn->shouldReceive('select')->once()->andReturn($mQuery);
// $query->from($tblOrder, $cols);
$mQuery->shouldReceive('from')->once();
// $query->joinLeft($tblPvItem, $on, $cols);
$mQuery->shouldReceive('joinLeft')->once();
// $query->where($where);
$mQuery->shouldReceive('where')->once();
// $rows = $conn->fetchAll($query);
$mRow = [];
$mRows = [$mRow];
$this->mConn->shouldReceive('fetchAll')->once()->andReturn($mRows);
// $item = $this->_manObj->create(Entity::class, $row);
$mItem = $this->_mock(\Praxigento\Pv\Data\Entity\Sale\Item::class);
$this->mManObj->shouldReceive('create')->once()->with(\Praxigento\Pv\Data\Entity\Sale\Item::class, $mRow)->andReturn($mItem);
// $result[$item->getSaleItemId()] = $item;
$mItem->shouldReceive('getSaleItemId')->once()->andReturn($ITEM_ID);
/** === Call and asserts === */
$res = $this->obj->getItemsByOrderId($ORDER_ID);
$this->assertTrue(is_array($res));
$this->assertTrue(isset($res[$ITEM_ID]));
}
示例14: testComposeShouldComposeAllComponents
public function testComposeShouldComposeAllComponents()
{
$this->mockSeeder->shouldReceive("setAllServiceProvidersFrom")->once();
$this->mockSeeder->shouldReceive("seedAll")->once();
$this->mockComposer->shouldReceive("setEnvironment")->with("")->once();
$this->installer->seed();
}
示例15: shouldCreateTheUser
/**
* @test
*/
public function shouldCreateTheUser()
{
$this->userSessionFactory->shouldReceive('create');
$user = $this->createUser();
$userToken = $this->createUserToken();
$this->repository->create($user, $userToken);
}