diff --git a/README.md b/README.md deleted file mode 100644 index dcc9bd2..0000000 --- a/README.md +++ /dev/null @@ -1,10 +0,0 @@ -# SucklessPHP - Another PHP framework that sucks less - -Follow this documentation: - -https://gitpull.it/w/suckless-php/ - -## License -Copyright (c) 2015-2019 [Valerio Bozzolan](http://boz.reyboz.it/) - -This is a **Free** as in **Freedom** project. It comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under the terms of the **GNU General Public License v3+**. diff --git a/tests/TestFilesystem.php b/phpunit/FilesystemTest.php similarity index 95% rename from tests/TestFilesystem.php rename to phpunit/FilesystemTest.php index fefd083..695a44a 100644 --- a/tests/TestFilesystem.php +++ b/phpunit/FilesystemTest.php @@ -1,60 +1,60 @@ assertEquals( append_dir( 'asd', 'dsa' ), 'asd/dsa' ); } /** * Test the append_dir() function */ public function testAppendDir2() { $this->assertEquals( append_dir( 'asd/', 'dsa' ), 'asd/dsa' ); } /** * Test the append_dir() function */ public function testAppendDir3() { $this->assertEquals( append_dir( 'asd', '/dsa' ), 'asd/dsa' ); } /** * Test the append_dir() function */ public function testAppendDir4() { $this->assertEquals( append_dir( 'asd/', '/dsa' ), 'asd/dsa' ); } /** * Test the append_dir() function with a custom glue */ public function testAppendDirCustomGlue() { $this->assertEquals( append_dir( 'asd\\', '\\dsa', '\\' ), 'asd\\dsa' // intended as "asd\dsa" ); } } diff --git a/tests/TestQuery.php b/phpunit/QueryTest.php similarity index 85% rename from tests/TestQuery.php rename to phpunit/QueryTest.php index 40accd7..0cd2b46 100644 --- a/tests/TestQuery.php +++ b/phpunit/QueryTest.php @@ -1,130 +1,148 @@ select( 'field' ); $query->from( 'table' ); $query->where( 'condition1' ); $query->openBracket() ->setGlue( 'OR' ); $query->where( 'condition2' ); $query->openBracket(); $query->where( 'condition3' ); $query->where( 'condition4' ); $query->closeBracket(); $query->where( 'condition5' ); $query->closeBracket() ->setGlue( 'AND' ); $query->where( 'condition6' ); $query->where( 'condition7' ); $this->assertEquals( 'SELECT field FROM `table` AS `table` WHERE condition1 AND (condition2 OR (condition3 OR condition4) OR condition5) AND condition6 AND condition7', $query->getQuery() ); } /** * Test the EXISTS */ public function testExistsCondition() { // create a couple for dummy query builders $query = new Query( new DBDummy() ); $query2 = new Query( new DBDummy() ); $query->from( 'one' ); $query2->from( 'two' ) ->whereInt( 'two_field', 2 ) ->compare( 'one.a', '<', 'two.b' ); $query->whereExists( $query2 ); $this->assertEquals( 'SELECT * FROM `one` AS `one` WHERE EXISTS (SELECT * FROM `two` AS `two` WHERE two_field = 2 AND one.a < two.b)', $query->getQuery() ); } /** * Test the FROM with an alias */ public function testFromWithAlias() { $query = new Query( new DBDummy() ); $query->fromAlias( 'one', 'asd' ); $this->assertEquals( 'SELECT * FROM `one` AS `asd`', $query->getQuery() ); } /** * Allow to have a query without the FROM */ public function testEmptyFrom() { $query = new Query( new DBDummy() ); $query->select( '1' ); $this->assertEquals( 'SELECT 1', $query->getQuery() ); } /** * SELECT with a custom AS argument */ public function testSelectAs() { $query = new Query( new DBDummy() ); $query->selectAs( '1', 'ciao' ); $this->assertEquals( - 'SELECT (1) ciao', + 'SELECT ( 1 ) ciao', $query->getQuery() ); } /** * Test the SELECT with the empty AS argument */ public function testSelectAsEmpty() { $query = new Query( new DBDummy() ); $query->selectAs( '1', null ); $this->assertEquals( - 'SELECT (1)', + 'SELECT ( 1 )', + $query->getQuery() + ); + } + + /** + * Test the SELECT with a NOT EXISTS constraint + */ + public function testSelectNotExists() { + + $query = new Query( new DBDummy() ); + $sub = new Query( new DBDummy() ); + + $sub->select( 1 ); + + $query->whereNotExists( $sub ); + + $this->assertEquals( + 'SELECT * WHERE NOT EXISTS (SELECT 1)', $query->getQuery() ); } } diff --git a/phpunit/README.md b/phpunit/README.md new file mode 100644 index 0000000..eef1711 --- /dev/null +++ b/phpunit/README.md @@ -0,0 +1,7 @@ +# How to run a test + +From the parent directory: + +``` +phpunit --bootstrap=phpunit/load.php --testdox phpunit +``` diff --git a/tests/load.php b/phpunit/load.php similarity index 100% rename from tests/load.php rename to phpunit/load.php diff --git a/tests/README.md b/tests/README.md deleted file mode 100644 index 05e5a94..0000000 --- a/tests/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# How to run a test - -``` -phpunit --bootstrap=load.php --testdox Test* -```