do not allow to stop already stopped timesheets (#289)

This commit is contained in:
Kevin Papst
2018-09-01 13:00:30 +02:00
committed by GitHub
parent b1546c0568
commit 62f91f4d38
15 changed files with 294 additions and 68 deletions

View File

@@ -11,10 +11,7 @@ namespace App\Tests\Controller;
use App\DataFixtures\UserFixtures;
use App\Entity\User;
use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Common\DataFixtures\Executor\ORMExecutor;
use Doctrine\Common\DataFixtures\Loader;
use Doctrine\ORM\EntityManager;
use App\Tests\KernelTestTrait;
use Symfony\Bundle\FrameworkBundle\Client;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use Symfony\Component\HttpFoundation\RedirectResponse;
@@ -24,6 +21,8 @@ use Symfony\Component\HttpFoundation\RedirectResponse;
*/
abstract class ControllerBaseTest extends WebTestCase
{
use KernelTestTrait;
public const DEFAULT_LANGUAGE = 'en';
/**
@@ -213,52 +212,6 @@ abstract class ControllerBaseTest extends WebTestCase
}
}
/**
* @param EntityManager $em
* @param Fixture $fixture
*/
protected function importFixture(EntityManager $em, Fixture $fixture)
{
$loader = new Loader();
$loader->addFixture($fixture);
$executor = new ORMExecutor($em, null);
$executor->execute($loader->getFixtures(), true);
}
/**
* @param EntityManager $em
* @param string $role
* @return User|null
*/
protected function getUserByRole(EntityManager $em, string $role = User::ROLE_USER)
{
$name = null;
switch ($role) {
case User::ROLE_SUPER_ADMIN:
$name = UserFixtures::USERNAME_SUPER_ADMIN;
break;
case User::ROLE_ADMIN:
$name = UserFixtures::USERNAME_ADMIN;
break;
case User::ROLE_TEAMLEAD:
$name = UserFixtures::USERNAME_TEAMLEAD;
break;
case User::ROLE_USER:
$name = UserFixtures::USERNAME_USER;
break;
default:
return null;
}
return $em->getRepository(User::class)->findOneBy(['username' => $name]);
}
/**
* @param Client $client
*/