Skip to content

Commit 1fadfae

Browse files
committed
Change structure & initiate tests
1 parent ba66428 commit 1fadfae

8 files changed

+73
-1
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Ignore composer generated files
2+
composer.lock
3+
vendor/

composer.json

+11-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
{
88
"name": "Samual Anthony",
99
"email": "sam@expertcoder.io"
10+
},
11+
{
12+
"name": "Maxime Hermouet",
13+
"email": "moux2003@hotmail.com"
1014
}
1115
],
1216
"require": {
@@ -15,6 +19,12 @@
1519
"sendgrid/sendgrid": "^5.0"
1620
},
1721
"autoload": {
18-
"psr-4": { "ExpertCoder\\Swiftmailer\\SendGridBundle\\": "" }
22+
"psr-4": { "ExpertCoder\\Swiftmailer\\SendGridBundle\\": "src/" }
23+
},
24+
"autoload-dev": {
25+
"psr-4": { "ExpertCoder\\Swiftmailer\\SendGridBundle\\Tests\\": "tests/"}
26+
},
27+
"require-dev": {
28+
"nyholm/symfony-bundle-test": "^1.3"
1929
}
2030
}
File renamed without changes.
File renamed without changes.

tests/BundleInitializationTest.php

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<?php
2+
3+
namespace ExpertCoder\Swiftmailer\SendGridBundle\Tests;
4+
5+
use Nyholm\BundleTest\BaseBundleTestCase;
6+
use Nyholm\BundleTest\CompilerPass\PublicServicePass;
7+
use ExpertCoder\Swiftmailer\SendGridBundle\ExpertCoderSwiftmailerSendGridBundle;
8+
use ExpertCoder\Swiftmailer\SendGridBundle\Services\SendGridTransport;
9+
10+
class BundleInitializationTest extends BaseBundleTestCase
11+
{
12+
protected function getBundleClass()
13+
{
14+
return ExpertCoderSwiftmailerSendGridBundle::class;
15+
}
16+
17+
protected function setUp()
18+
{
19+
parent::setUp();
20+
21+
// Make services public that have an idea that matches a regex
22+
$this->addCompilerPass(new PublicServicePass('|expertcoder_swift_mailer.*|'));
23+
}
24+
25+
public function testInitBundle()
26+
{
27+
// Boot the kernel.
28+
$this->bootKernel();
29+
30+
// Get the container
31+
$container = $this->getContainer();
32+
33+
// Test if services exists
34+
$this->assertTrue($container->has('expertcoder_swift_mailer.send_grid.transport'));
35+
$service = $container->get('expertcoder_swift_mailer.send_grid.transport');
36+
$this->assertInstanceOf(SendGridTransport::class, $service);
37+
38+
// Test if parameters exists
39+
$this->assertTrue($container->hasParameter('expertcoder_swiftmailer_sendgrid.api_key'));
40+
$this->assertTrue($container->hasParameter('expertcoder_swiftmailer_sendgrid.categories'));
41+
}
42+
43+
public function testBundleWithDifferentConfiguration()
44+
{
45+
// Create a new Kernel
46+
$kernel = $this->createKernel();
47+
48+
// Add some configuration
49+
$kernel->addConfigFile(__DIR__.'/config.yml');
50+
51+
// Add some other bundles we depend on
52+
$kernel->addBundle(OtherBundle::class);
53+
54+
// Boot the kernel as normal ...
55+
$this->bootKernel();
56+
57+
// ...
58+
}
59+
}

0 commit comments

Comments
 (0)