public function testBelongToGalleryRelationshipObjectReturned()
 {
     $meta = Factory::create('PostMeta', ['post_id' => 1]);
     Factory::create('Gallery');
     $relationship = $meta->gallery();
     assertThat($relationship, is(anInstanceOf('Illuminate\\Database\\Eloquent\\Relations\\BelongsTo')));
 }
 public function testTestHasManyMetaRetionshipObjectIsReturned()
 {
     $gallery = Factory::create('Gallery');
     Factory::create('PostMeta', ['post_id' => 1]);
     $relationship = $gallery->meta();
     assertThat($relationship, is(anInstanceOf('Illuminate\\Database\\Eloquent\\Relations\\HasMany')));
 }
示例#3
0
 public function testGetFileLicenseMatches()
 {
     $this->testDb->createPlainTables(array('license_ref', 'uploadtree', 'license_file', 'agent'));
     $this->testDb->insertData_license_ref();
     $lic0 = $this->dbManager->getSingleRow("Select * from license_ref limit 1");
     $licenseRefNumber = $lic0['rf_pk'];
     $licenseFileId = 1;
     $pfileId = 42;
     $agentId = 23;
     $matchPercent = 50;
     $uploadtreeId = 512;
     $uploadID = 123;
     $left = 2009;
     $right = 2014;
     $agentName = "fake";
     $agentRev = 1;
     $mydate = "'2014-06-04 14:01:30.551093+02'";
     $this->testDb->createViews(array('license_file_ref'));
     $this->dbManager->queryOnce("INSERT INTO license_file (fl_pk, rf_fk, agent_fk, rf_match_pct, rf_timestamp, pfile_fk)\n            VALUES ({$licenseFileId}, {$licenseRefNumber}, {$agentId}, {$matchPercent}, {$mydate}, {$pfileId})");
     $this->dbManager->queryOnce("INSERT INTO uploadtree (uploadtree_pk, upload_fk, pfile_fk, lft, rgt)\n            VALUES ({$uploadtreeId}, {$uploadID}, {$pfileId}, {$left}, {$right})");
     $stmt = __METHOD__ . '.insert.agent';
     $this->dbManager->prepare($stmt, "INSERT INTO agent (agent_pk, agent_name, agent_rev, agent_enabled) VALUES (\$1,\$2,\$3,\$4)");
     $this->dbManager->execute($stmt, array($agentId, $agentName, $agentRev, 'true'));
     $licDao = new LicenseDao($this->dbManager);
     $itemTreeBounds = new ItemTreeBounds($uploadtreeId, "uploadtree", $uploadID, $left, $right);
     $matches = $licDao->getAgentFileLicenseMatches($itemTreeBounds);
     $licenseRef = new LicenseRef($licenseRefNumber, $lic0['rf_shortname'], $lic0['rf_fullname']);
     $agentRef = new AgentRef($agentId, $agentName, $agentRev);
     $expected = array(new LicenseMatch($pfileId, $licenseRef, $agentRef, $licenseFileId, $matchPercent));
     assertThat($matches, equalTo($expected));
     assertThat($matches[0], is(anInstanceOf(LicenseMatch::classname())));
     $this->addToAssertionCount(\Hamcrest\MatcherAssert::getCount() - $this->assertCountBefore);
 }
