コード例 #1
0
 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();
 }
コード例 #2
0
 public function testOnKernelController()
 {
     $request = ShortifyPunit::mock('Symfony\\Component\\HttpFoundation\\Request');
     $requestStack = ShortifyPunit::mock('Symfony\\Component\\HttpFoundation\\RequestStack');
     $sandboxResponseManager = ShortifyPunit::mock('danrevah\\SandboxBundle\\Managers\\SandboxResponseManager');
     $event = ShortifyPunit::mock('Symfony\\Component\\HttpKernel\\Event\\FilterControllerEvent');
     $parameterBag = ShortifyPunit::mock('Symfony\\Component\\HttpFoundation\\ParameterBag');
     ShortifyPunit::when($request)->getContent()->returns('');
     $request->query = $parameterBag;
     $request->request = $parameterBag;
     ShortifyPunit::when($requestStack)->getCurrentRequest()->returns($request);
     ShortifyPunit::when($event)->getController()->returns([0, 1]);
     ShortifyPunit::when($event)->setController(anything())->returns(1);
     $sandboxListener = new SandboxListener($requestStack, $sandboxResponseManager);
     $sandboxListener->onKernelController($event);
     $this->assertTrue(ShortifyPunit::verify($event)->setController(anything())->atLeastOnce());
     $response = [false, 0, 0, 0];
     ShortifyPunit::when($sandboxResponseManager)->getResponseController(anything(), anything(), anything(), anything(), anything())->returns($response);
     $event2 = ShortifyPunit::mock('Symfony\\Component\\HttpKernel\\Event\\FilterControllerEvent');
     ShortifyPunit::when($event2)->setController(anything())->returns('');
     ShortifyPunit::when($event2)->getController(anything())->returns([0, 1]);
     $sandboxListener = new SandboxListener($requestStack, $sandboxResponseManager);
     $sandboxListener->onKernelController($event2);
     $this->assertTrue(ShortifyPunit::verify($event2)->setController(anything())->neverCalled());
 }
コード例 #3
0
 public function testDelegatesMatchingToAnotherMatcher()
 {
     $m1 = describedAs('irrelevant', anything());
     $m2 = describedAs('irrelevant', not(anything()));
     $this->assertTrue($m1->matches(new \stdClass()));
     $this->assertFalse($m2->matches('hi'));
 }
コード例 #4
0
 protected function prepareShowFolderTree($parentFolderId = 'parentFolderId')
 {
     $this->folderDao->shouldReceive('getFolderTreeCte')->with($parentFolderId)->andReturn($parentFolderId . 'Cte');
     $this->dbManager->shouldReceive('prepare')->withArgs(array(anything(), startsWith($parentFolderId . 'Cte')));
     $this->dbManager->shouldReceive('execute')->withArgs(array(anything(), array($parentFolderId)))->andReturn($res = $parentFolderId . 'Res');
     $this->dbManager->shouldReceive('freeResult')->with($res);
     return $res;
 }
コード例 #5
0
 /**
  * @test
  */
 function it_when_a_user_forgets_their_password_it_reset_and_they_are_notified()
 {
     $gateway = m::mock('OceanCrest\\UserGateway');
     $gateway->shouldReceive('getUserByEmail')->with('*****@*****.**')->andReturn(5)->once();
     $gateway->shouldReceive('updatePassword')->with(5, anything())->andReturn(true)->once();
     $transaction = new UserTransactions($gateway);
     $result = $transaction->resetPassword('*****@*****.**');
     $this->assertTrue($result);
     $this->assertCount(0, $transaction->getErrors());
 }
コード例 #6
0
 public function testDoesAutoCommitOnEvery100StashedTranslations()
 {
     $connection = m::mock('Doctrine\\CouchDB\\HTTP\\Client');
     $connection->shouldReceive('request')->with('POST', '/fake_db_name/_design/main/_view/find?', anything())->andReturn(new Response(200, array(), array('rows' => array()), true));
     $connection->shouldReceive('request')->with('POST', '/fake_db_name/_bulk_docs', m::any())->twice();
     $storage = self::storage(m::mock(self::couchDb($connection), array('getAllDatabases' => array('fake_db_name'))));
     for ($i = 0; $i < 201; $i++) {
         $storage->ensurePresence(self::yesString());
     }
 }
