/** * @covers ::add */ public function testAdd() { $models = new RepoModels(Model::getRepo()); $model = new Model(); $models->add($model); $this->assertSame([$model], Objects::toArray($models->all())); }
/** * @covers ::clear */ public function testClear() { $map = Model::getRepo()->getIdentityMap()->clear(); $map->get(new Model(['id' => 1], State::SAVED)); $this->assertCount(1, $map->getModels()); $map->clear(); $this->assertCount(0, $map->getModels()); }
public static function initialize(AbstractRepo $repo) { parent::initialize($repo); $repo->setRootRepo(Model::getRepo()); }
/** * @covers ::isModel */ public function testIsModel() { $repo = Model::getRepo(); $repoInherited = ModelInherited::getRepo(); $model = new Model(); $modelInherited = new Model(); $this->assertTrue($repo->isModel($model)); $this->assertTrue($repo->isModel($modelInherited)); $this->assertTrue($repoInherited->isModel($modelInherited)); $this->assertTrue($repoInherited->isModel($model)); $model = new ModelOther(); $this->assertFalse($repo->isModel($model)); }
/** * @covers ::get * @expectedException InvalidArgumentException */ public function testInvalidModel() { $map = new LinkMap(Model::getRepo()); $model = new ModelOther(); $map->get($model); }