Example #1
0
 public function testClear()
 {
     $cat = Category::findByPK(1);
     $cat->item = null;
     $cat->save();
     $data = Category::getDbConnection()->query((new Query())->select()->from(Category::getTableName()))->fetchAll(\PDO::FETCH_ASSOC);
     $this->assertEquals(['__id' => 1, 'num' => 1], $data[0]);
     $this->assertEquals(['__id' => 2, 'num' => 2], $data[1]);
     $data = Item::getDbConnection()->query((new Query())->select()->from(Item::getTableName()))->fetchAll(\PDO::FETCH_ASSOC);
     $this->assertEquals(['__id' => 1, 'num' => 1, '__category_id' => null], $data[0]);
     $this->assertEquals(['__id' => 2, 'num' => 2, '__category_id' => 2], $data[1]);
     $this->assertEquals(['__id' => 3, 'num' => 3, '__category_id' => null], $data[2]);
 }