public function testGetViewForResourcesInvokesViewGenerationForMissingResources()
 {
     $uri1 = "http://uri1";
     $uri2 = "http://uri2";
     $viewType = "someView";
     $context = "http://someContext";
     $mockDb = $this->getMockBuilder('\\MongoDB\\Database')->disableOriginalConstructor()->setMethods(['selectCollection'])->getMock();
     $mockColl = $this->getMockBuilder('\\MongoDB\\Collection')->disableOriginalConstructor()->setMethods(['findOne'])->getMock();
     $mockViewColl = $this->getMockBuilder('\\MongoDB\\Collection')->disableOriginalConstructor()->setMethods(['findOne'])->getMock();
     $mockDb->expects($this->any())->method("selectCollection")->will($this->returnValue($mockColl));
     $mockColl->expects($this->once())->method("findOne")->will($this->returnValue(array("_id" => $uri1)));
     // the actual returned doc is not important, it just has to not be null
     /** @var PHPUnit_Framework_MockObject_MockObject|TripodTestConfig $mockConfig */
     $mockConfig = $this->getMock('TripodTestConfig', array('getCollectionForCBD', 'getCollectionForView'));
     $mockConfig->expects($this->atLeastOnce())->method('getCollectionForCBD')->with('tripod_php_testing', $this->anything(), $this->anything())->will($this->returnValue($mockColl));
     $mockConfig->expects($this->atLeastOnce())->method('getCollectionForView')->with('tripod_php_testing', $this->anything(), $this->anything())->will($this->returnValue($mockViewColl));
     $mockConfig->loadConfig(\Tripod\Mongo\Config::getConfig());
     /* @var $mockTripodViews \Tripod\Mongo\Composites\Views */
     $mockTripodViews = $this->getMock('\\Tripod\\Mongo\\Composites\\Views', array('generateView', 'fetchGraph', 'getConfigInstance'), array('tripod_php_testing', $mockColl, $context));
     $mockTripodViews->expects($this->once())->method('generateView')->with($viewType, $uri2, $context)->will($this->returnValue(array("ok" => true)));
     $mockTripodViews->expects($this->exactly(2))->method("fetchGraph")->will($this->returnCallback(array($this, 'fetchGraphInGetViewForResourcesCallback')));
     $mockTripodViews->expects($this->atLeastOnce())->method('getConfigInstance')->will($this->returnValue($mockConfig));
     $resultGraph = $mockTripodViews->getViewForResources(array($uri1, $uri2), $viewType, $context);
     $expectedGraph = new \Tripod\ExtendedGraph();
     $expectedGraph->add_literal_triple($uri1, 'http://somepred', 'someval');
     $expectedGraph->add_literal_triple($uri2, 'http://somepred', 'someval');
     $this->assertEquals($expectedGraph->to_ntriples(), $resultGraph->to_ntriples());
 }