Skip to content

Commit

Permalink
Improve testing with multiple subscriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
loic425 committed Jun 22, 2023
1 parent 2e34e82 commit ec94944
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
19 changes: 15 additions & 4 deletions tests/Application/src/Tests/Controller/SubscriptionUiTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ public function it_allows_browsing_subscriptions(): void
$this->assertStringContainsString(sprintf('<a href="/admin/subscriptions/%s">Show</a>', $subscriptions['subscription_doc']->getId()), $content);
$this->assertStringContainsString(sprintf('<a href="/admin/subscriptions/%s/edit">Edit</a>', $subscriptions['subscription_doc']->getId()), $content);
$this->assertStringContainsString(sprintf('<form action="/admin/subscriptions/%s" method="post">', $subscriptions['subscription_doc']->getId()), $content);

$this->assertStringContainsString('<td>biff.tannen@bttf.com</td>', $content);
$this->assertStringContainsString(sprintf('<a href="/admin/subscriptions/%s">Show</a>', $subscriptions['subscription_biff']->getId()), $content);
$this->assertStringContainsString(sprintf('<a href="/admin/subscriptions/%s/edit">Edit</a>', $subscriptions['subscription_biff']->getId()), $content);
$this->assertStringContainsString(sprintf('<form action="/admin/subscriptions/%s" method="post">', $subscriptions['subscription_biff']->getId()), $content);
}

/** @test */
Expand Down Expand Up @@ -187,11 +192,17 @@ public function it_allows_accepting_multiple_subscription(): void

$this->assertResponseRedirects(null, expectedCode: Response::HTTP_FOUND);

/** @var Subscription $subscription */
$subscription = static::getContainer()->get('app.repository.subscription')->findOneBy(['email' => 'marty.mcfly@bttf.com']);
/** @var Subscription $firstSubscription */
$firstSubscription = static::getContainer()->get('app.repository.subscription')->findOneBy(['email' => 'marty.mcfly@bttf.com']);

$this->assertNotNull($subscription);
$this->assertSame('accepted', $subscription->getState());
/** @var Subscription $secondSubscription */
$secondSubscription = static::getContainer()->get('app.repository.subscription')->findOneBy(['email' => 'doc.brown@bttf.com']);

$this->assertNotNull($firstSubscription);
$this->assertSame('accepted', $firstSubscription->getState());

$this->assertNotNull($secondSubscription);
$this->assertSame('accepted', $secondSubscription->getState());
}

protected function buildMatcher(): Matcher
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ App\Subscription\Entity\Subscription:
email: 'marty.mcfly@bttf.com'
subscription_doc:
email: 'doc.brown@bttf.com'
subscription_biff:
email: 'biff.tannen@bttf.com'
state: accepted

0 comments on commit ec94944

Please sign in to comment.