Skip to content

Commit

Permalink
PHP unit
Browse files Browse the repository at this point in the history
  • Loading branch information
siddhuphp committed Aug 27, 2022
1 parent a53852e commit 9cd1740
Show file tree
Hide file tree
Showing 1,345 changed files with 139,928 additions and 0 deletions.
1 change: 1 addition & 0 deletions PHPUnit_By_siddhu/.phpunit.result.cache
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"version":1,"defects":{"TDD\\Test\\ReceiptTest::testTotal":3,"TDD\\Test\\ReceiptTest::testTax":4,"TDD\\Test\\ReceiptTest::test_total":3,"TDD\\Test\\ReceiptTest::test_total2":4,"TDD\\Test\\ReceiptTest::test_total3":4,"TDD\\Test\\ReceiptTest::test_total4":4,"TDD\\Test\\ReceiptTest::test_total5":3,"TDD\\Test\\InvoiceTest::testTotal":4,"TDD\\Test\\InvoiceTest::testTax":4,"TDD\\Test\\InvoiceTest::test_total2":4,"TDD\\Test\\ReceiptTest::test_total6":5},"times":{"TDD\\Test\\ReceiptTest::testTotal":0.026,"TDD\\Test\\ReceiptTest::testTax":0,"TDD\\Test\\ReceiptTest::test_total":0.019,"TDD\\Test\\ReceiptTest::test_total2":0.005,"TDD\\Test\\ReceiptTest::test_total3":0,"TDD\\Test\\ReceiptTest::test_total4":0.06,"TDD\\Test\\ReceiptTest::test_total5":0,"TDD\\Test\\InvoiceTest::testTotal":0.004,"TDD\\Test\\InvoiceTest::testTax":0,"TDD\\Test\\InvoiceTest::test_total2":0,"TDD\\Test\\ReceiptTest::test_total6":0}}
34 changes: 34 additions & 0 deletions PHPUnit_By_siddhu/Notes.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
PHPUnit notes


To check phpunit version follow command: vendor/bin/phpunit --version


To Run testing code: vendor/bin/phpunit tests
(or)
We can specify by name if we have large application: vendor/bin/phpunit tests/ReceiptTest.php
(or)
Even you can filter more deep, You can call specify method: vendor/bin/phpunit tests --filter=testTax
(or)
Even better you can filter with class more deep, You can call specify method: vendor/bin/phpunit tests --filter=ReceiptTest::testTax
(or)
Instead of running single command like above mentioned, we can setup phpunit.xml here we can mention default files or exclude files for testing and more options
After setup phpunit.xml file you can run command: vendor/bin/phpunit --testsuite=app
we can call specify method with filter command: vendor/bin/phpunit --testsuite=app --filter=testTax
Asserts functions

assertEquals => this assertEquals has 3 inputs ( first expected value, second actual value, Message displayed in case of failure)
Find more assert functions in https://phpunit.de/manual/current/en/appendixes.assertions.html

Arrange Act Assert => the basic pattern we use is called Arrange-Act-Assert


Arrange => All necessary preconditions and inputs.
Act => On the Object or Method under test.
Assert => That the Expected results have occurred.

We add two new methods => setUp() & tearDown() That PHPUnit call before every test method.



Test Double
11 changes: 11 additions & 0 deletions PHPUnit_By_siddhu/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"require-dev": {
"phpunit/phpunit": "^9.5"
},
"autoload": {
"classmap": [
"src/"
]
}

}
Loading

0 comments on commit 9cd1740

Please sign in to comment.