Skip to content
Browse files

updating tests to reflect new refactoring

  • Loading branch information...
1 parent 5e66f3a commit 91a6cb81dbd6ccf82a2fb307f2f70b4349fdbf99 @enygma committed Aug 9, 2012
View
22 Shield/tests/Shield/ConfigTest.php
@@ -10,12 +10,12 @@ class ConfigTest extends \PHPUnit_Framework_TestCase
public function setUp()
{
$this->_di = new Di();
- $this->_config = new Config($this->_di);
+ //$this->_config = new Config($this->_di);
}
public function tearDown()
{
$this->_di = null;
- $this->_config = null;
+ //$this->_config = null;
}
/**
@@ -25,9 +25,9 @@ public function tearDown()
*/
public function testSetGetValue()
{
- $this->_config->set('testing','foo123');
+ Config::set('testing','foo123');
$this->assertEquals(
- $this->_config->get('testing'),'foo123'
+ Config::get('testing'),'foo123'
);
}
@@ -38,7 +38,7 @@ public function testSetGetValue()
*/
public function testGetDefaultConfigFilename()
{
- $filename = $this->_config->getConfigFile();
+ $filename = Config::getConfigFile();
$this->assertEquals($filename,'config.php');
}
@@ -49,18 +49,18 @@ public function testGetDefaultConfigFilename()
*/
public function testSetConfigFilename()
{
- $originalConfig = $this->_config->getConfigFile();
+ $originalConfig = Config::getConfigFile();
$newFilename = 'testconfig.php';
- $this->_config->setConfigFile($newFilename);
+ Config::setConfigFile($newFilename);
$this->assertEquals(
$newFilename,
- $this->_config->getConfigFile()
+ Config::getConfigFile()
);
// reset it back to the original
- $this->_config->setConfigFile($originalConfig);
+ Config::setConfigFile($originalConfig);
}
/**
@@ -73,10 +73,10 @@ public function testSetCustomConfiguration()
$option = 'foo123';
$config = array('test' => $option);
- $this->_config->setConfig($config);
+ Config::setConfig($config);
$this->assertEquals(
- $this->_config->get('test'),
+ Config::get('test'),
$option
);
}
View
13 Shield/tests/Shield/InputTest.php
@@ -17,7 +17,8 @@ public function setUp()
global $_SERVER;
$this->_di = new Di();
- $this->_input = new Input($this->_di);
+ $this->_input = new Input(new Filter());
+ //$this->_config = new Config($this->_di);
}
public function tearDown()
{
@@ -42,11 +43,10 @@ public function testValidInputIsFiltered()
$validEmail = 'woo@test.com';
// create and register a Filter instance
- $filter = new Filter($this->_di);
+ $filter = new Filter();
$filter->add('testVal','email');
- $this->_di->register($filter);
- $input = new Input($this->_di);
+ $input = new Input($filter);
$input->set('get','testVal',$validEmail);
$result = $input->get('testVal');
@@ -69,13 +69,12 @@ public function testFilterAsClosure()
$validEmail = 'woo@test.com';
// create and register a Filter instance
- $filter = new Filter($this->_di);
+ $filter = new Filter();
$filter->add('testVal', function($value){
return 'returned: '.$value;
});
- $this->_di->register($filter);
- $input = new Input($this->_di);
+ $input = new Input($filter);
$input->set('get','testVal',$validEmail);
$result = $input->get('testVal');
View
19 Shield/tests/Shield/SessionTest.php
@@ -25,18 +25,19 @@ public function setUp()
global $_SESSION;
$this->_di = new Di();
- $this->_filter = new Filter($this->_di);
- $this->_di->register($this->_filter);
+ $this->_filter = new Filter($this->_config);
+ $this->_input = new Input($this->_filter);
+ //$this->_config = new Config();
- $this->_input = new Input($this->_di);
- $this->_config = new Config($this->_di);
- $this->_di->register(array(
- $this->_input, $this->_config
- ));
+ // $this->_di->register($this->_filter);
- $this->_session = new Session($this->_di);
+ // $this->_di->register(array(
+ // $this->_input, $this->_config
+ // ));
- $this->_di->register($this->_session);
+ $this->_session = new Session();
+
+ //$this->_di->register($this->_session);
session_start();
}
View
8 Shield/tests/Shield/TemplateTest.php
@@ -7,14 +7,16 @@ class TemplateTest extends \PHPUnit_Framework_TestCase
private $_template = null;
private $_di = null;
private $_config = null;
+ private $_filter = null;
public function setUp()
{
$this->_di = new Di();
- $this->_config = new Config($this->_di);
- $this->_template = new Template($this->_config);
+ Config::load();
+ $this->_filter = new Filter($this->_config);
+ $this->_template = new Template($this->_filter);
- $this->_di->register(new View($this->_config, $this->_template));
+ //$this->_di->register(new View($this->_template));
}
public function tearDown()
{
View
3 Shield/tests/bootstrap.php
@@ -7,8 +7,9 @@ function load($className)
$path = __DIR__.'/../'.str_replace('Shield\\', '/', $className).'.php';
if (is_file($path)) {
include_once $path;
+ return true;
} else {
- $this->_throwError('Could not load class: '.$className);
+ return false;
}
}
spl_autoload_register('load');

0 comments on commit 91a6cb8

Please sign in to comment.
Something went wrong with that request. Please try again.