コード例 #1
0
 public function testNoFirewall()
 {
     $this->tokenStorage->shouldReceive('getToken')->andReturnNull();
     $this->authorizationChecker->shouldNotReceive('isGranted');
     $this->accessDecisionManager->shouldReceive('decide')->once()->with(\Mockery::type('Symfony\\Component\\Security\\Core\\Authentication\\Token\\AnonymousToken'), array(PublishWorkflowChecker::VIEW_ATTRIBUTE), $this->document)->andReturn(true);
     $this->assertTrue($this->publishWorkflowChecker->isGranted(PublishWorkflowChecker::VIEW_ATTRIBUTE, $this->document));
 }
コード例 #2
0
ファイル: ConsoleWriterTest.php プロジェクト: aedart/scaffold
 /**
  * @test
  *
  * @dataProvider logDataProvider
  *
  * @covers ::log
  *
  * @covers ::interpolate
  *
  * @param string $level
  * @param string $message
  * @param array $context [optional]
  */
 public function canWriteToOutput($level, $message, array $context = [])
 {
     $output = $this->makeOutputMock();
     $output->shouldReceive('writeln')->once()->with(m::type('string'));
     $writer = $this->makeConsoleWriter($output);
     $writer->log($level, $message, $context);
 }
コード例 #3
0
 public function testMakePassingConfig()
 {
     $config = ['Reports' => ['permissions' => ['isStaff'], 'url' => 'reports']];
     $menu = m::mock('App\\Http\\Composers\\NavMenuComposer[build,filter]', [$this->app['menu'], $this->config, $this->auth, $this->gate]);
     $menu->shouldReceive('build')->once()->with($config, m::type('Caffeinated\\Menus\\Builder'));
     $menu->make('Profile', $config);
 }
コード例 #4
0
 /**
  * @test
  * @covers ::commit
  * @covers ::push
  */
 public function it_should_write_events_to_eventstore_on_flush()
 {
     $expectedEvents = [new WritableEvent(new UUID(), '123', [])];
     $this->eventstore->shouldReceive('writeToStream')->once()->with('streamUri', m::type(WritableEventCollection::class));
     $this->transaction->push('streamUri', $expectedEvents);
     $this->transaction->commit();
 }
 public function testSend()
 {
     $user = m::mock();
     $user->shouldReceive('getActivationCode')->once()->andReturn('secretC0d3');
     Mail::shouldReceive('queue')->once()->with(m::type('array'), array('user' => $user, 'code' => 'secretC0d3'), m::type('closure'));
     $this->activation->send($user);
 }
コード例 #6
0
ファイル: MigratorTest.php プロジェクト: singularity321/Arty
 public function testUpMigrationCanBePretended()
 {
     list($migrator, $repository, $filesystem, $resolver) = $this->getMocks();
     $filesystem->shouldReceive('glob')->once()->with(__DIR__ . '/*_*.php')->andReturn(array(__DIR__ . '/2_bar.php', __DIR__ . '/1_foo.php', __DIR__ . '/3_baz.php'));
     $filesystem->shouldReceive('requireOnce')->with(__DIR__ . '/2_bar.php');
     $filesystem->shouldReceive('requireOnce')->with(__DIR__ . '/1_foo.php');
     $filesystem->shouldReceive('requireOnce')->with(__DIR__ . '/3_baz.php');
     $repository->shouldReceive('getRan')->once()->andReturn(array('1_foo'));
     $repository->shouldReceive('getNextBatchNumber')->once()->andReturn(1);
     $barMock = M::mock('stdClass');
     $barMock->shouldReceive('getConnection')->once()->andReturn(null);
     $barMock->shouldReceive('up')->once();
     $bazMock = M::mock('stdClass');
     $bazMock->shouldReceive('getConnection')->once()->andReturn(null);
     $bazMock->shouldReceive('up')->once();
     $migrator->expects($this->at(0))->method('resolve')->with($this->equalTo('2_bar'))->will($this->returnValue($barMock));
     $migrator->expects($this->at(1))->method('resolve')->with($this->equalTo('3_baz'))->will($this->returnValue($bazMock));
     $connection = M::mock('stdClass');
     $connection->shouldReceive('pretend')->with(M::type('Closure'))->andReturnUsing(function ($closure) {
         $closure();
         return array(array('query' => 'foo'));
     }, function ($closure) {
         $closure();
         return array(array('query' => 'bar'));
     });
     $resolver->shouldReceive('connection')->with(null)->andReturn($connection);
     $migrator->run(__DIR__, true);
 }