示例#4
0
 public function testInterface()
 {
     assertThat($this->client, is(anInstanceOf('Graze\\Queue\\ConsumerInterface')));
     assertThat($this->client, is(anInstanceOf('Graze\\Queue\\DeleterInterface')));
     assertThat($this->client, is(anInstanceOf('Graze\\Queue\\ProducerInterface')));
     assertThat($this->client, is(anInstanceOf('Graze\\Queue\\PurgerInterface')));
 }
 public function testSetHostToCreateNewGallery()
 {
     $model = new RemoteModelStub();
     $model->setHost('Flickr');
     $gallery = $model->newModel();
     assertThat($gallery, is(anInstanceOf('PullAutomaticallyGalleries\\RemoteApi\\RemoteApiModelInterface')));
 }
 function testBoot()
 {
     $ioc = org_tubepress_impl_ioc_IocContainer::getInstance();
     $pm = $ioc->get(org_tubepress_api_plugin_PluginManager::_);
     $expectedSystemFilters = array(array(org_tubepress_api_const_plugin_FilterPoint::OPTION_SET_PRE_VALIDATION, 'org_tubepress_impl_plugin_filters_prevalidationoptionset_YouTubePlaylistPlPrefixRemover'), array(org_tubepress_api_const_plugin_FilterPoint::OPTION_SET_PRE_VALIDATION, 'org_tubepress_impl_plugin_filters_prevalidationoptionset_StringMagic'), array(org_tubepress_api_const_plugin_FilterPoint::TEMPLATE_EMBEDDED, 'org_tubepress_impl_plugin_filters_embeddedtemplate_CoreVariables'), array(org_tubepress_api_const_plugin_FilterPoint::HTML_EMBEDDED, 'org_tubepress_impl_plugin_filters_embeddedhtml_PlayerJavaScriptApi'), array(org_tubepress_api_const_plugin_FilterPoint::HTML_GALLERY, 'org_tubepress_impl_plugin_filters_galleryhtml_GalleryJs'), array(org_tubepress_api_const_plugin_FilterPoint::JAVASCRIPT_GALLERYINIT, 'org_tubepress_impl_plugin_filters_galleryinitjs_GalleryInitJsBaseParams'), array(org_tubepress_api_const_plugin_FilterPoint::TEMPLATE_GALLERY, 'org_tubepress_impl_plugin_filters_gallerytemplate_CoreVariables'), array(org_tubepress_api_const_plugin_FilterPoint::TEMPLATE_GALLERY, 'org_tubepress_impl_plugin_filters_gallerytemplate_EmbeddedPlayerName'), array(org_tubepress_api_const_plugin_FilterPoint::TEMPLATE_GALLERY, 'org_tubepress_impl_plugin_filters_gallerytemplate_Pagination'), array(org_tubepress_api_const_plugin_FilterPoint::TEMPLATE_GALLERY, 'org_tubepress_impl_plugin_filters_gallerytemplate_Player'), array(org_tubepress_api_const_plugin_FilterPoint::TEMPLATE_GALLERY, 'org_tubepress_impl_plugin_filters_gallerytemplate_VideoMeta'), array(org_tubepress_api_const_plugin_FilterPoint::TEMPLATE_PLAYER, 'org_tubepress_impl_plugin_filters_playertemplate_CoreVariables'), array(org_tubepress_api_const_plugin_FilterPoint::PROVIDER_RESULT, 'org_tubepress_impl_plugin_filters_providerresult_ResultCountCapper'), array(org_tubepress_api_const_plugin_FilterPoint::PROVIDER_RESULT, 'org_tubepress_impl_plugin_filters_providerresult_VideoBlacklist'), array(org_tubepress_api_const_plugin_FilterPoint::PROVIDER_RESULT, 'org_tubepress_impl_plugin_filters_providerresult_PerPageSorter'), array(org_tubepress_api_const_plugin_FilterPoint::PROVIDER_RESULT, 'org_tubepress_impl_plugin_filters_providerresult_VideoPrepender'), array(org_tubepress_api_const_plugin_FilterPoint::TEMPLATE_SEARCHINPUT, 'org_tubepress_impl_plugin_filters_searchinputtemplate_CoreVariables'), array(org_tubepress_api_const_plugin_FilterPoint::TEMPLATE_SINGLEVIDEO, 'org_tubepress_impl_plugin_filters_singlevideotemplate_CoreVariables'), array(org_tubepress_api_const_plugin_FilterPoint::TEMPLATE_SINGLEVIDEO, 'org_tubepress_impl_plugin_filters_singlevideotemplate_VideoMeta'), array(org_tubepress_api_const_plugin_FilterPoint::VARIABLE_READ_FROM_EXTERNAL_INPUT, 'org_tubepress_impl_plugin_filters_variablereadfromexternalinput_StringMagic'));
     foreach ($expectedSystemFilters as $filter) {
         $pm->shouldReceive('registerFilter')->with($filter[0], anInstanceOf($filter[1]))->once();
     }
     $pm->shouldReceive('registerListener')->with(org_tubepress_api_const_plugin_EventName::BOOT, anInstanceOf('org_tubepress_impl_plugin_listeners_StorageManagerInitListener'));
     $pm->shouldReceive('registerListener')->with(org_tubepress_api_const_plugin_EventName::BOOT, anInstanceOf('org_tubepress_impl_plugin_listeners_WordPressBoot'));
     $pm->shouldReceive('registerListener')->with(org_tubepress_api_const_plugin_EventName::BOOT, anInstanceOf('org_tubepress_impl_plugin_listeners_SkeletonExistsListener'));
     $pm->shouldReceive('notifyListeners')->with(org_tubepress_api_const_plugin_EventName::BOOT)->once();
     $envD = $ioc->get(org_tubepress_api_environment_Detector::_);
     $envD->shouldReceive('isWordPress')->once()->andReturn(false);
     $context = $ioc->get(org_tubepress_api_exec_ExecutionContext::_);
     $context->shouldReceive('get')->with(org_tubepress_api_const_options_names_Advanced::DEBUG_ON)->andReturn(false);
     $fe = $ioc->get(org_tubepress_api_filesystem_Explorer::_);
     $fe->shouldReceive('getDirectoriesInDirectory')->once()->with('<<user-content-dir>>/plugins', anything())->andReturn(array('fakedirectory'));
     $fe->shouldReceive('getFilenamesInDirectory')->once()->with('fakedirectory', anything())->andReturn(array(dirname(__FILE__) . '/../../../resources/simplePhpFile.php'));
     $th = $ioc->get(org_tubepress_api_theme_ThemeHandler::_);
     $th->shouldReceive('getUserContentDirectory')->once()->andReturn('<<user-content-dir>>');
     $sm = $ioc->get(org_tubepress_api_options_StorageManager::_);
     $sm->shouldReceive('init')->once();
     $this->_sut->boot();
 }
