Esempio n. 1
0
 public function executeModels(Models $models)
 {
     if ($models->count() == 1) {
         $this->model($models->getFirst());
     } else {
         $this->models($models);
     }
     $this->execute();
 }
Esempio n. 2
0
 /**
  * @covers ::getNext
  */
 public function testGetNext()
 {
     $model1 = new City();
     $model2 = new City();
     $model3 = new City();
     $models = new Models([$model1, $model2, $model3]);
     $models->getFirst();
     $this->assertSame($model2, $models->getNext());
     $this->assertSame($model3, $models->getNext());
     $this->assertNull($models->getNext());
 }
Esempio n. 3
0
 /**
  * @covers ::executeModels
  */
 public function testExecuteModels()
 {
     $models1 = new Models([new City(), new City()]);
     $models2 = new Models([new City()]);
     $update = $this->getMock('Harp\\Harp\\Query\\Update', ['models', 'model', 'execute'], [City::getRepo()]);
     $update->expects($this->at(0))->method('models')->with($this->identicalTo($models1))->will($this->returnSelf());
     $update->expects($this->at(1))->method('execute');
     $update->expects($this->at(2))->method('model')->with($this->identicalTo($models2->getFirst()))->will($this->returnSelf());
     $update->executeModels($models1);
     $update->executeModels($models2);
 }
Esempio n. 4
0
 /**
  * If no first, will return void model
  *
  * @return AbstractModel
  */
 public function getFirst()
 {
     return $this->current->getFirst();
 }
Esempio n. 5
0
 /**
  * If model doesn't exist, return a void model
  *
  * @return AbstractModel
  */
 public function getFirst()
 {
     return parent::getFirst() ?: $this->getRepo()->newVoidModel();
 }