Skip to main content

Questions tagged [phpunit]

PHPUnit is a unit testing framework that is written in php. It is based on the JUnit for Java framework

2 votes
2 answers
408 views

Firstly let me say I have never written a unit test in my life. I am trying to get the hang of PHPUnit, and so far it's working pretty well for me so far as "stateless" functions (that ...
user avatar
-6 votes
1 answer
231 views

First, the most obvious grouse someone has against this I can think of is the intricacies of an actual method. It's not enough to merely ensure no errors are thrown. Functions usually contain ...
I Want Answers's user avatar
3 votes
1 answer
698 views

In a php project that I maintain I have a database structure without migrations, hence no way to reproduce it or make on the fly a test database. And the queries used to be performed on them are ...
Dimitrios Desyllas's user avatar
4 votes
2 answers
282 views

I recently ran across some code in a public repo that I'd thought... just plain wrong. The first thing I noticed was /** * Sets a test mode status. * * @param boolean $mode Mode to set */ public ...
DFriend's user avatar
  • 149
2 votes
1 answer
761 views

In my job I have a small disagreement on whether we should utilize helper functions for making datasets especially in laravel framework. A sample for the test is: namespace Tests\MyAppTests; use ...
Dimitrios Desyllas's user avatar
0 votes
1 answer
685 views

I am making a project using the Laravel framework. I plan to create unit tests for my project. But I feel I don't really have an idea what to test because I mostly use library or framework functions. ...
lightning_missile's user avatar
1 vote
1 answer
1k views

Is there a feasible way of testing SQL queries that contain things like CURRENT_DATE and NOW() in a unit test? For example: public function deletePastEntries(): bool { $sql = "DELETE FROM queue ...
rink.attendant.6's user avatar
2 votes
4 answers
2k views

I have some code that reads five numbers from a database: class Repository extends DatabaseRepository { function getCoefficients(string $model) { return $this->getDatabaseLink()-&...
Dennis's user avatar
  • 8,267
-1 votes
1 answer
207 views

I have a system ("an engine", which is a piece of code) that takes in several parameters returns some output. The input parameters are several distinct and constrained sets. I can enumerate all of ...
Dennis's user avatar
  • 8,267
2 votes
2 answers
4k views

I'm starting to wrap my head around PHPunit. My questions is the following. Whenever I use variables that do not change within my range of test methods I can initialize them within my setUp() ...
Magiranu's user avatar
-2 votes
2 answers
1k views

I am new to unit testing. Started working on unit test using PHPUnit. But it seems to be taking too much time. If consider I take 3 hours to write a Class, its taking my 7 hours to write test case for ...
Pratik Joshi's user avatar
6 votes
2 answers
3k views

I'm having a bit of a philosophical argument with one of my colleagues regarding the "right" way to do unit tests (in this case with PHPUnit). I'm of the opinion that you should write one test method ...
GordonM's user avatar
  • 6,525
4 votes
0 answers
195 views

I'm currently writing unit tests for my PHP code. I've read that unit tests should not interract with external elements such as network and filesystem. In my code i have a curl wrapper class to ...
ᴄʀᴏᴢᴇᴛ's user avatar
2 votes
2 answers
156 views

Our company is using an external API that is actually in beta state. This means it's not stable at all yet, and it changes its requests/responses every week or so. I'd like to write test to ensure ...
Steve Chamaillard's user avatar
3 votes
2 answers
3k views

For service methods that call repository methods to interact with database how could I unit test these service methods? For example, public function updateSlideshow($data){ // do some logic and ...
mohsenJsh's user avatar
  • 1,365

15 30 50 per page