コード例 #7
0
 /**
  * @test
  * @runInSeparateProcess
  * @preserveGlobalState disabled
  * @covers ::part2
  * @covers ::getCircuit
  */
 public function solutionPart2()
 {
     $wireA = \Mockery::mock('\\Hamdrew\\AdventOfCode\\Day7\\Wire')->shouldReceive('getSignal')->andReturn(123)->getMock();
     $wireB = \Mockery::mock('\\Hamdrew\\AdventOfCode\\Day7\\Wire')->shouldReceive('getSignal')->getMock();
     $wireB->shouldReceive('setSource');
     $this->container->set(InputProvider::class, \Mockery::mock('alias:\\Hamdrew\\AdventOfCode\\InputProvider')->shouldReceive('getInputFromFileForDay')->with(7)->once()->getMock());
     \Mockery::mock('alias:\\Hamdrew\\AdventOfCode\\Day7\\CircuitInstructionParser')->shouldReceive('parse');
     $searchService = \Mockery::mock('alias:\\Hamdrew\\AdventOfCode\\Day7\\CircuitSearchService')->shouldReceive('findWireByName')->with(anything(), 'b')->andReturn($wireB)->getMock();
     $searchService->shouldReceive('findWireByName')->with(anything(), 'a')->andReturn($wireA);
     $this->assertSame('123', $this->container->get(SolutionDay7::class)->part2());
 }
コード例 #8
0
 public function setUp()
 {
     parent::setUp();
     Injector::nest();
     // Check dependencies
     if (!class_exists('Phockito')) {
         $this->skipTest = true;
         return $this->markTestSkipped("These tests need the Phockito module installed to run");
     }
     // Mock link checker
     $checker = Phockito::mock('LinkChecker');
     Phockito::when($checker)->checkLink('http://www.working.com')->return(200);
     Phockito::when($checker)->checkLink('http://www.broken.com/url/thing')->return(404);
     Phockito::when($checker)->checkLink('http://www.broken.com')->return(403);
     Phockito::when($checker)->checkLink('http://www.nodomain.com')->return(0);
     Phockito::when($checker)->checkLink('/internal/link')->return(null);
     Phockito::when($checker)->checkLink('[sitetree_link,id=9999]')->return(null);
     Phockito::when($checker)->checkLink('home')->return(null);
     Phockito::when($checker)->checkLink('broken-internal')->return(null);
     Phockito::when($checker)->checkLink('[sitetree_link,id=1]')->return(null);
     Phockito::when($checker)->checkLink(anything())->return(404);
     Injector::inst()->registerService($checker, 'LinkChecker');
 }
コード例 #9
0
 public function testHandleCsv()
 {
     $dbManager = M::mock(DbManager::classname());
     $licenseCsvImport = new LicenseCsvImport($dbManager);
     Reflectory::invokeObjectsMethodnameWith($licenseCsvImport, 'handleCsv', array(array('shortname', 'foo', 'text', 'fullname', 'notes')));
     assertThat(Reflectory::getObjectsProperty($licenseCsvImport, 'headrow'), is(notNullValue()));
     $dbManager->shouldReceive('getSingleRow')->with('SELECT rf_shortname,rf_source,rf_pk,rf_risk FROM license_ref WHERE rf_md5=md5($1)', anything())->andReturn(false);
     $dbManager->shouldReceive('prepare');
     $dbManager->shouldReceive('execute');
     $dbManager->shouldReceive('freeResult');
     $dbManager->shouldReceive('fetchArray')->andReturn(array('rf_pk' => 101, 'rf_risk' => 1));
     Reflectory::setObjectsProperty($licenseCsvImport, 'nkMap', array('licA' => false));
     Reflectory::invokeObjectsMethodnameWith($licenseCsvImport, 'handleCsv', array(array('licA', 'bar', 'txA', 'liceA', 'noteA')));
     assertThat(Reflectory::getObjectsProperty($licenseCsvImport, 'nkMap'), is(array('licA' => 101)));
 }