コード例 #7
0
 public function testCompilerPassesAreRegistered()
 {
     $container = m::mock('Symfony\\Component\\DependencyInjection\\ContainerBuilder');
     $container->shouldReceive('addCompilerPass')->once()->with(m::type('Dpn\\XmlSitemapBundle\\DependencyInjection\\Compiler\\GeneratorCompilerPass'));
     $bundle = new DpnXmlSitemapBundle();
     $bundle->build($container);
 }
コード例 #8
0
 public function testAddFilterFromValidator()
 {
     $router = m::mock('Illuminate\\Routing\\Router');
     $router->shouldReceive('addFilter')->once()->with('validator.login', m::type('Closure'));
     $factory = new Factory($this->request, m::mock('Illuminate\\Validation\\Factory'), $router);
     $factory->add('login', 'ValidatorStub2');
 }
コード例 #9
0
ファイル: AppTest.php プロジェクト: jenssegers/lean
 public function testLoadsServiceProvider()
 {
     $container = Mockery::mock('League\\Container\\Container');
     $container->shouldReceive('delegate')->once();
     $container->shouldReceive('addServiceProvider')->once()->with(Mockery::type('Jenssegers\\Lean\\SlimServiceProvider'));
     $app = new App($container);
 }
コード例 #10
0
 public function testDestroySuccessReturnsOkResponse()
 {
     $this->mockService->shouldReceive('remove')->once()->with(m::type('integer'))->andReturn(true);
     $this->mockResponse->shouldReceive('create')->once()->with(m::type('array'))->andReturn($this->mockResponse);
     $response = $this->controller->destroy(1000);
     $this->assertInstanceOf('Illuminate\\Http\\JsonResponse', $response);
 }
コード例 #11
0
 /**
  * A basic test example.
  *
  * @return void
  */
 public function testHandle()
 {
     // $this->expectsEvents(App\Events\ActionCreatedEvent::class, App\Events\TicketCreatedEvent::class);
     // $fetch = m::mock('App\Jobs\FetchEmailJob[getServer,getMessages,anonymousUser,createTicket,buildActions,processEmail]', [$this->email]);
     $piper = m::mock('App\\Services\\Piper\\Piper');
     $piper->shouldReceive('fetch')->once()->with(m::type('App\\Email'));
     $fetch = new FetchEmailJob($this->email);
     $fetch->handle($piper);
     // $messages = [m::mock('Fetch\Message'), m::mock('Fetch\Message'), m::mock('Fetch\Message')];
     // $server = m::mock();
     // $server->shouldReceive('getMessages')->once()->andReturn($messages);
     // $server->shouldReceive('getServerString')->once();
     // $server->shouldReceive('numMessages')->once();
     // Log::shouldReceive('debug')->once();
     // $fetch->shouldReceive('getServer')->once()->andReturn($server);
     // $fetch->shouldReceive('anonymousUser')->times(3)->andReturn(collect());
     // // $fetch->shouldReceive('getAssigned')->times(3)->andReturn(collect());
     // $fetch->shouldReceive('createTicket')->times(3)->andReturn(collect(['ticket' => m::mock('App\Ticket')]), collect());
     // $fetch->shouldReceive('buildActions')->times(3)->andReturn(collect());
     // $fetch->shouldReceive('processEmail')->times(3);
     // $parser = m::mock('App\Services\EmailParser');
     // $parser->shouldReceive('parse')->times(3)->andReturn(collect());
     // $user = m::mock('App\Contracts\Repositories\UserInterface');
     // $fetch->handle($parser, $user);
 }
コード例 #12
0
 public function testRollbackCommandCanBePretended()
 {
     $command = new RollbackCommand($migrator = m::mock('Illuminate\\Database\\Migrations\\Migrator'));
     $migrator->shouldReceive('setConnection')->once()->with('foo');
     $migrator->shouldReceive('rollback')->once()->with(m::type('Symfony\\Component\\Console\\Output\\OutputInterface'), true);
     $this->runCommand($command, array('--pretend' => true, '--database' => 'foo'));
 }
コード例 #13
0
 /**
  *  Tests if the createArticle method
  * on the repo is called.
  **/
 public function testServiceCreateNewArticleCreateArticleRepoCalled()
 {
     $fakeArticle = m::mock('Eloquent', 'App\\Models\\Article');
     $articleTitle = 'testing title';
     $this->fakeRepo->shouldReceive('createArticle')->once()->with(m::type('App\\Models\\User'), $articleTitle)->andReturn($fakeArticle);
     $this->service->createNewArticle($this->getMockUser(), $articleTitle);
 }
