コード例 #1
0
 public function testCanConstructNullResponseParser()
 {
     $httpRequest = $this->getMockBuilder('\\Onoi\\HttpRequest\\HttpRequest')->disableOriginalConstructor()->getMock();
     $filteredRecord = $this->getMockBuilder('\\Onoi\\Remi\\FilteredRecord')->disableOriginalConstructor()->getMock();
     $instance = new FilteredHttpResponseParserFactory($httpRequest);
     $this->assertInstanceOf('\\Onoi\\Remi\\NullResponseParser', $instance->newNullResponseParser($filteredRecord));
 }
コード例 #2
0
 /**
  * @dataProvider pmcidFileProvider
  */
 public function testPMCIDParser($id, $httpJsonRequestFile, $httpXmlRequestFile, $expectedResultFile)
 {
     list($id, $httpRequest, $jsonContents, $xmlContents, $expected) = $this->prepareFileContents($id, $httpJsonRequestFile, $httpXmlRequestFile, $expectedResultFile);
     $FilteredHttpResponseParserFactory = new FilteredHttpResponseParserFactory($httpRequest);
     $instance = $FilteredHttpResponseParserFactory->newNcbiPubMedCentralFilteredHttpResponseParser(new FilteredRecord());
     $this->assertEquals($jsonContents . $xmlContents, $instance->getRawResponseById($id));
     $instance->doFilterResponseById($id);
     $this->assertJsonStringEqualsJsonFile($expectedResultFile, $instance->getFilteredRecord()->asJsonString());
 }
コード例 #3
0
 /**
  * @dataProvider fileProvider
  */
 public function testParser($id, $httpRequestFile, $expectedResultFile)
 {
     $contents = file_get_contents($httpRequestFile);
     $httpRequest = $this->getMockBuilder('\\Onoi\\HttpRequest\\HttpRequest')->disableOriginalConstructor()->getMock();
     $httpRequest->expects($this->any())->method('execute')->will($this->returnValue($contents));
     $httpRequest->expects($this->any())->method('getLastError')->will($this->returnValue(''));
     $filteredHttpResponseParserFactory = new FilteredHttpResponseParserFactory($httpRequest);
     $instance = $filteredHttpResponseParserFactory->newViafFilteredHttpResponseParser(new FilteredRecord());
     $this->assertEquals($contents, $instance->getRawResponseById($id));
     $instance->doFilterResponseById($id);
     $this->assertJsonStringEqualsJsonFile($expectedResultFile, $instance->getFilteredRecord()->asJsonString());
 }