コード例 #10
0
 function testCanStubTypeHintedMethodsByPassingOnlyMockIntoWhen()
 {
     $mock = Phockito::mock('PhockitoHamcrestTest_MockMe');
     Phockito::when($mock)->Baz(anything())->return('PassMe');
     $this->assertEquals($mock->Baz(new PhockitoHamcrestTest_PassMe()), 'PassMe');
 }
コード例 #11
0
 function testHighlightQueryOnBoost()
 {
     $serviceMock = $this->getServiceMock();
     Phockito::when($serviceMock)->search(anything(), anything(), anything(), anything(), anything())->return($this->getFakeRawSolrResponse());
     $index = new SolrIndexTest_FakeIndex();
     $index->setService($serviceMock);
     // Search without highlighting
     $query = new SearchQuery();
     $query->search('term', null, array('Field1' => 1.5, 'HasOneObject_Field1' => 3));
     $index->search($query);
     Phockito::verify($serviceMock)->search('+(Field1:term^1.5 OR HasOneObject_Field1:term^3)', anything(), anything(), not(hasKeyInArray('hl.q')), anything());
     // Search with highlighting
     $query = new SearchQuery();
     $query->search('term', null, array('Field1' => 1.5, 'HasOneObject_Field1' => 3));
     $index->search($query, -1, -1, array('hl' => true));
     Phockito::verify($serviceMock)->search('+(Field1:term^1.5 OR HasOneObject_Field1:term^3)', anything(), anything(), hasKeyInArray('hl.q'), anything());
 }
コード例 #12
0
 /**
  * Executing service description defined operations returns the result
  * @group unit
  */
 public function testMagicOperationsReturnResult()
 {
     $responseData = array("this" => "that");
     Phockito::when($this->mockResponse->getStatusCode())->return(200);
     Phockito::when($this->mockResponse->json())->return($this->testDescription);
     Phockito::when($this->mockRequest->send())->return($this->mockResponse);
     Phockito::when($this->client)->get(anything())->return($this->mockRequest);
     Phockito::when($this->client)->callParent(anything(), anything())->return($responseData);
     $result = $this->client->SomeOperation(array());
     $this->assertEquals($result, $responseData);
 }
コード例 #13
0
 protected function createMatcher()
 {
     return \Hamcrest\Core\DescribedAs::describedAs('irrelevant', anything());
 }
コード例 #14
0
 public function testHamcrestEnabled()
 {
     $this->assertTrue(anything() instanceof \Hamcrest_Matcher);
 }
コード例 #15
0
 /**
  * Test that running all groups covers the entire range of dataobject IDs
  */
 public function testRunAllGroups()
 {
     $this->createDummyData(120);
     $logger = new SolrReindexTest_RecordingLogger();
     // Test that running all groups covers the complete set of ids
     $state = array('SolrReindexTest_Variant' => '1');
     for ($i = 0; $i < 6; $i++) {
         // See testReindexSegmentsGroups for test that each of these states is invoked during a full reindex
         $this->getHandler()->runGroup($logger, $this->index, $state, 'SolrReindexTest_Item', 6, $i);
     }
     // Count all ids updated
     $ids = array();
     foreach ($logger->filterMessages('Updated ') as $message) {
         $this->assertNotEmpty(preg_match('/^Updated (?<ids>[,\\d]+)/', $message, $matches));
         $ids = array_unique(array_merge($ids, explode(',', $matches['ids'])));
     }
     // Check ids
     $this->assertEquals(120, count($ids));
     Phockito::verify($this->service, 6)->deleteByQuery(anything());
     Phockito::verify($this->service, 1)->deleteByQuery('+(ClassHierarchy:SolrReindexTest_Item) +_query_:"{!frange l=0 u=0}mod(ID, 6)" +(_testvariant:"1")');
     Phockito::verify($this->service, 1)->deleteByQuery('+(ClassHierarchy:SolrReindexTest_Item) +_query_:"{!frange l=1 u=1}mod(ID, 6)" +(_testvariant:"1")');
     Phockito::verify($this->service, 1)->deleteByQuery('+(ClassHierarchy:SolrReindexTest_Item) +_query_:"{!frange l=2 u=2}mod(ID, 6)" +(_testvariant:"1")');
     Phockito::verify($this->service, 1)->deleteByQuery('+(ClassHierarchy:SolrReindexTest_Item) +_query_:"{!frange l=3 u=3}mod(ID, 6)" +(_testvariant:"1")');
     Phockito::verify($this->service, 1)->deleteByQuery('+(ClassHierarchy:SolrReindexTest_Item) +_query_:"{!frange l=4 u=4}mod(ID, 6)" +(_testvariant:"1")');
     Phockito::verify($this->service, 1)->deleteByQuery('+(ClassHierarchy:SolrReindexTest_Item) +_query_:"{!frange l=5 u=5}mod(ID, 6)" +(_testvariant:"1")');
 }
