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']);
 }
 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);
 }
 /**
  * _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);
 }
 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);
 }
 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);
 }
 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);
 }
 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);
 }
 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);
 }
 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));
 }
 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));
 }
 /** @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();
 }
Exemple #12
0
 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);
 }
 /**
  * @expectedException \Mockery\Exception
  */
 public function testAnyOfConstraintThrowsExceptionWhenConstraintUnmatched()
 {
     $this->mock->shouldReceive('foo')->with(Mockery::anyOf(1, 2))->once();
     $this->mock->foo(3);
     $this->container->mockery_verify();
 }
 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'))));
 }
 /**
  * @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);
 }
Exemple #16
0
 /**
  * Setup our class
  *
  * @access public
  * @param void
  * @return void
  */
 public function setUp()
 {
     $this->validUnits = m::anyOf(Zip::MILES, Zip::FEET, Zip::KILOMETERS, Zip::METERS, Zip::RADIANS, Zip::DEGREES);
 }
 public function testAbilityDefaultOptions()
 {
     /*
     |------------------------------------------------------------
     | Set
     |------------------------------------------------------------
     */
     $userPermNameA = 'user_can_a';
     $userPermNameB = 'user_can_b';
     $userPermNameC = 'user_can_c';
     $nonUserPermNameA = 'user_cannot_a';
     $nonUserPermNameB = 'user_cannot_b';
     $userRoleNameA = 'UserRoleA';
     $userRoleNameB = 'UserRoleB';
     $nonUserRoleNameA = 'NonUserRoleA';
     $nonUserRoleNameB = 'NonUserRoleB';
     $permA = $this->mockPermission($userPermNameA);
     $permB = $this->mockPermission($userPermNameB);
     $permC = $this->mockPermission($userPermNameC);
     $roleA = $this->mockRole($userRoleNameA);
     $roleB = $this->mockRole($userRoleNameB);
     $roleA->perms = [$permA];
     $roleB->perms = [$permB, $permC];
     $user = m::mock('HasRoleUser')->makePartial();
     $user->roles = [$roleA, $roleB];
     $user->id = 4;
     $user->primaryKey = 'id';
     /*
     |------------------------------------------------------------
     | Expectation
     |------------------------------------------------------------
     */
     $roleA->shouldReceive('cachedPermissions')->times(16)->andReturn($roleA->perms);
     $roleB->shouldReceive('cachedPermissions')->times(12)->andReturn($roleB->perms);
     Config::shouldReceive('get')->with('cache.ttl', 60)->times(32)->andReturn('1440');
     Cache::shouldReceive('remember')->times(32)->andReturn($user->roles);
     $user->shouldReceive('hasRole')->with(m::anyOf($userRoleNameA, $userRoleNameB), m::anyOf(true, false))->andReturn(true);
     $user->shouldReceive('hasRole')->with(m::anyOf($nonUserRoleNameA, $nonUserRoleNameB), m::anyOf(true, false))->andReturn(false);
     $user->shouldReceive('can')->with(m::anyOf($userPermNameA, $userPermNameB, $userPermNameC), m::anyOf(true, false))->andReturn(true);
     $user->shouldReceive('can')->with(m::anyOf($nonUserPermNameA, $nonUserPermNameB), m::anyOf(true, false))->andReturn(false);
     /*
     |------------------------------------------------------------
     | Assertion
     |------------------------------------------------------------
     */
     // Case: User has everything.
     $this->assertSame($user->ability([$userRoleNameA, $userRoleNameB], [$userPermNameA, $userPermNameB]), $user->ability([$userRoleNameA, $userRoleNameB], [$userPermNameA, $userPermNameB], ['validate_all' => false, 'return_type' => 'boolean']));
     // Case: User lacks a role.
     $this->assertSame($user->ability([$nonUserRoleNameA, $userRoleNameB], [$userPermNameA, $userPermNameB]), $user->ability([$nonUserRoleNameA, $userRoleNameB], [$userPermNameA, $userPermNameB], ['validate_all' => false, 'return_type' => 'boolean']));
     // Case: User lacks a permission.
     $this->assertSame($user->ability([$userRoleNameA, $userRoleNameB], [$nonUserPermNameA, $userPermNameB]), $user->ability([$userRoleNameA, $userRoleNameB], [$nonUserPermNameA, $userPermNameB], ['validate_all' => false, 'return_type' => 'boolean']));
     // Case: User lacks everything.
     $this->assertSame($user->ability([$nonUserRoleNameA, $nonUserRoleNameB], [$nonUserPermNameA, $nonUserPermNameB]), $user->ability([$nonUserRoleNameA, $nonUserRoleNameB], [$nonUserPermNameA, $nonUserPermNameB], ['validate_all' => false, 'return_type' => 'boolean']));
 }
