本文整理汇总了PHP中Mockery类的典型用法代码示例。如果您正苦于以下问题:PHP Mockery类的具体用法?PHP Mockery怎么用?PHP Mockery使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Mockery类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: dtestGetMultiple
function dtestGetMultiple()
{
$mockChainContext = \Mockery::mock('stdClass');
$mockChainContext->feed = $this->_multipleFeed;
$this->_sut->execute($mockChainContext);
$result = $mockChainContext->returnValue;
$this->assertTrue(is_array($result));
$this->assertEquals(8, count($result));
$video = $result[5];
$this->assertEquals('makimono', $video->getAuthorDisplayName());
$this->assertEquals('tagtool', $video->getAuthorUid());
$this->assertEquals('', $video->getCategory());
$this->assertEquals('N/A', $video->getCommentCount());
$this->assertEquals('Tagtool performance by Austrian artist Die.Puntigam at Illuminating York, 30th o...', $video->getDescription());
$this->assertEquals('6:52', $video->getDuration());
$this->assertEquals('http://vimeo.com/7416172', $video->getHomeUrl());
$this->assertEquals('7416172', $video->getId());
$this->assertEquals(array('Tagtool', 'Die.Puntigam', 'Illuminating York', 'Wall of Light'), $video->getKeywords());
$this->assertEquals('2', $video->getLikesCount());
$this->assertEquals('', $video->getRatingAverage());
$this->assertEquals('N/A', $video->getRatingCount());
$this->assertEquals('http://b.vimeocdn.com/ts/317/800/31780003_100.jpg', $video->getThumbnailUrl());
$this->assertEquals('', $video->getTimeLastUpdated());
$this->assertEquals('Nov 3, 2009', $video->getTimePublished());
$this->assertEquals('747', $video->getViewCount());
}
开发者ID:nidalhajaj,项目名称:tubepress,代码行数:26,代码来源:VimeoFactoryCommandTest.php
示例10: tearDown
/**
* This method is called after a test is executed.
*/
public function tearDown()
{
\Mockery::close();
$this->logger = null;
$this->futureFunc = null;
$this->response = null;
}
开发者ID:hitmeister,项目名称:api-sdk-php,代码行数:10,代码来源:ProcessResponseTest.php
示例11: shouldAddAnyInterfaceNamesToImplementsDefinition
/**
* @test
*/
public function shouldAddAnyInterfaceNamesToImplementsDefinition()
{
$pass = new InterfacePass();
$config = m::mock("Mockery\\Generator\\MockConfiguration", array("getTargetInterfaces" => array(m::mock(array("getName" => "Dave\\Dave")), m::mock(array("getName" => "Paddy\\Paddy")))));
$code = $pass->apply(static::CODE, $config);
$this->assertContains("implements MockInterface, \\Dave\\Dave, \\Paddy\\Paddy", $code);
}
开发者ID:EnmanuelCode,项目名称:backend-laravel,代码行数:10,代码来源:InterfacePassTest.php
示例12: shouldRemoveCallStaticTypeHintIfRequired
/**
* @test
*/
public function shouldRemoveCallStaticTypeHintIfRequired()
{
$pass = new CallTypeHintPass();
$config = m::mock("Mockery\\Generator\\MockConfiguration", array("requiresCallStaticTypeHintRemoval" => true))->shouldDeferMissing();
$code = $pass->apply(static::CODE, $config);
$this->assertContains('__callStatic($method, $args)', $code);
}
开发者ID:mockery,项目名称:mockery,代码行数:10,代码来源:CallTypeHintPassTest.php
示例13: test_install
public function test_install()
{
/** === Test Data === */
/** === Setup Mocks === */
// $setup->startSetup();
$this->mSetup->shouldReceive('startSetup')->once();
// $demPackage = $this->_toolDem->readDemPackage($pathToFile, $pathToNode);
$mDemPackage = $this->_mock(DataObject::class);
$this->mToolDem->shouldReceive('readDemPackage')->once()->withArgs([\Mockery::any(), '/dBEAR/package/Praxigento/package/Accounting'])->andReturn($mDemPackage);
// $demEntity = $demPackage->getData('package/Type/entity/Asset');
$mDemPackage->shouldReceive('getData');
//
// $this->_toolDem->createEntity($entityAlias, $demEntity);
//
$this->mToolDem->shouldReceive('createEntity')->withArgs([TypeAsset::ENTITY_NAME, \Mockery::any()]);
$this->mToolDem->shouldReceive('createEntity')->withArgs([TypeOperation::ENTITY_NAME, \Mockery::any()]);
$this->mToolDem->shouldReceive('createEntity')->withArgs([Account::ENTITY_NAME, \Mockery::any()]);
$this->mToolDem->shouldReceive('createEntity')->withArgs([Operation::ENTITY_NAME, \Mockery::any()]);
$this->mToolDem->shouldReceive('createEntity')->withArgs([Transaction::ENTITY_NAME, \Mockery::any()]);
$this->mToolDem->shouldReceive('createEntity')->withArgs([Balance::ENTITY_NAME, \Mockery::any()]);
$this->mToolDem->shouldReceive('createEntity')->withArgs([LogChangeAdmin::ENTITY_NAME, \Mockery::any()]);
$this->mToolDem->shouldReceive('createEntity')->withArgs([LogChangeCustomer::ENTITY_NAME, \Mockery::any()]);
// $setup->endSetup();
$this->mSetup->shouldReceive('endSetup')->once();
/** === Call and asserts === */
$this->obj->install($this->mSetup, $this->mContext);
}
开发者ID:praxigento,项目名称:mobi_mod_mage2_accounting,代码行数:27,代码来源:InstallSchema_Test.php
示例14: testVerify
function testVerify()
{
// Given
$this->startSession();
$userData = ['name' => 'Some name', 'email' => '[email protected]', 'password' => 'strongpassword', 'country_code' => '1', 'phone_number' => '5558180101'];
$user = new User($userData);
$user->authy_id = 'authy_id';
$user->save();
$this->be($user);
$mockAuthyApi = Mockery::mock('Authy\\AuthyApi')->makePartial();
$mockVerification = Mockery::mock();
$mockTwilioClient = Mockery::mock(\Twilio\Rest\Client::class)->makePartial();
$mockTwilioClient->messages = Mockery::mock();
$twilioNumber = config('services.twilio')['number'];
$mockTwilioClient->messages->shouldReceive('create')->with($user->fullNumber(), ['body' => 'You did it! Signup complete :)', 'from' => $twilioNumber])->once();
$mockAuthyApi->shouldReceive('verifyToken')->with($user->authy_id, 'authy_token')->once()->andReturn($mockVerification);
$mockVerification->shouldReceive('ok')->once()->andReturn(true);
$this->app->instance(\Twilio\Rest\Client::class, $mockTwilioClient);
$this->app->instance('Authy\\AuthyApi', $mockAuthyApi);
$modifiedUser = User::first();
$this->assertFalse($modifiedUser->verified);
// When
$response = $this->call('POST', route('user-verify'), ['token' => 'authy_token', '_token' => csrf_token()]);
// Then
$modifiedUser = User::first();
$this->assertRedirectedToRoute('user-index');
$this->assertTrue($modifiedUser->verified);
}
开发者ID:TwilioDevEd,项目名称:account-verification-laravel,代码行数:28,代码来源:UserControllerTest.php
示例15: 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
示例16: 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
示例17: 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
示例18: 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
示例19: 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
示例20: 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
注:本文中的Mockery类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论