예제 #1
0
 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');
 }
예제 #2
0
 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>'));
 }
예제 #3
0
 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'));
 }
예제 #4
0
 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();
 }
예제 #5
0
 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);
 }
 /**
  * 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);
 }
 public function testFilterQuery()
 {
     $relationship = m::mock(array('getPlainForeignKey' => '', 'getRelated' => m::mock(array('getTable' => 'table'))));
     $model = m::mock(array('getTable' => 'table', 'getKeyName' => '', 'method' => $relationship));
     $grammar = m::mock('Illuminate\\Database\\Query\\Grammars');
     $grammar->shouldReceive('wrap')->once()->andReturn('');
     $this->config->shouldReceive('getDataModel')->once()->andReturn($model);
     $this->column->shouldReceive('getOption')->times(3)->andReturn('column_name', 'method', 'select')->shouldReceive('getRelationshipWheres')->once()->andReturn('');
     $this->db->shouldReceive('raw')->once()->andReturn('foo')->shouldReceive('getQueryGrammar')->once()->andReturn($grammar);
     $selects = array();
     $this->column->filterQuery($selects);
     $this->assertEquals($selects, array('foo'));
 }
예제 #8
0
 public function testBase()
 {
     // WIP
     $service = m::mock('service');
     $service->shouldReceive('readTemp')->times(3)->andReturn(10, 12, 14);
     $this->markTestIncomplete('This test has not been implemented yet.');
 }
예제 #9
0
 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);
 }
예제 #10
0
 /**
  * {@inheritdoc}
  */
 public function setUp()
 {
     parent::setUp();
     $this->factory = new ProcessFactory('pwd');
     $this->directory = \Mockery::mock(\SplFileInfo::class);
     $this->directory->shouldReceive('__toString')->andReturn('/tmp');
 }
 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);
 }
예제 #12
0
 /**
  * Verify that talks with ampersands and other characters in them can
  * be created and then edited properly
  *
  * @test
  */
 public function ampersandsAcceptableCharacterForTalks()
 {
     $controller = new OpenCFP\Http\Controller\TalkController();
     $controller->setApplication($this->app);
     // Create a test double for SwiftMailer
     $swiftmailer = m::mock('StdClass');
     $swiftmailer->shouldReceive('send')->andReturn(true);
     $this->app['mailer'] = $swiftmailer;
     // Get our request object to return expected data
     $talk_data = ['title' => 'Test Title With Ampersand', 'description' => "The title should contain this & that", 'type' => 'regular', 'level' => 'entry', 'category' => 'other', 'desired' => 0, 'slides' => '', 'other' => '', 'sponsor' => '', 'user_id' => $this->app['sentry']->getUser()->getId()];
     $this->setPost($talk_data);
     /**
      * If the talk was successfully created, a success value is placed
      * into the session flash area for display
      */
     $create_response = $controller->processCreateAction($this->req);
     $create_flash = $this->app['session']->get('flash');
     $this->assertEquals($create_flash['type'], 'success');
     // Now, edit the results and update them
     $talk_data['id'] = 1;
     $talk_data['description'] = "The title should contain this & that & this other thing";
     $talk_data['title'] = "Test Title With Ampersand & More Things";
     $this->setPost($talk_data);
     $update_response = $controller->updateAction($this->req, $this->app);
     $update_flash = $this->app['session']->get('flash');
     $this->assertEquals($update_flash['type'], 'success');
 }
예제 #13
0
 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);
 }
예제 #14
0
 public function testHandleThrowPass()
 {
     $middleware = new AuthoriseRole();
     $this->assertTrue($middleware->handle(Mockery::mock('\\Illuminate\\Http\\Request'), function () {
         return true;
     }, 'su'));
 }
예제 #15
0
 /**
  * @return mixed Really a Filesystem|MockInterface but coding standards get confused
  */
 private function getFilesystem()
 {
     $fileSystem = m::mock(Filesystem::class);
     $fileSystem->shouldReceive('getAdapter')->andReturn(m::mock(AdapterInterface::class));
     $fileSystem->shouldReceive('getConfig')->andReturn(null);
     return $fileSystem;
 }
