/**
  * @param string   $notation
  * @param string   $returnType
  * @param string   $name
  * @param string[] $arguments
  * @param string   $description
  *
  * @dataProvider provideNotations
  * @covers phpDocumentor\Descriptor\Builder\Reflector\Tags\MethodAssembler::create
  * @covers phpDocumentor\Descriptor\Builder\Reflector\Tags\MethodAssembler::createArgumentDescriptorForMagicMethod
  */
 public function testCreateMethodDescriptorFromVariousNotations($notation, $returnType, $name, $arguments = array(), $description = '')
 {
     $this->builder->shouldReceive('buildDescriptor')->with(m::on(function (TypeCollection $value) use($returnType) {
         return $value[0] == $returnType;
     }))->andReturn(new Collection(array($returnType)));
     foreach ($arguments as $argument) {
         list($argumentType, $argumentName, $argumentDefault) = $argument;
         $this->builder->shouldReceive('buildDescriptor')->with(m::on(function (TypeCollection $value) use($argumentType) {
             return $value[0] == $argumentType;
         }))->andReturn(new Collection(array($argumentType)));
     }
     $tag = new MethodTag('method', $notation);
     $descriptor = $this->fixture->create($tag);
     $this->assertSame(1, $descriptor->getResponse()->getTypes()->count());
     $this->assertSame($returnType, $descriptor->getResponse()->getTypes()->get(0));
     $this->assertSame($name, $descriptor->getMethodName());
     $this->assertSame($description, $descriptor->getDescription());
     $this->assertSame(count($arguments), $descriptor->getArguments()->count());
     foreach ($arguments as $argument) {
         list($argumentType, $argumentName, $argumentDefault) = $argument;
         $this->assertSame($argumentType, $descriptor->getArguments()->get($argumentName)->getTypes()->get(0));
         $this->assertSame($argumentName, $descriptor->getArguments()->get($argumentName)->getName());
         $this->assertSame($argumentDefault, $descriptor->getArguments()->get($argumentName)->getDefault());
     }
 }