コード例 #16
0
 public function testMyJobs()
 {
     $groupId = 2;
     $GLOBALS['SysConf']['auth'][Auth::GROUP_ID] = $groupId;
     $GLOBALS['SysConf']['auth'][Auth::USER_ID] = 1;
     $this->uploadPermissionDao->shouldReceive('isAccessible')->withArgs(array(anything(), $groupId))->andReturnUsing(function ($upload, $group) {
         return $upload == 1 || $upload == 2 || $upload == 4;
     });
     $testOurJobs = $this->showJobsDao->myJobs(true);
     assertThat($testOurJobs, is(arrayContainingInAnyOrder($this->job_pks)));
     $testMyJobs = $this->showJobsDao->myJobs(false);
     assertThat($testMyJobs, equalTo(array(1)));
     $this->dbManager->queryOnce("UPDATE job SET job_queued=job_queued-INTERVAL '30 days' WHERE job_pk=1");
     $this->dbManager->prepare(__METHOD__ . 'insert.perm_upload', "INSERT INTO perm_upload (perm_upload_pk, perm, upload_fk, group_fk) VALUES (\$1, \$2, \$3, \$4)");
     $testOutdatedJobs = $this->showJobsDao->myJobs(true);
     assertThat($testOutdatedJobs, equalTo(array(2)));
 }
コード例 #17
0
 public function testCrawlerRespectsDatabaseContents()
 {
     $storage = m::mock();
     $storage->shouldReceive('ensurePresence')->with(anything())->atLeast(4);
     self::crawler($storage)->collectTranslations(array(vfsStream::url('templates')), '.html');
 }
コード例 #18
0
ファイル: BaseServiceTest.php プロジェクト: grimmlink/podata
 public function testRegisterWritersV3()
 {
     /** @var BaseService $service */
     $service = Phockito::spy('\\POData\\BaseService');
     $service->setHost($this->mockHost);
     //TODO: have to do this since the registry & config is actually only instantiated during a handleRequest
     //will change this once that request pipeline is cleaned up
     Phockito::when($service->getODataWriterRegistry())->return($this->mockRegistry);
     $fakeConfig = new ServiceConfiguration($this->mockMetaProvider);
     $fakeConfig->setMaxDataServiceVersion(ProtocolVersion::V3());
     Phockito::when($service->getConfiguration())->return($fakeConfig);
     //fake the service url
     $fakeUrl = "http://host/service.svc/Collection";
     Phockito::when($this->mockHost->getAbsoluteServiceUri())->return(new Url($fakeUrl));
     Phockito::verify($this->mockRegistry, 0)->register(anything());
     //nothing should be registered at first
     $service->registerWriters();
     //only 2 writers for v1
     Phockito::verify($this->mockRegistry, 6)->register(anything());
     Phockito::verify($this->mockRegistry, 1)->register(anInstanceOf('\\POData\\Writers\\Atom\\AtomODataWriter'));
     Phockito::verify($this->mockRegistry, 5)->register(anInstanceOf('\\POData\\Writers\\Json\\JsonODataV1Writer'));
     //since v2 & light derives from this,,it's 1+1+3 times
     Phockito::verify($this->mockRegistry, 4)->register(anInstanceOf('\\POData\\Writers\\Json\\JsonODataV2Writer'));
     //since light derives from this it's 1+3 times
     Phockito::verify($this->mockRegistry, 3)->register(anInstanceOf('\\POData\\Writers\\Json\\JsonLightODataWriter'));
 }