예제 #16
0
 public function testValidSegmentsWithIndex()
 {
     $body['docs'] = '1';
     $mockTransport = m::mock('\\Elasticsearch\\Transport')->shouldReceive('performRequest')->once()->with('PUT', '/testIndex/_settings', array(), array('docs' => 1))->getMock();
     $action = new Put($mockTransport);
     $action->setBody($body)->setIndex('testIndex')->performRequest();
 }
 /**
  * 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();
 }
 public function testGetCustomersInvalidCustomer()
 {
     $this->setExpectedException('\\DomainException');
     $jsonProvider = \Mockery::mock('\\KieranBamforth\\CustomerInviter\\CustomerProvider\\JsonProvider[isCustomerValid]', [$this->json]);
     $jsonProvider->shouldReceive('isCustomerValid')->andReturn(false);
     $jsonProvider->getCustomers();
 }
 /**
  * @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();
 }
예제 #20
0
파일: CdnTest.php 프로젝트: filipegar/cdn
 /**
  * Integration Test.
  */
 public function testPushCommand()
 {
     $configuration_file = ['bypass' => false, 'default' => 'AwsS3', 'url' => 'https://s3.amazonaws.com', 'threshold' => 10, 'providers' => ['aws' => ['s3' => ['region' => 'us-standard', 'version' => 'latest', 'buckets' => ['my-bucket-name' => '*'], 'acl' => 'public-read', 'cloudfront' => ['use' => false, 'cdn_url' => ''], 'metadata' => [], 'expires' => gmdate('D, d M Y H:i:s T', strtotime('+5 years')), 'cache-control' => 'max-age=2628000', 'version' => '']]], 'include' => ['directories' => [__DIR__], 'extensions' => [], 'patterns' => []], 'exclude' => ['directories' => [], 'files' => [], 'extensions' => [], 'patterns' => [], 'hidden' => true]];
     $m_consol = M::mock('Symfony\\Component\\Console\\Output\\ConsoleOutput');
     $m_consol->shouldReceive('writeln')->atLeast(1);
     $finder = new \Vinelab\Cdn\Finder($m_consol);
     $asset = new \Vinelab\Cdn\Asset();
     $provider_factory = new \Vinelab\Cdn\ProviderFactory();
     $m_config = M::mock('Illuminate\\Config\\Repository');
     $m_config->shouldReceive('get')->with('cdn')->once()->andReturn($configuration_file);
     $helper = new \Vinelab\Cdn\CdnHelper($m_config);
     $m_console = M::mock('Symfony\\Component\\Console\\Output\\ConsoleOutput');
     $m_console->shouldReceive('writeln')->atLeast(2);
     $m_validator = M::mock('Vinelab\\Cdn\\Validators\\Contracts\\ProviderValidatorInterface');
     $m_validator->shouldReceive('validate');
     $m_helper = M::mock('Vinelab\\Cdn\\CdnHelper');
     $m_spl_file = M::mock('Symfony\\Component\\Finder\\SplFileInfo');
     $m_spl_file->shouldReceive('getPathname')->andReturn('vinelab/cdn/tests/Vinelab/Cdn/AwsS3ProviderTest.php');
     $m_spl_file->shouldReceive('getRealPath')->andReturn(__DIR__ . '/AwsS3ProviderTest.php');
     // partial mock
     $p_aws_s3_provider = M::mock('\\Vinelab\\Cdn\\Providers\\AwsS3Provider[connect]', array($m_console, $m_validator, $m_helper));
     $m_s3 = M::mock('Aws\\S3\\S3Client')->shouldIgnoreMissing();
     $m_s3->shouldReceive('factory')->andReturn('Aws\\S3\\S3Client');
     $m_command = M::mock('Aws\\Command');
     $m_s3->shouldReceive('getCommand')->andReturn($m_command);
     $m_s3->shouldReceive('execute');
     $p_aws_s3_provider->setS3Client($m_s3);
     $p_aws_s3_provider->shouldReceive('connect')->andReturn(true);
     \Illuminate\Support\Facades\App::shouldReceive('make')->once()->andReturn($p_aws_s3_provider);
     $cdn = new \Vinelab\Cdn\Cdn($finder, $asset, $provider_factory, $helper);
     $result = $cdn->push();
     assertEquals($result, true);
 }
