added internal rates (#1591)

This commit is contained in:
Kevin Papst
2020-04-08 14:50:15 +02:00
committed by GitHub
parent 82c713031e
commit 68d703d1e3
128 changed files with 4044 additions and 1571 deletions

View File

@@ -9,9 +9,13 @@
namespace App\Tests\API;
use App\DataFixtures\UserFixtures;
use App\Entity\Customer;
use App\Entity\Project;
use App\Entity\ProjectRate;
use App\Entity\User;
use App\Repository\ProjectRateRepository;
use App\Repository\ProjectRepository;
use App\Repository\Query\VisibilityInterface;
use App\Tests\Mocks\ProjectTestMetaFieldSubscriberMock;
use Symfony\Component\HttpFoundation\Response;
@@ -22,6 +26,52 @@ use Symfony\Component\HttpKernel\HttpKernelBrowser;
*/
class ProjectControllerTest extends APIControllerBaseTest
{
use RateControllerTestTrait;
protected function getRateUrl(string $id = '1', ?string $rateId = null): string
{
if (null !== $rateId) {
return sprintf('/api/projects/%s/rates/%s', $id, $rateId);
}
return sprintf('/api/projects/%s/rates', $id);
}
protected function importTestRates(string $id): array
{
/** @var ProjectRateRepository $rateRepository */
$rateRepository = $this->getEntityManager()->getRepository(ProjectRate::class);
/** @var ProjectRepository $repository */
$repository = $this->getEntityManager()->getRepository(Project::class);
/** @var Project|null $project */
$project = $repository->find($id);
if (null === $project) {
$project = new Project();
$project->setName('foooo');
$project->setCustomer($this->getEntityManager()->getRepository(Customer::class)->find(1));
$repository->saveProject($project);
}
$rate1 = new ProjectRate();
$rate1->setProject($project);
$rate1->setRate(17.45);
$rate1->setIsFixed(false);
$rateRepository->saveRate($rate1);
$rate2 = new ProjectRate();
$rate2->setProject($project);
$rate2->setRate(99);
$rate2->setInternalRate(9);
$rate2->setIsFixed(true);
$rate2->setUser($this->getUserByName(UserFixtures::USERNAME_USER));
$rateRepository->saveRate($rate2);
return [$rate1, $rate2];
}
public function testIsSecure()
{
$this->assertUrlIsSecured('/api/projects');
@@ -41,7 +91,7 @@ class ProjectControllerTest extends APIControllerBaseTest
protected function loadProjectTestData(HttpKernelBrowser $client)
{
$em = static::$kernel->getContainer()->get('doctrine.orm.entity_manager');
$em = $this->getEntityManager();
$customer = $em->getRepository(Customer::class)->find(1);
@@ -278,7 +328,7 @@ class ProjectControllerTest extends APIControllerBaseTest
$this->assertTrue($client->getResponse()->isSuccessful());
$em = static::$kernel->getContainer()->get('doctrine.orm.entity_manager');
$em = $this->getEntityManager();
/** @var Project $project */
$project = $em->getRepository(Project::class)->find(1);
$this->assertEquals('another,testing,bar', $project->getMetaField('metatestmock')->getValue());