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_function_exists_use_random_bytes()
 {
     MonkeyPatch::patchFunction('function_exists', function ($function) {
         if ($function === 'random_bytes') {
             return true;
         } elseif ($function === 'openssl_random_pseudo_bytes') {
             return false;
         } elseif ($function === 'mcrypt_create_iv') {
             return false;
         } else {
             return __GO_TO_ORIG__;
         }
     }, 'Patching_on_function');
     MonkeyPatch::verifyInvokedOnce('function_exists', ['random_bytes']);
     MonkeyPatch::verifyInvokedOnce('function_exists', ['exit']);
     MonkeyPatch::verifyInvokedMultipleTimes('function_exists', 2);
     MonkeyPatch::verifyNeverInvoked('function_exists', ['openssl_random_pseudo_bytes']);
     MonkeyPatch::verifyNeverInvoked('function_exists', ['mcrypt_create_iv']);
     $output = $this->request('GET', 'patching_on_function/function_exists');
     $this->assertContains("I use random_bytes().", $output);
     $this->assertContains("Do you know? There is no exit() function in PHP.", $output);
 }