/** * @covers CitationParserService::parse */ public function testParse() { $citation = new Citation(METADATA_GENRE_JOURNALARTICLE, 'rawCitation'); // Set an "unclean" article title and add a comment // to test whether parse() cleans this up. $citation->setArticleTitle('Article Title with Punctuation.'); $citation->addComment('Comment with Punctuation.'); // Mock CitationParserService->parseInternal() which will usually // be implemented by sub-classes. $mockCPService =& $this->getMock('CitationParserService', array('parseInternal')); // Set up the parseInternal() method $mockCPService->expects($this->once())->method('parseInternal')->with($this->equalTo($mockCPService->getCitationString($citation)))->will($this->returnValue($citation)); // Call the SUT $citation = $mockCPService->parse($citation); // Test whether the citation has been cleaned up. self::assertEquals('Article Title with Punctuation', $citation->getArticleTitle()); self::assertEquals(array('Comment with Punctuation'), $citation->getComments()); }