public function setUp()
 {
     parent::setUp();
     $this->subjectConfirmation = m::mock('SAML2\\XML\\saml\\SubjectConfirmation');
     $this->subjectConfirmationData = m::mock('SAML2\\XML\\saml\\SubjectConfirmationData');
     $this->subjectConfirmation->SubjectConfirmationData = $this->subjectConfirmationData;
 }
Exemple #2
0
 public function setUp()
 {
     $this->mockProxy = M::mock('Webservice\\TransactionDbProxy');
     $this->handler = new BugHandler();
     $this->handler->setLanguage("de");
     $this->handler->setDbProxy($this->mockProxy);
 }
 public function testAddingRouteActuallyAddsPhalcoreRoute()
 {
     $route = $this->instance->add('/foo', ['controller' => 'foo', 'action' => 'bar']);
     $this->assertInstanceOf('Phalcore\\Mvc\\Router\\Route', $route);
     $this->assertContains($route, $this->instance->getRoutes());
     $this->assertNotContains(m::mock('Phalcore\\Mvc\\Router\\Route'), $this->instance->getRoutes());
 }
 /**
  * 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');
 }
 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'));
 }
Exemple #6
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;
 }
 public function testHandleThrowPass()
 {
     $middleware = new AuthoriseRole();
     $this->assertTrue($middleware->handle(Mockery::mock('\\Illuminate\\Http\\Request'), function () {
         return true;
     }, 'su'));
 }
 /**
  * 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();
 }
Exemple #9
0
 /**
  * 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);
 }
 public function setUp()
 {
     DI::reset();
     DI::setDefault($di = new DI());
     $this->instance = m::mock('Phalcore\\Di\\Facade');
     $di->setShared('foo', m::mock('foo'));
 }
 public function testGetCustomersInvalidCustomer()
 {
     $this->setExpectedException('\\DomainException');
     $jsonProvider = \Mockery::mock('\\KieranBamforth\\CustomerInviter\\CustomerProvider\\JsonProvider[isCustomerValid]', [$this->json]);
     $jsonProvider->shouldReceive('isCustomerValid')->andReturn(false);
     $jsonProvider->getCustomers();
 }
 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);
 }
 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);
 }
 public function testBoot()
 {
     $this->app['orlex.controller.dirs'] = [$path = '/sample/path/to/controllers'];
     $this->app['orlex.route.compiler'] = m::mock('Orlex\\AnnotationManager\\Compiler');
     $this->app['orlex.route.compiler']->shouldReceive('compile')->once()->with($path)->andReturnNull();
     $this->provider->boot($this->app);
 }
 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();
 }
 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']);
 }
 /**
  * @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();
 }
Exemple #18
0
 public function setUp()
 {
     parent::setUp();
     $this->mVideo_validator = M::mock('Agency\\Validators\\Contracts\\VideoValidatorInterface');
     $this->parser = new parser($this->mVideo_validator);
     $this->mVideo = M::mock('Agency\\Video');
 }
    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());
    }
 /**
  * @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);
 }
 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());
 }
 public function testIfTrueWhenNonAjaxRequest()
 {
     $filter = new Filter();
     $request = m::mock('Illuminate\\Http\\Request');
     $request->shouldReceive('ajax')->once()->andReturn(false);
     $this->assertTrue($filter->filter($request));
 }
Exemple #23
0
 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');
 }
Exemple #24
0
 function testDelete()
 {
     $http = m::mock(new Services_Twilio_TinyHttp());
     $http->shouldReceive('delete')->once()->with('/v1/Services/SV123')->andReturn(array(204, array('Content-Type' => 'application/json'), ''));
     $ipMessagingClient = new IPMessaging_Services_Twilio('AC123', '123', null, $http);
     $ipMessagingClient->services->delete('SV123');
 }
 /**
  * @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 testBase()
 {
     // WIP
     $service = m::mock('service');
     $service->shouldReceive('readTemp')->times(3)->andReturn(10, 12, 14);
     $this->markTestIncomplete('This test has not been implemented yet.');
 }
 /**
  * {@inheritdoc}
  */
 public function setUp()
 {
     parent::setUp();
     $this->factory = new ProcessFactory('pwd');
     $this->directory = \Mockery::mock(\SplFileInfo::class);
     $this->directory->shouldReceive('__toString')->andReturn('/tmp');
 }
 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);
 }
 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);
 }
 public function setUp()
 {
     $this->req_tok_sample = file('./tests/samples/twt_request_token.txt')[0];
     $this->acc_tok_sample = file('./tests/samples/twt_access_token.txt')[0];
     $this->token = new OAuthToken();
     $this->response = M::mock('Vinelab\\Http\\Response');
 }