Exemple #18
0
 /**
  * @param $path
  * @param $to
  * @param $getSqlReturn
  *
  * @dataProvider writeSqlFileProvider
  */
 public function testWriteSqlFile($path, $from, $to, $getSqlReturn)
 {
     $expectedReturn = 123;
     $sqlWriter = m::instanceMock('overload:Doctrine\\DBAL\\Migrations\\SqlFileWriter');
     $sqlWriter->shouldReceive('write')->with(m::type('array'), m::anyOf('up', 'down'))->andReturn($expectedReturn);
     $outputWriter = m::mock('Doctrine\\DBAL\\Migrations\\OutputWriter');
     $outputWriter->shouldReceive('write');
     $config = m::mock('Doctrine\\DBAL\\Migrations\\Configuration\\Configuration')->makePartial();
     $config->shouldReceive('getCurrentVersion')->andReturn($from);
     $config->shouldReceive('getOutputWriter')->andReturn($outputWriter);
     if ($to == null) {
         // this will always just test the "up" direction
         $config->shouldReceive('getLatestVersion')->andReturn($from + 1);
     }
     $migration = m::mock('Doctrine\\DBAL\\Migrations\\Migration[getSql]', [$config])->makePartial();
     $migration->shouldReceive('getSql')->with($to)->andReturn($getSqlReturn);
     $result = $migration->writeSqlFile($path, $to);
     $this->assertEquals($expectedReturn, $result);
 }
 public function testGcReturnsTrue()
 {
     $result = $this->sessionHandler->gc(m::anyOf('int'));
     $this->assertTrue($result);
 }
 public function testProcessWithDefinitionFailure()
 {
     $contextConfig = ['context1' => ['tag' => 'tag1'], 'context2' => ['tag' => 'tag2']];
     $taggedServices = ['tag1' => ['id1' => [], 'id2' => []], 'tag2' => ['id3' => []]];
     $this->container->shouldReceive('getParameter')->with('dms_chainlink.contexts')->once()->andReturn($contextConfig);
     $this->container->shouldReceive('setDefinition')->with('/^dms_chainlink\\.context\\..*/', m::type('Symfony\\Component\\DependencyInjection\\Definition'))->twice();
     $this->container->shouldReceive('setAlias')->with(m::anyOf('context1', 'context2'), m::anyOf(HandleTagsPass::SERVICE_PREFIX . 'context1', HandleTagsPass::SERVICE_PREFIX . 'context2'))->twice();
     $this->container->shouldReceive('hasDefinition')->with(m::anyOf(HandleTagsPass::SERVICE_PREFIX . 'context1', HandleTagsPass::SERVICE_PREFIX . 'context2'))->twice()->andReturn(false);
     $this->container->shouldReceive('getDefinition')->never();
     $this->container->shouldReceive('getDefinition')->never();
     $this->container->shouldReceive('findTaggedServiceIds')->never();
     $this->pass->process($this->container);
 }
Exemple #21
0
 public function test_after_call_notifies_friends()
 {
     $twilio = M::spy(TwilioClient::class);
     App::instance(TwilioClient::class, $twilio);
     $user = factory(User::class)->create();
     $number = new PhoneNumber(['number' => TwilioClient::formatNumberFromTwilio($this->afterCallPost['Caller'])]);
     $user->phoneNumbers()->save($number);
     $friend1 = factory(Friend::class)->make();
     $friend2 = factory(Friend::class)->make();
     $friend3 = factory(Friend::class)->make();
     $user->friends()->saveMany([$friend1, $friend2, $friend3]);
     $someoneElse = factory(User::class)->create();
     $someoneElsesFriend = factory(Friend::class)->make();
     $someoneElse->friends()->save($someoneElsesFriend);
     $this->post(route('hook.after-call'), $this->afterCallPost);
     // Awkward, must include text to the owner...
     $twilio->shouldHaveReceived('text')->times(4)->with(M::anyOf($number->number, $friend1->number, $friend2->number, $friend3->number), M::on(function ($message) {
         return strpos($message, $this->afterCallPost['RecordingUrl']) !== false;
     }));
 }
