Skip to content

Tag: phpunit

Feature test for HTTP RESTful API on Laravel 8

I’m trying to write a feature test in RESTful API that I have been created in laravel 8. I have ChatController that gets user chats by getUserChats method: that called by this route: this is my feature test on this route: the test runs successfully by this green output OK (1 test, 3 assertions) but I do…

a PHPpunit test fail randomly

I have a Quiz class. This class load 10 questions from a database depending on the level and the type of the quiz Object: level 0 load the ten first, level 1 load the next ten and so on. So in my test i create in a test database 30 questions. Then i create quiz object with different level and

laravel feature tests with locales

I am new to Laravel and I am having an issue to write a test function that asserts that the HTTP response of my welcome page is 200 knowing that I have EN and FR locales defined, meaning that the test should test both localhost:8000/en and localhost:8000/fr. This is my exampletest.php: I don’t like writ…

Mock class with fluent interface in Phpunit

I am mocking this sample class with fluent methods that doesn’t have return type declaration: Using PhpUnit: By default, this will not work on fluent methods without return type declaration so I need to add the ff.: This works but cumbersome to write if there are a lot fluent methods. My question is, is…

Symfony 3.4 Functional tests

I have been stuck for some time on an error to do my functional tests with symfony 3.4. My app run a custom GuardAuthenticator for authenticate my users within CAS authentication. This is just for explain the context. In my tests, I don’t want to use it, I want to use a specific authentication system. I…