phpunit

Symfony functional test fail but the same request works in browser

核能气质少年 提交于 2020-12-08 07:15:07
问题 I followed the Symfony documentation about functional tests in order to write my first one, but I have some issues. The response I get via browser works good: But when I run phpunit -c app/ in the shell I get a failure. 1) AppBundle\Tests\Controller\MeterAPIControllerTest::testGetAllVariables Failed asserting that 500 matches expected 200. This is the code: <?php namespace AppBundle\Tests\Controller; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; class MeterAPIControllerTest extends

Make phpunit catch php7 TypeError

空扰寡人 提交于 2020-11-30 09:15:30
问题 I am trying to validate that a php7 function accept only integers. This is the class: <?php declare(strict_types=1); class Post { private $id; public function setId(int $id) { $this->id = $id; } } And this is the test: <?php declare(strict_types=1); class PostTest extends \PHPUnit_Framework_TestCase { private function getPostEntity() { return new Post(); } public function testSetId() { $valuesExpected = [123, '123a']; foreach ($valuesExpected as $input) { $this->getPostEntity()->setId($input)

Make phpunit catch php7 TypeError

…衆ロ難τιáo~ 提交于 2020-11-30 09:14:50
问题 I am trying to validate that a php7 function accept only integers. This is the class: <?php declare(strict_types=1); class Post { private $id; public function setId(int $id) { $this->id = $id; } } And this is the test: <?php declare(strict_types=1); class PostTest extends \PHPUnit_Framework_TestCase { private function getPostEntity() { return new Post(); } public function testSetId() { $valuesExpected = [123, '123a']; foreach ($valuesExpected as $input) { $this->getPostEntity()->setId($input)

Make phpunit catch php7 TypeError

孤街浪徒 提交于 2020-11-30 09:13:30
问题 I am trying to validate that a php7 function accept only integers. This is the class: <?php declare(strict_types=1); class Post { private $id; public function setId(int $id) { $this->id = $id; } } And this is the test: <?php declare(strict_types=1); class PostTest extends \PHPUnit_Framework_TestCase { private function getPostEntity() { return new Post(); } public function testSetId() { $valuesExpected = [123, '123a']; foreach ($valuesExpected as $input) { $this->getPostEntity()->setId($input)