示例#2
0
 public function testSend()
 {
     $mockException = \Mockery::mock('\\ErrorException');
     $mockRequest = \Mockery::mock('\\Symfony\\Component\\HttpFoundation\\Request');
     $mockContainer = \Mockery::mock('\\Symfony\\Component\\DependencyInjection\\ContainerInterface');
     $mockTemplating = \Mockery::mock('Symfony\\Component\\Templating\\EngineInterface');
     $mockEd = \Mockery::mock('\\Symfony\\Component\\EventDispatcher\\EventDispatcherInterface');
     $mockMailer = \Mockery::mock('\\Swift_Mailer');
     $mockTransport = \Mockery::mock('\\Swift_Transport');
     $mockSpool = \Mockery::mock('\\Swift_Transport_SpoolTransport');
     $mockMemSpool = \Mockery::mock('\\Swift_MemorySpool');
     $mockHeaders = \Mockery::mock('\\Symfony\\Component\\DependencyInjection\\ParameterBag\\ParameterBagInterface');
     $mockHeaders->shouldReceive('get')->once()->with('host')->andReturn('xyz');
     $mockEd->shouldReceive('dispatch')->once()->with('ehough.bundle.emailErrors.preMail', \Mockery::on(function ($event) {
         return $event instanceof GenericEvent && is_array($event->getSubject()) && $event->getArgument('shouldSend') === true;
     }));
     $mockRequest->headers = $mockHeaders;
     $mockContainer->shouldReceive('get')->once()->with('templating')->andReturn($mockTemplating);
     $mockContainer->shouldReceive('get')->once()->with('mailer')->andReturn($mockMailer);
     $mockContainer->shouldReceive('get')->once()->with('swiftmailer.transport.real')->andReturn($mockTransport);
     $mockContainer->shouldReceive('get')->once()->with('event_dispatcher')->andReturn($mockEd);
     $context = array('foo' => 'bar');
     $mockTemplating->shouldReceive('render')->once()->with('EhoughEmailErrorsBundle::mail.html.twig', \Mockery::on(function ($arg) {
         return is_array($arg) && $arg['exception'] instanceof \Symfony\Component\Debug\Exception\FlattenException && $arg['request'] instanceof Request && is_array($arg['context']);
     }))->andReturn('foobar');
     $this->_sut->setContainer($mockContainer);
     $mockMailer->shouldReceive('send')->once()->with(\Mockery::on(function ($arg) {
         return $arg instanceof \Swift_Message && $arg->getSubject() === '[xyz] Error 500: ' && $arg->getBody() === 'foobar';
     }));
     $mockMailer->shouldReceive('getTransport')->once()->andReturn($mockSpool);
     $mockSpool->shouldReceive('getSpool')->once()->andReturn($mockMemSpool);
     $mockMemSpool->shouldReceive('flushQueue')->once()->with($mockTransport);
     $this->_sut->sendMail($mockException, $mockRequest, $context, true);
 }
 public function test_process_upsertEventsGetCalled()
 {
     $mockPdoFacade = \Mockery::mock('\\TestDbAcle\\Db\\Mysql\\Pdo\\PdoFacade');
     $dataTree = new \TestDbAcle\Psv\PsvTree();
     $dataTree->addTable(new \TestDbAcle\Psv\Table\Table('user', array(array("user_id" => "10", "first_name" => "john", "last_name" => "miller"), array("user_id" => "20", "first_name" => "stu", "last_name" => "Smith"))));
     $self = $this;
     // we need to pass this in for PHP version<5.4
     $checkUpserterClosure = function ($upserter) use($self) {
         $self->assertTrue($upserter instanceof \TestDbAcle\Db\DataInserter\Sql\InsertBuilder);
         $self->assertEquals('user', $upserter->getTableName());
         return true;
     };
     $testListener1 = \Mockery::mock('\\TestDbAcle\\Db\\DataInserter\\UpsertListenerInterface');
     $testListener2 = \Mockery::mock('\\TestDbAcle\\Db\\DataInserter\\UpsertListenerInterface');
     $mockPdoFacade->shouldReceive('clearTable')->once()->with('user')->ordered();
     $mockPdoFacade->shouldReceive('executeSql')->once()->with("INSERT INTO `user` ( `user_id`, `first_name`, `last_name` ) VALUES ( '10', 'john', 'miller' )")->ordered();
     $testListener1->shouldReceive('afterUpsert')->once()->with(\Mockery::on($checkUpserterClosure));
     $testListener2->shouldReceive('afterUpsert')->once()->with(\Mockery::on($checkUpserterClosure));
     $mockPdoFacade->shouldReceive('executeSql')->once()->with("INSERT INTO `user` ( `user_id`, `first_name`, `last_name` ) VALUES ( '20', 'stu', 'Smith' )")->ordered();
     $testListener1->shouldReceive('afterUpsert')->once()->with(\Mockery::on($checkUpserterClosure));
     $testListener2->shouldReceive('afterUpsert')->once()->with(\Mockery::on($checkUpserterClosure));
     $dataInserter = new \TestDbAcle\Db\DataInserter\DataInserter($mockPdoFacade, new \TestDbAcle\Db\DataInserter\Factory\UpsertBuilderFactory($mockPdoFacade));
     $dataInserter->addUpsertListener($testListener1);
     $dataInserter->addUpsertListener($testListener2);
     $dataInserter->process($dataTree);
 }
 /**
  * Will return a table model after converting index and field models from persistence to domain.
  *
  * @runInSeparateProcess
  * @preserveGlobalState disabled
  */
 public function testWillReturnATableModelAfterConvertingIndexAndFieldModelsFromPersistenceToDomain()
 {
     /** @var \Mockery\MockInterface|SchemaMapper $mapper */
     $mapper = \Mockery::mock('\\DatabaseInspect\\Domain\\Mappers\\SchemaMapper')->makePartial();
     // define input
     $tableName = 'table_1';
     $fieldEntries = [\Mockery::mock(TableField::class), \Mockery::mock(TableField::class), \Mockery::mock(TableField::class)];
     $indexEntries = [\Mockery::mock(TableIndex::class), \Mockery::mock(TableIndex::class)];
     // define internal DTO -> Domain model translators
     $indexCollection = \Mockery::mock(TableIndexCollection::class);
     $fieldCollection = \Mockery::mock(TableFieldCollection::class);
     $mapper->shouldReceive('buildTableFieldCollectionFromPersistence')->once()->with($fieldEntries)->andReturn($fieldCollection);
     $mapper->shouldReceive('buildTableIndexCollectionFromPersistence')->once()->with($indexEntries)->andReturn($indexCollection);
     // define static Table build asserts and expectation
     $buildOutput = \Mockery::mock(Table::class);
     $closureCheckTableNamePassedToTableBuild = \Mockery::on(function (StringLiteral $tableName) {
         return $tableName->toNative() === 'table_1';
     });
     $request = \Mockery::mock('overload:DatabaseInspect\\Domain\\Models\\Table');
     $request->shouldReceive('build')->once()->with($closureCheckTableNamePassedToTableBuild, $fieldCollection, $indexCollection)->andReturn($buildOutput);
     // perform action
     /** @var Table $output */
     $response = $mapper->buildTableFromPersistence($tableName, $fieldEntries, $indexEntries);
     // assert expectation
     static::assertSame($buildOutput, $response);
 }
 public function testCanSendNormalRequest()
 {
     $this->streamMock->shouldReceive('streamContextCreate')->once()->with(m::on(function ($arg) {
         if (!isset($arg['http']) || !isset($arg['ssl'])) {
             return false;
         }
         if ($arg['http'] !== ['method' => 'GET', 'timeout' => 60, 'ignore_errors' => true, 'header' => 'X-foo: bar']) {
             return false;
         }
         $caInfo = array_diff_assoc($arg['ssl'], ['verify_peer' => true, 'verify_peer_name' => true, 'allow_self_signed' => true]);
         if (count($caInfo) !== 1) {
             return false;
         }
         if (1 !== preg_match('/.+\\/certs\\/DigiCertHighAssuranceEVRootCA\\.pem$/', $caInfo['cafile'])) {
             return false;
         }
         return true;
     }))->andReturn(null);
     $this->streamMock->shouldReceive('getResponseHeaders')->once()->andReturn(explode("\n", trim($this->fakeRawHeader)));
     $this->streamMock->shouldReceive('fileGetContents')->once()->with('http://foo.com/')->andReturn($this->fakeRawBody);
     $this->streamClient->addRequestHeader('X-foo', 'bar');
     $responseBody = $this->streamClient->send('http://foo.com/');
     $this->assertEquals($responseBody, $this->fakeRawBody);
     $this->assertEquals($this->streamClient->getResponseHeaders(), $this->fakeHeadersAsArray);
     $this->assertEquals(200, $this->streamClient->getResponseHttpStatusCode());
 }
 protected function verifyCorrectLoadingRoutesForType($type)
 {
     $basePath = 'base/path';
     $moduleARoutePrefix = 'sample-prefix-module-a';
     $moduleBRoutePrefix = 'sample-prefix-module-b';
     $moduleARouteFile = 'moduleA/routes.php';
     $moduleBRouteFile = 'moduleB/routes.php';
     $router = m::mock(Router::class);
     $moduleA = m::mock(stdClass::class);
     $moduleB = m::mock(stdClass::class);
     $moduleA->shouldReceive('routingControllerNamespace')->once()->withNoArgs()->andReturn('moduleAControllerNamespace');
     $moduleB->shouldReceive('routingControllerNamespace')->once()->withNoArgs()->andReturn('moduleBControllerNamespace');
     $this->modular->shouldReceive('withRoutes')->once()->andReturn(collect([$moduleA, $moduleB]));
     $router->shouldReceive('group')->once()->with(['namespace' => 'moduleAControllerNamespace'], m::on(function ($closure) use($router) {
         call_user_func($closure, $router);
         return true;
     }));
     $this->app->shouldReceive('basePath')->times(2)->andReturn($basePath);
     $moduleA->shouldReceive('routePrefix')->once()->with(compact('type'))->andReturn($moduleARoutePrefix);
     $moduleA->shouldReceive('routesFilePath')->once()->with($moduleARoutePrefix)->andReturn($moduleARouteFile);
     $file = m::mock(stdClass::class);
     $this->app->shouldReceive('offsetGet')->times(2)->with('files')->andReturn($file);
     $file->shouldReceive('getRequire')->once()->with($basePath . DIRECTORY_SEPARATOR . $moduleARouteFile);
     $router->shouldReceive('group')->once()->with(['namespace' => 'moduleBControllerNamespace'], m::on(function ($closure) use($router) {
         call_user_func($closure, $router);
         return true;
     }));
     $moduleB->shouldReceive('routePrefix')->once()->with(compact('type'))->andReturn($moduleBRoutePrefix);
     $moduleB->shouldReceive('routesFilePath')->once()->with($moduleBRoutePrefix)->andReturn($moduleBRouteFile);
     $file->shouldReceive('getRequire')->once()->with($basePath . DIRECTORY_SEPARATOR . $moduleBRouteFile);
     $this->assertSame(null, $this->modular->loadRoutes($router, $type));
 }
 /**
  * @test
  */
 public function it_can_retry_a_message()
 {
     $id = 1234;
     $body = 'test';
     $routingKey = 'foo';
     $priority = 3;
     $headers = ['foo' => 'bar'];
     /** @var MockInterface|EnvelopeInterface $envelope */
     $envelope = Mock::mock(EnvelopeInterface::class);
     $envelope->shouldReceive('getDeliveryTag')->andReturn($id);
     $envelope->shouldReceive('getBody')->andReturn($body);
     $envelope->shouldReceive('getRoutingKey')->andReturn($routingKey);
     $envelope->shouldReceive('getPriority')->andReturn($priority);
     $envelope->shouldReceive('getHeaders')->andReturn($headers);
     $envelope->shouldReceive('getContentType')->andReturn(MessageProperties::CONTENT_TYPE_BASIC);
     $envelope->shouldReceive('getDeliveryMode')->andReturn(MessageProperties::DELIVERY_MODE_PERSISTENT);
     $attempt = 2;
     $publisher = $this->createPublisherMock();
     $publisher->shouldReceive('publish')->once()->with(Mock::on(function (Message $retryMessage) use($envelope, $attempt) {
         $this->assertSame($envelope->getDeliveryTag(), $retryMessage->getId(), 'Delivery tag of the retry-message is not the same');
         $this->assertSame($envelope->getBody(), $retryMessage->getBody(), 'Body of the retry-message is not the same');
         $this->assertSame($envelope->getRoutingKey(), $retryMessage->getRoutingKey(), 'Routing key of the retry-message is not the same');
         $this->assertArraySubset($envelope->getHeaders(), $retryMessage->getHeaders(), 'Headers are not properly cloned');
         $this->assertSame($retryMessage->getPriority(), $envelope->getPriority() - 1, 'Priority should decrease with 1');
         $this->assertSame($attempt, $retryMessage->getHeader(RetryProcessor::PROPERTY_KEY), 'There should be an "attempt" header in the retry message');
         return true;
     }))->andReturn(true);
     $strategy = new DeprioritizeStrategy($publisher);
     $result = $strategy->retry($envelope, $attempt);
     $this->assertTrue($result);
 }
 public function testCanSendNormalRequest()
 {
     $this->streamMock->shouldReceive('streamContextCreate')->once()->with(\Mockery::on(function ($arg) {
         if (!isset($arg['http']) || !isset($arg['ssl'])) {
             return false;
         }
         if ($arg['http'] !== array('method' => 'GET', 'timeout' => 60, 'ignore_errors' => true, 'header' => 'X-foo: bar')) {
             return false;
         }
         if ($arg['ssl']['verify_peer'] !== true) {
             return false;
         }
         if (false === preg_match('/.fb_ca_chain_bundle\\.crt$/', $arg['ssl']['cafile'])) {
             return false;
         }
         return true;
     }))->andReturn(null);
     $this->streamMock->shouldReceive('getResponseHeaders')->once()->andReturn(explode("\n", trim($this->fakeRawHeader)));
     $this->streamMock->shouldReceive('fileGetContents')->once()->with('http://foo.com/')->andReturn($this->fakeRawBody);
     $this->streamClient->addRequestHeader('X-foo', 'bar');
     $responseBody = $this->streamClient->send('http://foo.com/');
     $this->assertEquals($responseBody, $this->fakeRawBody);
     $this->assertEquals($this->streamClient->getResponseHeaders(), $this->fakeHeadersAsArray);
     $this->assertEquals(200, $this->streamClient->getResponseHttpStatusCode());
 }
