Skip to content

Commit

Permalink
Check activity items in test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
niklasnatter committed Feb 8, 2022
1 parent da4a357 commit ebef22d
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion Tests/Functional/Controller/FormControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace Sulu\Bundle\FormBundle\Tests\Functional\Controller;

use Doctrine\ORM\EntityManagerInterface;
use Sulu\Bundle\ActivityBundle\Domain\Model\ActivityInterface;
use Sulu\Bundle\FormBundle\Configuration\MailConfiguration;
use Sulu\Bundle\FormBundle\Entity\Form;
use Sulu\Bundle\FormBundle\Entity\FormField;
Expand Down Expand Up @@ -102,6 +103,10 @@ public function testPostMinimal(): void
$this->assertHttpStatusCode(201, $this->client->getResponse());
$response = json_decode($this->client->getResponse()->getContent(), true);
$this->assertMinimalForm($response);

$activity = $this->em->getRepository(ActivityInterface::class)->findOneBy(['type' => 'created']);
$this->assertNotNull($activity);
$this->assertSame((string) $response['id'], $activity->getResourceId());
}

public function testPostFull(): void
Expand Down Expand Up @@ -157,6 +162,10 @@ public function testPostTriggerCopy(): void
$response['title'] = str_replace(' (2)', '', $response['title']);

$this->assertFullForm($response);

$activity = $this->em->getRepository(ActivityInterface::class)->findOneBy(['type' => 'copied']);
$this->assertNotNull($activity);
$this->assertSame((string) $response['id'], $activity->getResourceId());
}

public function testPutMinimal(): void
Expand All @@ -176,6 +185,10 @@ public function testPutMinimal(): void
$this->assertHttpStatusCode(200, $this->client->getResponse());
$response = json_decode($this->client->getResponse()->getContent(), true);
$this->assertMinimalForm($response);

$activity = $this->em->getRepository(ActivityInterface::class)->findOneBy(['type' => 'modified']);
$this->assertNotNull($activity);
$this->assertSame((string) $response['id'], $activity->getResourceId());
}

public function testPutFull(): void
Expand Down Expand Up @@ -206,10 +219,11 @@ public function testPutNotExist(): void
public function testDelete(): void
{
$form = $this->createFullForm();
$formId = $form->getId();

$this->client->request(
'DELETE',
'/admin/api/forms/' . $form->getId()
'/admin/api/forms/' . $formId
);

$this->assertHttpStatusCode(204, $this->client->getResponse());
Expand All @@ -221,6 +235,10 @@ public function testDelete(): void
);

$this->assertHttpStatusCode(404, $this->client->getResponse());

$activity = $this->em->getRepository(ActivityInterface::class)->findOneBy(['type' => 'removed']);
$this->assertNotNull($activity);
$this->assertSame((string) $formId, $activity->getResourceId());
}

public function testDeleteNotFound(): void
Expand Down

0 comments on commit ebef22d

Please sign in to comment.