Example #1
0
 /**
  * Tests FUSE and lists, FUSE enforces no more than
  * 3 sugar cubes in coffee.
  *
  * @return void
  */
 public function testCoffeeWithSugarAndFUSE()
 {
     $coffee = R::dispense('coffee');
     $coffee->size = 'XL';
     $coffee->ownSugar = R::dispense('sugar', 5);
     $id = R::store($coffee);
     $coffee = R::load('coffee', $id);
     asrt(count($coffee->ownSugar), 3);
     $coffee->ownSugar = R::dispense('sugar', 2);
     $id = R::store($coffee);
     $coffee = R::load('coffee', $id);
     asrt(count($coffee->ownSugar), 2);
     $cocoa = R::dispense('cocoa');
     $cocoa->name = 'Fair Cocoa';
     list($taste1, $taste2) = R::dispense('taste', 2);
     $taste1->name = 'sweet';
     $taste2->name = 'bitter';
     $cocoa->ownTaste = array($taste1, $taste2);
     R::store($cocoa);
     $cocoa->name = 'Koko';
     R::store($cocoa);
     if (method_exists(R::getDatabaseAdapter()->getDatabase(), 'getPDO')) {
         $pdo = R::getDatabaseAdapter()->getDatabase()->getPDO();
         $driver = new RPDO($pdo);
         pass();
         asrt($pdo->getAttribute(\PDO::ATTR_ERRMODE), \PDO::ERRMODE_EXCEPTION);
         asrt($pdo->getAttribute(\PDO::ATTR_DEFAULT_FETCH_MODE), \PDO::FETCH_ASSOC);
         asrt(strval($driver->GetCell('select 123')), '123');
     }
     $a = new SQL();
     $a->setSqlState('test');
     $b = strval($a);
     asrt(strpos($b, '[test] - ') === 0, TRUE);
 }