示例#9
0
 public function testGettingUserDetails()
 {
     $server = m::mock('Wheniwork\\OAuth1\\Client\\Server\\Intuit[createHttpClient,protocolHeader]', [$this->getMockClientCredentials()]);
     $temporaryCredentials = m::mock('League\\OAuth1\\Client\\Credentials\\TokenCredentials');
     $temporaryCredentials->shouldReceive('getIdentifier')->andReturn('tokencredentialsidentifier');
     $temporaryCredentials->shouldReceive('getSecret')->andReturn('tokencredentialssecret');
     $server->shouldReceive('createHttpClient')->andReturn($client = m::mock('stdClass'));
     $me = $this;
     $client->shouldReceive('get')->with('https://appcenter.intuit.com/api/v1/user/current', m::on(function ($headers) use($me) {
         $me->assertTrue(isset($headers['Authorization']));
         // OAuth protocol specifies a strict number of
         // headers should be sent, in the correct order.
         // We'll validate that here.
         $pattern = '/OAuth oauth_consumer_key=".*?", oauth_nonce="[a-zA-Z0-9]+", oauth_signature_method="HMAC-SHA1", oauth_timestamp="\\d{10}", oauth_version="1.0", oauth_token="tokencredentialsidentifier", oauth_signature=".*?"/';
         $matches = preg_match($pattern, $headers['Authorization']);
         $me->assertEquals(1, $matches, 'Asserting that the authorization header contains the correct expression.');
         return true;
     }))->once()->andReturn($request = m::mock('stdClass'));
     $request->shouldReceive('send')->once()->andReturn($response = m::mock('stdClass'));
     $response->shouldReceive('xml')->once()->andReturn($this->getUserPayload());
     $user = $server->getUserDetails($temporaryCredentials);
     $this->assertInstanceOf('League\\OAuth1\\Client\\Server\\User', $user);
     $this->assertEquals('John Doe', $user->name);
     $this->assertEquals(null, $server->getUserUid($temporaryCredentials));
     $this->assertEquals('*****@*****.**', $server->getUserEmail($temporaryCredentials));
 }