示例#7
0
 public function testFormatterImplementsInterfaces()
 {
     $formatter = new MockFormatter();
     assertThat($formatter, is(anInstanceOf(FormatterInterface::class)));
     assertThat($formatter, is(anInstanceOf(ProcessorAwareInterface::class)));
     assertThat($formatter, is(anInstanceOf(FilterAwareInterface::class)));
     assertThat($formatter, is(anInstanceOf(SorterAwareInterface::class)));
 }
示例#8
0
 public function testDispatchNotFoundRoute()
 {
     $dispatcher = new Dispatcher($this->router);
     $response = $dispatcher->dispatch('GET', '/not-found');
     assertThat($response, is(anInstanceOf('Rootr\\Response')));
     assertThat($this->readAttribute($response, 'status'), is(equalTo(404)));
     assertThat($this->readAttribute($response, 'body'), is(equalTo('Not Found')));
 }
示例#9
0
 public function testCreateMessageWithValidator()
 {
     $message = $this->factory->createMessage('bar', ['validator' => function ($msg) {
         return false;
     }]);
     assertThat($message, is(anInstanceOf('Graze\\Queue\\Message\\MessageInterface')));
     assertThat($message->getBody(), is(identicalTo('bar')));
     assertThat($message->isValid(), is(identicalTo(false)));
 }
