本文整理汇总了PHP中Mockery::self方法的典型用法代码示例。如果您正苦于以下问题:PHP Mockery::self方法的具体用法?PHP Mockery::self怎么用?PHP Mockery::self使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mockery
的用法示例。
在下文中一共展示了Mockery::self方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
protected function setUp()
{
$this->app = m::mock(Container::class);
$this->app->shouldReceive('make')->andReturn(m::self());
$this->cache = m::mock(CacheManager::class);
$this->manager = new MetaDataManager($this->app);
}
示例2: 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->connection->shouldReceive('createQueryBuilder')->once()->andReturn(\Mockery::mock()->shouldReceive('select')->once()->with($fields)->andReturn(\Mockery::self())->getMock()->shouldReceive('from')->once()->with($this->table)->andReturn(\Mockery::self())->getMock()->shouldReceive('execute')->once()->andReturn(\Mockery::mock()->shouldReceive('fetch')->times(4)->with(\PDO::FETCH_ASSOC)->andReturn($row1, $row2, $row3, false)->getMock())->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) {
$encryptedRow = 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($encrypted = $this->getFaker()->unique()->word)->getMock();
$encryptedRow[$field] = $encrypted;
}
$this->connection->shouldReceive('update')->once()->with($this->table, $encryptedRow, array($this->idField => $row[$this->idField]));
}
$this->rotator->rotate($observer, $encryptor, $newProfile);
}
示例3: testJob_Is_Not_Find
public function testJob_Is_Not_Find()
{
$this->fixture->shouldReceive('getJobByVacancyId')->with(2)->andReturn(\Mockery::self())->atLeast(1);
$this->fixture->shouldReceive('extendJob')->andReturn(true)->atLeast(1);
$parser = new Parser([], $this->fixture);
$parser->parseVacancy(2, null);
}
示例4: endTest
/**
* endTest is called after each test and checks if \Mockery::close() has
* been called, and will let the test fail if it hasn't.
*
* @param PHPUnit_Framework_Test $test
* @param float $time
*/
public function endTest(\PHPUnit_Framework_Test $test, $time)
{
if (!$test instanceof \PHPUnit_Framework_TestCase) {
// We need the getTestResultObject and getStatus methods which are
// not part of the interface.
return;
}
if ($test->getStatus() !== \PHPUnit_Runner_BaseTestRunner::STATUS_PASSED) {
// If the test didn't pass there is no guarantee that
// verifyMockObjects and assertPostConditions have been called.
// And even if it did, the point here is to prevent false
// negatives, not to make failing tests fail for more reasons.
return;
}
try {
// The self() call is used as a sentinel. Anything that throws if
// the container is closed already will do.
\Mockery::self();
} catch (\LogicException $_) {
return;
}
$e = new \PHPUnit_Framework_ExpectationFailedException(sprintf("Mockery's expectations have not been verified. Make sure that \\Mockery::close() is called at the end of the test. Consider using %s\\MockeryPHPUnitIntegration or extending %s\\MockeryTestCase.", __NAMESPACE__, __NAMESPACE__));
$result = $test->getTestResultObject();
$result->addFailure($test, $e, $time);
}
示例5: _before
protected function _before()
{
$serviceLocator = \Mockery::mock('Zend\\ServiceManager\\ServiceLocatorInterface');
$serviceLocator->shouldReceive('get')->with('elasticsearch')->andReturn(\Mockery::self());
$serviceLocator->shouldReceive('search')->with(array('index' => 'test-index', 'body' => 'test-query'))->andReturn(array('test-response', 'test-data'));
$this->service = new ElasticSearch($serviceLocator);
}
示例6: setUp
protected function setUp()
{
$this->app = m::mock(Container::class);
$this->app->shouldReceive('make')->andReturn(m::self());
$this->app->shouldReceive('get')->with('doctrine.cache.default', 'array')->andReturn('array');
$this->manager = new CacheManager($this->app);
}
示例7: testGetLoggedUserId
public function testGetLoggedUserId()
{
$authenticator_mock = \Mockery::mock('Jacopo\\Authentication\\SentryAuthenticator');
$authenticator_mock->shouldReceive('getLoggedUser')->once()->andReturn(\Mockery::self())->shouldReceive('toArray')->once()->andReturn(['id' => 'foobar']);
$this->app->instance('authenticator', $authenticator_mock);
assertThat($this->authMgr()->getLoggedUserId(), identicalTo('foobar'));
}
示例8: testConfigureOptionsResolver
public function testConfigureOptionsResolver()
{
$this->factory->configureOptionsResolver(\Mockery::mock('Symfony\\Component\\OptionsResolver\\OptionsResolver')->shouldReceive('setRequired')->once()->with(array('container'))->andReturn(\Mockery::self())->getMock()->shouldReceive('setAllowedTypes')->once()->with(array('container' => 'Symfony\\Component\\DependencyInjection\\ContainerInterface'))->andReturn(\Mockery::self())->getMock());
$container = new Container();
$factory = new ContainerParametersSourceBuilder($container);
$factory->configureOptionsResolver(\Mockery::mock('Symfony\\Component\\OptionsResolver\\OptionsResolver')->shouldReceive('setRequired')->once()->with(array('container'))->andReturn(\Mockery::self())->getMock()->shouldReceive('setAllowedTypes')->once()->with(array('container' => 'Symfony\\Component\\DependencyInjection\\ContainerInterface'))->andReturn(\Mockery::self())->getMock()->shouldReceive('setDefaults')->once()->with(array('container' => $container))->andReturn(\Mockery::self())->getMock());
}
示例9: testAuthenticatingWithQueryStringSucceedsAndReturnsUserObject
public function testAuthenticatingWithQueryStringSucceedsAndReturnsUserObject()
{
$request = Request::create('foo', 'GET', ['token' => 'foo']);
$this->auth->shouldReceive('setToken')->with('foo')->andReturn(m::self());
$this->auth->shouldReceive('authenticate')->once()->andReturn((object) ['id' => 1]);
$this->assertEquals(1, $this->provider->authenticate($request, m::mock('Dingo\\Api\\Routing\\Route'))->id);
}
示例10: testSetLookUpIdCallsApaiioDependencyCorrectly
public function testSetLookUpIdCallsApaiioDependencyCorrectly()
{
$apai_op_mock = Mockery::mock('ApaiIO\\Operations\\Lookup');
$apai_op_mock->shouldReceive('setItemId')->once()->with('stub item id')->andReturn(Mockery::self());
$this->app->instance('ApaiIO\\Operations\\Lookup', $apai_op_mock);
$lookup_op = $this->app->make('Giftertipster\\Service\\Api\\AmzProductApi\\ApaiIO\\Operations\\LookupOperation');
$response = $lookup_op->setItemId('stub item id');
}
示例11: setUp
protected function setUp()
{
$this->app = m::mock(Container::class);
$this->app->shouldReceive('make')->andReturn(m::self());
$this->config = m::mock(Repository::class);
$this->config->shouldReceive('get');
$this->manager = new ConnectionManager($this->app);
}
示例12: testFlush
public function testFlush()
{
$cache = $this->getCache();
$cache->shouldReceive('flush');
$cache->shouldReceive('getStore')->andReturn(m::self());
$transCache = new TransCache($cache);
$transCache->flush();
}
示例13: getPropelQuery
protected function getPropelQuery($model, $results)
{
$mock = Mockery::mock('overload:PropelQuery');
$mock->shouldReceive('from')->once()->with($model)->andReturn(\Mockery::self());
$mock->shouldReceive('setFormatter')->once()->with('PropelOnDemandFormatter')->andReturn(\Mockery::self());
$mock->shouldReceive('find')->once()->andReturn($results);
return $mock;
}
示例14: testGetSchema
public function testGetSchema()
{
$connection = M::mock('Fuel\\Database\\Connection');
$connection->shouldReceive('getSchemaManager')->andReturn(M::self());
$connection->shouldReceive('createSchema')->andReturn('called');
$schema = new Schema($connection);
$this->assertEquals('called', $schema->getSchema());
}
示例15: getConn
protected function getConn()
{
$conn = m::mock(\Xpressengine\Database\VirtualConnectionInterface::class);
$conn->shouldReceive('where')->andReturn(m::self());
$conn->shouldReceive('table')->andReturn(m::self());
$conn->shouldReceive('insert')->andReturn(m::self());
$conn->shouldReceive('update')->andReturn(m::self());
return $conn;
}