Exemple #22
0
 public function testUpdateSuccess()
 {
     Input::replace(array('title' => 'Foo', 'task' => 'Foo'));
     $this->mock->shouldReceive('findOrFail')->with(3)->once()->andReturn($this->mock);
     $this->mock->shouldReceive('uniqueExcept')->with(\Mockery::anyOf('title', 'slug'))->twice();
     $this->mock->shouldReceive('update')->once()->andReturn(true);
     $this->mock->shouldReceive('slug')->andReturn('foo');
     $this->mock->shouldReceive('highestSeriesOrder')->once()->andReturn(1);
     $this->mock->shouldReceive('identify')->once();
     $this->mock->shouldReceive('saveRelations')->twice()->andReturn(array(1, 2, 3));
     $this->mock->shouldReceive('categories', 'tags')->once()->andReturn($this->mock);
     $this->mock->shouldReceive('sync')->twice()->andReturn($this->mock);
     $this->put($this->url . '/3');
     $this->assertRedirectedToRoute($this->route . '.index');
 }
 public function test_should_return_and_validate_full_commit()
 {
     $this->set_get_refs_heads_master(true);
     $this->set_get_commits(true);
     $this->set_get_trees(true);
     $this->set_get_blobs(true);
     $this->api_cache->shouldReceive('set_blob')->times(3)->with(Mockery::anyOf('9fa5c7537f8582b71028ff34b8c20dfd0f3b2a25', '8d9b2e6fd93761211dc03abd71f4a9189d680fd0', '2d73165945b0ccbe4932f1363457986b0ed49f19'), Mockery::type('WordPress_GitHub_Sync_Blob'))->andReturnUsing(function ($sha, $blob) {
         return $blob;
     });
     $this->api_cache->shouldReceive('set_tree')->once()->with('9108868e3800bec6763e51beb0d33e15036c3626', Mockery::type('WordPress_GitHub_Sync_Tree'))->andReturnUsing(function ($sha, $tree) {
         return $tree;
     });
     $this->api_cache->shouldReceive('set_commit')->once()->with('db2510854e6aeab68ead26b48328b19f4bdf926e', Mockery::type('WordPress_GitHub_Sync_Commit'))->andReturnUsing(function ($sha, $commit) {
         return $commit;
     });
     $this->assertInstanceOf('WordPress_GitHub_Sync_Commit', $master = $this->fetch->master());
     /**
      * Validate the commit's api data mapped correctly.
      */
     $this->assertSame('7497c0574b9430ff5e5521b4572b7452ea36a056', $master->sha());
     $this->assertSame('*****@*****.**', $master->author()->email);
     $this->assertSame('2015-11-02T00:36:54Z', $master->author()->date);
     $this->assertSame('*****@*****.**', $master->committer()->email);
     $this->assertSame('2015-11-02T00:36:54Z', $master->committer()->date);
     $this->assertSame('Initial full site export - wpghs', $master->message());
     $this->assertCount(1, $parents = $master->parents());
     $this->assertSame('db2510854e6aeab68ead26b48328b19f4bdf926e', $parents[0]->sha);
     $this->assertInstanceOf('WordPress_GitHub_Sync_Tree', $tree = $master->tree());
     /**
      * Validate the tree's api data mapped correctly.
      */
     $this->assertSame('9108868e3800bec6763e51beb0d33e15036c3626', $tree->sha());
     $this->assertCount(3, $blobs = $tree->blobs());
     /**
      * Validate the blobs' api data mapped correctly.
      */
     $blobs = $tree->blobs();
     $this->assertCount(3, $blobs);
     foreach ($blobs as $blob) {
         $this->assertTrue(in_array($blob->sha(), array('2d73165945b0ccbe4932f1363457986b0ed49f19', '8d9b2e6fd93761211dc03abd71f4a9189d680fd0', '9fa5c7537f8582b71028ff34b8c20dfd0f3b2a25')));
         $this->assertTrue(in_array($blob->path(), array('_pages/sample-page.md', '_posts/2015-11-02-hello-world.md', 'README.md')));
     }
 }