Next major version 2 with PHP 8.1, Symfony 6, Tabler UI, 2FA ... (#2902)
This commit is contained in:
@@ -9,9 +9,11 @@
|
||||
|
||||
namespace App\Tests\API;
|
||||
|
||||
use App\Entity\ActivityRate;
|
||||
use App\Entity\CustomerRate;
|
||||
use App\Entity\ProjectRate;
|
||||
use App\Entity\RateInterface;
|
||||
use App\Entity\User;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
/**
|
||||
* @group integration
|
||||
@@ -41,7 +43,8 @@ trait RateControllerTestTrait
|
||||
'internal_rate' => 6.66,
|
||||
'is_fixed' => false
|
||||
];
|
||||
$this->assertEntityNotFoundForPost(User::ROLE_ADMIN, $this->getRateUrl(99), $data, 'Not found');
|
||||
$client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);
|
||||
$this->assertEntityNotFoundForPost($client, $this->getRateUrl(99), $data);
|
||||
}
|
||||
|
||||
public function testAddRateMissingUserAction()
|
||||
@@ -71,10 +74,7 @@ trait RateControllerTestTrait
|
||||
];
|
||||
$this->request($client, $this->getRateUrl(), 'POST', [], json_encode($data));
|
||||
$response = $client->getResponse();
|
||||
$this->assertFalse($response->isSuccessful());
|
||||
$this->assertEquals(Response::HTTP_FORBIDDEN, $response->getStatusCode());
|
||||
$json = json_decode($response->getContent(), true);
|
||||
$this->assertEquals('Access denied.', $json['message']);
|
||||
$this->assertApiResponseAccessDenied($response, 'Access denied.');
|
||||
}
|
||||
|
||||
public function testAddRateAction()
|
||||
@@ -178,12 +178,14 @@ trait RateControllerTestTrait
|
||||
|
||||
public function testDeleteRateEntityNotFound()
|
||||
{
|
||||
$this->assertEntityNotFoundForDelete(User::ROLE_ADMIN, $this->getRateUrl(99, 1));
|
||||
$client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);
|
||||
$this->assertNotFoundForDelete($client, $this->getRateUrl(99, 1));
|
||||
}
|
||||
|
||||
public function testDeleteRateRateNotFound()
|
||||
{
|
||||
$this->assertEntityNotFoundForDelete(User::ROLE_ADMIN, $this->getRateUrl(1, 99));
|
||||
$client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);
|
||||
$this->assertNotFoundForDelete($client, $this->getRateUrl(1, 99));
|
||||
}
|
||||
|
||||
public function testDeleteRateWithInvalidAssignment()
|
||||
@@ -198,9 +200,12 @@ trait RateControllerTestTrait
|
||||
public function testDeleteNotAllowed()
|
||||
{
|
||||
$client = $this->getClientForAuthenticatedUser(User::ROLE_USER);
|
||||
$this->importTestRates(1);
|
||||
$rates = $this->importTestRates(1);
|
||||
|
||||
$this->request($client, $this->getRateUrl(1, 1), 'DELETE');
|
||||
/** @var ActivityRate|ProjectRate|CustomerRate $rate */
|
||||
$rate = $rates[0];
|
||||
|
||||
$this->request($client, $this->getRateUrl(1, $rate->getId()), 'DELETE');
|
||||
$this->assertApiResponseAccessDenied($client->getResponse(), 'Access denied.');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user