コード例 #14
0
 public function testSetsHttpClient()
 {
     $serviceFactory = Mockery::mock('OAuth\\ServiceFactory');
     $serviceFactory->shouldReceive('setHttpClient')->with(Mockery::type('OAuth\\Common\\Http\\Client\\CurlClient'))->times(1);
     $oauth = new OAuth($serviceFactory, new Memory());
     $oauth->setHttpClient('CurlClient');
 }
 public function testFireWithEmptyHostsArrayCallsError()
 {
     list($arguments, $options) = $this->createArgumentsAndOptions();
     $this->setMockAwsExpectations($arguments, array());
     $this->mockCommand->shouldReceive('error')->with(m::type('string'))->once();
     $this->controller->fire($arguments, $options);
 }
 public function testSend()
 {
     $user = m::mock();
     $user->shouldReceive('getResetPasswordCode')->once()->andReturn('123456789');
     Mail::shouldReceive('queue')->once()->with(m::type('array'), array('user' => $user, 'code' => '123456789'), m::type('closure'));
     $this->reset->send($user);
 }
コード例 #17
0
 public function testFireWithNullHostCallsError()
 {
     list($arguments, $options) = $this->createArgumentsAndOptions();
     $this->mockAws->shouldReceive('getPublicDNSFromInstanceId')->with(array_get($arguments, CommandRules::INSTANCE_ID))->andReturnNull()->once();
     $this->mockCommand->shouldReceive('error')->with(m::type('string'))->once();
     $this->controller->fire($arguments, $options);
 }
コード例 #18
0
ファイル: PusherAuthTest.php プロジェクト: jahvi/chatty
 /**
  * Test that a user can subscribe to a pusher channel
  *
  * @return void
  */
 public function testCanSubscribeMemberToPusherChannel()
 {
     $this->request->shouldReceive('input')->times(3)->andReturn('foo');
     $this->pusher->shouldReceive('presence_auth')->once()->with('foo', 'foo', m::type('string'), ['username' => 'foo']);
     $this->call('POST', 'pusher/auth');
     $this->assertResponseOk();
 }
コード例 #19
0
ファイル: HeaderBagTests.php プロジェクト: hardwork2015/cdp
 public function testRemove()
 {
     $phpunit = $this;
     $request = m::mock('jyggen\\Curl\\RequestInterface');
     $headerbag = new HeaderBag(array(), $request);
     $request->shouldReceive('setOption')->times(1)->with(m::mustBe(CURLOPT_HTTPHEADER), m::type('array'));
     $headerbag->remove('foo');
 }
コード例 #20
0
ファイル: LdapTest.php プロジェクト: folkevil/BookStack
 public function test_initial_incorrect_details()
 {
     $this->mockLdap->shouldReceive('connect')->once()->andReturn($this->resourceId);
     $this->mockLdap->shouldReceive('setOption')->once();
     $this->mockLdap->shouldReceive('searchAndGetEntries')->times(2)->with($this->resourceId, config('services.ldap.base_dn'), Mockery::type('string'), Mockery::type('array'))->andReturn(['count' => 1, 0 => ['uid' => [$this->mockUser->name], 'cn' => [$this->mockUser->name], 'dn' => ['dc=test' . config('services.ldap.base_dn')]]]);
     $this->mockLdap->shouldReceive('bind')->times(3)->andReturn(true, true, false);
     $this->visit('/login')->see('Username')->type($this->mockUser->name, '#username')->type($this->mockUser->password, '#password')->press('Sign In')->seePageIs('/login')->see('These credentials do not match our records.')->dontSeeInDatabase('users', ['external_auth_id' => $this->mockUser->name]);
 }
コード例 #21
0
 public function testServiceProviderIsWorking()
 {
     $appMock = m::mock('Illuminate\\Foundation\\Application');
     $appMock->shouldReceive('singleton')->with('apiconsumer', m::type('Closure'));
     $provider = $this->app->make('Optimus\\ApiConsumer\\Provider\\LaravelServiceProvider', [$appMock]);
     $this->assertNull($provider->register());
     $provider->boot();
 }
コード例 #22
0
 /**
  * @test
  */
 public function itEnrichesMetadataWhenEventsAreCommittedBeforePassingThemToTheNextEventStore()
 {
     $id = AggregateId::fromString('some-id');
     $eventStream = $this->createEventStream($id);
     $this->messageRecorder->shouldReceive('record')->times(3)->with(\Mockery::type('SimpleBus\\Message\\Message'));
     $this->nextEventStore->shouldReceive('commit')->once()->with($eventStream);
     $this->eventStore->commit($eventStream);
 }