示例#10
0
 public function testWriterAddsTheSqlFormatterExtension()
 {
     $this->twigEnvironment->shouldReceive('addExtension')->once()->with(m::on(function ($argument) {
         return $argument instanceof SqlFormatterExtension;
     }));
     $writer = new Writer($this->fileSystem, $this->twigEnvironment, $this->twigEngine);
 }
示例#11
0
 /**
  * Init tuff.
  */
 public function setUp()
 {
     $this->validSwiftMessage = m::on(function ($message) {
         return $message instanceof \Swift_Message;
     });
     $this->templName = 'myTemplate';
     $this->templ = m::mock('Symfony\\Bundle\\FrameworkBundle\\Templating\\EngineInterface')->shouldReceive('render')->once()->with($this->templName, array())->andReturn("subject\nBody\nmoreBody")->getMock();
 }
 public function testClearAll()
 {
     $validKeys = SessionStorage::$validKeys;
     $storage = m::mock('Happyr\\LinkedIn\\Storage\\SessionStorage[clear]')->shouldReceive('clear')->times(count($validKeys))->with(m::on(function ($arg) use($validKeys) {
         return in_array($arg, $validKeys);
     }))->getMock();
     $storage->clearAll();
 }
示例#13
0
 protected function assertEqualAggregatedRoot(RecordsMessages $expected)
 {
     return m::on(function (RecordsMessages $actual) use($expected) {
         $actual = clone $actual;
         $actual->eraseMessages();
         return Assertions::equalTo($expected)->evaluate($actual, '', true);
     });
 }
