/** * @engine isolate * @dataProvider createAndSaveRawModelWithOneToManyRelation */ public function testUpdateCollection($testBrand, $cars) { // include_once __DIR__ . '/../scripts/tested_models.php'; $testBrand->getCar()->update(array('nameCar' => 'test')); $req = Model::getDataSource()->prepare(' SELECT count(*) as nb FROM cars WHERE nameCar = ? '); $req->execute(array('test')); $res = $req->fetch(\PDO::FETCH_ASSOC); $this->string($res['nb'])->isEqualTo('3'); $testBrand->getCar()->update(array('nameCar' => 'test')); $req = Model::getDataSource()->prepare(' SELECT count(*) as nb FROM cars WHERE nameCar = ? '); $req->execute(array('test')); $res = $req->fetch(\PDO::FETCH_ASSOC); $this->string($res['nb'])->isEqualTo('3'); }
/** * @engine isolate * @dataProvider createAndSaveRawModelWithManyToManyRelation */ public function testUnsetRelation($car, $tags, $resultBDD) { $car->unsetTag($tags); $req = \PicORM\Model::getDataSource()->prepare('SELECT count(*) as nb FROM car_have_tag WHERE idCar = ?'); $req->execute(array($car->idCar)); $resultBDD = $req->fetch(\PDO::FETCH_ASSOC); $this->string($resultBDD['nb'])->isEqualTo("0"); }