public function test_auth() { MonkeyPatch::patchMethod('Ion_auth_model', ['login' => true]); MonkeyPatch::verifyInvoked('Ion_auth_model::login', ['foo', 'bar']); MonkeyPatch::verifyInvokedOnce('Ion_auth_model::login', ['foo', 'bar']); MonkeyPatch::verifyNeverInvoked('Ion_auth_model::login', ['username', 'PHS/DL1m6OMYg']); MonkeyPatch::verifyInvokedOnce('CI_Input::post', ['id']); MonkeyPatch::verifyInvokedOnce('CI_Input::post', ['password']); MonkeyPatch::verifyInvokedMultipleTimes('CI_Input::post', 2); $output = $this->request('POST', 'patching_on_method/auth', ['id' => 'foo', 'password' => 'bar']); $this->assertContains('Okay!', $output); }
public function test_say_good_afternoon_at_13() { MonkeyPatch::patchMethod('Greeting', ['getCurrentHour' => '13']); $result = $this->obj->say(); $this->assertEquals('Good Afternoon.', $result); }
/** * @group patcher */ public function test_index_logged_in_with_method_patch() { MonkeyPatch::patchMethod('Ion_auth', ['logged_in' => TRUE]); $output = $this->request('GET', 'auth_check_in_construct'); $this->assertContains('You are logged in.', $output); }