示例#14
0
 protected function stubCreateDequeueMessage($body, $id, $handle)
 {
     $this->factory->shouldReceive('createMessage')->once()->with($body, m::on(function ($opts) use($id, $handle) {
         $meta = ['Attributes' => [], 'MessageAttributes' => [], 'MessageId' => $id, 'ReceiptHandle' => $handle];
         $validator = isset($opts['validator']) && is_callable($opts['validator']);
         return isset($opts['metadata']) && $opts['metadata'] === $meta && $validator;
     }))->andReturn($this->messageA);
 }
 /**
  * Tests that a clone of the provider's options are passed to ProviderResource::fetch().
  */
 public function testFetchWithOptions()
 {
     $this->setOptions($options = \Mockery::mock(EncapsulatedOptions::class));
     $this->provider->fetch(MockFactory::mockResource($this->provider)->shouldReceive('fetch')->with($this->connector, \Mockery::on(function (EncapsulatedOptions $argument) use($options) {
         self::assertNotSame($options, $argument);
         return get_class($options) === get_class($argument);
     }))->getMock());
 }
示例#16
0
 public function testDump()
 {
     $this->console->shouldReceive('run')->with(m::on(function ($parameter) {
         $pattern = "/pg_dump --inserts --schema='public' 'testDatabase' > 'testfile.sql'/";
         return preg_match($pattern, $parameter) == true;
     }), null, ['PGHOST' => 'localhost', 'PGUSER' => 'testUser', 'PGPASSWORD' => 'password', 'PGPORT' => '5432'])->once()->andReturn(true);
     $this->assertTrue($this->database->dump('testfile.sql'));
 }
 public function testDump()
 {
     $this->console->shouldReceive('run')->with(m::on(function ($parameter) {
         $pattern = "/mysqldump --defaults-extra-file='(.*)' --skip-comments --skip-extended-insert 'testDatabase' > 'testfile.sql'/";
         return preg_match($pattern, $parameter) == true;
     }), null)->once()->andReturn(true);
     $this->assertTrue($this->database->dump('testfile.sql'));
 }
 public function testBoot()
 {
     // Make sure that boot() registers the singleton instance
     $this->app->shouldReceive('singleton')->with('filter', m::on(function ($closure) {
         // The closure should create an instance of Filter\Filter
         return call_user_func($closure, null) instanceof Filter;
     }))->times(1);
     $this->provider->boot();
 }
