diff --git a/tests/B8Framework/CacheTest.php b/tests/B8Framework/CacheTest.php index cffccd50..4facef7b 100755 --- a/tests/B8Framework/CacheTest.php +++ b/tests/B8Framework/CacheTest.php @@ -6,34 +6,33 @@ use b8\Config, b8\Cache; class CacheTest extends PHPUnit_Framework_TestCase { - public function testCreateSingleton() - { - $cache = Cache::getCache(Cache::TYPE_APC); - $this->assertTrue($cache instanceof Cache); - } + public function testCreateSingleton() + { + $cache = Cache::getCache(Cache::TYPE_APC); + $this->assertTrue($cache instanceof Cache); + } - public function testDisableCaching() - { - $config = new Config(); - Config::getInstance()->set('DisableCaching', true); + public function testDisableCaching() + { + $config = new Config(); + Config::getInstance()->set('DisableCaching', true); - $cache = Cache::getCache(Cache::TYPE_APC); - $this->assertFalse($cache->isEnabled()); - $this->assertFalse($cache->set('anything', 10)); - $this->assertTrue(is_null($cache->get('anything'))); + $cache = Cache::getCache(Cache::TYPE_APC); + $this->assertFalse($cache->isEnabled()); + $this->assertFalse($cache->set('anything', 10)); + $this->assertTrue(is_null($cache->get('anything'))); - Config::getInstance()->set('DisableCaching', false); - } + Config::getInstance()->set('DisableCaching', false); + } - public function testCaching() - { - $cache = Cache::getCache(Cache::TYPE_APC); + public function testCaching() + { + $cache = Cache::getCache(Cache::TYPE_APC); - if($cache->isEnabled()) - { - $this->assertTrue($cache->set('anything', 10)); - $this->assertTrue($cache->get('anything') == 10); - $this->assertTrue(is_null($cache->get('invalid'))); - } - } + if ($cache->isEnabled()) { + $this->assertTrue($cache->set('anything', 10)); + $this->assertTrue($cache->get('anything') == 10); + $this->assertTrue(is_null($cache->get('invalid'))); + } + } } diff --git a/tests/B8Framework/DatabaseGenerationTest.php b/tests/B8Framework/DatabaseGenerationTest.php index fd51864e..d0fdf4a5 100644 --- a/tests/B8Framework/DatabaseGenerationTest.php +++ b/tests/B8Framework/DatabaseGenerationTest.php @@ -6,70 +6,70 @@ use b8\Database\Generator, b8\Database\Map, b8\Database; class DatabaseGenerationTest extends \PHPUnit_Framework_TestCase { - protected $_host = 'localhost'; - protected $_user = 'b8_test'; - protected $_pass = 'b8_test'; - protected $_name = 'b8_test'; - protected $_db; + protected $_host = 'localhost'; + protected $_user = 'b8_test'; + protected $_pass = 'b8_test'; + protected $_name = 'b8_test'; + protected $_db; - public function setUp() - { - Database::setDetails($this->_name, $this->_user, $this->_pass); - Database::setWriteServers([$this->_host]); + public function setUp() + { + Database::setDetails($this->_name, $this->_user, $this->_pass); + Database::setWriteServers([$this->_host]); - $this->_db = Database::getConnection('write'); + $this->_db = Database::getConnection('write'); - $this->_db->query('DROP TABLE IF EXISTS tres'); - $this->_db->query('DROP TABLE IF EXISTS dos'); - $this->_db->query('DROP TABLE IF EXISTS uno'); - } + $this->_db->query('DROP TABLE IF EXISTS tres'); + $this->_db->query('DROP TABLE IF EXISTS dos'); + $this->_db->query('DROP TABLE IF EXISTS uno'); + } - public function testCreateDatabase() - { - $gen = new Generator($this->_db, 'Test', __DIR__ . '/data/generation/models/'); - $gen->generate(); + public function testCreateDatabase() + { + $gen = new Generator($this->_db, 'Test', __DIR__ . '/data/generation/models/'); + $gen->generate(); - $map = new Map($this->_db); - $t = $map->generate(); + $map = new Map($this->_db); + $t = $map->generate(); - $this->assertTrue(array_key_exists('uno', $t)); - $this->assertTrue(array_key_exists('dos', $t)); - $this->assertTrue(array_key_exists('tres', $t)); - $this->assertFalse(array_key_exists('bad_table', $t)); - $this->assertTrue(count($t['uno']['indexes']) == 1); - $this->assertTrue(count($t['dos']['indexes']) == 3); - $this->assertTrue(count($t['tres']['indexes']) == 2); - $this->assertTrue(count($t['uno']['columns']) == 11); - $this->assertTrue(count($t['dos']['columns']) == 4); - $this->assertTrue(count($t['tres']['columns']) == 6); - $this->assertTrue(array_key_exists('PRIMARY', $t['uno']['indexes'])); - $this->assertTrue(array_key_exists('PRIMARY', $t['dos']['indexes'])); - $this->assertFalse(array_key_exists('PRIMARY', $t['tres']['indexes'])); - } + $this->assertTrue(array_key_exists('uno', $t)); + $this->assertTrue(array_key_exists('dos', $t)); + $this->assertTrue(array_key_exists('tres', $t)); + $this->assertFalse(array_key_exists('bad_table', $t)); + $this->assertTrue(count($t['uno']['indexes']) == 1); + $this->assertTrue(count($t['dos']['indexes']) == 3); + $this->assertTrue(count($t['tres']['indexes']) == 2); + $this->assertTrue(count($t['uno']['columns']) == 11); + $this->assertTrue(count($t['dos']['columns']) == 4); + $this->assertTrue(count($t['tres']['columns']) == 6); + $this->assertTrue(array_key_exists('PRIMARY', $t['uno']['indexes'])); + $this->assertTrue(array_key_exists('PRIMARY', $t['dos']['indexes'])); + $this->assertFalse(array_key_exists('PRIMARY', $t['tres']['indexes'])); + } - public function testUpdateDatabase() - { - $gen = new Generator($this->_db, 'Test', __DIR__ . '/data/generation/models/'); - $gen->generate(); + public function testUpdateDatabase() + { + $gen = new Generator($this->_db, 'Test', __DIR__ . '/data/generation/models/'); + $gen->generate(); - $gen = new Generator($this->_db, 'Update', __DIR__ . '/data/generation/update_models/'); - $gen->generate(); + $gen = new Generator($this->_db, 'Update', __DIR__ . '/data/generation/update_models/'); + $gen->generate(); - $map = new Map($this->_db); - $t = $map->generate(); + $map = new Map($this->_db); + $t = $map->generate(); - $this->assertTrue(array_key_exists('uno', $t)); - $this->assertTrue(array_key_exists('dos', $t)); - $this->assertTrue(array_key_exists('tres', $t)); - $this->assertFalse(array_key_exists('bad_table', $t)); - $this->assertTrue(count($t['uno']['indexes']) == 1); - $this->assertTrue(count($t['dos']['indexes']) == 3); - $this->assertTrue(count($t['tres']['indexes']) == 3); - $this->assertTrue(count($t['uno']['columns']) == 10); - $this->assertTrue(count($t['dos']['columns']) == 4); - $this->assertTrue(count($t['tres']['columns']) == 10); - $this->assertTrue(array_key_exists('PRIMARY', $t['uno']['indexes'])); - $this->assertTrue(array_key_exists('PRIMARY', $t['dos']['indexes'])); - $this->assertTrue(array_key_exists('PRIMARY', $t['tres']['indexes'])); - } + $this->assertTrue(array_key_exists('uno', $t)); + $this->assertTrue(array_key_exists('dos', $t)); + $this->assertTrue(array_key_exists('tres', $t)); + $this->assertFalse(array_key_exists('bad_table', $t)); + $this->assertTrue(count($t['uno']['indexes']) == 1); + $this->assertTrue(count($t['dos']['indexes']) == 3); + $this->assertTrue(count($t['tres']['indexes']) == 3); + $this->assertTrue(count($t['uno']['columns']) == 10); + $this->assertTrue(count($t['dos']['columns']) == 4); + $this->assertTrue(count($t['tres']['columns']) == 10); + $this->assertTrue(array_key_exists('PRIMARY', $t['uno']['indexes'])); + $this->assertTrue(array_key_exists('PRIMARY', $t['dos']['indexes'])); + $this->assertTrue(array_key_exists('PRIMARY', $t['tres']['indexes'])); + } } diff --git a/tests/B8Framework/DatabaseTest.php b/tests/B8Framework/DatabaseTest.php index fb5dfee8..f7cefbb9 100755 --- a/tests/B8Framework/DatabaseTest.php +++ b/tests/B8Framework/DatabaseTest.php @@ -6,50 +6,50 @@ use b8\Database; class DatabaseTest extends \PHPUnit_Framework_TestCase { - protected $_host = 'localhost'; - protected $_user = 'b8_test'; - protected $_pass = 'b8_test'; - protected $_name = 'b8_test'; + protected $_host = 'localhost'; + protected $_user = 'b8_test'; + protected $_pass = 'b8_test'; + protected $_name = 'b8_test'; - public function testGetReadConnection() - { - Database::setDetails($this->_name, $this->_user, $this->_pass); - Database::setReadServers([$this->_host]); + public function testGetReadConnection() + { + Database::setDetails($this->_name, $this->_user, $this->_pass); + Database::setReadServers([$this->_host]); - $connection = Database::getConnection('read'); + $connection = Database::getConnection('read'); - $this->assertInstanceOf('\b8\Database', $connection); - } + $this->assertInstanceOf('\b8\Database', $connection); + } - public function testGetWriteConnection() - { - Database::setDetails($this->_name, $this->_user, $this->_pass); - Database::setWriteServers([$this->_host]); + public function testGetWriteConnection() + { + Database::setDetails($this->_name, $this->_user, $this->_pass); + Database::setWriteServers([$this->_host]); - $connection = Database::getConnection('write'); + $connection = Database::getConnection('write'); - $this->assertInstanceOf('\b8\Database', $connection); - } + $this->assertInstanceOf('\b8\Database', $connection); + } - public function testGetDetails() - { - Database::setDetails($this->_name, $this->_user, $this->_pass); - Database::setReadServers(['localhost']); + public function testGetDetails() + { + Database::setDetails($this->_name, $this->_user, $this->_pass); + Database::setReadServers(['localhost']); - $details = Database::getConnection('read')->getDetails(); - $this->assertTrue(is_array($details)); - $this->assertTrue(($details['db'] == $this->_name)); - $this->assertTrue(($details['user'] == $this->_user)); - $this->assertTrue(($details['pass'] == $this->_pass)); - } + $details = Database::getConnection('read')->getDetails(); + $this->assertTrue(is_array($details)); + $this->assertTrue(($details['db'] == $this->_name)); + $this->assertTrue(($details['user'] == $this->_user)); + $this->assertTrue(($details['pass'] == $this->_pass)); + } - /** - * @expectedException \Exception - */ - public function testConnectionFailure() - { - Database::setDetails('non_existant', 'invalid_user', 'incorrect_password'); - Database::setReadServers(['localhost']); - Database::getConnection('read'); - } + /** + * @expectedException \Exception + */ + public function testConnectionFailure() + { + Database::setDetails('non_existant', 'invalid_user', 'incorrect_password'); + Database::setReadServers(['localhost']); + Database::getConnection('read'); + } } \ No newline at end of file diff --git a/tests/B8Framework/FormTest.php b/tests/B8Framework/FormTest.php index b0e6b4cd..515f78cd 100755 --- a/tests/B8Framework/FormTest.php +++ b/tests/B8Framework/FormTest.php @@ -6,173 +6,173 @@ use b8\Form, b8\Config; class FormTest extends \PHPUnit_Framework_TestCase { - public function testFormBasics() - { - $f = new Form(); - $f->setAction('/'); - $f->setMethod('POST'); + public function testFormBasics() + { + $f = new Form(); + $f->setAction('/'); + $f->setMethod('POST'); - $this->assertTrue($f->getAction() == '/'); - $this->assertTrue($f->getMethod() == 'POST'); + $this->assertTrue($f->getAction() == '/'); + $this->assertTrue($f->getMethod() == 'POST'); - $config = new Config(); - Config::getInstance()->set('ViewPath', __DIR__ . '/data/view/'); + $config = new Config(); + Config::getInstance()->set('ViewPath', __DIR__ . '/data/view/'); - $this->assertTrue($f->render('form') == '/POST'); + $this->assertTrue($f->render('form') == '/POST'); - Config::getInstance()->set('ViewPath', ''); - $this->assertTrue(strpos((string)$f, '