示例#10
0
 public function testCancelUsurpation()
 {
     $token = $this->mock('Symfony\\Component\\Security\\Core\\Authentication\\Token\\AbstractToken');
     $user = new User();
     $token->shouldReceive('getUser')->once()->andReturn($user);
     $this->om->shouldReceive('refresh')->once()->with($user);
     $this->sc->shouldReceive('setToken')->once()->with(anInstanceOf('Symfony\\Component\\Security\\Core\\Authentication\\Token\\UsernamePasswordToken'));
     $this->getUpdater()->cancelUsurpation($token);
 }
 public function testShouldMonitorExecutionOfFunction()
 {
     $result = monitorExecution(function () {
     });
     assertThat($result->dateStart, anInstanceOf('Datetime'));
     assertThat($result->dateFinish, anInstanceOf('Datetime'));
     assertThat($result->elapsedSeconds, greaterThanOrEqualTo(0));
     assertThat($result->convertSecondsToReadableString(), is('0s'));
     assertThat($result->hasFailed(), is(false));
 }
 public function testDetectCircularDependencies()
 {
     $items = array('item1' => array('deps' => null, 'id' => 'item1'), 'item2' => array('deps' => null, 'id' => 'item2'), 'item3' => array('deps' => array('item2'), 'id' => 'item3'), 'item4' => array('deps' => array('item1', 'item3'), 'id' => 'item4'), 'item5' => array('deps' => array('item4', 'item6', 'item7'), 'id' => 'item5'), 'item6' => array('deps' => array('item2'), 'id' => 'item6'), 'item7' => array('deps' => array('item1', 'item4', 'item5'), 'id' => 'item7'));
     $resolver = new DependencyResolver();
     $resolver->register($items);
     try {
         $resolver->resolveAll();
     } catch (\Exception $e) {
         assertThat($e, is(anInstanceOf('\\RuntimeException')));
     }
 }
 public function testUpdateJob()
 {
     Artisan::call('migrate');
     RangeCronJob::create(['job_name' => 'foobar job', 'last_id_processed' => 1, 'last_status' => 'fooness']);
     $job = $this->repo->findJob('foobar job');
     assertThat($job, anInstanceOf('Giftertipster\\Entity\\Eloquent\\RangeCronJob'));
     $this->repo->updateJob($job, 'test status', 0);
     $updated_job = $this->repo->findJob('foobar job');
     assertThat($updated_job->last_status, identicalTo('test status'));
     assertThat($updated_job->last_id_processed, equalTo(0));
 }