示例#19
0
 public function testDispatchTickertapeEvent()
 {
     $event = new tubepress_event_impl_tickertape_EventBase();
     $this->_mockDispatcher->shouldReceive('dispatch')->once()->with('some event', Mockery::on(function ($event) {
         return $event instanceof tubepress_event_impl_tickertape_EventBase;
     }))->andReturn(array('x'));
     $result = $this->_sut->dispatch('some event', $event);
     $this->assertEquals(array('x'), $result);
 }
示例#20
0
 public function getSendCallbackMock()
 {
     return Mockery::on(function ($callback) {
         $emailMock = Mockery::mock("stdClass");
         $emailMock->shouldReceive("to")->once()->with("*****@*****.**", "Chris");
         $callback($emailMock);
         return true;
     });
 }
示例#21
0
 protected function expectGet($url)
 {
     $that = $this;
     $url = $this->curl->buildUrl($url, $this->apiKey);
     return $this->curl->shouldReceive('get')->once()->with(m::on(function ($postUrl) use($url, $that) {
         $that->assertEquals($postUrl, $url);
         return true;
     }));
 }
 public function setUp()
 {
     $repo = m::mock('Xpressengine\\Member\\Repositories\\VirtualGroupRepositoryInterface');
     $repo->shouldReceive('fetchAllByMember')->with(null)->andReturn([]);
     $repo->shouldReceive('fetchAllByMember')->with(m::on(function ($arg) {
         return $arg !== null;
     }))->andReturn([(object) ['id' => 'virtual', 'title' => 'Virtual']]);
     AbstractRegisteredPermission::setVirtualGroupRepository($repo);
 }
 public function expectToDispatcher($expect_type = 'reply')
 {
     $action = factory(App\TicketAction::class)->make(['id' => $this->faker->randomDigit]);
     $dispatcher = m::mock('Illuminate\\Bus\\Dispatcher[dispatchFrom]', [$this->app]);
     $dispatcher->shouldReceive('dispatchFrom')->once()->with('App\\Jobs\\ActionCreateJob', m::on(function ($param) use($expect_type) {
         // var_dump($param->all())
         return $param->get('type') == $expect_type;
     }), [])->andReturn($action);
     $this->app->instance('Illuminate\\Contracts\\Bus\\Dispatcher', $dispatcher);
 }
