Category : phpunit

I have the same problem as many other similar questions but none of the solutions worked. I have a very simple test case: class ExampleTest extends TestCase { public function test_find_english() { $this->withoutExceptionHandling(); $response = $this->get("api/find?id=1&language=eng"); $response->assertOk(); } } If I go to the endpoint in a browser or Postman I get the expected result, ..

Read more

I’m trying to mock a repository containing all modules, and it has a method called findAll() that returns all elements from that repository. I cant seem to be able to pull any data from the mocked repository. Any ideas how I could fix it? Mocking repository: $moduleRepository = $this->createMock(ModuleRepository::class); Trying to use method from ModuleRepository ..

Read more

How to prevent phpunit from launching functions that I don’t want? <?php namespace AppTests; use AppCoreSecurityModuleService; use SymfonyBundleFrameworkBundleTestWebTestCase; class moduleTest extends WebTestCase { /** * @var ModuleService */ private ModuleService $moduleService; /** * moduleTest constructor. * @param ModuleService $moduleService */ public function __construct(ModuleService $moduleService) { $this->moduleService = $moduleService; } public function testModule() { $modules = ..

Read more

I’m very new to symphony and phpunit tests. use SymfonyBundleFrameworkBundleTestWebTestCase; class moduleTest extends WebTestCase{ public function testModule(){ $modules = $this->getDoctrine()->getRepository(‘test:module’)->findAll(); } } I’m trying to do a test and check whether the module count is correct, but I can’t even get the modules out of the database. I get this error: Error: Call to undefined ..

Read more

I have nothing write into testcase, it is just empty like public function testData() { } public function dataProvider() { dd($this->id) } But I have written query into setup /* * create the object against which we will test */ protected function setUp() :void { parent::setup(); $this->id = Event::inRandomOrder()->select(‘id’)->whereNotNull(‘logo’)->first(); dd($this->id); } But this is not ..

Read more

When I try to install PHPUnit in docker, I got the error message but mcrypt seems to be installed. What did I miss ? $ composer require phpunit/phpunit=3.7.* –dev The requested PHP extension ext-mcrypt * is missing from your system. Install or enable PHP’s mcrypt extension. $ yum list installed | grep mcrypt libmcrypt.x86_64 2.5.8-9.el6 ..

Read more