O
O
Optimus2017-03-19 22:17:09
PHP
Optimus, 2017-03-19 22:17:09

How to do a unit test?

I want to learn TDD. In accordance with the approach, you must first write the test, and then the code.
Functionality:
1) on a certain date, you need to debit money from the user's account in accordance with his tariff plan
2) write to the database that the money was debited and what it was debited for
3) update the date of the next debit: move forward 30 days
Everything it will be in one class, it will have 3 described methods
. I think like this:
First you need to simulate the input values. But they are not there, to prescribe any number and tariff plan yourself? How can I find out if the data has been written to the database?
There is a unique inscription in the "for what they were charged for" method, for example, "for servicing the Scarlet Rose store in March 2017" - it is not clear how to test the appearance of this inscription in the database...
Well, for 30 days ahead, the easiest thing is probably to move and check, but here the question is also whether I need to go down to converting the cut into seconds and check what = exactly 86400 x 30?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question