Core/tests/mocks/core/input.php
Abel Hoogeveen 5df6b733d0 Implemented many unit tests.
The following tests for classes have been implemented:
- Security
- Input
- Encryption Library
- Utf8

A mocking autoloader has been added (but is not yet configured correctly)
2016-06-02 23:57:23 +02:00

53 lines
1.2 KiB
PHP

<?php
use FuzeWorks\Input;
use FuzeWorks\Factory;
class Mock_Core_Input extends Input {
/**
* Since we use GLOBAL to fetch Security and Utf8 classes,
* we need to use inversion of control to mock up
* the same process within CI_Input class constructor.
*
* @covers CI_Input::__construct()
*/
public function __construct($security, $utf8)
{
parent::__construct();
$this->_allow_get_array = ($this->factory->config->getConfig('routing')->allow_get_array === TRUE);
$this->_enable_xss = ($this->factory->config->getConfig('security')->global_xss_filtering === TRUE);
$this->_enable_csrf = ($this->factory->config->getConfig('security')->csrf_protection === TRUE);
// Assign Security and Utf8 classes
$this->security = $security;
$this->uni = $utf8;
// Sanitize global arrays
$this->_sanitize_globals();
}
public function fetch_from_array($array, $index = '', $xss_clean = FALSE)
{
return parent::_fetch_from_array($array, $index, $xss_clean);
}
/**
* Lie about being a CLI request
*
* We take advantage of this in libraries/Session_test
*/
public function is_cli_request()
{
return FALSE;
}
public function __set($name, $value)
{
if ($name === 'ip_address')
{
$this->ip_address = $value;
}
}
}