public function testCheckSpamScoreOfSentEmailAction() { $emailSource = file_get_contents(__DIR__ . "/sentEmail.txt"); $requestMock = $this->getMockBuilder("Symfony\\Component\\HttpFoundation\\Request")->disableOriginalConstructor()->setMethods(array('get'))->getMock(); $requestMock->expects($this->once())->method('get')->will($this->returnValue($emailSource)); $containerMock = $this->getMockBuilder("Symfony\\Component\\DependencyInjection\\ContainerInterface")->disableOriginalConstructor()->getMock(); $containerMock->expects($this->once())->method("get")->will($this->returnValueMap(array(array('request', ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, $requestMock)))); $controller = new AzineEmailTemplateController(); $controller->setContainer($containerMock); $jsonResponse = $controller->checkSpamScoreOfSentEmailAction(); $json = $jsonResponse->getContent(); if (strpos($json, "Getting the spam-info failed") !== false) { $this->markTestIncomplete("It seems postmarks spam-check-service is unresponsive.\n\n{$json}"); } $this->assertNotContains("Getting the spam-info failed.", $jsonResponse->getContent(), "Spamcheck returned:\n" . $jsonResponse->getContent()); $this->assertContains("SpamScore", $jsonResponse->getContent()); }