コード例 #19
0
 public function testDeciderScanWithTwoEventAndNoAgentShouldMakeADecision()
 {
     $this->setUpTables();
     $this->setUpRepo();
     $dbManager = M::mock(DbManager::classname());
     $agentDao = M::mock(AgentDao::classname());
     $clearingDao = M::mock(ClearingDao::classname());
     $uploadDao = M::mock(UploadDao::classname());
     $highlightDao = M::mock(HighlightDao::classname());
     $decisionProcessor = M::mock(ClearingDecisionProcessor::classname());
     $agentLicenseEventProcessor = M::mock(AgentLicenseEventProcessor::classname());
     $uploadId = 13243;
     /*mock for Agent class **/
     $agentDao->shouldReceive('arsTableExists')->andReturn(true);
     $agentDao->shouldReceive('getCurrentAgentId')->andReturn($agentId = 24);
     $agentDao->shouldReceive('writeArsRecord')->with(anything(), $agentId, $uploadId)->andReturn($arsId = 2);
     $agentDao->shouldReceive('writeArsRecord')->with(anything(), $agentId, $uploadId, $arsId, true)->andReturn(0);
     $jobId = 42;
     $groupId = 6;
     $userId = 2;
     $itemIds = array(4343, 43);
     $bounds0 = M::mock(ItemTreeBounds::classname());
     $bounds0->shouldReceive('getItemId')->andReturn($itemIds[0]);
     $bounds0->shouldReceive('containsFiles')->andReturn(false);
     $bounds1 = M::mock(ItemTreeBounds::classname());
     $bounds1->shouldReceive('getItemId')->andReturn($itemIds[1]);
     $bounds1->shouldReceive('containsFiles')->andReturn(false);
     $bounds = array($bounds0, $bounds1);
     $uploadDao->shouldReceive('getItemTreeBounds')->with($itemIds[0])->andReturn($bounds[0]);
     $uploadDao->shouldReceive('getItemTreeBounds')->with($itemIds[1])->andReturn($bounds[1]);
     $clearingDao->shouldReceive('getEventIdsOfJob')->with($jobId)->andReturn(array($itemIds[0] => array(), $itemIds[1] => array()));
     $dbManager->shouldReceive('begin')->times(count($itemIds));
     $dbManager->shouldReceive('commit')->times(count($itemIds));
     /* dummy expectations needed for unmockable LicenseMap constructor */
     $dbManager->shouldReceive('prepare');
     $res = M::Mock(DbManager::classname());
     $dbManager->shouldReceive('execute')->andReturn($res);
     $row1 = array('rf_fk' => 2334, 'parent_fk' => 1);
     $row2 = array('rf_fk' => 2333, 'parent_fk' => 1);
     $dbManager->shouldReceive('fetchArray')->with($res)->andReturn($row1, $row2, false);
     $dbManager->shouldReceive('freeResult')->with($res);
     /* /expectations for LicenseMap */
     $decisionProcessor->shouldReceive('hasUnhandledScannerDetectedLicenses')->with($bounds0, $groupId, array(), anything())->andReturn(true);
     $clearingDao->shouldReceive('markDecisionAsWip')->with($itemIds[0], $userId, $groupId);
     $decisionProcessor->shouldReceive('hasUnhandledScannerDetectedLicenses')->with($bounds1, $groupId, array(), anything())->andReturn(false);
     $decisionProcessor->shouldReceive('makeDecisionFromLastEvents')->with($bounds1, $userId, $groupId, DecisionTypes::IDENTIFIED, false, array());
     $runner = new SchedulerTestRunnerMock($dbManager, $agentDao, $clearingDao, $uploadDao, $highlightDao, $decisionProcessor, $agentLicenseEventProcessor);
     list($success, $output, $retCode) = $runner->run($uploadId, $userId, $groupId, $jobId, $args = "");
     $this->assertTrue($success, 'cannot run decider');
     $this->assertEquals($retCode, 0, 'decider failed: ' . $output);
     assertThat($this->getHeartCount($output), equalTo(count($itemIds)));
     $this->rmRepo();
 }
コード例 #20
0
 protected function createMatcher()
 {
     return \Hamcrest\Core\Every::everyItem(anything());
 }
