public function testVerifyClassMethods() { double::registerClass('demo\\UserModel', ['save' => null]); $user = new ClassProxy('demo\\UserModel'); $service = new UserService(); $service->create(array('name' => 'davert')); $user->verifyInvoked('save'); $user->verifyInvoked('save', []); $user->verifyInvokedMultipleTimes('save', 1); $user->verifyNeverInvoked('getName'); }
public function testVerifyMagicMethods() { $this->specify('works for class proxy', function () { // Set up user object. double::registerClass("demo\\UserModel", ['renameUser' => "Bob Jones", 'save' => null]); $userProxy = new ClassProxy("demo\\UserModel"); $user = new UserModel(['name' => "John Smith"]); // Rename the user via magic method. UserService::renameStatic($user, "Bob Jones"); // Assert rename was counted. $userProxy->verifyInvoked('renameUser'); }); $this->specify('works for instance proxy', function () { // Set up user object. $user = new UserModel(['name' => "John Smith"]); double::registerObject($user); $user = new InstanceProxy($user); // Rename the user via magic method. $user->renameUser("Bob Jones"); // Assert rename was counted. $user->verifyInvoked('renameUser'); }); }
public function testMagic() { double::registerClass('\\demo\\UserService', ['rename' => 'David Copperfield']); $admin = new UserService(); $this->assertEquals('David Copperfield', $admin->rename()); }