Suppose there is a class. With two methods.
function getId($string) { /*Проверяем строку на валидность и если все окей, пишем ее в свойство класса*/ $this->id = $string; } function buildUrl() { /*Проверяем наличие свойства и строим URL для доступа к чему-то там...*/ if ($this->id) {/*бла-бла-бла*/} } Now the question. When covering tests, what should I pass on to methods? What they expect to ideally take? That is, a valid string in the first case and a non-empty property in the second.
Or what they do not expect? Any non-valid nonsense in the first case and the lack of properties in the second.
Or two tests, one for the expected parameters, and the second for the unexpected?
PS I just understand testing, so I’m not good at the hardware.
PPS If this is important, then in case of success, methods give true , and in case of failure, they throw Exception . Because, with the wrong parameters to continue the execution of the script does not make sense.