Learn all the skills and knowledge required to set up your unit tests properly and professionally.
PHPUnit dos and don'ts
BeginnerContinuous Integration (CI)Code Coverage
When writing a unit tests. There are couple of things to do and couple of things which should be avoided. In this article I have listed the dos and don'ts with regards to unit testing.
PHPUnit Incomplete and Skipped Tests
Unfinished tests
Sometimes it happens that you have not finished writing a test due to focus on other aspects of a project. In such a scenarion you can use the phpunit feature to mark the test as incomplete.
PHPUnit Data Providers
BeginnerContinuous Integration (CI)Code Coverage
A function/method can accept unpredictable arguments. In order to test large number of arguments efficiently and quick. PHPUnit provides the @dataProvider annotation.
PHPUnit mock magic functions
BeginnerContinuous Integration (CI)Magic MethodsCode Coverage
Magic Methods are a feature of PHP. Learn how to test magic methods with PHPUnit.
PHPUnit mock method with different values
BeginnerContinuous Integration (CI)Code CoverageMethod
Learn how to unit tests a method with different parameter values.
PHPUnit partial mock
BeginnerContinuous Integration (CI)Code Coverage
When writing unit tests, sometimes we mock classes or interfaces which have certain functions which are missing. This happens a lot during my development with magento. In such a scenario PHPUnit gives you the possibility to provide function name(s) for that interface or class. You can use Partial mocks or use getMockBuilder to mock the class and the missing function properly.
PHPUnit - How to unit test a method with no return value?
BeginnerContinuous Integration (CI)Code Coverage
When writing unit tests, sometimes we mock classes or interfaces which have certain functions which are missing. This happens a lot during my development with magento. In such a scenario PHPUnit gives you the possibility to provide function name(s) for that interface or class. You can use Partial mocks or use getMockBuilder to mock the class and the missing function properly.
PHPUnit - setUpBeforeClass static method
BeginnerContinuous Integration (CI)Code CoverageSpeed
Recently while writing a unit test, I came across testing a class which needed to test several arbitrary arguments. All the arguments were in a text file which had more than 10000 lines of data. I had to open the file and read it four times as I had four test scenarios. The total time for the tests to be executed was around 4.5 seconds.
PHPUnit Testing Exceptions
BeginnerContinuous Integration (CI)Code CoverageExceptions
There are two ways to tell PHPUnit that you wish to test that an exception was thrown, when you tried to execute your code. It is a good practice to write meaningful names describing which exception was been thrown.
How to setup unit test for magento command
IntermediateContinuous Integration (CI)Code CoverageConsole CommandMagento
When writing a unit tests. There are couple of things to do and couple of things which should be avoided. In this article I have listed the dos and don'ts with regards to unit testing.