Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [phpunit]

PHPUnit is the de facto standard for writing unit tests for PHP code.

4
votes
1answer
142 views

Bill settlement for multiple users

I want to improve the logic for bill settlement and calculation of amount due. I managed to write code with T.D.D., but I think those loops could be improved somehow. Do you have any ideas on that ...
3
votes
0answers
361 views

PHPUnit testing my custom helper Facade classes in Laravel 5.5

I have been reading up on TDD and it's something I genuinely want to learn and be good at. This is something I haven't been doing as a developer and I thought it's about time I get into it. These are ...
4
votes
0answers
113 views

Curl-based REST Client Library (round 3)

This code review request relates to this code review which covers the basic single REST call use case in this this REST client library. This code review covers the classes and unit tests for the ...
2
votes
0answers
84 views

Curl-based REST client library (round 2)

This is a second iteration on an earlier review - cURL based REST client library I have done some refactoring to split out the REST HTTP response into it's own class from what was in the previous ...
3
votes
2answers
614 views

cURL based REST client library

I have recently refactored a REST client library and was hoping to get review for both the class itself and the unit tests that cover it. This code is developed against PHP 7.1, but tested against ...
2
votes
0answers
79 views

PHPUnit test recomendations

This is my first PHPUnit test with mocks, for a Symfony 3 project. Can anyone give me some advice about this code? ...
1
vote
0answers
167 views

Unit test for my image resizer class

I made a class that will be used to get an image properties like width, height, and MIME type. ...
3
votes
2answers
143 views

PHPUnit test for a PaymentMethodRuleManager

The following code snippet is about adding rules that filters Payment Methods listing to customer, for email we provide 4 different types of payment methods, but we do show them depending on some ...
1
vote
1answer
347 views

Functional test with PHPUnit / Symfony

I am trying to test my first functional tests. I would like to know if my functional test is well done, or if the structure of it is not optimal. Any advice will be useful to me. As I said, I just ...
4
votes
1answer
128 views

Testing a Pivotal API request client using lots of mocking

I have a class that is all about doing HTTP requests, and logging (in file system & database). It's only using 3 dependencies to do these things, so I'm fine with the code so far. Here it is for ...
0
votes
1answer
154 views

Repository code in Laravel

I am practicing to code in the right way and make it testable. Please review this code and tell me anything bad practices of it. Entity: ...
3
votes
3answers
193 views

XML parser using PHP

It is just one of the files. I have also tried to write some tests using PHPUnit. Please give me some suggestions to improve my coding-writing skills. The below is the test file for the above file: <...
2
votes
1answer
368 views

Car store implementation using abstract factory

I'm studying design patterns and I made this car store implementation. Although I'm confident that the idea is right, I'm not confident that the implementation is good. I would like you to check it ...
4
votes
1answer
220 views

Simple Pizza Factory with tests

I implemented the Simple Factory Pattern with some unit tests, but I'm with a feeling that I did something wrong and that I can improve it. Tell me what you think about the code (source and tests). ...
3
votes
0answers
835 views

Laravel Testing: Is this testing too much of the inner workings?

So I'm using laravel for a project and have a InvoiceRepository and a InvoiceRepositoryTest and I have written the test first ...
1
vote
1answer
5k views

Unit Testing of Curl based Rest Client Library

I ran into some issues with unit testing in that getting the response body etc from the curl handle was tricky. I didn't want to necessarily use a mock or abstract the curl functionality. A colleague ...
5
votes
1answer
262 views

Mock user table class

I've just created my first tests using mock classes. So far my tests are running much faster and now I guess I'm solely focusing on a single class (in this case I'm testing UserTable and mocking the ...
3
votes
1answer
771 views

BDD tests in PHPUnit

No one in my team knows how to write BDD tests, so I started writing some and it's quite working well. I think the time has come to improve the code quality. This contains a lot of duplicated code ...