Changeset 1298

Show
Ignore:
Timestamp:
01/25/08 00:34:11 (7 months ago)
Author:
mikey
Message:

continued refactoring #118: converted tests for net::stubbles::rdbms

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/main/php/net/stubbles/rdbms/pdo/stubDatabasePDOStatement.php

    r1281 r1298  
    6262     * @throws  stubDatabaseException 
    6363     * @see     http://php.net/pdostatement-bindColumn 
    64      * @see     net::stubbles::rdbms.stubDatabaseResult::bindColumn() 
     64     * @see     net::stubbles::rdbms::stubDatabaseResult::bindColumn() 
    6565     */ 
    6666    public function bindColumn($column, &$variable, $type = null) 
    6767    { 
    6868        try { 
    69             return $this->pdoStatement->bindColumn($column, $variable, $type); 
     69            return $this->pdoStatement->bindColumn($column, $variable, $type, null, null); 
    7070        } catch (PDOException $pdoe) { 
    7171            throw new stubDatabaseException($pdoe->getMessage(), $pdoe); 
     
    8888     * @throws  stubDatabaseException 
    8989     * @see     http://php.net/pdostatement-bindParam 
    90      * @see     net::stubbles::rdbms.stubDatabaseStatement::bindParam() 
     90     * @see     net::stubbles::rdbms::stubDatabaseStatement::bindParam() 
    9191     */ 
    9292    public function bindParam($param, &$variable, $type = null, $length = null) 
    9393    { 
    9494        try { 
    95             return $this->pdoStatement->bindParam($param, $variable, $type, $length); 
     95            return $this->pdoStatement->bindParam($param, $variable, $type, $length, null); 
    9696        } catch (PDOException $pdoe) { 
    9797            throw new stubDatabaseException($pdoe->getMessage(), $pdoe); 
     
    111111     * @throws  stubDatabaseException 
    112112     * @see     http://php.net/pdostatement-bindValue 
    113      * @see     net::stubbles::rdbms.stubDatabaseStatement::bindValue() 
     113     * @see     net::stubbles::rdbms::stubDatabaseStatement::bindValue() 
    114114     */ 
    115115    public function bindValue($param, $value, $type = null) 
     
    131131     * @throws  stubDatabaseException 
    132132     * @see     http://php.net/pdostatement-execute 
    133      * @see     net::stubbles::rdbms.stubDatabaseStatement::execute() 
     133     * @see     net::stubbles::rdbms::stubDatabaseStatement::execute() 
    134134     */ 
    135135    public function execute(array $values = array()) 
     
    154154     * @throws  stubDatabaseException 
    155155     * @see     http://php.net/pdostatement-fetch 
    156      * @see     net::stubbles::rdbms.stubDatabaseResult::fetch() 
     156     * @see     net::stubbles::rdbms::stubDatabaseResult::fetch() 
    157157     */ 
    158158    public function fetch($fetchMode = null, array $driverOptions = array()) 
     
    179179     * @throws  stubDatabaseException 
    180180     * @see     http://php.net/pdostatement-fetchColumn 
    181      * @see     net::stubbles::rdbms.stubDatabaseResult::fetchOne() 
     181     * @see     net::stubbles::rdbms::stubDatabaseResult::fetchOne() 
    182182     */ 
    183183    public function fetchOne($columnNumber = 0) 
     
    198198     * @throws  stubDatabaseException 
    199199     * @see     http://php.net/pdostatement-fetchAll 
    200      * @see     net::stubbles::rdbms.stubDatabaseResult::fetchAll() 
     200     * @see     net::stubbles::rdbms::stubDatabaseResult::fetchAll() 
    201201     */ 
    202202    public function fetchAll($fetchMode = null, array $driverOptions = array()) 
     
    204204        try { 
    205205            if (null === $fetchMode) { 
    206                 return $this->pdoStatement->fetchAll(); 
     206                return $this->pdoStatement->fetchAll(null, null, null); 
    207207            } 
    208208             
    209209            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); 
    211211            } 
    212212             
    213             return $this->pdoStatement->fetchAll($fetchMode); 
     213            return $this->pdoStatement->fetchAll($fetchMode, null, null); 
    214214        } catch (PDOException $pdoe) { 
    215215            throw new stubDatabaseException($pdoe->getMessage(), $pdoe); 
     
    223223     * @throws  stubDatabaseException 
    224224     * @see     http://php.net/pdostatement-nextRowset 
    225      * @see     net::stubbles::rdbms.stubDatabaseResult::next() 
     225     * @see     net::stubbles::rdbms::stubDatabaseResult::next() 
    226226     */ 
    227227    public function next() 
     
    240240     * @throws  stubDatabaseException 
    241241     * @see     http://php.net/pdostatement-rowCount 
    242      * @see     net::stubbles::rdbms.stubDatabaseResult::count() 
     242     * @see     net::stubbles::rdbms::stubDatabaseResult::count() 
    243243     */ 
    244244    public function count() 
     
    261261     * @throws  stubDatabaseException 
    262262     * @see     http://php.net/pdostatement-closeCursor 
    263      * @see     net::stubbles::rdbms.stubDatabaseResult::free() 
     263     * @see     net::stubbles::rdbms::stubDatabaseResult::free() 
    264264     */ 
    265265    public function free() 
     
    280280     * 
    281281     * @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() 
    284283     */ 
    285284    public function clean() 
  • trunk/src/test/AllTests.php

    r1288 r1298  
    2020require_once 'PHPUnit/Util/Filter.php'; 
    2121PHPUnit_Util_Filter::addDirectoryToWhitelist(stubConfig::getSourcePath() . '/php'); 
     22PHPUnit_Util_Filter::removeDirectoryFromWhitelist(stubConfig::getSourcePath() . '/php/net/stubbles/util/ext'); 
    2223PHPUnit_Util_Filter::removeDirectoryFromWhitelist(stubConfig::getSourcePath() . '/php/net/stubbles/util/xjconf'); 
    2324PHPUnit_Util_Filter::removeDirectoryFromWhitelist(stubConfig::getSourcePath() . '/php/org'); 
     
    2829require_once $dir . '/php/net/stubbles/ioc/IOCTestSuite.php'; 
    2930require_once $dir . '/php/net/stubbles/ipo/IPOTestSuite.php'; 
     31require_once $dir . '/php/net/stubbles/rdbms/RDBMSTestSuite.php'; 
    3032require_once $dir . '/php/net/stubbles/util/UtilTestSuite.php'; 
    3133require_once $dir . '/php/net/stubbles/websites/WebsitesTestSuite.php'; 
     
    6163        $suite->addTestSuite('IOCTestSuite'); 
    6264        $suite->addTestSuite('IPOTestSuite'); 
     65        $suite->addTestSuite('RDBMSTestSuite'); 
    6366        $suite->addTestSuite('UtilTestSuite'); 
    6467        $suite->addTestSuite('WebsitesTestSuite'); 
  • trunk/src/test/php/net/stubbles/rdbms/RDBMSTestSuite.php

    r951 r1298  
    1313 * @subpackage  test 
    1414 */ 
    15 class RDBMSTestSuite extends TestSuite 
     15class RDBMSTestSuite extends PHPUnit_Framework_TestSuite 
    1616{ 
    1717    /** 
    18      * constructor 
     18     * returns the test suite to be run 
     19     * 
     20     * @return  PHPUnit_Framework_TestSuite 
    1921     */ 
    20     public function __construct() 
     22    public static function suite() 
    2123    { 
    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'); 
    2729         
    2830        // 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'); 
    3941         
    4042        // 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'); 
    4345         
    4446        // 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'); 
    5052         
    5153        // 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; 
    6062    } 
    6163} 
  • trunk/src/test/php/net/stubbles/rdbms/criteria/stubAndCriterionTestCase.php

    r1225 r1298  
    88 */ 
    99stubClassLoader::load('net::stubbles::rdbms::criteria::stubAndCriterion'); 
    10 Mock::generate('stubCriterion'); 
    1110/** 
    1211 * Test for net::stubbles::rdbms::criteria::stubAndCriterion. 
     
    1514 * @subpackage  rdbms_criteria_test 
    1615 */ 
    17 class stubAndCriterionTestCase extends UnitTestCase 
     16class stubAndCriterionTestCase extends PHPUnit_Framework_TestCase 
    1817{ 
    1918    /** 
     
    2322     */ 
    2423    protected $andCriterion; 
    25      
     24 
    2625    /** 
    2726     * set up test environment 
     
    3130        $this->andCriterion = new stubAndCriterion(); 
    3231    } 
    33      
     32 
    3433    /** 
    3534     * check that no criterion added triggers a stubCriterionException 
     35     * 
     36     * @test 
     37     * @expectedException  stubCriterionException 
    3638     */ 
    37     public function testZero() 
     39    public function zero() 
    3840    { 
    3941        $this->assertFalse($this->andCriterion->hasCriterion()); 
    40         $this->expectException('stubCriterionException'); 
    4142        $this->andCriterion->toSQL(); 
    4243    } 
    43      
     44 
    4445    /** 
    4546     * check that one criterion is handled correct 
     47     * 
     48     * @test 
    4649     */ 
    47     public function testOne() 
     50    public function one() 
    4851    { 
    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')); 
    5154        $this->andCriterion->addCriterion($mockCriterionOne); 
    5255        $this->assertTrue($this->andCriterion->hasCriterion()); 
    53         $this->assertEqual($this->andCriterion->toSQL(), '(foo)'); 
     56        $this->assertEquals('(foo)', $this->andCriterion->toSQL()); 
    5457    } 
    55      
     58 
    5659    /** 
    5760     * check that two criteria are handled correct 
     61     * 
     62     * @test 
    5863     */ 
    59     public function testTwo() 
     64    public function two() 
    6065    { 
    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')); 
    6368        $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')); 
    6671        $this->andCriterion->addCriterion($mockCriterionTwo); 
    6772        $this->assertTrue($this->andCriterion->hasCriterion()); 
    68         $this->assertEqual($this->andCriterion->toSQL(), '(foo AND bar)'); 
     73        $this->assertEquals('(foo AND bar)', $this->andCriterion->toSQL()); 
    6974    } 
    7075} 
  • trunk/src/test/php/net/stubbles/rdbms/criteria/stubEqualCriterionTestCase.php

    r1225 r1298  
    1414 * @subpackage  rdbms_criteria_test 
    1515 */ 
    16 class stubEqualCriterionTestCase extends UnitTestCase 
     16class stubEqualCriterionTestCase extends PHPUnit_Framework_TestCase 
    1717{ 
    1818    /** 
    1919     * check that a null value gets correct operator 
     20     * 
     21     * @test 
    2022     */ 
    21     public function testNull() 
     23    public function equalsNull() 
    2224    { 
    2325        $equalCriterion = new stubEqualCriterion('foo', null); 
    24         $this->assertEqual($equalCriterion->toSQL(), '`foo` IS NULL'); 
     26        $this->assertEquals('`foo` IS NULL',$equalCriterion->toSQL()); 
    2527        $equalCriterion = new stubEqualCriterion('foo', null, 'bar'); 
    26         $this->assertEqual($equalCriterion->toSQL(), '`bar`.`foo` IS NULL'); 
     28        $this->assertEquals('`bar`.`foo` IS NULL', $equalCriterion->toSQL()); 
    2729    } 
    28      
     30 
    2931    /** 
    3032     * check that any other value gets correct operator 
     33     * 
     34     * @test 
    3135     */ 
    32     public function testValue() 
     36    public function value() 
    3337    { 
    3438        $equalCriterion = new stubEqualCriterion('foo', 'bar'); 
    35         $this->assertEqual($equalCriterion->toSQL(), "`foo` = 'bar'"); 
     39        $this->assertEquals("`foo` = 'bar'", $equalCriterion->toSQL()); 
    3640        $equalCriterion = new stubEqualCriterion('foo', 'bar', 'baz'); 
    37         $this->assertEqual($equalCriterion->toSQL(), "`baz`.`foo` = 'bar'"); 
     41        $this->assertEquals("`baz`.`foo` = 'bar'", $equalCriterion->toSQL()); 
    3842    } 
    3943} 
  • trunk/src/test/php/net/stubbles/rdbms/criteria/stubGreaterEqualCriterionTestCase.php

    r1225 r1298  
    1414 * @subpackage  rdbms_criteria_test 
    1515 */ 
    16 class stubGreaterEqualCriterionTestCase extends UnitTestCase 
     16class stubGreaterEqualCriterionTestCase extends PHPUnit_Framework_TestCase 
    1717{ 
    1818    /** 
    1919     * check that a null value throws a stubCriterionException 
     20     * 
     21     * @test 
     22     * @expectedException  stubCriterionException 
    2023     */ 
    21     public function testNull() 
     24    public function equalsNull() 
    2225    { 
    23         $this->expectException('stubCriterionException'); 
    2426        $greaterEqualCriterion = new stubGreaterEqualCriterion('foo', null); 
    2527    } 
    26      
     28 
    2729    /** 
    2830     * check that any other value gets correct sql result 
     31     * 
     32     * @test 
    2933     */ 
    30     public function testValue() 
     34    public function value() 
    3135    { 
    3236        $greaterEqualCriterion = new stubGreaterEqualCriterion('foo', 5); 
    33         $this->assertEqual($greaterEqualCriterion->toSQL(), "`foo` >= '5'"); 
     37        $this->assertEquals("`foo` >= '5'", $greaterEqualCriterion->toSQL()); 
    3438        $greaterEqualCriterion = new stubGreaterEqualCriterion('foo', 6, 'baz'); 
    35         $this->assertEqual($greaterEqualCriterion->toSQL(), "`baz`.`foo` >= '6'"); 
     39        $this->assertEquals("`baz`.`foo` >= '6'", $greaterEqualCriterion->toSQL()); 
    3640    } 
    3741} 
  • trunk/src/test/php/net/stubbles/rdbms/criteria/stubGreaterThanCriterionTestCase.php

    r1225 r1298  
    1414 * @subpackage  rdbms_criteria_test 
    1515 */ 
    16 class stubGreaterThanCriterionTestCase extends UnitTestCase 
     16class stubGreaterThanCriterionTestCase extends PHPUnit_Framework_TestCase 
    1717{ 
    1818    /** 
    1919     * check that a null value throws a stubCriterionException 
     20     * 
     21     * @test 
     22     * @expectedException  stubCriterionException 
    2023     */ 
    21     public function testNull() 
     24    public function equalsNull() 
    2225    { 
    23         $this->expectException('stubCriterionException'); 
    2426        $greaterThanCriterion = new stubGreaterThanCriterion('foo', null); 
    2527    } 
    26      
     28 
    2729    /** 
    2830     * check that any other value gets correct sql result 
     31     * 
     32     * @test 
    2933     */ 
    30     public function testValue() 
     34    public function value() 
    3135    { 
    3236        $greaterThanCriterion = new stubGreaterThanCriterion('foo', 5); 
    33         $this->assertEqual($greaterThanCriterion->toSQL(), "`foo` > '5'"); 
     37        $this->assertEquals("`foo` > '5'", $greaterThanCriterion->toSQL()); 
    3438        $greaterThanCriterion = new stubGreaterThanCriterion('foo', 6, 'baz'); 
    35         $this->assertEqual($greaterThanCriterion->toSQL(), "`baz`.`foo` > '6'"); 
     39        $this->assertEquals("`baz`.`foo` > '6'", $greaterThanCriterion->toSQL()); 
    3640    } 
    3741} 
  • trunk/src/test/php/net/stubbles/rdbms/criteria/stubInCriterionTestCase.php

    r1225 r1298  
    1414 * @subpackage  rdbms_criteria_test 
    1515 */ 
    16 class stubInCriterionTestCase extends UnitTestCase 
     16class stubInCriterionTestCase extends PHPUnit_Framework_TestCase 
    1717{ 
    1818    /** 
    1919     * check that a null value throws a stubCriterionException 
     20     * 
     21     * @test 
     22     * @expectedException  stubCriterionException 
    2023     */ 
    21     public function testNonArray() 
     24    public function nonArray() 
    2225    { 
    23         $this->expectException('stubCriterionException'); 
    2426        $inCriterion = new stubInCriterion('foo', 'bar'); 
    2527    } 
    26      
     28 
    2729    /** 
    2830     * check that one value is handled correct 
     31     * 
     32     * @test 
    2933     */ 
    30     public function testOne() 
     34    public function one() 
    3135    { 
    3236        $inCriterion = new stubInCriterion('foo', array('bar')); 
    33         $this->assertEqual($inCriterion->toSQL(), "`foo` IN ('bar')"); 
     37        $this->assertEquals("`foo` IN ('bar')", $inCriterion->toSQL()); 
    3438        $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()); 
    3640    } 
    37      
     41 
    3842    /** 
    3943     * check that two values are handled correct 
     44     * 
     45     * @test 
    4046     */ 
    41     public function testTwo() 
     47    public function two() 
    4248    { 
    4349        $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()); 
    4551        $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()); 
    4753    } 
    4854} 
  • trunk/src/test/php/net/stubbles/rdbms/criteria/stubLessEqualCriterionTestCase.php

    r1225 r1298  
    1414 * @subpackage  rdbms_criteria_test 
    1515 */ 
    16 class stubLessEqualCriterionTestCase extends UnitTestCase 
     16class stubLessEqualCriterionTestCase extends PHPUnit_Framework_TestCase 
    1717{ 
    1818    /** 
    1919     * check that a null value throws a stubCriterionException 
     20     * 
     21     * @test 
     22     * @expectedException  stubCriterionException 
    2023     */ 
    21     public function testNull() 
     24    public function equalsNull() 
    2225    { 
    23         $this->expectException('stubCriterionException'); 
    2426        $lessEqualCriterion = new stubLessEqualCriterion('foo', null); 
    2527    } 
    26      
     28 
    2729    /** 
    2830     * check that any other value gets correct sql result 
     31     * 
     32     * @test 
    2933     */ 
    30     public function testValue() 
     34    public function value() 
    3135    { 
    3236        $lessEqualCriterion = new stubLessEqualCriterion('foo', 5); 
    33         $this->assertEqual($lessEqualCriterion->toSQL(), "`foo` <= '5'"); 
     37        $this->assertEquals("`foo` <= '5'", $lessEqualCriterion->toSQL()); 
    3438        $lessEqualCriterion = new stubLessEqualCriterion('foo', 6, 'baz'); 
    35         $this->assertEqual($lessEqualCriterion->toSQL(), "`baz`.`foo` <= '6'"); 
     39        $this->assertEquals("`baz`.`foo` <= '6'", $lessEqualCriterion->toSQL()); 
    3640    } 
    3741} 
  • trunk/src/test/php/net/stubbles/rdbms/criteria/stubLessThanCriterionTestCase.php

    r1225 r1298  
    1414 * @subpackage  rdbms_criteria_test 
    1515 */ 
    16 class stubLessThanCriterionTestCase extends UnitTestCase 
     16class stubLessThanCriterionTestCase extends PHPUnit_Framework_TestCase 
    1717{ 
    1818    /** 
    1919     * check that a null value throws a stubCriterionException 
     20     * 
     21     * @test 
     22     * @expectedException  stubCriterionException 
    2023     */ 
    21     public function testNull() 
     24    public function equalsNull() 
    2225    { 
    23         $this->expectException('stubCriterionException'); 
    2426        $lessThanCriterion = new stubLessThanCriterion('foo', null); 
    2527    } 
    26      
     28 
    2729    /** 
    2830     * check that any other value gets correct sql result 
     31     * 
     32     * @test 
    2933     */ 
    30     public function testValue() 
     34    public function value() 
    3135    { 
    3236        $lessThanCriterion = new stubLessThanCriterion('foo', 5); 
    33         $this->assertEqual($lessThanCriterion->toSQL(), "`foo` < '5'"); 
     37        $this->assertEquals("`foo` < '5'", $lessThanCriterion->toSQL()); 
    3438        $lessThanCriterion = new stubLessThanCriterion('foo', 6, 'baz'); 
    35         $this->assertEqual($lessThanCriterion->toSQL(), "`baz`.`foo` < '6'"); 
     39        $this->assertEquals("`baz`.`foo` < '6'", $lessThanCriterion->toSQL()); 
    3640    } 
    3741} 
  • trunk/src/test/php/net/stubbles/rdbms/criteria/stubLikeCriterionTestCase.php

    r1225 r1298  
    1414 * @subpackage  rdbms_criteria_test 
    1515 */ 
    16 class stubLikeCriterionTestCase extends UnitTestCase 
     16class stubLikeCriterionTestCase extends PHPUnit_Framework_TestCase 
    1717{ 
    1818    /** 
    1919     * check that a null value throws a stubCriterionException 
     20     * 
     21     * @test 
     22     * @expectedException  stubCriterionException 
    2023     */ 
    21     public function testNull() 
     24    public function equalsNull() 
    2225    { 
    23         $this->expectException('stubCriterionException'); 
    2426        $likeCriterion = new stubLikeCriterion('foo', null); 
    2527    } 
    26      
     28 
    2729    /** 
    2830     * check that any other value gets correct sql result 
     
    3133    { 
    3234        $likeCriterion = new stubLikeCriterion('foo', '%bar'); 
    33         $this->assertEqual($likeCriterion->toSQL(), "`foo` LIKE '%bar'"); 
     35        $this->assertEquals("`foo` LIKE '%bar'", $likeCriterion->toSQL()); 
    3436        $likeCriterion = new stubLikeCriterion('foo', 'bar%', 'baz'); 
    35         $this->assertEqual($likeCriterion->toSQL(), "`baz`.`foo` LIKE 'bar%'"); 
     37        $this->assertEquals("`baz`.`foo` LIKE 'bar%'", $likeCriterion->toSQL()); 
    3638    } 
    3739} 
  • trunk/src/test/php/net/stubbles/rdbms/criteria/stubNegateCriterionTestCase.php

    r1225 r1298  
    88 */ 
    99stubClassLoader::load('net::stubbles::rdbms::criteria::stubNegateCriterion'); 
    10 Mock::generate('stubCriterion'); 
    1110/** 
    1211 * Test for net::stubbles::rdbms::criteria::stubNegateCriterion. 
     
    1514 * @subpackage  rdbms_criteria_test 
    1615 */ 
    17 class stubNegateCriterionTestCase extends UnitTestCase 
     16class stubNegateCriterionTestCase extends PHPUnit_Framework_TestCase 
    1817{ 
    1918    /** 
    2019     * check that the given criterion is negated 
     20     * 
     21     * @test 
    2122     */ 
    22     public function testNegation() 
     23    public function negation() 
    2324    { 
    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')); 
    2627        $negateCriterion = new stubNegateCriterion($mockCriterion); 
    27         $this->assertEqual($negateCriterion->toSQL(), 'NOT (foo)'); 
     28        $this->assertEquals('NOT (foo)', $negateCriterion->toSQL()); 
    2829    } 
    2930} 
  • trunk/src/test/php/net/stubbles/rdbms/criteria/stubOrCriterionTestCase.php

    r1225 r1298  
    88 */ 
    99stubClassLoader::load('net::stubbles::rdbms::criteria::stubOrCriterion'); 
    10 Mock::generate('stubCriterion'); 
    1110/** 
    1211 * Test for net::stubbles::rdbms::criteria::stubOrCriterion. 
     
    1514 * @subpackage  rdbms_criteria_test 
    1615 */ 
    17 class stubOrCriterionTestCase extends UnitTestCase 
     16class stubOrCriterionTestCase extends PHPUnit_Framework_TestCase 
    1817{ 
    1918    /** 
     
    2322     */ 
    2423    protected $orCriterion; 
    25      
     24 
    2625    /** 
    2726     * set up test environment 
     
    3130        $this->orCriterion = new stubOrCriterion(); 
    3231    } 
    33      
     32 
    3433    /** 
    3534     * check that no criterion added triggers a stubCriterionException 
     35     * 
     36     * @test 
     37     * @expectedException  stubCriterionException 
    3638     */ 
    37     public function testZero() 
     39    public function zero() 
    3840    { 
    3941        $this->assertFalse($this->orCriterion->hasCriterion()); 
    40         $this->expectException('stubCriterionException'); 
    4142        $this->orCriterion->toSQL(); 
    4243    } 
    43      
     44 
    4445    /** 
    4546     * check that one criterion is handled correct 
     47     * 
     48     * @test 
    4649     */ 
    47     public function testOne() 
     50    public function one() 
    4851    { 
    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')); 
    5154        $this->orCriterion->addCriterion($mockCriterionOne); 
    5255        $this->assertTrue($this->orCriterion->hasCriterion()); 
    53         $this->assertEqual($this->orCriterion->toSQL(), '(foo)'); 
     56        $this->assertEquals('(foo)', $this->orCriterion->toSQL()); 
    5457    } 
    55      
     58 
    5659    /** 
    5760     * check that two criteria are handled correct 
     61     * 
     62     * @test 
    5863     */ 
    59     public function testTwo() 
     64    public function two() 
    6065    { 
    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')); 
    6368        $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')); 
    6671        $this->orCriterion->addCriterion($mockCriterionTwo); 
    6772        $this->assertTrue($this->orCriterion->hasCriterion()); 
    68         $this->assertEqual($this->orCriterion->toSQL(), '(foo OR bar)'); 
     73        $this->assertEquals('(foo OR bar)', $this->orCriterion->toSQL()); 
    6974    } 
    7075} 
  • trunk/src/test/php/net/stubbles/rdbms/pdo/stubDatabasePDOConnectionTestCase.php

    r1232 r1298  
    88 */ 
    99stubClassLoader::load('net::stubbles::rdbms::pdo::stubDatabasePDOConnection'); 
    10 Mock::generate('PDO'); 
    1110if (extension_loaded('pdo') == true) { 
    1211    class TestPDOStatement extends PDOStatement {} 
     
    3231 * @subpackage  rdbms_test 
    3332 */ 
    34 class stubDatabasePDOConnectionTestCase extends UnitTestCase 
     33class stubDatabasePDOConnectionTestCase extends PHPUnit_Framework_TestCase 
    3534{ 
    3635    /** 
     
    5251     */ 
    5352    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 
    6354    /** 
    6455     * set up test environment 
     
    6657    public function setUp() 
    6758    { 
    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); 
    6964        $this->connectionData = new stubDatabaseConnectionData(); 
    7065        $this->pdoConnection  = new TeststubDatabasePDOConnection($this->connectionData); 
    7166        $this->pdoConnection->setPDO($this->mockPDO); 
    7267    } 
    73      
     68 
    7469    /** 
    7570     * clear test environment 
     
    7974        $this->pdoConnection->disconnect(); 
    8075    } 
    81      
     76 
    8277    /** 
    8378     * 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 
    9087    /** 
    9188     * 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    { 
    9695        $this->pdoConnection->foo('bar'); 
    9796    } 
    98      
     97 
    9998    /** 
    10099     * 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)); 
    114110        $this->assertTrue($this->pdoConnection->beginTransaction()); 
    115111        $this->assertTrue($this->pdoConnection->commit());