Пример #1
0
 /**
  * @depends testDbDriver
  */
 public function testQuote()
 {
     $dbh = Rorm::getDatabase();
     $this->assertEquals('TRUE', Rorm::quote($dbh, true));
     $this->assertEquals('FALSE', Rorm::quote($dbh, false));
     $this->assertEquals('NULL', Rorm::quote($dbh, null));
     $this->assertEquals(17, Rorm::quote($dbh, 17));
     $this->assertEquals(28.75, Rorm::quote($dbh, 28.75));
     $this->assertInternalType('integer', Rorm::quote($dbh, 10));
     $this->assertInternalType('float', Rorm::quote($dbh, 10.6));
     $this->assertEquals("'lorem'", Rorm::quote($dbh, 'lorem'));
     // todo test object with __toString
 }
Пример #2
0
 /**
  * @param string $class
  * @param PDO|null $dbh if null the default database connection is used
  */
 public function __construct($class = 'stdClass', PDO $dbh = null)
 {
     $this->class = $class;
     $this->classIsOrmModel = is_subclass_of($this->class, '\\Rorm\\Model');
     $this->dbh = $dbh ? $dbh : Rorm::getDatabase();
 }
Пример #3
0
 /**
  * @depends testModels
  */
 public function testQuoteIdentifier()
 {
     $quoter = Rorm::getIdentifierQuoter(Rorm::getDatabase('sqlite'));
     $this->assertEquals('"sqlite"', $quoter('sqlite'));
 }
Пример #4
0
 /**
  * @return \PDO
  */
 public static function getDatabase()
 {
     return Rorm::getDatabase(static::$_connection);
 }
Пример #5
0
 /**
  * @param $value
  * @param $expected
  *
  * @dataProvider providerQuoteIdentifier
  * @fixme this test requires the sqlite connection
  */
 public function testQuoteIdentifier($value, $expected)
 {
     $quoter = Rorm::getIdentifierQuoter(Rorm::getDatabase('sqlite'));
     $this->assertEquals($expected, $quoter($value));
 }