# HG changeset patch # User Markus Bröker # Date 1447430464 -3600 # Node ID 66b604c61e6246514d24dfdb70536c37eb8785fe # Parent 16e5372a872ecc42ac34b474ef3093a023f57a33 Testreihe für die Datenbank-Klasse hinzu gefügt diff --git a/.idea/php.xml b/.idea/php.xml --- a/.idea/php.xml +++ b/.idea/php.xml @@ -1,4 +1,9 @@ + + + + + \ No newline at end of file diff --git a/config/config.php b/config/config.php --- a/config/config.php +++ b/config/config.php @@ -18,7 +18,7 @@ $classPath = sprintf('classes/%s.php', $nsClass); if (file_exists($filename)) { - require_once "$classPath"; + require_once BFW_PATH . "/$classPath"; return true; } @@ -26,7 +26,7 @@ return false; } -require_once 'library/log4php/Logger.php'; +require_once BFW_PATH . '/library/log4php/Logger.php'; Logger::configure(BFW_PATH . '/config/log4php.xml'); spl_autoload_register('bfw_autoLoader'); diff --git a/config/log4php.xml b/config/log4php.xml --- a/config/log4php.xml +++ b/config/log4php.xml @@ -2,7 +2,7 @@ - + diff --git a/data/import/test_users.csv b/data/import/test_users.csv --- a/data/import/test_users.csv +++ b/data/import/test_users.csv @@ -1,12 +1,2 @@ group_id;username;password;firstname;lastname -3;manager1@testbox.de;098f6bcd4621d373cade4e832627b4f6;Manager1;Testbox -4;supporter1@testbox.de;098f6bcd4621d373cade4e832627b4f6;supporter1;Testbox -4;supporter2@testbox.de;098f6bcd4621d373cade4e832627b4f6;supporter2;Testbox -4;supporter3@testbox.de;098f6bcd4621d373cade4e832627b4f6;supporter3;Testbox -4;supporter4@testbox.de;098f6bcd4621d373cade4e832627b4f6;supporter4;Testbox -4;supporter5@testbox.de;098f6bcd4621d373cade4e832627b4f6;supporter5;Testbox -4;supporter6@testbox.de;098f6bcd4621d373cade4e832627b4f6;supporter6;Testbox -4;supporter7@testbox.de;098f6bcd4621d373cade4e832627b4f6;supporter7;Testbox -4;supporter8@testbox.de;098f6bcd4621d373cade4e832627b4f6;supporter8;Testbox -4;supporter9@testbox.de;098f6bcd4621d373cade4e832627b4f6;supporter9;Testbox -4;supporter10@testbox.de;098f6bcd4621d373cade4e832627b4f6;supporter10;Testbox +3;test1@testbox.de;098f6bcd4621d373cade4e832627b4f6;Test1;Testbox \ No newline at end of file diff --git a/tests/bfw/DatabaseTest.php b/tests/bfw/DatabaseTest.php new file mode 100644 --- /dev/null +++ b/tests/bfw/DatabaseTest.php @@ -0,0 +1,52 @@ +object = Database::getInstance(); + } + + public function testStore() { + $data = array(); + $data['password'] = md5(rand(0, 255)); + + $result = $this->object->store('t_user', 1, $data); + $this->assertTrue($result !== false); + } + + public function testFetch() { + $data = $this->object->fetch('t_user', 'id = 1'); + + $this->assertEquals('system@testbox.de', $data['username']); + } + + public function testFetchAll() { + $data = $this->object->fetchAll('t_user', 'id < 3'); + + $this->assertTrue(is_array($data)); + + foreach ($data as $row) { + echo sprintf("%s\n", implode(', ', $row)); + } + } + + public function testFind() { + $data = $this->object->find('t_user', -1); + $this->assertEquals(null, $data); + + $data = $this->object->find('t_user', 1); + $this->assertEquals(1, $data['id']); + } + + public function testFindAll() { + $data1 = $this->object->findAll('t_user', true); + $data2 = $this->object->findAll('t_user', false); + + $this->assertTrue(count($data1) != count($data2)); + } +}