コード例 #21
0
ファイル: testRouter.php プロジェクト: tagged/kleinbottle
 public function testActionMethods()
 {
     $this->mockController();
     $response = $this->router->routeRequest('/routing/test/5/tests/custom', 'POST');
     Phockito::verify($this->controller)->custom(anything(), anything());
     Phockito::reset($this->controller);
     $this->assertEquals($response->body(), '{"action":"custom","var":"5","var2":null}');
     $response = $this->router->routeRequest('/routing/nested/5/child/70/tests/custom', 'POST');
     Phockito::verify($this->controller)->custom(anything(), anything());
     $this->assertEquals($response->body(), '{"action":"custom","var":"5","var2":"70"}');
 }
コード例 #22
0
 /**
  * Testing with Hamcrest matching functions
  */
 public function testWithHamcrestMatcher()
 {
     $mock = ShortifyPunit::mock('Foo');
     ShortifyPunit::when($mock)->bar(equalTo(1))->foo(anything())->returns(10);
     $this->assertTrue(ShortifyPunit::verify($mock)->bar(1)->foo(2)->neverCalled());
     $this->assertTrue(ShortifyPunit::verify($mock)->bar(1)->foo(2)->atLeast(0));
     $this->assertTrue(ShortifyPunit::verify($mock)->bar(1)->foo(2)->calledTimes(0));
     $this->assertTrue(ShortifyPunit::verify($mock)->bar(1)->foo(2)->lessThan(1));
     $this->assertFalse(ShortifyPunit::verify($mock)->bar(1)->foo(2)->atLeastOnce());
     $mock->bar(1)->foo(2);
     $this->assertFalse(ShortifyPunit::verify($mock)->bar(1)->foo(2)->neverCalled());
     $this->assertTrue(ShortifyPunit::verify($mock)->bar(1)->foo(2)->atLeast(1));
     $this->assertTrue(ShortifyPunit::verify($mock)->bar(1)->foo(2)->atLeastOnce());
     $this->assertTrue(ShortifyPunit::verify($mock)->bar(1)->foo(2)->calledTimes(1));
     $this->assertTrue(ShortifyPunit::verify($mock)->bar(1)->foo(2)->lessThan(2));
     $this->assertFalse(ShortifyPunit::verify($mock)->bar(1)->foo(2)->atLeast(2));
     $this->assertFalse(ShortifyPunit::verify($mock)->bar(1)->foo(2)->calledTimes(2));
     $this->assertFalse(ShortifyPunit::verify($mock)->bar(1)->foo(2)->lessThan(1));
 }