示例#14
0
 public function testAuthenticateSuccess()
 {
     $user = $this->mock('Claroline\\CoreBundle\\Entity\\User');
     $user->shouldReceive('getSalt')->once()->andReturn('salt');
     $user->shouldReceive('getPassword')->once()->andReturn('trueEncodedPw');
     $user->shouldReceive('getRoles')->once()->andReturn(array());
     $encoder = $this->mock('Symfony\\Component\\Security\\Core\\Encoder\\PasswordEncoderInterface');
     $this->userRepo->shouldReceive('loadUserByUsername')->once()->with('name')->andReturn($user);
     $this->encoderFactory->shouldReceive('getEncoder')->andReturn($encoder);
     $encoder->shouldReceive('encodePassword')->once()->with('pw', 'salt')->andReturn('trueEncodedPw');
     $this->sc->shouldReceive('setToken')->with(anInstanceOf('Symfony\\Component\\Security\\Core\\Authentication\\Token\\UsernamePasswordToken'));
     $this->assertTrue($this->authenticator->authenticate('name', 'pw'));
 }
 public function testShouldFormatTraversableAccordingToConvertMethod()
 {
     $items = ['foo', 'bar', 'baz'];
     /** @var Generator **/
     $result = (new MockFormatter())->formatTraversable(new ArrayIterator($items));
     assertThat('The result of `formatTraversable` should be a Generator.', $result, is(anInstanceOf('Generator')));
     /** @var Generator **/
     $result = (new MockFormatter())->formatTraversable(new ArrayIterator($items));
     assertThat('Every item in the result should be an array.', iterator_to_array($result), everyItem(is(typeOf('array'))));
     /** @var Generator **/
     $result = (new MockFormatter())->formatTraversable(new ArrayIterator($items));
     assertThat('The result should be the same size as the number of items passed to `formatTraversable`.', $result, is(traversableWithSize(count($items))));
     /** @var Generator **/
     $result = (new MockFormatter())->formatTraversable(new ArrayIterator($items));
     assertThat('The result should be correctly formatted.', iterator_to_array($result), is(anArray([['count' => 1], ['count' => 2], ['count' => 3]])));
 }
 function testConvert()
 {
     $ioc = org_tubepress_impl_ioc_IocContainer::getInstance();
     $pm = $ioc->get(org_tubepress_api_plugin_PluginManager::_);
     $pm->shouldReceive('hasFilters')->once()->with(org_tubepress_api_const_plugin_FilterPoint::VIDEO)->andReturn(true);
     $pm->shouldReceive('runFilters')->once()->with(org_tubepress_api_const_plugin_FilterPoint::VIDEO, 'one', 'providerrr')->andReturn('modified one');
     $pm->shouldReceive('runFilters')->once()->with(org_tubepress_api_const_plugin_FilterPoint::VIDEO, 'two', 'providerrr')->andReturn('modified two');
     $pc = $ioc->get(org_tubepress_api_provider_ProviderCalculator::_);
     $pc->shouldReceive('calculateCurrentVideoProvider')->once()->andReturn('providerrr');
     $mockChainContext = \Mockery::mock('stdClass');
     $mockChainContext->returnValue = array('one', 'two');
     $chain = $ioc->get(org_tubepress_spi_patterns_cor_Chain::_);
     $chain->shouldReceive('execute')->once()->with(anInstanceOf('stdClass'), array('org_tubepress_impl_factory_commands_YouTubeFactoryCommand', 'org_tubepress_impl_factory_commands_VimeoFactoryCommand'))->andReturn(true);
     $chain->shouldReceive('createContextInstance')->once()->andReturn($mockChainContext);
     $this->assertEquals(array('modified one', 'modified two'), $this->_sut->feedToVideoArray('bla'));
 }
 function testGetHtml()
 {
     $mockTemplate = \Mockery::mock('org_tubepress_api_template_Template');
     $mockTemplate->shouldReceive('toString')->once()->andReturn('templateAsString');
     $mockChainContext = \Mockery::mock('stdClass');
     $mockChainContext->template = $mockTemplate;
     $mockChainContext->dataUrl = 'dataurl';
     $mockChainContext->embeddedImplementationName = 'implname';
     $ioc = org_tubepress_impl_ioc_IocContainer::getInstance();
     $pc = $ioc->get(org_tubepress_api_provider_ProviderCalculator::_);
     $pc->shouldReceive('calculateProviderOfVideoId')->with('videoid')->once()->andReturn('video_provider');
     $chain = $ioc->get(org_tubepress_spi_patterns_cor_Chain::_);
     $chain->shouldReceive('execute')->once()->with(anInstanceOf('stdClass'), array('org_tubepress_impl_embedded_commands_JwFlvCommand', 'org_tubepress_impl_embedded_commands_EmbedPlusCommand', 'org_tubepress_impl_embedded_commands_YouTubeIframeCommand', 'org_tubepress_impl_embedded_commands_VimeoCommand'))->andReturn(true);
     $chain->shouldReceive('createContextInstance')->once()->andReturn($mockChainContext);
     $pm = $ioc->get(org_tubepress_api_plugin_PluginManager::_);
     $pm->shouldReceive('runFilters')->once()->with(org_tubepress_api_const_plugin_FilterPoint::TEMPLATE_EMBEDDED, $mockTemplate, 'videoid', 'video_provider', 'dataurl', 'implname')->andReturn($mockTemplate);
     $pm->shouldReceive('runFilters')->once()->with(org_tubepress_api_const_plugin_FilterPoint::HTML_EMBEDDED, 'templateAsString', 'videoid', 'video_provider', 'implname')->andReturn('final_result');
     $result = $this->_sut->getHtml('videoid');
     $this->assertEquals('final_result', $result);
 }
