Ejemplo n.º 1
0
 private function _setupForeignKeysTest()
 {
     $owner = new Mock\SDBOwner();
     $owner->name = 'MyCarsOwner';
     $id = rand(1, 999999999) . 'myID' . rand(1, 100);
     $owner->id($id);
     $this->assertTrue($owner->save(true), "Failed saving: " . $owner->errorMessagesString());
     $cars = Mock\SDBCar::FindAll();
     $cars->each(function ($car) use($id) {
         $car->owner_id = $id;
     });
     $cars->save();
 }
Ejemplo n.º 2
0
use FlexibleORMTests\Mock;
use FlexibleORMTests\ORMTest;
set_include_path(get_include_path() . PATH_SEPARATOR . __DIR__ . '/..');
require_once 'ORMTest.php';
$sdb = SDBStatement::GetSDBConnection();
$sdb->delete_domain(Mock\SDBOwner::TableName());
//$sdb->create_domain( '123_mustbeescaped' );
//$sdb->put_attributes(
//    '123_mustbeescaped',
//    'test',
//    array('note' => 'This domain name should be escaped with backticks'));
Mock\SDBCar::CreateDomain();
Mock\SDBOwner::CreateDomain();
$owners = range(1, 12);
foreach ($owners as $owner) {
    $owner = new Mock\SDBOwner(array('name' => 'Jarrod ' . $owner));
    $owner->save();
}
/**
 * Test failures and exceptions for SDBStatement
 *
 * Most of the features are already tested in ORMModelSDBTest
 */
class SDBStatementTest extends ORMTest
{
    const DOMAIN = 'SDBStatementTest';
    public function testInjectionInsert()
    {
        $query = new SDBStatement("INSERT INTO cars (brand, colour, doors) VALUES ( ?, ?, ? )");
        $query->bindValues(array('\'?\' ? \'red\'', '4', "\\'3"));
        $this->assertEquals(array('brand' => '\'?\' ? \'red\'', 'colour' => '4', 'doors' => "\\'3"), $query->attributes());