コード例 #23
0
/*
Copyright (C) 2015, Siemens AG

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
version 2 as published by the Free Software Foundation.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/
namespace Fossology\Decider;

use Mockery as M;
$deciderPlugin = M::mock();
//'Fossology\\DeciderJob\\UI\\DeciderJobAgentPlugin');
$deciderPlugin->shouldReceive('AgentAdd')->withArgs(array(16, 2, anything(), arrayWithSize(1)))->once();
$GLOBALS['xyyzzzDeciderJob'] = $deciderPlugin;
function plugin_find($x)
{
    return $GLOBALS['xyyzzzDeciderJob'];
}
function IsAlreadyScheduled($jobId, $agentName, $uploadId)
{
    return 177;
}
コード例 #24
0
 public function it_logs_the_cancellation_of_a_transaction()
 {
     $transaction = $this->getTransactionInterfaceMock();
     $transaction->shouldReceive('cancel')->with(anything())->once()->andReturn($expected);
     $logger = $this->getLoggerMock();
     $logger->shouldReceive('info')->once();
     $dragonpay = new DragonpayApi(array_merge($this->getMerchantCredentials(), $this->getLoggingConfig()), null, $transaction, $logger);
     $dragonpay->cancel([]);
 }
コード例 #25
0
ファイル: IsAnythingTest.php プロジェクト: cruni505/prestomed
 public function testCanOverrideDescription()
 {
     $description = 'description';
     $this->assertDescription($description, anything($description));
 }
 /**
  * Test that reindex will generate a top top level queued job, and executing this will perform
  * the necessary initialisation of the grouped queued jobs
  */
 public function testReindexSegmentsGroups()
 {
     $this->createDummyData(18);
     // Create pre-existing jobs
     $this->getQueuedJobService()->queueJob(new SolrReindexQueuedJob());
     $this->getQueuedJobService()->queueJob(new SolrReindexGroupQueuedJob());
     $this->getQueuedJobService()->queueJob(new SolrReindexGroupQueuedJob());
     // Initiate re-index
     $logger = new SolrReindexTest_RecordingLogger();
     $this->getHandler()->triggerReindex($logger, 6, 'Solr_Reindex');
     // Old jobs should be cancelled
     $this->assertEquals(1, $logger->countMessages('Cancelled 1 re-index tasks and 2 re-index groups'));
     $this->assertEquals(1, $logger->countMessages('Queued Solr Reindex Job'));
     // Next job should be queue job
     $job = $this->getQueuedJobService()->getNextJob();
     $this->assertInstanceOf('SolrReindexQueuedJob', $job);
     $this->assertEquals(6, $job->getBatchSize());
     // Test that necessary items are created
     $logger->clear();
     $job->setLogger($logger);
     $job->process();
     // Deletes are performed in the main task prior to individual groups being processed
     // 18 records means 3 groups of 6 in each variant (6 total)
     Phockito::verify($this->service, 2)->deleteByQuery(anything());
     $this->assertEquals(1, $logger->countMessages('Beginning init of reindex'));
     $this->assertEquals(6, $logger->countMessages('Queued Solr Reindex Group '));
     $this->assertEquals(3, $logger->countMessages(' of SolrReindexTest_Item in {"SolrReindexTest_Variant":"0"}'));
     $this->assertEquals(3, $logger->countMessages(' of SolrReindexTest_Item in {"SolrReindexTest_Variant":"1"}'));
     $this->assertEquals(1, $logger->countMessages('Completed init of reindex'));
     // Test that invalid classes are removed
     $this->assertNotEmpty($logger->getMessages('Clearing obsolete classes from SolrReindexTest_Index'));
     Phockito::verify($this->service, 1)->deleteByQuery('-(ClassHierarchy:SolrReindexTest_Item)');
     // Test that valid classes in invalid variants are removed
     $this->assertNotEmpty($logger->getMessages('Clearing all records of type SolrReindexTest_Item in the current state: {"SolrReindexTest_Variant":"2"}'));
     Phockito::verify($this->service, 1)->deleteByQuery('+(ClassHierarchy:SolrReindexTest_Item) +(_testvariant:"2")');
 }
 public function testDoesNotMatchNull()
 {
     $this->assertMismatchDescription('was null', hasKeyValuePair(anything(), anything()), null);
 }
コード例 #28
0
 /**
  * Hamcrest API with normal parameters caused problems
  * Bug Fix in - v1.0.6
  */
 public function testHamcrestWithNormalParam()
 {
     $mock = ShortifyPunit::mock('SimpleClassForMocking');
     ShortifyPunit::when($mock)->first_method(anything(), 'a')->returns(1);
     ShortifyPunit::when($mock)->first_method(anything(), 'b')->returns(2);
     $this->assertEquals($mock->first_method('anything...', 'a'), 1);
     $this->assertEquals($mock->first_method('anything...', 'b'), 2);
 }
コード例 #29
0
 /** Just a quickie roundup of a few Hamcrest matchers to check nothing obvious out of place **/
 public function testAnythingConstraintMatchesArgument()
 {
     $this->mock->shouldReceive('foo')->with(anything())->once();
     $this->mock->foo(2);
     $this->container->mockery_verify();
 }
コード例 #30
0
 function testInsertTableRowReturning()
 {
     $this->driver->shouldReceive('insertPreparedAndReturn')->withArgs(array(anything(), '/insert into europe \\(animal\\) values \\(\\$1\\)/i', array('mouse'), 'id'))->andReturnUsing(function ($stmt, $sql, $params, $colName) {
         return $colName == 'id' ? 23 : -1;
     });
     $returnId = $this->dbManager->insertInto('europe', 'animal', array('mouse'), $log = 'logging', 'id');
     assertThat($returnId, equalTo(23));
 }