-
Notifications
You must be signed in to change notification settings - Fork 18
Add unit and functional test suites #87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
b80769d
Add unit and functional test suites
loevgaard 95d4458
Run unit and functional tests in CI
loevgaard 6638f0a
Cover the bundle class with a unit test
loevgaard 9bfbd69
Exclude payum/payum-bundle 2.7.0 from the test application
loevgaard 40d9736
Build the test application frontend in CI instead of disabling asset …
loevgaard 7c67b7f
Lower the mutation score thresholds instead of ignoring mutators
loevgaard 6dfecdf
Set the mutation score thresholds to the actual single-threaded score
loevgaard b0d2b9a
Import the Payum routes format-agnostically in the test application
loevgaard a777f5e
Revert "Import the Payum routes format-agnostically in the test appli…
loevgaard File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,6 +11,6 @@ | |
| "badge": "3.x" | ||
| } | ||
| }, | ||
| "minMsi": 100.00, | ||
| "minCoveredMsi": 100.00 | ||
| "minMsi": 87, | ||
| "minCoveredMsi": 87 | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,140 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Setono\SyliusFacebookPlugin\Tests\Functional\Admin; | ||
|
|
||
| use Setono\SyliusFacebookPlugin\Model\PixelInterface; | ||
| use Setono\SyliusFacebookPlugin\Tests\Functional\FunctionalTestCase; | ||
| use Symfony\Bundle\FrameworkBundle\KernelBrowser; | ||
| use Symfony\Component\Security\Core\User\UserInterface; | ||
|
|
||
| final class ManagingPixelsTest extends FunctionalTestCase | ||
| { | ||
| /** | ||
| * @test | ||
| */ | ||
| public function it_lists_pixels(): void | ||
| { | ||
| $client = $this->createAuthenticatedClient(); | ||
| self::createPixel('123456789', true, self::createChannel('WEB')); | ||
|
|
||
| $client->request('GET', '/admin/facebook/pixels/'); | ||
|
|
||
| self::assertResponseIsSuccessful(); | ||
| self::assertSelectorTextContains('table', '123456789'); | ||
| } | ||
|
|
||
| /** | ||
| * @test | ||
| */ | ||
| public function it_creates_a_pixel(): void | ||
| { | ||
| $client = $this->createAuthenticatedClient(); | ||
| self::createChannel('WEB'); | ||
|
|
||
| $client->request('GET', '/admin/facebook/pixels/new'); | ||
| self::assertResponseIsSuccessful(); | ||
|
|
||
| $client->submitForm('Create', [ | ||
| 'setono_sylius_facebook_pixel[pixelId]' => '123456789', | ||
| 'setono_sylius_facebook_pixel[accessToken]' => 'access_token', | ||
| 'setono_sylius_facebook_pixel[enabled]' => '1', | ||
| 'setono_sylius_facebook_pixel[channels]' => ['WEB'], | ||
| ]); | ||
|
|
||
| self::assertResponseRedirects(); | ||
| $client->followRedirect(); | ||
| self::assertResponseIsSuccessful(); | ||
|
|
||
| $pixel = self::getPixelRepository()->findOneBy(['pixelId' => '123456789']); | ||
| self::assertInstanceOf(PixelInterface::class, $pixel); | ||
| self::assertSame('access_token', $pixel->getAccessToken()); | ||
| self::assertTrue($pixel->isEnabled()); | ||
| self::assertCount(1, $pixel->getChannels()); | ||
| } | ||
|
|
||
| /** | ||
| * @test | ||
| */ | ||
| public function it_does_not_create_a_pixel_with_an_invalid_pixel_id(): void | ||
| { | ||
| $client = $this->createAuthenticatedClient(); | ||
| self::createChannel('WEB'); | ||
|
|
||
| $client->request('GET', '/admin/facebook/pixels/new'); | ||
| $client->submitForm('Create', [ | ||
| 'setono_sylius_facebook_pixel[pixelId]' => 'not a number', | ||
| 'setono_sylius_facebook_pixel[channels]' => ['WEB'], | ||
| ]); | ||
|
|
||
| self::assertSelectorExists('.sylius-validation-error'); | ||
| self::assertNull(self::getPixelRepository()->findOneBy(['pixelId' => 'not a number'])); | ||
| } | ||
|
|
||
| /** | ||
| * @test | ||
| */ | ||
| public function it_updates_a_pixel(): void | ||
| { | ||
| $client = $this->createAuthenticatedClient(); | ||
| $pixelId = (int) self::createPixel('123456789', true, self::createChannel('WEB'))->getId(); | ||
|
|
||
| $client->request('GET', sprintf('/admin/facebook/pixels/%d/edit', $pixelId)); | ||
| self::assertResponseIsSuccessful(); | ||
|
|
||
| $client->submitForm('Save changes', [ | ||
| 'setono_sylius_facebook_pixel[pixelId]' => '987654321', | ||
| 'setono_sylius_facebook_pixel[enabled]' => false, | ||
| ]); | ||
|
|
||
| self::assertResponseRedirects(); | ||
|
|
||
| // The kernel is rebooted between requests, so fetch the pixel again instead of refreshing a detached entity | ||
| self::getEntityManager()->clear(); | ||
| $pixel = self::getPixelRepository()->find($pixelId); | ||
| self::assertInstanceOf(PixelInterface::class, $pixel); | ||
| self::assertSame('987654321', $pixel->getPixelId()); | ||
| self::assertFalse($pixel->isEnabled()); | ||
| } | ||
|
|
||
| /** | ||
| * @test | ||
| */ | ||
| public function it_deletes_a_pixel(): void | ||
| { | ||
| $client = $this->createAuthenticatedClient(); | ||
| $pixel = self::createPixel('123456789', true, self::createChannel('WEB')); | ||
| $pixelId = (int) $pixel->getId(); | ||
|
|
||
| $client->request('GET', '/admin/facebook/pixels/'); | ||
| $client->submitForm('Delete'); | ||
|
|
||
| self::assertResponseRedirects(); | ||
| self::getEntityManager()->clear(); | ||
| self::assertNull(self::getPixelRepository()->find($pixelId)); | ||
| } | ||
|
|
||
| /** | ||
| * @test | ||
| */ | ||
| public function it_requires_an_authenticated_administrator(): void | ||
| { | ||
| $client = self::createClient(); | ||
|
|
||
| $client->request('GET', '/admin/facebook/pixels/'); | ||
|
|
||
| self::assertResponseRedirects('/admin/login'); | ||
| } | ||
|
|
||
| private function createAuthenticatedClient(): KernelBrowser | ||
| { | ||
| $client = self::createClient(); | ||
|
|
||
| $adminUser = self::createAdminUser(); | ||
| self::assertInstanceOf(UserInterface::class, $adminUser); | ||
| $client->loginUser($adminUser, 'admin'); | ||
|
|
||
| return $client; | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.