Esempio n. 1
0
 /**
  * @covers ::add
  */
 public function testAdd()
 {
     $models = new RepoModels(Model::getRepo());
     $model = new Model();
     $models->add($model);
     $this->assertSame([$model], Objects::toArray($models->all()));
 }
Esempio n. 2
0
 /**
  * @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());
 }
Esempio n. 3
0
 public static function initialize(AbstractRepo $repo)
 {
     parent::initialize($repo);
     $repo->setRootRepo(Model::getRepo());
 }
Esempio n. 4
0
 /**
  * @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));
 }
Esempio n. 5
0
 /**
  * @covers ::get
  * @expectedException InvalidArgumentException
  */
 public function testInvalidModel()
 {
     $map = new LinkMap(Model::getRepo());
     $model = new ModelOther();
     $map->get($model);
 }