added tags for timesheets (#604)

This commit is contained in:
Mathias
2019-05-12 01:40:04 +02:00
committed by Kevin Papst
parent f31118292c
commit e29e183e84
84 changed files with 2132 additions and 158 deletions

View File

@@ -11,6 +11,7 @@ namespace App\Tests\Repository;
use App\Entity\Activity;
use App\Entity\Project;
use App\Entity\Tag;
use App\Entity\Timesheet;
use App\Entity\User;
use App\Repository\Query\BaseQuery;
@@ -119,4 +120,39 @@ class TimesheetRepositoryTest extends AbstractRepositoryTest
$repository->save($timesheet);
$this->assertEquals(1, $timesheet->getId());
}
public function testSaveWithTags()
{
$em = $this->getEntityManager();
$activityRepository = $em->getRepository(Activity::class);
$activity = $activityRepository->find(1);
$projectRepository = $em->getRepository(Project::class);
$project = $projectRepository->find(1);
$user = $this->getUserByRole($em, User::ROLE_USER);
$repository = $em->getRepository(Timesheet::class);
$tagOne = new Tag();
$tagOne->setName('Travel');
$tagTwo = new Tag();
$tagTwo->setName('Picture');
$timesheet = new Timesheet();
$timesheet
->setBegin(new \DateTime())
->setEnd(new \DateTime())
->setDescription('foo')
->setUser($user)
->setActivity($activity)
->setProject($project)
->addTag($tagOne)
->addTag($tagTwo);
$this->assertNull($timesheet->getId());
$repository->save($timesheet);
$this->assertEquals(1, $timesheet->getId());
$this->assertEquals(2, $timesheet->getTags()->count());
$this->assertEquals('Travel', $timesheet->getTags()->get(0)->getName());
$this->assertEquals(1, $timesheet->getTags()->get(0)->getId());
$this->assertEquals('Picture', $timesheet->getTags()->get(1)->getName());
$this->assertEquals(2, $timesheet->getTags()->get(1)->getId());
}
}