PHP ve PHPUnit bir davalarını nesnesi oluşturmak için çalışıyorum. Şimdiye kadar, ben bu var:
$object = $this->getMock('object',
array('set_properties',
'get_events'),
array(),
'object_test',
null);
$object
->expects($this->once())
->method('get_events')
->will($this->returnValue(array()));
$mo = new multiple_object($object);
Ignoring my hideously ambiguous object names for the minute, I understand that what I've done is
- Created a mock object, with 2 methods to configure,
- Configured the 'get_events' method to return a blank array, and
- Dropped the mock into the constructor.
Ne şimdi yapmak istiyorum ikinci yöntemini yapılandırmak, ama ben bunu nasıl açıklayan bir şey bulamıyorum. Ben böyle bir şey yapmak istiyorum
$object
->expects($this->once())
->method('get_events')
->will($this->returnValue(array()))
->expects($this->once())
->method('set_properties')
->with($this->equalTo(array()))
ya da böyle, ama bu işe yaramazsa. Bunu nasıl yapmalıyım?
Ben test etmek için yapılandırılmış birden fazla yöntemi gerekiyorsa teğet, bu, ben kötü kodumu yapılandırılmış ettik gösterir?