示例#24
0
 public function testQueryIsBuilt()
 {
     $query = m::mock(Builder::class);
     $tag = new Tag(['id' => 1]);
     $filter = new Filter($tag);
     $query->shouldReceive('leftJoin')->with('pages_tags as pt_without-0', m::on(function () {
         return true;
     }))->andReturnSelf()->shouldReceive('on')->with('pages.id', '=', 'pt_without-0.page_id')->andReturnSelf()->shouldReceive('on')->with('pt_without-0.tag_id', '=', $tag->getId())->andReturnSelf()->shouldReceive('whereNull')->with('pt_without-0.page_id');
     $filter->build($query);
 }
示例#25
0
 protected function setUp()
 {
     $this->swift_mailer = \Mockery::mock('Swift_Mailer')->shouldReceive('send')->once()->with(\Mockery::on($this->validateEmail()))->getMock();
     $this->template = \Mockery::mock('Twig_Template')->shouldIgnoreMissing();
     $this->config_email = '*****@*****.**';
     $this->config_title = 'Reset';
     $this->user_email = '*****@*****.**';
     $this->user_id = 123;
     $this->reset_code = '987abc';
     $this->reset_mailer = new ResetEmailer($this->swift_mailer, $this->template, $this->config_email, $this->config_title);
 }
示例#26
0
 public function testRoute()
 {
     list($urlGenerator, $config) = $this->getMocks();
     $instance = new UrlMaker($urlGenerator, $config);
     $mockFile = m::mock('Xpressengine\\Storage\\File');
     $mockFile->id = 1;
     $urlGenerator->shouldReceive('route')->once()->with(m::on(function () {
         return true;
     }), ['id' => 1])->andReturn();
     $instance->route($mockFile);
 }
 /**
  * @expectedException \Akamon\OAuth2\Server\Domain\Exception\OAuthError\InvalidUserCredentialsOAuthErrorException
  */
 public function testGrantShouldThrowAnInvalidUserCredentialsException()
 {
     $username = '******';
     $password = '******';
     $userCredentials = new UserCredentials($username, $password);
     $inputData = ['username' => $username, 'password' => $password];
     $this->userCredentialsChecker->shouldReceive('check')->once()->with(\Mockery::on(function ($v) use($userCredentials) {
         return $v == $userCredentials;
     }))->andReturn(false);
     $this->processor->process($this->createClient(), $inputData);
 }
 public function testApplyingScopeWorksWhenValidAccount()
 {
     $manager = $this->managerWithAccount();
     $scope = new ModelAccountOrSystemResourceScope($manager);
     $builder = m::mock(Builder::class);
     $model = m::mock(Model::class);
     $builder->shouldReceive('where')->once()->with(m::on(function ($argument) {
         return $argument instanceof \Closure;
     }))->andReturnSelf();
     $scope->apply($builder, $model);
 }
 private function checkEmailContent($checks)
 {
     $mock = Mockery::mock($this->app['mailer']->getSwiftMailer());
     $this->app['mailer']->setSwiftMailer($mock);
     $mock->shouldReceive('send')->withArgs([Mockery::on(function ($message) use($checks) {
         $this->assertEquals($checks['title'], $message->getSubject());
         $this->assertSame([$checks['email'] => null], $message->getTo());
         $this->assertContains($checks['content'], $message->getBody());
         return true;
     }), Mockery::any()])->once();
 }
示例#30
0
 public function testFlushTo()
 {
     $mockLogger = $this->mock(tubepress_api_log_LoggerInterface::_);
     $mockLogger->shouldReceive('debug')->once()->with(Mockery::on(function ($m) {
         $utils = new tubepress_util_impl_StringUtils();
         return $utils->endsWith($m, 'something');
     }), array());
     $this->_sut->debug('something');
     $this->_sut->flushTo($mockLogger);
     $this->assertTrue(true);
 }