本文整理汇总了PHP中Mockery::anyOf方法的典型用法代码示例。如果您正苦于以下问题:PHP Mockery::anyOf方法的具体用法?PHP Mockery::anyOf怎么用?PHP Mockery::anyOf使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mockery
的用法示例。
在下文中一共展示了Mockery::anyOf方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testThatQuickCallCorrectlyCallsSingleRequest
public function testThatQuickCallCorrectlyCallsSingleRequest()
{
$mock = m::mock(self::classPath . '[singleRequest]', [$this->appMock, $this->requestMock, $this->routerMock]);
$mock->shouldReceive('singleRequest')->times(2)->withArgs([m::anyOf('GET', 'POST'), '/endpoint', ['data'], ['server'], 'content']);
$mock->quickCall('GET', ['/endpoint', ['data'], ['server'], 'content']);
$mock->quickCall('GET', ['/endpoint', ['data'], ['server'], 'content']);
}
示例2: setUp
public function setUp()
{
$factoryTypeMock = m::mock('Ladybug\\Type\\FactoryType');
$factoryTypeMock->shouldReceive('factory')->with(m::anyOf(1, 2, 3), m::any())->andReturn(new Type\IntType());
$extendedTypeFactoryMock = m::mock('Ladybug\\Type\\ExtendedTypeFactory');
$extendedTypeFactoryMock->shouldReceive('factory')->with('collection', m::any())->andReturn(new CollectionType());
$this->inspector = new SplQueueInspector($factoryTypeMock, $extendedTypeFactoryMock);
}
示例3: _createHelperRepository
/**
* _createHelperRepository
*
* @return \Radic\BladeExtensions\Helpers\HelperRepository
*/
protected function _createHelperRepository()
{
foreach ($this->helperClasses as $name => $class) {
$this->helperMocks[$name] = m::mock($class);
$this->container->shouldReceive('make')->once()->with(m::anyOf($class))->andReturn($this->helperMocks[$name]);
}
return new HelperRepository($this->container);
}
示例4: testBuildForm
public function testBuildForm()
{
$builder = m::mock('Symfony\\Component\\Form\\FormBuilderInterface');
$input = array('buttons' => array('save' => array('type' => 'submit', 'options' => array('label' => 'button.save')), 'cancel' => array('type' => 'button', 'options' => array('label' => 'button.cancel'))));
$buttonBuilder = new ButtonBuilder('name');
$builder->shouldReceive('add')->with(m::anyOf('save', 'cancel'), m::anyOf('submit', 'button'), m::hasKey('label'))->twice()->andReturn($buttonBuilder);
$this->type = new FormActionsType();
$this->type->buildForm($builder, $input);
}
示例5: setUp
public function setUp()
{
$factoryTypeMock = m::mock('Ladybug\\Type\\FactoryType');
$factoryTypeMock->shouldReceive('factory')->with(m::anyOf(1, 2, 3), m::any())->andReturn(new Type\IntType());
$managerInspectorMock = m::mock('Ladybug\\Inspector\\InspectorManager');
$managerInspectorMock->shouldReceive('get')->andReturn(null);
$metadataResolverMock = m::mock('Ladybug\\Metadata\\MetadataResolver');
$metadataResolverMock->shouldReceive('has')->andReturn(false);
$this->type = new Type\ResourceType($factoryTypeMock, $managerInspectorMock, $metadataResolverMock);
}
示例6: setUp
public function setUp()
{
$maxlevel = 8;
$factoryTypeMock = m::mock('Ladybug\\Type\\FactoryType');
$factoryTypeMock->shouldReceive('factory')->with(m::anyOf(1, 2, 3), m::any())->andReturnUsing(function ($var, $level) {
$intType = new Type\IntType();
$intType->load($var, $level);
return $intType;
});
$this->type = new Type\ArrayType($maxlevel, $factoryTypeMock);
}
示例7: testItConvertsASnakeCasedParameter
public function testItConvertsASnakeCasedParameter()
{
$validator = m::mock('Symfony\\Component\\Validator\\Validator\\ValidatorInterface')->shouldReceive('validate')->andReturn(new ConstraintViolationList([]))->getMock();
$paramConverter = new JsonConvertibleParamConverter($validator);
$foo = new Foo();
$foo->bar = 'baz';
$foo->camelCased = 'yeah';
$request = $this->createJsonRequest((object) ['foo_bar' => ['bar' => 'baz', 'camel_cased' => 'yeah']]);
$request->attributes = m::mock('Symfony\\Component\\HttpFoundation\\ParameterBag')->shouldReceive('set')->once()->with('fooBar', m::anyOf($foo))->getMock();
$configuration = new ParamConverter(['name' => 'fooBar', 'class' => 'Surfnet\\StepupBundle\\Tests\\Request\\Foo']);
$paramConverter->apply($request, $configuration);
}
示例8: setUp
public function setUp()
{
$maxlevel = 8;
$factoryTypeMock = m::mock('Ladybug\\Type\\FactoryType');
$factoryTypeMock->shouldReceive('factory')->with(m::anyOf(1, 2, 3, 4), m::any())->andReturnUsing(function ($var, $level) {
$intType = new Type\IntType();
$intType->load($var, $level);
return $intType;
});
$managerInspectorMock = m::mock('Ladybug\\Inspector\\InspectorManager');
$managerInspectorMock->shouldReceive('get')->andReturn(null);
$metadataResolverMock = m::mock('Ladybug\\Metadata\\MetadataResolver');
$metadataResolverMock->shouldReceive('has')->andReturn(false);
$this->type = new Type\ObjectType($maxlevel, $factoryTypeMock, $managerInspectorMock, $metadataResolverMock);
}
示例9: testGenerateSitemapFromRoutesWithObjectRoute
public function testGenerateSitemapFromRoutesWithObjectRoute()
{
$service = m::mock(SitemapGeneratorCommand::class . '[getValuesAttributes,generateCombinations]', [$this->router, $this->objectManager, []]);
$service->shouldAllowMockingProtectedMethods();
$reflectionService = new \ReflectionClass($service);
$reflectionOutput = $reflectionService->getProperty('output');
$reflectionOutput->setAccessible(true);
$reflectionOutput->setValue($service, $this->output);
$service->setHelperSet(new HelperSet([new FormatterHelper()]));
$sitemap = m::mock(Sitemap::class);
$routes = ['route_name' => ['options' => ['param1' => ['defaults' => [0], 'repository' => ['object' => 'TestObject', 'property' => 'id']], 'param2' => ['repository' => ['object' => 'Test1Object', 'property' => 'id']]], 'lastmod' => (new \DateTime('now'))->getTimestamp(), 'changefreq' => Sitemap::WEEKLY, 'priority' => '0.8']];
$service->shouldReceive('getValuesAttributes')->once()->andReturn([['0', '1', '2'], ['a', 'b']]);
$service->shouldReceive('generateCombinations')->once()->andReturn([['1', 'a'], ['1', 'b'], ['2', 'a'], ['2', 'b']]);
$this->router->shouldReceive('generate')->times(4)->andReturn('a', 'b', 'c', 'd');
$sitemap->shouldReceive('addItem')->times(4)->with(m::anyOf('a', 'b', 'c', 'd'), (new \DateTime('now'))->getTimestamp(), Sitemap::WEEKLY, '0.8');
$sitemap->shouldReceive('setMaxUrls')->andReturn();
$reflectionMethod = new \ReflectionMethod($service, 'generateSitemapFromRoutes');
$reflectionMethod->setAccessible(true);
$this->assertInstanceOf(Sitemap::class, $reflectionMethod->invoke($service, $sitemap, $routes));
}
示例10: testTransportsWhichThrowExceptionsAreNotRetried
public function testTransportsWhichThrowExceptionsAreNotRetried()
{
$e = new Swift_TransportException('maur b0rken');
$message1 = $this->getMockery('Swift_Mime_Message');
$message2 = $this->getMockery('Swift_Mime_Message');
$message3 = $this->getMockery('Swift_Mime_Message');
$message4 = $this->getMockery('Swift_Mime_Message');
$t1 = $this->getMockery('Swift_Transport');
$t2 = $this->getMockery('Swift_Transport');
$connectionState1 = false;
$connectionState2 = false;
$testCase = $this;
$t1->shouldReceive('isStarted')->zeroOrMoreTimes()->andReturnUsing(function () use(&$connectionState1) {
return $connectionState1;
});
$t1->shouldReceive('start')->once()->andReturnUsing(function () use(&$connectionState1) {
if (!$connectionState1) {
$connectionState1 = true;
}
});
$t1->shouldReceive('send')->once()->with($message1, \Mockery::any())->andReturnUsing(function () use(&$connectionState1, $e, $testCase) {
if ($connectionState1) {
throw $e;
}
$testCase->fail();
});
$t1->shouldReceive('send')->never()->with($message2, \Mockery::any());
$t1->shouldReceive('send')->never()->with($message3, \Mockery::any());
$t1->shouldReceive('send')->never()->with($message4, \Mockery::any());
$t2->shouldReceive('isStarted')->zeroOrMoreTimes()->andReturnUsing(function () use(&$connectionState2) {
return $connectionState2;
});
$t2->shouldReceive('start')->once()->andReturnUsing(function () use(&$connectionState2) {
if (!$connectionState2) {
$connectionState2 = true;
}
});
$t2->shouldReceive('send')->times(4)->with(\Mockery::anyOf($message1, $message3, $message3, $message4), \Mockery::any())->andReturnUsing(function () use(&$connectionState2, $testCase) {
if ($connectionState2) {
return 1;
}
$testCase->fail();
});
$transport = $this->getTransport(array($t1, $t2));
$transport->start();
$this->assertEquals(1, $transport->send($message1));
$this->assertEquals(1, $transport->send($message2));
$this->assertEquals(1, $transport->send($message3));
$this->assertEquals(1, $transport->send($message4));
}
示例11: it_generates_migration_when_no_errors
/** @test */
public function it_generates_migration_when_no_errors()
{
$app = m::mock(Application::class);
$command = m::mock(ModuleMakeMigration::class)->makePartial()->shouldAllowMockingProtectedMethods();
$command->setLaravel($app);
$command->shouldReceive('verifyConfigExistence')->once()->andReturn(null);
$tableName = 'sample table';
$userMigrationName = 'sample name';
$migrationType = 'sample type';
$moduleName = 'ModuleA';
$command->shouldReceive('proceed')->once()->withNoArgs()->passthru();
$command->shouldReceive('argument')->once()->with('module')->andReturn($moduleName);
$command->shouldReceive('argument')->once()->with('name')->once()->andReturn($userMigrationName);
$command->shouldReceive('option')->once()->with('type')->once()->andReturn($migrationType);
$command->shouldReceive('option')->once()->with('table')->once()->andReturn($tableName);
$moduleAMock = m::mock(Module::class);
$moduleAMock->shouldReceive('name')->once()->withNoArgs()->andReturn($moduleName);
$moduleAMock->shouldReceive('foo')->andReturn('bar');
$modules = collect([$moduleAMock]);
$command->shouldReceive('verifyExisting')->once()->with(m::on(function ($arg) use($moduleAMock, $moduleName) {
return $arg->first() == $moduleName;
}))->andReturn($modules);
$command->shouldReceive('createMigrationFile')->once()->with(m::on(function ($arg) use($moduleName) {
return $arg instanceof Module && $arg->foo() == 'bar';
}), $userMigrationName, $migrationType, $tableName)->passthru();
$stubGroupName = 'sample stub group';
$migrationStubFileName = 'sample stub file';
$migrationsPath = 'db/migrations';
$command->shouldReceive('getStubGroup')->once()->andReturn($stubGroupName);
$config = m::mock(Config::class);
$app->shouldReceive('offsetGet')->once()->with('modular.config')->andReturn($config);
$config->shouldNotReceive('migrationDefaultType');
$config->shouldReceive('migrationStubFileName')->once()->with($migrationType)->andReturn($migrationStubFileName);
$now = Carbon::now();
$expectedMigrationFileNames = [$now->format('Y_m_d_His') . '_' . snake_case($userMigrationName) . '.php', with(clone $now)->subSecond(1)->format('Y_m_d_His') . '_' . snake_case($userMigrationName) . '.php', with(clone $now)->addSecond(1)->format('Y_m_d_His') . '_' . snake_case($userMigrationName) . '.php'];
$fullMigrationName = m::anyOf($migrationsPath . DIRECTORY_SEPARATOR . $expectedMigrationFileNames[0], $migrationsPath . DIRECTORY_SEPARATOR . $expectedMigrationFileNames[1], $migrationsPath . DIRECTORY_SEPARATOR . $expectedMigrationFileNames[2]);
$command->shouldReceive('getMigrationFileName')->once()->with($userMigrationName)->passthru();
$migrationClass = studly_case($userMigrationName);
$moduleAMock->shouldReceive('migrationsPath')->once()->with(true)->andReturn($migrationsPath);
$command->shouldReceive('copyStubFileIntoModule')->once()->with($moduleAMock, $migrationStubFileName, $stubGroupName, $fullMigrationName, ['migrationClass' => $migrationClass, 'table' => $tableName]);
$expectedInfo = m::anyOf('[Module ' . $moduleName . '] Created migration file: ' . $expectedMigrationFileNames[0], '[Module ' . $moduleName . '] Created migration file: ' . $expectedMigrationFileNames[1], '[Module ' . $moduleName . '] Created migration file: ' . $expectedMigrationFileNames[2]);
$command->shouldReceive('info')->once()->with($expectedInfo);
$command->handle();
}
示例12: testRouteNeedsRoleOrPermission
public function testRouteNeedsRoleOrPermission()
{
/*
|------------------------------------------------------------
| Set
|------------------------------------------------------------
*/
$app = new stdClass();
$app->router = m::mock('Route');
$entrust = new Entrust($app);
$route = 'route';
$oneRole = 'RoleA';
$manyRole = ['RoleA', 'RoleB', 'RoleC'];
$onePerm = 'can_a';
$manyPerm = ['can_a', 'can_b', 'can_c'];
$oneRoleOnePermFilterName = $this->makeFilterName($route, [$oneRole], [$onePerm]);
$oneRoleManyPermFilterName = $this->makeFilterName($route, [$oneRole], $manyPerm);
$manyRoleOnePermFilterName = $this->makeFilterName($route, $manyRole, [$onePerm]);
$manyRoleManyPermFilterName = $this->makeFilterName($route, $manyRole, $manyPerm);
/*
|------------------------------------------------------------
| Expectation
|------------------------------------------------------------
*/
$app->router->shouldReceive('filter')->with(m::anyOf($oneRoleOnePermFilterName, $oneRoleManyPermFilterName, $manyRoleOnePermFilterName, $manyRoleManyPermFilterName), m::type('Closure'))->times(4)->ordered();
$app->router->shouldReceive('when')->with($route, m::anyOf($oneRoleOnePermFilterName, $oneRoleManyPermFilterName, $manyRoleOnePermFilterName, $manyRoleManyPermFilterName))->times(4);
/*
|------------------------------------------------------------
| Assertion
|------------------------------------------------------------
*/
$entrust->routeNeedsRoleOrPermission($route, $oneRole, $onePerm);
$entrust->routeNeedsRoleOrPermission($route, $oneRole, $manyPerm);
$entrust->routeNeedsRoleOrPermission($route, $manyRole, $onePerm);
$entrust->routeNeedsRoleOrPermission($route, $manyRole, $manyPerm);
}
示例13: testAnyOfConstraintThrowsExceptionWhenConstraintUnmatched
/**
* @expectedException \Mockery\Exception
*/
public function testAnyOfConstraintThrowsExceptionWhenConstraintUnmatched()
{
$this->mock->shouldReceive('foo')->with(Mockery::anyOf(1, 2))->once();
$this->mock->foo(3);
$this->container->mockery_verify();
}
示例14: testCreateAgentStatus
public function testCreateAgentStatus()
{
$successfulAgents = array(array('agent_id' => $this->agentId, 'agent_rev' => 'a0815', 'agent_name' => $this->agentName));
$this->agentDaoMock->shouldReceive('getSuccessfulAgentEntries')->with($this->agentName, $this->uploadId)->andReturn($successfulAgents);
$this->agentDaoMock->shouldReceive('getRunningAgentIds')->never();
$this->agentDaoMock->shouldReceive('getCurrentAgentRef')->with($this->agentName)->andReturn(new AgentRef($this->agentId, $this->agentName, 'a0815'));
$fakedAgentName = 'ghost';
$this->agentDaoMock->shouldReceive('arsTableExists')->with(M::anyOf($this->agentName, $fakedAgentName))->andReturn(true, false)->twice();
$vars = $this->scanJobProxy->createAgentStatus(array($this->agentName, $fakedAgentName));
assertThat($vars, is(array(array('successfulAgents' => $successfulAgents, 'uploadId' => $this->uploadId, 'agentName' => $this->agentName, 'currentAgentId' => $this->agentId, 'currentAgentRev' => 'a0815'))));
}
示例15: testWriteSqlFile
/**
* @param $path
* @param $to
* @param $getSqlReturn
*
* @dataProvider writeSqlFileProvider
*/
public function testWriteSqlFile($path, $direction, $getSqlReturn)
{
$version = 1;
$outputWriter = m::mock('Doctrine\\DBAL\\Migrations\\OutputWriter');
$outputWriter->shouldReceive('write');
$connection = m::mock('Doctrine\\DBAL\\Connection');
$connection->shouldReceive(array('getSchemaManager' => 'something', 'getDatabasePlatform' => 'something else'));
$config = m::mock('Doctrine\\DBAL\\Migrations\\Configuration\\Configuration')->makePartial();
$config->shouldReceive('getOutputWriter')->andReturn($outputWriter);
$config->shouldReceive('getConnection')->andReturn($connection);
$migration = m::mock('Doctrine\\DBAL\\Migrations\\Version[execute]', array($config, $version, 'stdClass'))->makePartial();
$migration->shouldReceive('execute')->with($direction, true)->andReturn($getSqlReturn);
$expectedReturn = 123;
$sqlWriter = m::instanceMock('overload:Doctrine\\DBAL\\Migrations\\SqlFileWriter');
$sqlWriter->shouldReceive('write')->with(m::type('array'), m::anyOf('up', 'down'))->andReturn($expectedReturn);
$result = $migration->writeSqlFile($path, $direction);
$this->assertEquals($expectedReturn, $result);
}