示例#18
0
 public function testGetCopyrightHighlights()
 {
     $this->testDb->createPlainTables(array(), true);
     $this->testDb->createInheritedTables();
     $uploadDao = M::mock('Fossology\\Lib\\Dao\\UploadDao');
     $uploadDao->shouldReceive('getUploadEntry')->with(1)->andReturn(array('pfile_fk' => 8));
     $uploadDao->shouldReceive('getUploadEntry')->with(2)->andReturn(array('pfile_fk' => 9));
     $copyrightDao = new CopyrightDao($this->dbManager, $uploadDao);
     $noHighlights = $copyrightDao->getHighlights($uploadTreeId = 1);
     assertThat($noHighlights, emptyArray());
     $this->testDb->insertData(array('copyright'));
     $highlights = $copyrightDao->getHighlights($uploadTreeId = 1);
     assertThat($highlights, arrayWithSize(1));
     $highlight0 = $highlights[0];
     assertThat($highlight0, anInstanceOf(Highlight::classname()));
     $this->assertInstanceOf('Fossology\\Lib\\Data\\Highlight', $highlight0);
     assertThat($highlight0->getEnd(), equalTo(201));
     $hilights = $copyrightDao->getHighlights($uploadTreeId = 2);
     assertThat($hilights, arrayWithSize(1));
     $hilight0 = $hilights[0];
     assertThat($hilight0->getStart(), equalTo(0));
 }
 public function testCustomAction()
 {
     $controller = $this->getController(array('checkAccess'));
     $action = 'action';
     $node = $this->mock('Claroline\\CoreBundle\\Entity\\Resource\\ResourceNode');
     $res = $this->mock('Claroline\\CoreBundle\\Entity\\Resource\\AbstractResource');
     $this->resourceManager->shouldReceive('getResourceFromNode')->with($node)->once()->andReturn($res);
     $type = $this->mock('Claroline\\CoreBundle\\Entity\\Resource\\ResourceType');
     $type->shouldReceive('getName')->andReturn('type');
     $node->shouldReceive('getResourceType')->andReturn($type);
     $customActionEvent = $this->mock('Claroline\\CoreBundle\\Event\\CustomActionResourceEvent');
     $menuAction = $this->mock('Claroline\\CoreBundle\\Entity\\Resource\\MenuAction');
     $menuAction->shouldReceive('getValue')->once()->andReturn(42);
     $this->maskManager->shouldReceive('getMenuFromNameAndResourceType')->with($action, $type)->andReturn($menuAction);
     $decoder = $this->mock('Claroline\\CoreBundle\\Entity\\Resource\\MaskDecoder');
     $decoder->shouldReceive('getName')->andReturn('decoderaction');
     $this->maskManager->shouldReceive('getByValue')->once()->with($type, 42)->andReturn($decoder);
     $controller->shouldReceive('checkAccess')->with('decoderaction', anInstanceOf('Claroline\\CoreBundle\\Library\\Resource\\ResourceCollection'));
     $this->dispatcher->shouldReceive('dispatch')->once()->with('action_type', 'CustomActionResource', array($res))->andReturn($customActionEvent);
     $response = new \Symfony\Component\HttpFoundation\Response();
     $customActionEvent->shouldReceive('getResponse')->andReturn($response);
     $this->assertEquals($response->getContent(), $controller->customAction('action', $node)->getContent());
     $this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\Response', $controller->customAction('action', $node));
 }
示例#20
0
 public function testDecribesActualClassInMismatchMessage()
 {
     $this->assertMismatchDescription('[Hamcrest_Core_SampleBaseClass] <good>', anInstanceOf('Hamcrest_Core_SampleSubClass'), $this->_baseClassInstance);
 }
 public function testRunReturnsFalseWithErrorsWhenResponseIsNotValidated()
 {
     $this->ConfigMock->shouldReceive('setCountry')->andReturn($this->ConfigMock);
     $this->ConfigMock->shouldReceive('setAccessKey')->andReturn($this->ConfigMock);
     $this->ConfigMock->shouldReceive('setSecretKey')->andReturn($this->ConfigMock);
     $this->ConfigMock->shouldReceive('setAssociateTag')->andReturn($this->ConfigMock);
     $this->ApaiIOMock->shouldReceive('runOperation')->once()->andReturn('<xml>foo</xml>');
     $SearchOperationMock = Mockery::mock('ApaiIO\\Operations\\Search');
     $this->app->instance('ApaiIO\\Configuration\\GenericConfiguration', $this->ConfigMock);
     $this->app->instance('ApaiIO\\ApaiIO', $this->ApaiIOMock);
     $response_validator_mock = Mockery::mock('Giftertipster\\Service\\Api\\AmzProductApi\\ResponseValidationInterface');
     $response_validator_mock->shouldReceive('validate')->with(anInstanceOf('\\SimpleXMLElement'))->andReturn(false);
     $response_validator_mock->shouldReceive('errors')->once()->andReturn(['errors stub']);
     $this->app->instance('Giftertipster\\Service\\Api\\AmzProductApi\\ResponseValidationInterface', $response_validator_mock);
     $Repository = $this->app->make('Giftertipster\\Service\\Api\\AmzProductApi\\ApaiIO\\ApaiIOAmzProductApi');
     $Response = $Repository->run($SearchOperationMock);
     $errors = $Repository->errors();
     assertThat($Response, identicalTo(false));
     assertThat($errors, identicalTo(['errors stub']));
 }
