Guy Verville Posted July 29, 2018 Share Posted July 29, 2018 Hi, I have some problem configuring a test with wireHttp involved. This code works ok on a real template (called testPageController.php). I have two local sites to make the test. public function getOtherSiteConnectionTest() { $config = wire("config"); $http = new WireHttp(); $chemin = "http://" . $config->afmqOtherSite . " /en/afmq-services/hello/"; $response = $http->get($chemin); $expected = "hello"; $actual = $response; Assert::equal($expected, $actual); } Nette Tester tells me it has forgotten to make the test which means a misconfiguration of a sort. What I did wrong? Link to comment Share on other sites More sharing options...
tpr Posted July 29, 2018 Share Posted July 29, 2018 Could you post the entire test class (only with this one test method of course) to check? Link to comment Share on other sites More sharing options...
Guy Verville Posted July 29, 2018 Author Share Posted July 29, 2018 Sure! Of course, $path should be a valid path in your website. <?php namespace ProcessWire; use \Tester\Assert; use \Tester\TestCase; /** * @testCase */ class GetOtherSiteResponseTest extends TestCase { public function getOtherSiteConnectionTest() { $config = wire("config"); $http = new WireHttp(); $path = "http://" . $config->afmqOtherSite . " /en/afmq-services/hello/"; $response = $http->get($path); $expected = "Succès!"; $actual = $response; Assert::equal($expected, $actual); } } (new GetOtherSiteResponseTest())->run(); The code of the template that responds is simple (this is crude test. I am using Twig templating). <?php namespace ProcessWire; require_once "MainController.php"; /** * Class AfmqServicesController * @package ProcessWire */ Class AfmqServicesController extends MainController { /** * Simple test * * @return void */ public function render(): void { $view = wire("view"); $input = wire('input'); $urlSegment = $input->urlSegment1; switch($urlSegment){ case "hello": echo "OK"; exit(); break; default: exit(); break; } } } (new AfmqServicesController())->render(); Link to comment Share on other sites More sharing options...
tpr Posted July 29, 2018 Share Posted July 29, 2018 I think the issue is that the method name format is "testSomething" though I haven't read about it in the docs. Once I renamed the method it worked fine. 2 1 Link to comment Share on other sites More sharing options...
Guy Verville Posted July 29, 2018 Author Share Posted July 29, 2018 Thank you, it was the problem! Link to comment Share on other sites More sharing options...
tpr Posted July 29, 2018 Share Posted July 29, 2018 Great, at least it turned out somebody makes use of the module ? 1 Link to comment Share on other sites More sharing options...
Guy Verville Posted July 29, 2018 Author Share Posted July 29, 2018 You bet, our Quality Assurance department was very happy to discover that! While a lot of website do not require unit testing, we try to implement those with our more complex websites. 4 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now