Skip to content

Commit

Permalink
Add some work about tests
Browse files Browse the repository at this point in the history
  • Loading branch information
moux2003 committed Feb 18, 2018
1 parent bb86adb commit e400625
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 18 deletions.
4 changes: 3 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"type": "symfony-bundle",
"description": "Swiftmailer Transport and Symfony bundle for Sendgrid",
"homepage": "https://github.com/expertcoder/SwiftmailerSendGridBundle",
"license": "MIT",
"authors": [
{
"name": "Samual Anthony",
Expand All @@ -15,7 +16,8 @@
],
"require": {
"php": ">=5.4",
"symfony/symfony": ">=2.7",
"symfony/symfony": "~2.7|~3.3|~4.0",
"swiftmailer/swiftmailer": ">=4.2.0,<6.0.0",
"sendgrid/sendgrid": "^5.0"
},
"autoload": {
Expand Down
32 changes: 32 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit backupGlobals="false"
backupStaticAttributes="false"
colors="false"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
codecoverage="true"
bootstrap="./vendor/autoload.php"
>

<formatter type="clover" usefile="false"/>
<testsuites>
<testsuite name="Test Suite">
<directory>./tests</directory>
</testsuite>
</testsuites>

<filter>
<whitelist>
<directory suffix=".php">./</directory>
<exclude>
<directory>vendor</directory>
<directory>tests</directory>
</exclude>
</whitelist>
</filter>
</phpunit>
23 changes: 6 additions & 17 deletions tests/BundleInitializationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ protected function setUp()

public function testInitBundle()
{
// Create a new Kernel
$kernel = $this->createKernel();

// Add some configuration
$kernel->addConfigFile(__DIR__.'/config_test.yml');

// Boot the kernel.
$this->bootKernel();

Expand All @@ -39,21 +45,4 @@ public function testInitBundle()
$this->assertTrue($container->hasParameter('expertcoder_swiftmailer_sendgrid.api_key'));
$this->assertTrue($container->hasParameter('expertcoder_swiftmailer_sendgrid.categories'));
}

public function testBundleWithDifferentConfiguration()
{
// Create a new Kernel
$kernel = $this->createKernel();

// Add some configuration
$kernel->addConfigFile(__DIR__.'/config.yml');

// Add some other bundles we depend on
$kernel->addBundle(OtherBundle::class);

// Boot the kernel as normal ...
$this->bootKernel();

// ...
}
}
3 changes: 3 additions & 0 deletions tests/config_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
expert_coder_swiftmailer_send_grid:
api_key: myApiKey
categories: [category1, category2]
17 changes: 17 additions & 0 deletions tests/manual-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/sh
# Helper script for testing purpose (local tests)
# One argument needed: Symfony major version to test against (ie. 2, 3 or 4)

if [ $# -eq 0 ] # check if argument exists
then
echo "Please add Symfony major version to test against (ex: 'sh tests/manual-test.sh 2' to test Sf 2.7)"
exit 0;
fi

composer require --dev --no-update symfony/phpunit-bridge:^4.0 dunglas/symfony-lock:^$1
composer update --prefer-dist --no-interaction --prefer-stable --quiet
composer update --prefer-stable --prefer-lowest --prefer-dist --no-interaction
./vendor/bin/simple-phpunit install

composer validate --strict --no-check-lock
./vendor/bin/simple-phpunit

0 comments on commit e400625

Please sign in to comment.