Exemple #1
0
 /**
  * @covers ::getRepo
  */
 public function testGetRepo()
 {
     $repo1 = Model::getRepo();
     $repo2 = SoftDeleteModel::getRepo();
     $this->assertInstanceOf('Harp\\Core\\Test\\Repo\\TestRepo', $repo1);
     $this->assertInstanceOf('Harp\\Core\\Test\\Repo\\TestRepo', $repo2);
     $this->assertNotSame($repo1, $repo2);
     $this->assertEquals(__NAMESPACE__ . '\\Model', $repo1->getModelClass());
     $this->assertEquals(__NAMESPACE__ . '\\SoftDeleteModel', $repo2->getModelClass());
 }
 /**
  * @covers ::realDelete
  * @covers ::isSoftDeleted
  */
 public function testRealDelete()
 {
     $object = new SoftDeleteModel(null, State::SAVED);
     $object->delete();
     $this->assertTrue($object->isDeleted());
     $this->assertTrue($object->isSoftDeleted());
     $object->realDelete();
     $this->assertTrue($object->isDeleted());
     $this->assertFalse($object->isSoftDeleted());
 }
Exemple #3
0
 /**
  * @covers ::byRepo
  */
 public function testByRepo()
 {
     $source = [0 => new Model(), 1 => new Model(), 2 => new SoftDeleteModel(), 3 => new Model(), 4 => new SoftDeleteModel()];
     $models = new Models($source);
     $expected = [[Model::getRepo(), [$source[0], $source[1], $source[3]]], [SoftDeleteModel::getRepo(), [$source[2], $source[4]]]];
     $i = 0;
     $models->byRepo(function ($repo, Models $repoModels) use($expected, &$i) {
         $this->assertSame($expected[$i][0], $repo);
         $this->assertSame($expected[$i][1], Objects::toArray($repoModels->all()));
         $i++;
     });
 }