示例#22
0
 /** @dataProvider provideDates */
 public function testShouldExtractPartOfDate($unit, $expectedDate)
 {
     $today = new Today();
     assertThat($today->date, anInstanceOf('DateTime'));
     assertThat($today->{$unit}, is(date($expectedDate)));
 }
 public function testConstructAndSanity()
 {
     $uploadBrowseProxy = new UploadBrowseProxy($this->groupId, UserDao::USER, $this->testDb->getDbManager(), true);
     assertThat($uploadBrowseProxy, is(anInstanceOf(UploadBrowseProxy::classname())));
 }
示例#24
0
 public function testCreateWithPatternBuilder()
 {
     $patternBuilder = \Mockery::mock('Rootr\\PatternBuilder');
     $router = new Router($patternBuilder);
     assertThat($router, is(anInstanceOf('Rootr\\Router')));
 }
示例#25
0
 public function testGetSingleVideo()
 {
     $val = array($this->_fakeVideo);
     $this->_setupSingleVideoMocks($val);
     $ioc = org_tubepress_impl_ioc_IocContainer::getInstance();
     $pc = $ioc->get(org_tubepress_api_provider_ProviderCalculator::_);
     $pc->shouldReceive('calculateProviderOfVideoId')->with('video-id')->andReturn('video-provider');
     $pm = $ioc->get(org_tubepress_api_plugin_PluginManager::_);
     $pm->shouldReceive('runFilters')->with(org_tubepress_api_const_plugin_FilterPoint::PROVIDER_RESULT, anInstanceOf('org_tubepress_api_provider_ProviderResult'), 'video-provider')->once();
     $this->assertEquals($this->_fakeVideo, $this->_sut->getSingleVideo('video-id'));
 }
示例#26
0
 public function testGetPreviousItemWithMultipleFiles()
 {
     $subentries = $this->getSubentriesForMultipleFiles();
     $this->prepareModularTable($subentries);
     $nextItem = $this->uploadDao->getPreviousItem(1, 6);
     assertThat($nextItem, anInstanceOf(Item::classname()));
     assertThat($nextItem->getId(), is(8));
 }
 /**
  * @expectedException \RuntimeException
  */
 public function testSandboxMultiResponseException()
 {
     // [1] Check basic multiResponse with one response by params
     $request = new ParameterBag(['some_parameter' => 3, 'some_parameter2' => 4]);
     $query = new ParameterBag();
     $rawRequest = new ArrayCollection();
     $object = new testObject();
     $method = 'annotatedResponseFunction';
     $annotationsReader = ShortifyPunit::mock('Doctrine\\Common\\Annotations\\AnnotationReader');
     $responseObj = new \StdClass();
     $responseObj->parameters = [['name' => 'some_parameter', 'required' => true]];
     $responseObj->type = 'json';
     $responseObj->responseCode = 200;
     $responseObj->multiResponse = [['resource' => '@SandboxBundle/Resources/responses/token.json']];
     ShortifyPunit::when($annotationsReader)->getMethodAnnotation(anInstanceOf('ReflectionMethod'), 'danrevah\\SandboxBundle\\Annotation\\ApiSandboxResponse')->returns(false);
     ShortifyPunit::when($annotationsReader)->getMethodAnnotation(anInstanceOf('ReflectionMethod'), 'danrevah\\SandboxBundle\\Annotation\\ApiSandboxMultiResponse')->returns($responseObj);
     $sandboxResponseManager = $this->createManager(true, $annotationsReader);
     $sandboxResponseManager->getResponseController($object, $method, $request, $query, $rawRequest);
 }