コード例 #23
0
ファイル: ExecutorTest.php プロジェクト: sayiho/Jumper
 /**
  * @test
  * @expectedException \Jumper\Exception\ExecutorException
  * @expectedExceptionMessage An error occurs when execution php on target host with the following message: Runtime message error
  */
 public function remotePhpErrorShouldThrowExecutorException()
 {
     $this->communicator->shouldReceive('isConnected')->withNoArgs()->andReturn(true)->once()->ordered();
     $this->communicator->shouldReceive('run')->with(m::type('string'))->andThrow('\\RuntimeException', 'Runtime message error')->once()->ordered();
     $this->stringifier->shouldReceive('getSerializeFunctionName')->withNoArgs()->once()->ordered();
     $this->executor->run(function () {
     });
 }
コード例 #24
0
 public function testReadSingleReturnsModelObject()
 {
     $this->repoModel->shouldReceive('where')->once()->with('id', $this->modelId)->andReturn($this->mockCollection);
     $this->mockCollection->shouldReceive('with')->once()->with(m::type('array'))->andReturn($this->mockCollection);
     $this->mockCollection->shouldReceive('first')->once()->andReturn($this->mockModel);
     $model = $this->repo->readSingle($this->modelId);
     $this->assertInstanceOf('Illuminate\\Database\\Eloquent\\Model', $model);
 }
コード例 #25
0
 public function testCreatesConcatStubs()
 {
     $this->config->shouldReceive('get')->once()->with('simple-guardbuilder::pipelines')->andReturn($this->testPipelines);
     $this->file->shouldReceive('get')->once()->with(m::type('string'))->andReturn($this->concatStub);
     $stub = $this->builder->getConcatStubs();
     $this->fs->put(__DIR__ . '/test.stub', $stub);
     $this->assertEquals($this->resultConcatStub, $stub);
 }
コード例 #26
0
 /**
  * Asserts if the createEdition
  * is called in the fakeRepo.
  **/
 public function testServiceCreateEditionCreateEditionCalled()
 {
     $fakeEdition = m::mock('Eloquent', 'App\\Models\\Edition');
     $articleID = 1;
     $testContent = 'testing content';
     $this->fakeRepo->shouldReceive('createEdition')->once()->with($articleID, $testContent, m::type('App\\Models\\User'))->andReturn($fakeEdition);
     $this->service->createEdition($articleID, 'testing content', $this->getMockUser());
 }
コード例 #27
0
 /** @test */
 public function it_should_work_just_fine_when_given_valid_dsn()
 {
     $app = $this->trainApplicationWithDatabaseConfig('mysql:dbname=cfp_travis;host=127.0.0.1', 'root', null);
     // Set expectation that database should be registered in the container.
     // $app['db'] = new PDO(...)
     $app->shouldReceive('offsetSet')->with('db', m::type('PDO'));
     $this->sut->register($app);
 }
コード例 #28
0
ファイル: WriterTest.php プロジェクト: viserio/log
 public function testRotatingFileHandlerCanBeAdded()
 {
     $monolog = $this->mock(Logger::class);
     $monolog->shouldReceive('pushHandler')->once()->with(Mock::type(RotatingFileHandler::class));
     $monolog->shouldReceive('pushProcessor')->once();
     $writer = new Writer($monolog);
     $writer->setEventsDispatcher($this->getEventsDispatcher());
     $writer->useDailyFiles(__DIR__, 5);
 }
コード例 #29
0
 public function testRenderSitemap()
 {
     $templating = m::mock('Symfony\\Component\\Templating\\EngineInterface');
     $templating->shouldReceive('render')->twice()->with('DpnXmlSitemapBundle::sitemap.xml.twig', m::type('array'))->andReturn('rendered template');
     $manager = new SitemapManager(array(), 1, $templating);
     $manager->addGenerator(new TestGenerator(2));
     $this->assertSame('rendered template', $manager->renderSitemap());
     $this->assertSame('rendered template', $manager->renderSitemap(2));
 }
コード例 #30
0
ファイル: CommandsTest.php プロジェクト: sschlein/captainhook
 public function testCanDeleteWebhook()
 {
     $webhook = \Mpociot\CaptainHook\Webhook::create(["url" => "http://foo.baz", "event" => "DeleteWebhook"]);
     $cmd = m::mock("\\Mpociot\\CaptainHook\\Commands\\DeleteWebhook[argument,info]");
     $cmd->shouldReceive("argument")->with("id")->andReturn($webhook->getKey());
     $cmd->shouldReceive("info")->with(m::type("string"));
     $cmd->handle();
     $this->notSeeInDatabase("webhooks", ["url" => "http://foo.baz", "event" => "DeleteWebhook"]);
 }