As mentioned in some answer, you should use the assertEquals() method. The second part is that you can use several statements. Therefore, if phpunit detects a failure on the first statement, the whole test fails.
Why not use assertTrue() ? Since it is unclear whether you use, for example, if ($object) ... in one place in the code and assertTrue($object); in another.
Also, make sure your procedure is running correctly. Therefore, if you get an exception while trying to get an answer, the test will fail. Although exceptions should be checked as well as test cases. That is, you should try to post an invalid request and throw an assert exception. What a good test looks like - it should check all possible situations, hehe =)
So this is the code you should get:
public function testAddAccount() { $response = $this->api->addAccount('7629428643'); $this->assertEquals($response->success, true); $this->assertEquals($response->id, '7629428643'); $this->setExpectedException('MyException'); $response = $this->api->addAccount('wrong_account'); }
shybovycha
source share