Skip to content

Commit

Permalink
Merge pull request #117 from airtonzanon/airton/integration
Browse files Browse the repository at this point in the history
Integration Test
  • Loading branch information
airtonzanon authored Feb 17, 2023
2 parents 3861bce + 0fd8a30 commit 4dcd594
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ jobs:
build:
name: CI
runs-on: ubuntu-latest
env:
contentful_space_id: ${{ secrets.CONTENTFUL_SPACE_ID }}
contentful_token: ${{ secrets.CONTENTFUL_TOKEN }}

strategy:
matrix:
Expand Down
7 changes: 3 additions & 4 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,13 @@
verbose="true"
colors="true"
>
<php>
<env name="contentful_space_id" value="test-space-id" />
<env name="contentful_token" value="test-token123444" />
</php>
<testsuites>
<testsuite name="unit">
<directory>./tests/Unit</directory>
</testsuite>
<testsuite name="integration">
<directory>./tests/Integration</directory>
</testsuite>
</testsuites>
<coverage>
<include>
Expand Down
28 changes: 28 additions & 0 deletions tests/Integration/SculpinContentfulCommandTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php
declare(strict_types=1);

namespace AirtonZanon\SculpinContentfulBundle\Tests\Integration;

use AirtonZanon\SculpinContentfulBundle\Command\SculpinContentfulCommand;
use Contentful\Delivery\Client;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Console\Tester\CommandTester;

final class SculpinContentfulCommandTest extends TestCase
{
public function testExecuteSuccessScenario(): void {
$command = new SculpinContentfulCommand();

$contentfulSpaceId = getenv('contentful_space_id');
$contentfulToken = getenv('contentful_token');

$client = new Client($contentfulToken, $contentfulSpaceId);

$command->setContentfulClient($client);
$commandTester = new CommandTester($command);
$commandTester->execute([]);

$output = $commandTester->getDisplay();
self::assertStringContainsString("Created file", $output);
}
}

0 comments on commit 4dcd594

Please sign in to comment.