Changeset 1298
- Timestamp:
- 01/25/08 00:34:11 (7 months ago)
- Files:
-
- trunk/src/main/php/net/stubbles/rdbms/pdo/stubDatabasePDOStatement.php (modified) (12 diffs)
- trunk/src/test/AllTests.php (modified) (3 diffs)
- trunk/src/test/php/net/stubbles/rdbms/RDBMSTestSuite.php (modified) (1 diff)
- trunk/src/test/php/net/stubbles/rdbms/criteria/stubAndCriterionTestCase.php (modified) (4 diffs)
- trunk/src/test/php/net/stubbles/rdbms/criteria/stubEqualCriterionTestCase.php (modified) (1 diff)
- trunk/src/test/php/net/stubbles/rdbms/criteria/stubGreaterEqualCriterionTestCase.php (modified) (1 diff)
- trunk/src/test/php/net/stubbles/rdbms/criteria/stubGreaterThanCriterionTestCase.php (modified) (1 diff)
- trunk/src/test/php/net/stubbles/rdbms/criteria/stubInCriterionTestCase.php (modified) (1 diff)
- trunk/src/test/php/net/stubbles/rdbms/criteria/stubLessEqualCriterionTestCase.php (modified) (1 diff)
- trunk/src/test/php/net/stubbles/rdbms/criteria/stubLessThanCriterionTestCase.php (modified) (1 diff)
- trunk/src/test/php/net/stubbles/rdbms/criteria/stubLikeCriterionTestCase.php (modified) (2 diffs)
- trunk/src/test/php/net/stubbles/rdbms/criteria/stubNegateCriterionTestCase.php (modified) (2 diffs)
- trunk/src/test/php/net/stubbles/rdbms/criteria/stubOrCriterionTestCase.php (modified) (4 diffs)
- trunk/src/test/php/net/stubbles/rdbms/pdo/stubDatabasePDOConnectionTestCase.php (modified) (5 diffs)
- trunk/src/test/php/net/stubbles/rdbms/pdo/stubDatabasePDOStatementTestCase.php (modified) (11 diffs)
- trunk/src/test/php/net/stubbles/rdbms/stubDatabaseConnectionDataTestCase.php (modified) (2 diffs)
- trunk/src/test/php/net/stubbles/rdbms/stubDatabaseConnectionPoolTestCase.php (modified) (8 diffs)
- trunk/src/test/php/net/stubbles/rdbms/stubDatabaseInitializerTestCase.php (modified) (2 diffs)
- trunk/src/test/run.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/main/php/net/stubbles/rdbms/pdo/stubDatabasePDOStatement.php
r1281 r1298 62 62 * @throws stubDatabaseException 63 63 * @see http://php.net/pdostatement-bindColumn 64 * @see net::stubbles::rdbms .stubDatabaseResult::bindColumn()64 * @see net::stubbles::rdbms::stubDatabaseResult::bindColumn() 65 65 */ 66 66 public function bindColumn($column, &$variable, $type = null) 67 67 { 68 68 try { 69 return $this->pdoStatement->bindColumn($column, $variable, $type );69 return $this->pdoStatement->bindColumn($column, $variable, $type, null, null); 70 70 } catch (PDOException $pdoe) { 71 71 throw new stubDatabaseException($pdoe->getMessage(), $pdoe); … … 88 88 * @throws stubDatabaseException 89 89 * @see http://php.net/pdostatement-bindParam 90 * @see net::stubbles::rdbms .stubDatabaseStatement::bindParam()90 * @see net::stubbles::rdbms::stubDatabaseStatement::bindParam() 91 91 */ 92 92 public function bindParam($param, &$variable, $type = null, $length = null) 93 93 { 94 94 try { 95 return $this->pdoStatement->bindParam($param, $variable, $type, $length );95 return $this->pdoStatement->bindParam($param, $variable, $type, $length, null); 96 96 } catch (PDOException $pdoe) { 97 97 throw new stubDatabaseException($pdoe->getMessage(), $pdoe); … … 111 111 * @throws stubDatabaseException 112 112 * @see http://php.net/pdostatement-bindValue 113 * @see net::stubbles::rdbms .stubDatabaseStatement::bindValue()113 * @see net::stubbles::rdbms::stubDatabaseStatement::bindValue() 114 114 */ 115 115 public function bindValue($param, $value, $type = null) … … 131 131 * @throws stubDatabaseException 132 132 * @see http://php.net/pdostatement-execute 133 * @see net::stubbles::rdbms .stubDatabaseStatement::execute()133 * @see net::stubbles::rdbms::stubDatabaseStatement::execute() 134 134 */ 135 135 public function execute(array $values = array()) … … 154 154 * @throws stubDatabaseException 155 155 * @see http://php.net/pdostatement-fetch 156 * @see net::stubbles::rdbms .stubDatabaseResult::fetch()156 * @see net::stubbles::rdbms::stubDatabaseResult::fetch() 157 157 */ 158 158 public function fetch($fetchMode = null, array $driverOptions = array()) … … 179 179 * @throws stubDatabaseException 180 180 * @see http://php.net/pdostatement-fetchColumn 181 * @see net::stubbles::rdbms .stubDatabaseResult::fetchOne()181 * @see net::stubbles::rdbms::stubDatabaseResult::fetchOne() 182 182 */ 183 183 public function fetchOne($columnNumber = 0) … … 198 198 * @throws stubDatabaseException 199 199 * @see http://php.net/pdostatement-fetchAll 200 * @see net::stubbles::rdbms .stubDatabaseResult::fetchAll()200 * @see net::stubbles::rdbms::stubDatabaseResult::fetchAll() 201 201 */ 202 202 public function fetchAll($fetchMode = null, array $driverOptions = array()) … … 204 204 try { 205 205 if (null === $fetchMode) { 206 return $this->pdoStatement->fetchAll( );206 return $this->pdoStatement->fetchAll(null, null, null); 207 207 } 208 208 209 209 if (PDO::FETCH_COLUMN == $fetchMode) { 210 return $this->pdoStatement->fetchAll($fetchMode, ((isset($driverOptions['columnIndex']) == false) ? (0) : ($driverOptions['columnIndex'])) );210 return $this->pdoStatement->fetchAll($fetchMode, ((isset($driverOptions['columnIndex']) == false) ? (0) : ($driverOptions['columnIndex'])), null); 211 211 } 212 212 213 return $this->pdoStatement->fetchAll($fetchMode );213 return $this->pdoStatement->fetchAll($fetchMode, null, null); 214 214 } catch (PDOException $pdoe) { 215 215 throw new stubDatabaseException($pdoe->getMessage(), $pdoe); … … 223 223 * @throws stubDatabaseException 224 224 * @see http://php.net/pdostatement-nextRowset 225 * @see net::stubbles::rdbms .stubDatabaseResult::next()225 * @see net::stubbles::rdbms::stubDatabaseResult::next() 226 226 */ 227 227 public function next() … … 240 240 * @throws stubDatabaseException 241 241 * @see http://php.net/pdostatement-rowCount 242 * @see net::stubbles::rdbms .stubDatabaseResult::count()242 * @see net::stubbles::rdbms::stubDatabaseResult::count() 243 243 */ 244 244 public function count() … … 261 261 * @throws stubDatabaseException 262 262 * @see http://php.net/pdostatement-closeCursor 263 * @see net::stubbles::rdbms .stubDatabaseResult::free()263 * @see net::stubbles::rdbms::stubDatabaseResult::free() 264 264 */ 265 265 public function free() … … 280 280 * 281 281 * @return bool true on success, false on failure 282 * @throws stubDatabaseException 283 * @see net::stubbles::rdbms.stubDatabaseStatement::clean() 282 * @see net::stubbles::rdbms::stubDatabaseStatement::clean() 284 283 */ 285 284 public function clean() trunk/src/test/AllTests.php
r1288 r1298 20 20 require_once 'PHPUnit/Util/Filter.php'; 21 21 PHPUnit_Util_Filter::addDirectoryToWhitelist(stubConfig::getSourcePath() . '/php'); 22 PHPUnit_Util_Filter::removeDirectoryFromWhitelist(stubConfig::getSourcePath() . '/php/net/stubbles/util/ext'); 22 23 PHPUnit_Util_Filter::removeDirectoryFromWhitelist(stubConfig::getSourcePath() . '/php/net/stubbles/util/xjconf'); 23 24 PHPUnit_Util_Filter::removeDirectoryFromWhitelist(stubConfig::getSourcePath() . '/php/org'); … … 28 29 require_once $dir . '/php/net/stubbles/ioc/IOCTestSuite.php'; 29 30 require_once $dir . '/php/net/stubbles/ipo/IPOTestSuite.php'; 31 require_once $dir . '/php/net/stubbles/rdbms/RDBMSTestSuite.php'; 30 32 require_once $dir . '/php/net/stubbles/util/UtilTestSuite.php'; 31 33 require_once $dir . '/php/net/stubbles/websites/WebsitesTestSuite.php'; … … 61 63 $suite->addTestSuite('IOCTestSuite'); 62 64 $suite->addTestSuite('IPOTestSuite'); 65 $suite->addTestSuite('RDBMSTestSuite'); 63 66 $suite->addTestSuite('UtilTestSuite'); 64 67 $suite->addTestSuite('WebsitesTestSuite'); trunk/src/test/php/net/stubbles/rdbms/RDBMSTestSuite.php
r951 r1298 13 13 * @subpackage test 14 14 */ 15 class RDBMSTestSuite extends TestSuite15 class RDBMSTestSuite extends PHPUnit_Framework_TestSuite 16 16 { 17 17 /** 18 * constructor 18 * returns the test suite to be run 19 * 20 * @return PHPUnit_Framework_TestSuite 19 21 */ 20 public function __construct()22 public static function suite() 21 23 { 22 $ this->TestSuite('All rdbms tests');23 $dir = dirname(__FILE__);24 $ this->addTestFile($dir . '/stubDatabaseConnectionDataTestCase.php');25 $ this->addTestFile($dir . '/stubDatabaseConnectionPoolTestCase.php');26 $ this->addTestFile($dir . '/stubDatabaseInitializerTestCase.php');24 $suite = new self(); 25 $dir = dirname(__FILE__); 26 $suite->addTestFile($dir . '/stubDatabaseConnectionDataTestCase.php'); 27 $suite->addTestFile($dir . '/stubDatabaseConnectionPoolTestCase.php'); 28 $suite->addTestFile($dir . '/stubDatabaseInitializerTestCase.php'); 27 29 28 30 // criteria 29 $ this->addTestFile($dir . '/criteria/stubAndCriterionTestCase.php');30 $ this->addTestFile($dir . '/criteria/stubEqualCriterionTestCase.php');31 $ this->addTestFile($dir . '/criteria/stubGreaterEqualCriterionTestCase.php');32 $ this->addTestFile($dir . '/criteria/stubGreaterThanCriterionTestCase.php');33 $ this->addTestFile($dir . '/criteria/stubInCriterionTestCase.php');34 $ this->addTestFile($dir . '/criteria/stubLessEqualCriterionTestCase.php');35 $ this->addTestFile($dir . '/criteria/stubLessThanCriterionTestCase.php');36 $ this->addTestFile($dir . '/criteria/stubLikeCriterionTestCase.php');37 $ this->addTestFile($dir . '/criteria/stubNegateCriterionTestCase.php');38 $ this->addTestFile($dir . '/criteria/stubOrCriterionTestCase.php');31 $suite->addTestFile($dir . '/criteria/stubAndCriterionTestCase.php'); 32 $suite->addTestFile($dir . '/criteria/stubEqualCriterionTestCase.php'); 33 $suite->addTestFile($dir . '/criteria/stubGreaterEqualCriterionTestCase.php'); 34 $suite->addTestFile($dir . '/criteria/stubGreaterThanCriterionTestCase.php'); 35 $suite->addTestFile($dir . '/criteria/stubInCriterionTestCase.php'); 36 $suite->addTestFile($dir . '/criteria/stubLessEqualCriterionTestCase.php'); 37 $suite->addTestFile($dir . '/criteria/stubLessThanCriterionTestCase.php'); 38 $suite->addTestFile($dir . '/criteria/stubLikeCriterionTestCase.php'); 39 $suite->addTestFile($dir . '/criteria/stubNegateCriterionTestCase.php'); 40 $suite->addTestFile($dir . '/criteria/stubOrCriterionTestCase.php'); 39 41 40 42 // pdo 41 $ this->addTestFile($dir . '/pdo/stubDatabasePDOConnectionTestCase.php');42 $ this->addTestFile($dir . '/pdo/stubDatabasePDOStatementTestCase.php');43 $suite->addTestFile($dir . '/pdo/stubDatabasePDOConnectionTestCase.php'); 44 $suite->addTestFile($dir . '/pdo/stubDatabasePDOStatementTestCase.php'); 43 45 44 46 // persistence 45 $this->addTestFile($dir . '/persistence/stubSetterMethodHelperTestCase.php');46 $this->addTestFile($dir . '/persistence/creator/stubDatabaseCreatorTestCase.php');47 $this->addTestFile($dir . '/persistence/eraser/stubDatabaseEraserTestCase.php');48 $this->addTestFile($dir . '/persistence/finder/stubDatabaseFinderTestCase.php');49 $this->addTestFile($dir . '/persistence/serializer/stubDatabaseSerializerTestCase.php');47 #$suite->addTestFile($dir . '/persistence/stubSetterMethodHelperTestCase.php'); 48 #$suite->addTestFile($dir . '/persistence/creator/stubDatabaseCreatorTestCase.php'); 49 #$suite->addTestFile($dir . '/persistence/eraser/stubDatabaseEraserTestCase.php'); 50 #$suite->addTestFile($dir . '/persistence/finder/stubDatabaseFinderTestCase.php'); 51 #$suite->addTestFile($dir . '/persistence/serializer/stubDatabaseSerializerTestCase.php'); 50 52 51 53 // querybuilder 52 $this->addTestFile($dir . '/querybuilder/stubDatabaseMySQLQueryBuilderTestCase.php');53 $this->addTestFile($dir . '/querybuilder/stubDatabaseQueryBuilderFactoryTestCase.php');54 $this->addTestFile($dir . '/querybuilder/stubDatabaseSelectTestCase.php');55 $this->addTestFile($dir . '/querybuilder/stubDatabaseTableColumnTestCase.php');56 $this->addTestFile($dir . '/querybuilder/stubDatabaseTableDescriptionTestCase.php');57 $this->addTestFile($dir . '/querybuilder/stubDatabaseTableJoinTestCase.php');58 $this->addTestFile($dir . '/querybuilder/stubDatabaseTableRowTestCase.php');59 54 #$suite->addTestFile($dir . '/querybuilder/stubDatabaseMySQLQueryBuilderTestCase.php'); 55 #$suite->addTestFile($dir . '/querybuilder/stubDatabaseQueryBuilderFactoryTestCase.php'); 56 #$suite->addTestFile($dir . '/querybuilder/stubDatabaseSelectTestCase.php'); 57 #$suite->addTestFile($dir . '/querybuilder/stubDatabaseTableColumnTestCase.php'); 58 #$suite->addTestFile($dir . '/querybuilder/stubDatabaseTableDescriptionTestCase.php'); 59 #$suite->addTestFile($dir . '/querybuilder/stubDatabaseTableJoinTestCase.php'); 60 #$suite->addTestFile($dir . '/querybuilder/stubDatabaseTableRowTestCase.php'); 61 return $suite; 60 62 } 61 63 } trunk/src/test/php/net/stubbles/rdbms/criteria/stubAndCriterionTestCase.php
r1225 r1298 8 8 */ 9 9 stubClassLoader::load('net::stubbles::rdbms::criteria::stubAndCriterion'); 10 Mock::generate('stubCriterion');11 10 /** 12 11 * Test for net::stubbles::rdbms::criteria::stubAndCriterion. … … 15 14 * @subpackage rdbms_criteria_test 16 15 */ 17 class stubAndCriterionTestCase extends UnitTestCase16 class stubAndCriterionTestCase extends PHPUnit_Framework_TestCase 18 17 { 19 18 /** … … 23 22 */ 24 23 protected $andCriterion; 25 24 26 25 /** 27 26 * set up test environment … … 31 30 $this->andCriterion = new stubAndCriterion(); 32 31 } 33 32 34 33 /** 35 34 * check that no criterion added triggers a stubCriterionException 35 * 36 * @test 37 * @expectedException stubCriterionException 36 38 */ 37 public function testZero()39 public function zero() 38 40 { 39 41 $this->assertFalse($this->andCriterion->hasCriterion()); 40 $this->expectException('stubCriterionException');41 42 $this->andCriterion->toSQL(); 42 43 } 43 44 44 45 /** 45 46 * check that one criterion is handled correct 47 * 48 * @test 46 49 */ 47 public function testOne()50 public function one() 48 51 { 49 $mockCriterionOne = new MockstubCriterion();50 $mockCriterionOne-> setReturnValue('toSQL', 'foo');52 $mockCriterionOne = $this->getMock('stubCriterion'); 53 $mockCriterionOne->expects($this->once())->method('toSQL')->will($this->returnValue('foo')); 51 54 $this->andCriterion->addCriterion($mockCriterionOne); 52 55 $this->assertTrue($this->andCriterion->hasCriterion()); 53 $this->assertEqual ($this->andCriterion->toSQL(), '(foo)');56 $this->assertEquals('(foo)', $this->andCriterion->toSQL()); 54 57 } 55 58 56 59 /** 57 60 * check that two criteria are handled correct 61 * 62 * @test 58 63 */ 59 public function t estTwo()64 public function two() 60 65 { 61 $mockCriterionOne = new MockstubCriterion();62 $mockCriterionOne-> setReturnValue('toSQL', 'foo');66 $mockCriterionOne = $this->getMock('stubCriterion'); 67 $mockCriterionOne->expects($this->once())->method('toSQL')->will($this->returnValue('foo')); 63 68 $this->andCriterion->addCriterion($mockCriterionOne); 64 $mockCriterionTwo = new MockstubCriterion();65 $mockCriterionTwo-> setReturnValue('toSQL', 'bar');69 $mockCriterionTwo = $this->getMock('stubCriterion'); 70 $mockCriterionTwo->expects($this->once())->method('toSQL')->will($this->returnValue('bar')); 66 71 $this->andCriterion->addCriterion($mockCriterionTwo); 67 72 $this->assertTrue($this->andCriterion->hasCriterion()); 68 $this->assertEqual ($this->andCriterion->toSQL(), '(foo AND bar)');73 $this->assertEquals('(foo AND bar)', $this->andCriterion->toSQL()); 69 74 } 70 75 } trunk/src/test/php/net/stubbles/rdbms/criteria/stubEqualCriterionTestCase.php
r1225 r1298 14 14 * @subpackage rdbms_criteria_test 15 15 */ 16 class stubEqualCriterionTestCase extends UnitTestCase16 class stubEqualCriterionTestCase extends PHPUnit_Framework_TestCase 17 17 { 18 18 /** 19 19 * check that a null value gets correct operator 20 * 21 * @test 20 22 */ 21 public function testNull()23 public function equalsNull() 22 24 { 23 25 $equalCriterion = new stubEqualCriterion('foo', null); 24 $this->assertEqual ($equalCriterion->toSQL(), '`foo` IS NULL');26 $this->assertEquals('`foo` IS NULL',$equalCriterion->toSQL()); 25 27 $equalCriterion = new stubEqualCriterion('foo', null, 'bar'); 26 $this->assertEqual ($equalCriterion->toSQL(), '`bar`.`foo` IS NULL');28 $this->assertEquals('`bar`.`foo` IS NULL', $equalCriterion->toSQL()); 27 29 } 28 30 29 31 /** 30 32 * check that any other value gets correct operator 33 * 34 * @test 31 35 */ 32 public function testValue()36 public function value() 33 37 { 34 38 $equalCriterion = new stubEqualCriterion('foo', 'bar'); 35 $this->assertEqual ($equalCriterion->toSQL(), "`foo` = 'bar'");39 $this->assertEquals("`foo` = 'bar'", $equalCriterion->toSQL()); 36 40 $equalCriterion = new stubEqualCriterion('foo', 'bar', 'baz'); 37 $this->assertEqual ($equalCriterion->toSQL(), "`baz`.`foo` = 'bar'");41 $this->assertEquals("`baz`.`foo` = 'bar'", $equalCriterion->toSQL()); 38 42 } 39 43 } trunk/src/test/php/net/stubbles/rdbms/criteria/stubGreaterEqualCriterionTestCase.php
r1225 r1298 14 14 * @subpackage rdbms_criteria_test 15 15 */ 16 class stubGreaterEqualCriterionTestCase extends UnitTestCase16 class stubGreaterEqualCriterionTestCase extends PHPUnit_Framework_TestCase 17 17 { 18 18 /** 19 19 * check that a null value throws a stubCriterionException 20 * 21 * @test 22 * @expectedException stubCriterionException 20 23 */ 21 public function testNull()24 public function equalsNull() 22 25 { 23 $this->expectException('stubCriterionException');24 26 $greaterEqualCriterion = new stubGreaterEqualCriterion('foo', null); 25 27 } 26 28 27 29 /** 28 30 * check that any other value gets correct sql result 31 * 32 * @test 29 33 */ 30 public function testValue()34 public function value() 31 35 { 32 36 $greaterEqualCriterion = new stubGreaterEqualCriterion('foo', 5); 33 $this->assertEqual ($greaterEqualCriterion->toSQL(), "`foo` >= '5'");37 $this->assertEquals("`foo` >= '5'", $greaterEqualCriterion->toSQL()); 34 38 $greaterEqualCriterion = new stubGreaterEqualCriterion('foo', 6, 'baz'); 35 $this->assertEqual ($greaterEqualCriterion->toSQL(), "`baz`.`foo` >= '6'");39 $this->assertEquals("`baz`.`foo` >= '6'", $greaterEqualCriterion->toSQL()); 36 40 } 37 41 } trunk/src/test/php/net/stubbles/rdbms/criteria/stubGreaterThanCriterionTestCase.php
r1225 r1298 14 14 * @subpackage rdbms_criteria_test 15 15 */ 16 class stubGreaterThanCriterionTestCase extends UnitTestCase16 class stubGreaterThanCriterionTestCase extends PHPUnit_Framework_TestCase 17 17 { 18 18 /** 19 19 * check that a null value throws a stubCriterionException 20 * 21 * @test 22 * @expectedException stubCriterionException 20 23 */ 21 public function testNull()24 public function equalsNull() 22 25 { 23 $this->expectException('stubCriterionException');24 26 $greaterThanCriterion = new stubGreaterThanCriterion('foo', null); 25 27 } 26 28 27 29 /** 28 30 * check that any other value gets correct sql result 31 * 32 * @test 29 33 */ 30 public function testValue()34 public function value() 31 35 { 32 36 $greaterThanCriterion = new stubGreaterThanCriterion('foo', 5); 33 $this->assertEqual ($greaterThanCriterion->toSQL(), "`foo` > '5'");37 $this->assertEquals("`foo` > '5'", $greaterThanCriterion->toSQL()); 34 38 $greaterThanCriterion = new stubGreaterThanCriterion('foo', 6, 'baz'); 35 $this->assertEqual ($greaterThanCriterion->toSQL(), "`baz`.`foo` > '6'");39 $this->assertEquals("`baz`.`foo` > '6'", $greaterThanCriterion->toSQL()); 36 40 } 37 41 } trunk/src/test/php/net/stubbles/rdbms/criteria/stubInCriterionTestCase.php
r1225 r1298 14 14 * @subpackage rdbms_criteria_test 15 15 */ 16 class stubInCriterionTestCase extends UnitTestCase16 class stubInCriterionTestCase extends PHPUnit_Framework_TestCase 17 17 { 18 18 /** 19 19 * check that a null value throws a stubCriterionException 20 * 21 * @test 22 * @expectedException stubCriterionException 20 23 */ 21 public function testNonArray()24 public function nonArray() 22 25 { 23 $this->expectException('stubCriterionException');24 26 $inCriterion = new stubInCriterion('foo', 'bar'); 25 27 } 26 28 27 29 /** 28 30 * check that one value is handled correct 31 * 32 * @test 29 33 */ 30 public function testOne()34 public function one() 31 35 { 32 36 $inCriterion = new stubInCriterion('foo', array('bar')); 33 $this->assertEqual ($inCriterion->toSQL(), "`foo` IN ('bar')");37 $this->assertEquals("`foo` IN ('bar')", $inCriterion->toSQL()); 34 38 $inCriterion = new stubInCriterion('foo', array('bar'), 'baz'); 35 $this->assertEqual ($inCriterion->toSQL(), "`baz`.`foo` IN ('bar')");39 $this->assertEquals("`baz`.`foo` IN ('bar')", $inCriterion->toSQL()); 36 40 } 37 41 38 42 /** 39 43 * check that two values are handled correct 44 * 45 * @test 40 46 */ 41 public function t estTwo()47 public function two() 42 48 { 43 49 $inCriterion = new stubInCriterion('foo', array('bar', 'dummy')); 44 $this->assertEqual ($inCriterion->toSQL(), "`foo` IN ('bar', 'dummy')");50 $this->assertEquals("`foo` IN ('bar', 'dummy')", $inCriterion->toSQL()); 45 51 $inCriterion = new stubInCriterion('foo', array('bar', 'dummy'), 'baz'); 46 $this->assertEqual ($inCriterion->toSQL(), "`baz`.`foo` IN ('bar', 'dummy')");52 $this->assertEquals("`baz`.`foo` IN ('bar', 'dummy')", $inCriterion->toSQL()); 47 53 } 48 54 } trunk/src/test/php/net/stubbles/rdbms/criteria/stubLessEqualCriterionTestCase.php
r1225 r1298 14 14 * @subpackage rdbms_criteria_test 15 15 */ 16 class stubLessEqualCriterionTestCase extends UnitTestCase16 class stubLessEqualCriterionTestCase extends PHPUnit_Framework_TestCase 17 17 { 18 18 /** 19 19 * check that a null value throws a stubCriterionException 20 * 21 * @test 22 * @expectedException stubCriterionException 20 23 */ 21 public function testNull()24 public function equalsNull() 22 25 { 23 $this->expectException('stubCriterionException');24 26 $lessEqualCriterion = new stubLessEqualCriterion('foo', null); 25 27 } 26 28 27 29 /** 28 30 * check that any other value gets correct sql result 31 * 32 * @test 29 33 */ 30 public function testValue()34 public function value() 31 35 { 32 36 $lessEqualCriterion = new stubLessEqualCriterion('foo', 5); 33 $this->assertEqual ($lessEqualCriterion->toSQL(), "`foo` <= '5'");37 $this->assertEquals("`foo` <= '5'", $lessEqualCriterion->toSQL()); 34 38 $lessEqualCriterion = new stubLessEqualCriterion('foo', 6, 'baz'); 35 $this->assertEqual ($lessEqualCriterion->toSQL(), "`baz`.`foo` <= '6'");39 $this->assertEquals("`baz`.`foo` <= '6'", $lessEqualCriterion->toSQL()); 36 40 } 37 41 } trunk/src/test/php/net/stubbles/rdbms/criteria/stubLessThanCriterionTestCase.php
r1225 r1298 14 14 * @subpackage rdbms_criteria_test 15 15 */ 16 class stubLessThanCriterionTestCase extends UnitTestCase16 class stubLessThanCriterionTestCase extends PHPUnit_Framework_TestCase 17 17 { 18 18 /** 19 19 * check that a null value throws a stubCriterionException 20 * 21 * @test 22 * @expectedException stubCriterionException 20 23 */ 21 public function testNull()24 public function equalsNull() 22 25 { 23 $this->expectException('stubCriterionException');24 26 $lessThanCriterion = new stubLessThanCriterion('foo', null); 25 27 } 26 28 27 29 /** 28 30 * check that any other value gets correct sql result 31 * 32 * @test 29 33 */ 30 public function testValue()34 public function value() 31 35 { 32 36 $lessThanCriterion = new stubLessThanCriterion('foo', 5); 33 $this->assertEqual ($lessThanCriterion->toSQL(), "`foo` < '5'");37 $this->assertEquals("`foo` < '5'", $lessThanCriterion->toSQL()); 34 38 $lessThanCriterion = new stubLessThanCriterion('foo', 6, 'baz'); 35 $this->assertEqual ($lessThanCriterion->toSQL(), "`baz`.`foo` < '6'");39 $this->assertEquals("`baz`.`foo` < '6'", $lessThanCriterion->toSQL()); 36 40 } 37 41 } trunk/src/test/php/net/stubbles/rdbms/criteria/stubLikeCriterionTestCase.php
r1225 r1298 14 14 * @subpackage rdbms_criteria_test 15 15 */ 16 class stubLikeCriterionTestCase extends UnitTestCase16 class stubLikeCriterionTestCase extends PHPUnit_Framework_TestCase 17 17 { 18 18 /** 19 19 * check that a null value throws a stubCriterionException 20 * 21 * @test 22 * @expectedException stubCriterionException 20 23 */ 21 public function testNull()24 public function equalsNull() 22 25 { 23 $this->expectException('stubCriterionException');24 26 $likeCriterion = new stubLikeCriterion('foo', null); 25 27 } 26 28 27 29 /** 28 30 * check that any other value gets correct sql result … … 31 33 { 32 34 $likeCriterion = new stubLikeCriterion('foo', '%bar'); 33 $this->assertEqual ($likeCriterion->toSQL(), "`foo` LIKE '%bar'");35 $this->assertEquals("`foo` LIKE '%bar'", $likeCriterion->toSQL()); 34 36 $likeCriterion = new stubLikeCriterion('foo', 'bar%', 'baz'); 35 $this->assertEqual ($likeCriterion->toSQL(), "`baz`.`foo` LIKE 'bar%'");37 $this->assertEquals("`baz`.`foo` LIKE 'bar%'", $likeCriterion->toSQL()); 36 38 } 37 39 } trunk/src/test/php/net/stubbles/rdbms/criteria/stubNegateCriterionTestCase.php
r1225 r1298 8 8 */ 9 9 stubClassLoader::load('net::stubbles::rdbms::criteria::stubNegateCriterion'); 10 Mock::generate('stubCriterion');11 10 /** 12 11 * Test for net::stubbles::rdbms::criteria::stubNegateCriterion. … … 15 14 * @subpackage rdbms_criteria_test 16 15 */ 17 class stubNegateCriterionTestCase extends UnitTestCase16 class stubNegateCriterionTestCase extends PHPUnit_Framework_TestCase 18 17 { 19 18 /** 20 19 * check that the given criterion is negated 20 * 21 * @test 21 22 */ 22 public function testNegation()23 public function negation() 23 24 { 24 $mockCriterion = new MockstubCriterion();25 $mockCriterion-> setReturnValue('toSQL', 'foo');25 $mockCriterion = $this->getMock('stubCriterion'); 26 $mockCriterion->expects($this->once())->method('toSQL')->will($this->returnValue('foo')); 26 27 $negateCriterion = new stubNegateCriterion($mockCriterion); 27 $this->assertEqual ($negateCriterion->toSQL(), 'NOT (foo)');28 $this->assertEquals('NOT (foo)', $negateCriterion->toSQL()); 28 29 } 29 30 } trunk/src/test/php/net/stubbles/rdbms/criteria/stubOrCriterionTestCase.php
r1225 r1298 8 8 */ 9 9 stubClassLoader::load('net::stubbles::rdbms::criteria::stubOrCriterion'); 10 Mock::generate('stubCriterion');11 10 /** 12 11 * Test for net::stubbles::rdbms::criteria::stubOrCriterion. … … 15 14 * @subpackage rdbms_criteria_test 16 15 */ 17 class stubOrCriterionTestCase extends UnitTestCase16 class stubOrCriterionTestCase extends PHPUnit_Framework_TestCase 18 17 { 19 18 /** … … 23 22 */ 24 23 protected $orCriterion; 25 24 26 25 /** 27 26 * set up test environment … … 31 30 $this->orCriterion = new stubOrCriterion(); 32 31 } 33 32 34 33 /** 35 34 * check that no criterion added triggers a stubCriterionException 35 * 36 * @test 37 * @expectedException stubCriterionException 36 38 */ 37 public function testZero()39 public function zero() 38 40 { 39 41 $this->assertFalse($this->orCriterion->hasCriterion()); 40 $this->expectException('stubCriterionException');41 42 $this->orCriterion->toSQL(); 42 43 } 43 44 44 45 /** 45 46 * check that one criterion is handled correct 47 * 48 * @test 46 49 */ 47 public function testOne()50 public function one() 48 51 { 49 $mockCriterionOne = new MockstubCriterion();50 $mockCriterionOne-> setReturnValue('toSQL', 'foo');52 $mockCriterionOne = $this->getMock('stubCriterion'); 53 $mockCriterionOne->expects($this->once())->method('toSQL')->will($this->returnValue('foo')); 51 54 $this->orCriterion->addCriterion($mockCriterionOne); 52 55 $this->assertTrue($this->orCriterion->hasCriterion()); 53 $this->assertEqual ($this->orCriterion->toSQL(), '(foo)');56 $this->assertEquals('(foo)', $this->orCriterion->toSQL()); 54 57 } 55 58 56 59 /** 57 60 * check that two criteria are handled correct 61 * 62 * @test 58 63 */ 59 public function t estTwo()64 public function two() 60 65 { 61 $mockCriterionOne = new MockstubCriterion();62 $mockCriterionOne-> setReturnValue('toSQL', 'foo');66 $mockCriterionOne = $this->getMock('stubCriterion'); 67 $mockCriterionOne->expects($this->once())->method('toSQL')->will($this->returnValue('foo')); 63 68 $this->orCriterion->addCriterion($mockCriterionOne); 64 $mockCriterionTwo = new MockstubCriterion();65 $mockCriterionTwo-> setReturnValue('toSQL', 'bar');69 $mockCriterionTwo = $this->getMock('stubCriterion'); 70 $mockCriterionTwo->expects($this->once())->method('toSQL')->will($this->returnValue('bar')); 66 71 $this->orCriterion->addCriterion($mockCriterionTwo); 67 72 $this->assertTrue($this->orCriterion->hasCriterion()); 68 $this->assertEqual ($this->orCriterion->toSQL(), '(foo OR bar)');73 $this->assertEquals('(foo OR bar)', $this->orCriterion->toSQL()); 69 74 } 70 75 } trunk/src/test/php/net/stubbles/rdbms/pdo/stubDatabasePDOConnectionTestCase.php
r1232 r1298 8 8 */ 9 9 stubClassLoader::load('net::stubbles::rdbms::pdo::stubDatabasePDOConnection'); 10 Mock::generate('PDO');11 10 if (extension_loaded('pdo') == true) { 12 11 class TestPDOStatement extends PDOStatement {} … … 32 31 * @subpackage rdbms_test 33 32 */ 34 class stubDatabasePDOConnectionTestCase extends UnitTestCase33 class stubDatabasePDOConnectionTestCase extends PHPUnit_Framework_TestCase 35 34 { 36 35 /** … … 52 51 */ 53 52 protected $mockPDO; 54 55 /** 56 * skip the test if PDO is not available 57 */ 58 public function skip() 59 { 60 $this->skipUnless(extension_loaded('pdo'), 'stubDatabasePDOConnection requires PHP-extension "pdo".'); 61 } 62 53 63 54 /** 64 55 * set up test environment … … 66 57 public function setUp() 67 58 { 68 $this->mockPDO = new MockPDO(); 59 if (extension_loaded('pdo') === false) { 60 $this->markTestSkipped('net::stubbles::rdbms::pdo::stubDatabasePDOConnection requires PHP-extension "pdo".'); 61 } 62 63 $this->mockPDO = $this->getMock('PDO', array(), array(), '', false); 69 64 $this->connectionData = new stubDatabaseConnectionData(); 70 65 $this->pdoConnection = new TeststubDatabasePDOConnection($this->connectionData); 71 66 $this->pdoConnection->setPDO($this->mockPDO); 72 67 } 73 68 74 69 /** 75 70 * clear test environment … … 79 74 $this->pdoConnection->disconnect(); 80 75 } 81 76 82 77 /** 83 78 * check that the connection data is returned as expected 84 */ 85 public function testConnectionData() 86 { 87 $this->assertReference($this->pdoConnection->getConnectionData(), $this->connectionData); 88 } 89 79 * 80 * @test 81 */ 82 public function connectionData() 83 { 84 $this->assertSame($this->connectionData, $this->pdoConnection->getConnectionData()); 85 } 86 90 87 /** 91 88 * assert that a call to an undefined pdo method throws an stubDatabaseException 92 */ 93 public function testUndefinedMethod() 94 { 95 $this->expectException('stubDatabaseException'); 89 * 90 * @test 91 * @expectedException stubDatabaseException 92 */ 93 public function undefinedMethod() 94 { 96 95 $this->pdoConnection->foo('bar'); 97 96 } 98 97 99 98 /** 100 99 * assert that a call to the methods delivers the expected result 101 */ 102 public function testMethods() 103 { 104 $this->mockPDO->expectOnce('beginTransaction'); 105 $this->mockPDO->setReturnValue('beginTransaction', true); 106 $this->mockPDO->expectOnce('commit'); 107 $this->mockPDO->setReturnValue('commit', true); 108 $this->mockPDO->expectOnce('rollBack'); 109 $this->mockPDO->setReturnValue('rollBack', true); 110 $this->mockPDO->expectOnce('exec', array('foo')); 111 $this->mockPDO->setReturnValue('exec', 66); 112 $this->mockPDO->expectOnce('lastInsertId'); 113 $this->mockPDO->setReturnValue('lastInsertId', 5); 100 * 101 * @test 102 */ 103 public function methods() 104 { 105 $this->mockPDO->expects($this->once())->method('beginTransaction')->will($this->returnValue(true)); 106 $this->mockPDO->expects($this->once())->method('commit')->will($this->returnValue(true)); 107 $this->mockPDO->expects($this->once())->method('rollBack')->will($this->returnValue(true)); 108 $this->mockPDO->expects($this->once())->method('exec')->with($this->equalTo('foo'))->will($this->returnValue(66)); 109 $this->mockPDO->expects($this->once())->method('lastInsertId')->will($this->returnValue(5)); 114 110 $this->assertTrue($this->pdoConnection->beginTransaction()); 115 111 $this->assertTrue($this->pdoConnection->commit());
