I have a trouble to test what type of content returns the method. On success it returns string or int
, at fail returns array
. So code like this
public function createAddressBook($bookName)
{
if (true)
{
return 'OK';
}
return ['error' => 'FAIL'];
}
The real code of the method is API request for new book ID that is int or string
and i don't know what value will returns. My test code is like so:
public function setUp()
{
$this->stub = $this->createMock(\My\Class::class);
}
public function tearDown()
{
$this->stub = null;
}
public function testCreateAddressBook()
{
$this->stub->method('createAddressBook')->with('TestBookName');
$result = $this->stub->createAddressBook('TestBookName');
//what to do now?
}
My question is how to test method for returning value type?
Aucun commentaire:
Enregistrer un commentaire