예제 #21
0
    public function testCommitHydratorHappyPath()
    {
        $sha = "c3c8d149d63338c1215e0b06c839768cdf1933d5";
        $data = <<<EOF
tree b4ac469697c1e0f5fbb5702befc59fd7a90970a0
parent b3bf978c063bc6491919a97d1f6d6c9a6c074a2d
parent deadbeefcafec0ffee19a97d1f6d6c9a6c074a2d
parent cafebabe063bc6491919a97d1f6d6c9a6c074a2d
author Magnus Nordlander <*****@*****.**> 1316430078 +0200
committer Magnus Nordlander <*****@*****.**> 1316430078 +0200

Updated to version 2.1.2
EOF;
        $raw_object = M::mock('Gittern\\Transport\\RawObject', array('getSha' => $sha, 'getData' => $data));
        $hydrator = new CommitHydrator(M::mock('Gittern\\Repository'));
        $commit = $hydrator->hydrate($raw_object);
        $this->assertEquals($sha, $commit->getSha());
        $this->assertEquals("b4ac469697c1e0f5fbb5702befc59fd7a90970a0", $commit->getTree()->getSha());
        $parents = $commit->getParents();
        $this->assertEquals("b3bf978c063bc6491919a97d1f6d6c9a6c074a2d", $parents[0]->getSha());
        $user = new GitObject\User('Magnus Nordlander', "*****@*****.**");
        $this->assertEquals($user, $commit->getAuthor());
        $this->assertEquals($user, $commit->getCommitter());
        $timestamp = \DateTime::createFromFormat('U O', '1316430078 +0200');
        $this->assertEquals($timestamp, $commit->getAuthorTime());
        $this->assertEquals($timestamp, $commit->getCommitTime());
    }
 public function testGetSchemas()
 {
     $generator = new Generator($this->em, $this->schemaTool);
     $metadataFactory = m::mock('Doctrine\\ORM\\Mapping\\ClassMetadataFactory');
     $connection = m::mock('Doctrine\\DBAL\\Connection');
     $schemaManager = m::mock('Doctrine\\DBAL\\Schema\\AbstractSchemaManager');
     $this->em->shouldReceive('getMetadataFactory')->once()->andReturn($metadataFactory);
     $metadataFactory->shouldReceive('getAllMetadata')->once()->andReturn($this->metadata);
     $this->em->shouldReceive('getConnection')->once()->andReturn($connection);
     $connection->shouldReceive('getSchemaManager')->once()->andReturn($schemaManager);
     $schemaManager->shouldReceive('createSchema')->once()->andReturn($this->fromSchema);
     $this->schemaTool->shouldReceive('getSchemaFromMetadata')->once()->with($this->metadata)->andReturn($this->toSchema);
     // multiple calls should return different clones of the same schemas
     $schemasA = $generator->getSchemas();
     $schemasB = $generator->getSchemas();
     $this->assertEquals(3, count($schemasA));
     $this->assertEquals(3, count($schemasB));
     $this->assertEquals($schemasA['metadata'], $this->metadata);
     $this->assertEquals($schemasB['metadata'], $this->metadata);
     $this->assertEquals($schemasA['fromSchema'], $this->fromSchema);
     $this->assertNotSame($schemasA['fromSchema'], $this->fromSchema);
     $this->assertEquals($schemasA['toSchema'], $this->toSchema);
     $this->assertNotSame($schemasA['toSchema'], $this->toSchema);
     $this->assertEquals($schemasB['fromSchema'], $this->fromSchema);
     $this->assertEquals($schemasB['toSchema'], $this->toSchema);
     $this->assertNotSame($schemasB['fromSchema'], $this->fromSchema);
     $this->assertNotSame($schemasB['toSchema'], $this->toSchema);
     $this->assertNotSame($schemasA['fromSchema'], $schemasB['fromSchema']);
     $this->assertNotSame($schemasA['toSchema'], $schemasB['toSchema']);
 }
 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());
 }
예제 #24
0
 /**
  * This method is called after a test is executed.
  */
 public function tearDown()
 {
     \Mockery::close();
     $this->logger = null;
     $this->futureFunc = null;
     $this->response = null;
 }
예제 #25
0
파일: SortTest.php 프로젝트: alpas29/cms
 public function test_it_sets_default_order_by()
 {
     $Manager = m::mock('Devise\\Support\\Sortable\\Manager');
     $Framework = new \Devise\Support\Framework();
     $Sort = new Sort($Manager, $Framework);
     $Sort->setDefaultOrderBy('fieldname');
 }
 /**
  * @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);
 }
예제 #27
0
 /**
  * @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);
 }
 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);
 }
 function testVerify()
 {
     // Given
     $this->startSession();
     $userData = ['name' => 'Some name', 'email' => '*****@*****.**', '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);
 }
예제 #30
0
 public function testIfTrueWhenNonAjaxRequest()
 {
     $filter = new Filter();
     $request = m::mock('Illuminate\\Http\\Request');
     $request->shouldReceive('ajax')->once()->andReturn(false);
     $this->assertTrue($filter->filter($request));
 }