Skip to content

Instantly share code, notes, and snippets.

@jjaffeux
Created June 5, 2012 19:29
Show Gist options
  • Save jjaffeux/2877198 to your computer and use it in GitHub Desktop.
Save jjaffeux/2877198 to your computer and use it in GitHub Desktop.
test config item
<?php

class Encrypt_test extends CI_TestCase {

  public function set_up()
  {
    $cls =& $this->ci_core_class('cfg');
    $this->ci_set_config(array(
        'encryption_key'    => 'OHAI'
    ));
    $this->config = new $cls;  

    $obj = new StdClass;
    $obj->encrypt = new Mock_Libraries_Encrypt();
    $this->ci_instance($obj);
    $this->encrypt = $obj->encrypt;
  }

  // --------------------------------------------------------------------

  public function test_encode()
  {
    $msg = 'My secret message';
    $encrypted_string = $this->encrypt->encode($msg);
  }
}
There was 1 error:

1) Encrypt_test::test_encode
Undefined property: stdClass::$config

/Applications/MAMP/htdocs/codeigniter/system/libraries/Encrypt.php:108
/Applications/MAMP/htdocs/codeigniter/system/libraries/Encrypt.php:153
/Applications/MAMP/htdocs/codeigniter/tests/codeigniter/libraries/Encrypt_test.php:33
/Applications/MAMP/htdocs/codeigniter/tests/mocks/ci_testcase.php:168

Line 108 is :

$key = $CI->config->item('encryption_key');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment