本文整理汇总了PHP中Mockery\MockInterface类的典型用法代码示例。如果您正苦于以下问题:PHP MockInterface类的具体用法?PHP MockInterface怎么用?PHP MockInterface使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MockInterface类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
开发者ID:lordthorzonus,项目名称:yii2-algolia,代码行数:8,代码来源:SynchronousAutoIndexBehaviorTest.php
示例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());
}
开发者ID:cloudtracer,项目名称:opencfp,代码行数:8,代码来源:ProfileApiControllerTest.php
示例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]);
}
开发者ID:praxigento,项目名称:mobi_mod_mage2_bonus_loyalty,代码行数:31,代码来源:Bonus_Test.php
示例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));
}
开发者ID:stopfstedt,项目名称:ilios,代码行数:10,代码来源:ListRootUsersCommandTest.php
示例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);
}
开发者ID:djordje,项目名称:laravel-sentry-backend,代码行数:7,代码来源:ControllersSessionControllerTest.php
示例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);
}
开发者ID:praxigento,项目名称:mobi_mod_mage2_odoo,代码行数:31,代码来源:Rest_Test.php
示例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);
}
开发者ID:bbonnesoeur,项目名称:phpDocumentor2,代码行数:38,代码来源:CheckStyleTest.php
示例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());
}
开发者ID:SaveYa,项目名称:FixedWidth,代码行数:7,代码来源:LineReaderTest.php
示例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);
}
开发者ID:djordje,项目名称:laravel-sentry-backend,代码行数:32,代码来源:ControllersPasswordResetControllerTest.php
示例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());
}
开发者ID:jaredfaris,项目名称:opencfp,代码行数:8,代码来源:TalkApiControllerTest.php
示例11: testExecuteWithoutViolations
public function testExecuteWithoutViolations()
{
$list = new ConstraintViolationList([]);
$this->validator->shouldReceive('validate')->once()->andReturn($list);
$this->middleware->execute(new FakeCommand(), function () {
});
}
开发者ID:nejcpenko,项目名称:tactician-bundle,代码行数:7,代码来源:ValidatorMiddlewareTest.php
示例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'));
}
开发者ID:Cliffus,项目名称:laravel-lucene-search,代码行数:7,代码来源:HtmlTest.php
示例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]));
}
开发者ID:praxigento,项目名称:mobi_mod_mage2_pv,代码行数:35,代码来源:Item_Test.php
示例14: testComposeShouldComposeAllComponents
public function testComposeShouldComposeAllComponents()
{
$this->mockSeeder->shouldReceive("setAllServiceProvidersFrom")->once();
$this->mockSeeder->shouldReceive("seedAll")->once();
$this->mockComposer->shouldReceive("setEnvironment")->with("")->once();
$this->installer->seed();
}
开发者ID:PhonemeCms,项目名称:cms,代码行数:7,代码来源:InstallPhonemeTest.php
示例15: shouldCreateTheUser
/**
* @test
*/
public function shouldCreateTheUser()
{
$this->userSessionFactory->shouldReceive('create');
$user = $this->createUser();
$userToken = $this->createUserToken();
$this->repository->create($user, $userToken);
}
开发者ID:raptorlab,项目名称:veloci,代码行数:10,代码来源:InMemoryUserSessionRepositoryTest.php
示例16: testSetHighlighterAnalyzer
public function testSetHighlighterAnalyzer()
{
$this->app->instance('filterClass1', $tokenFilterMock = m::mock('ZendSearch\\Lucene\\Analysis\\TokenFilter\\TokenFilterInterface'));
$this->analyzer->shouldReceive('addFilter')->with($tokenFilterMock)->once();
$this->config->setHighlighterAnalyzer();
$this->assertEquals($this->analyzer, Analyzer::getDefault());
}
开发者ID:Cliffus,项目名称:laravel-lucene-search,代码行数:7,代码来源:ConfigTest.php
示例17: it_correctly_parses_arrays_and_traversables
/**
* @group certificate
* @test
*
* @dataProvider invalidConfigurationProvider
* @expectedException \SAML2\Exception\InvalidArgumentException
*/
public function it_correctly_parses_arrays_and_traversables($configurationValue)
{
$this->configurationMock->shouldReceive('getCertificateFingerprints')->once()->andReturn($configurationValue);
$result = $this->fingerprintLoader->loadFingerprints($this->configurationMock);
$this->assertInstanceOf('\\SAML2\\Certificate\\FingerprintCollection', $result);
$this->assertCount(count($configurationValue), $result);
}
开发者ID:SysBind,项目名称:saml2,代码行数:14,代码来源:FingerprintLoaderTest.php
示例18: testCreateService
public function testCreateService()
{
$config = array('PhpClientPoeditor' => array('options' => array()));
$this->serviceLocator->shouldReceive('get')->with('Config')->andReturn($config)->once();
$instance = $this->fixture->createService($this->serviceLocator);
$this->assertInstanceOf('PhpClientPoeditor\\Options\\Options', $instance);
}
开发者ID:maikay,项目名称:zf2-poeditor-php-client,代码行数:7,代码来源:OptionsFactoryTest.php
示例19: createDirGenTest
protected function createDirGenTest($baseDir, $dir)
{
$this->fs->shouldReceive('exists')->once()->with(m::mustBe(Path::join($baseDir, $dir)))->andReturn(false);
$this->fs->shouldReceive('makeDirectory')->once()->with(m::mustBe(Path::join($baseDir, $dir)), m::mustBe(0755), m::mustBe(true))->andReturn(true);
$generator = $this->generator->generateDirectoryStructure($baseDir, [$dir]);
$this->assertInstanceOf(StubGenerator::class, $generator);
}
开发者ID:caffeinated,项目名称:beverage,代码行数:7,代码来源:StubGeneratorTest.php
示例20: testUserNotFound
/**
* @covers \Ilios\CliBundle\Command\AddRootUserCommand::execute
*/
public function testUserNotFound()
{
$userId = 0;
$this->userManager->shouldReceive('findOneBy')->with(['id' => $userId])->andReturn(null);
$this->setExpectedException('Exception', "No user with id #{$userId} was found.");
$this->commandTester->execute(['command' => AddRootUserCommand::COMMAND_NAME, 'userId' => $userId]);
}
开发者ID:stopfstedt,项目名称:ilios,代码行数:10,代码来源:AddRootUserCommandTest.php
注:本文中的Mockery\MockInterface类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论