示例#28
0
 public function testReceiveMessageWaitTimeSecondsOption()
 {
     $options = ['ReceiveMessageWaitTimeSeconds' => 20];
     $adapter = new SqsAdapter($this->client, 'foo', $options);
     $url = $this->stubCreateQueue('foo', $options);
     $timeout = $this->stubQueueVisibilityTimeout($url);
     $this->stubCreateDequeueMessage('foo', 0, 'a');
     $this->stubCreateDequeueMessage('bar', 1, 'b');
     $this->stubCreateDequeueMessage('baz', 2, 'c');
     $this->model->shouldReceive('get')->once()->with('Messages')->andReturn([['Body' => 'foo', 'Attributes' => [], 'MessageAttributes' => [], 'MessageId' => 0, 'ReceiptHandle' => 'a'], ['Body' => 'bar', 'Attributes' => [], 'MessageAttributes' => [], 'MessageId' => 1, 'ReceiptHandle' => 'b'], ['Body' => 'baz', 'Attributes' => [], 'MessageAttributes' => [], 'MessageId' => 2, 'ReceiptHandle' => 'c']]);
     $this->client->shouldReceive('receiveMessage')->once()->with(['QueueUrl' => $url, 'AttributeNames' => ['All'], 'MaxNumberOfMessages' => 3, 'VisibilityTimeout' => $timeout, 'WaitTimeSeconds' => 20])->andReturn($this->model);
     $iterator = $adapter->dequeue($this->factory, 3);
     assertThat($iterator, is(anInstanceOf('Generator')));
     assertThat(iterator_to_array($iterator), is(equalTo($this->messages)));
 }
示例#29
0
 public function testShouldInitalize()
 {
     $dataValidator = new DataValidator();
     assertThat('`Graze\\DataValidator\\DataValidator` should implement `Graze\\DataValidator\\DataValidatorInterface`.', $dataValidator, is(anInstanceOf(DataValidatorInterface::class)));
 }
示例#30
0
 public function testRelevantClearingEvents()
 {
     $groupId = 701;
     $this->buildProposals(array(array(301, 1, $groupId, 401, false, -99), array(301, 2, $groupId, 402, true, -98), array(301, 2, $groupId, 401, true, -97)), $firstEventId = 0);
     $this->buildDecisions(array(array(301, 1, $groupId, DecisionTypes::IDENTIFIED, -90, DecisionScopes::REPO, array($firstEventId, $firstEventId + 1, $firstEventId + 2))));
     $itemTreeBounds = M::mock(ItemTreeBounds::classname());
     $itemTreeBounds->shouldReceive('getItemId')->andReturn(301);
     $itemTreeBounds->shouldReceive('getUploadTreeTableName')->andReturn('uploadtree');
     $itemTreeBounds->shouldReceive('containsFiles')->andReturn(false);
     $itemTreeBounds->shouldReceive('getUploadId')->andReturn($this->items[301][0]);
     $itemTreeBounds->shouldReceive('getLeft')->andReturn($this->items[301][4]);
     $itemTreeBounds->shouldReceive('getRight')->andReturn($this->items[301][5]);
     $events1 = $this->clearingDao->getRelevantClearingEvents($itemTreeBounds, $groupId);
     assertThat($events1, arrayWithSize(2));
     assertThat($events1, hasKeyInArray(401));
     assertThat($events1, hasKeyInArray(402));
     assertThat($events1[401], is(anInstanceOf(ClearingEvent::classname())));
     assertThat($events1[402]->getEventId(), is($firstEventId + 1));
     assertThat($events1[401]->getEventId(), is($firstEventId + 2));
 }