feat: let managers edit the staffing matrix
This commit is contained in:
1 parent
f9d2ff084d
commit
4ff963d1e2
15 files changed
+84
-52
No files matched your search
+32
-11
@@ -2,7 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Tests\Controller\Admin\System\StaffingRule;
|
||||
namespace App\Tests\Controller\Administrative\System\StaffingRule;
|
||||
|
||||
use App\Entity\User;
|
||||
use App\Repository\StaffingRuleRepository;
|
||||
@@ -29,7 +29,7 @@ class StaffingRuleControllerTest extends WebTestCase
|
||||
$this->resetStaffingTables(self::getContainer()->get(Connection::class));
|
||||
$this->entityManager->createQuery(sprintf('DELETE FROM %s', User::class))->execute();
|
||||
|
||||
$this->client->loginUser($this->admin());
|
||||
$this->client->loginUser($this->user('ROLE_TEAM_ADMIN'));
|
||||
}
|
||||
|
||||
public function testARuleIsCreatedWithItsCodeNormalized(): void
|
||||
@@ -44,12 +44,33 @@ class StaffingRuleControllerTest extends WebTestCase
|
||||
$this->assertTrue($rules[0]->isSkiBeginner());
|
||||
$this->assertFalse($rules[0]->isEnabled());
|
||||
|
||||
$this->client->request('GET', '/admin/system/staffing-rule');
|
||||
$this->client->request('GET', '/administrative/system/staffing-rule');
|
||||
|
||||
$this->assertSame(Response::HTTP_OK, $this->client->getResponse()->getStatusCode());
|
||||
$this->assertStringContainsString('DKIMP', (string) $this->client->getResponse()->getContent());
|
||||
}
|
||||
|
||||
public function testAManagerEditsTheMatrixToo(): void
|
||||
{
|
||||
$this->client->loginUser($this->user('ROLE_MANAGER'));
|
||||
|
||||
$this->submitCreate('DKIMP');
|
||||
$this->assertCount(1, $this->repository()->getList());
|
||||
|
||||
$this->client->request('GET', '/administrative/system/staffing-rule/preview');
|
||||
$this->assertResponseIsSuccessful();
|
||||
}
|
||||
|
||||
public function testATeamerIsRefused(): void
|
||||
{
|
||||
$this->client->loginUser($this->user('ROLE_TEAMER'));
|
||||
|
||||
$this->client->request('GET', '/administrative/system/staffing-rule');
|
||||
|
||||
// the access-denied handler sends a teamer home instead of answering 403
|
||||
$this->assertResponseRedirects('/teamer');
|
||||
}
|
||||
|
||||
public function testASecondRowForTheSameProductIsRefused(): void
|
||||
{
|
||||
$this->submitCreate('DKIMP');
|
||||
@@ -74,7 +95,7 @@ class StaffingRuleControllerTest extends WebTestCase
|
||||
{
|
||||
$this->submitCreate('DKIMP');
|
||||
|
||||
$this->client->request('GET', '/admin/system/staffing-rule/preview');
|
||||
$this->client->request('GET', '/administrative/system/staffing-rule/preview');
|
||||
|
||||
$this->assertSame(Response::HTTP_OK, $this->client->getResponse()->getStatusCode());
|
||||
$this->assertStringContainsString('Keine Termine', (string) $this->client->getResponse()->getContent());
|
||||
@@ -86,7 +107,7 @@ class StaffingRuleControllerTest extends WebTestCase
|
||||
$this->staffingDestination($this->entityManager, 'DKIMP110127', 'DKIMP');
|
||||
$this->entityManager->flush();
|
||||
|
||||
$this->client->request('GET', '/admin/system/staffing-rule/preview');
|
||||
$this->client->request('GET', '/administrative/system/staffing-rule/preview');
|
||||
|
||||
$content = (string) $this->client->getResponse()->getContent();
|
||||
|
||||
@@ -109,7 +130,7 @@ class StaffingRuleControllerTest extends WebTestCase
|
||||
$this->entityManager->flush();
|
||||
|
||||
// same date: ordered by product code
|
||||
$this->client->request('GET', '/admin/system/staffing-rule/preview?limit=1&page=2');
|
||||
$this->client->request('GET', '/administrative/system/staffing-rule/preview?limit=1&page=2');
|
||||
|
||||
$content = (string) $this->client->getResponse()->getContent();
|
||||
|
||||
@@ -124,7 +145,7 @@ class StaffingRuleControllerTest extends WebTestCase
|
||||
$this->staffingDestination($this->entityManager, 'DKIMP110127', 'DKIMP');
|
||||
$this->entityManager->flush();
|
||||
|
||||
$this->client->request('GET', '/admin/system/staffing-rule/export');
|
||||
$this->client->request('GET', '/administrative/system/staffing-rule/export');
|
||||
|
||||
$this->assertSame(Response::HTTP_OK, $this->client->getResponse()->getStatusCode());
|
||||
$this->assertSame(
|
||||
@@ -135,7 +156,7 @@ class StaffingRuleControllerTest extends WebTestCase
|
||||
|
||||
private function submitCreate(string $productCode): void
|
||||
{
|
||||
$crawler = $this->client->request('GET', '/admin/system/staffing-rule/create');
|
||||
$crawler = $this->client->request('GET', '/administrative/system/staffing-rule/create');
|
||||
$form = $crawler->filter('form')->form([
|
||||
'staffing_rule[productCode]' => $productCode,
|
||||
'staffing_rule[guides]' => '2',
|
||||
@@ -152,13 +173,13 @@ class StaffingRuleControllerTest extends WebTestCase
|
||||
return self::getContainer()->get(StaffingRuleRepository::class);
|
||||
}
|
||||
|
||||
private function admin(): User
|
||||
private function user(string $role): User
|
||||
{
|
||||
$user = (new User())
|
||||
->setFirstName('Anna')
|
||||
->setLastName('Admin')
|
||||
->setEmail('anna.admin@example.com')
|
||||
->setRoles(['ROLE_TEAM_ADMIN'])
|
||||
->setEmail(sprintf('%s@example.com', strtolower($role)))
|
||||
->setRoles([$role])
|
||||
->setBusProAddressId(1)
|
||||
->setBusProPersonId(1)
|
||||
;
|
||||
Reference in new issue
Block a user