Commit 93d49671 authored by Fabien Potencier's avatar Fabien Potencier

moved the loading of Swiftmailer to the boot method

If not, defining the Swiftmailer class_path after registering the
provider does not work.
parent 9981120f
......@@ -79,16 +79,16 @@ class SwiftmailerServiceProvider implements ServiceProviderInterface
$app['swiftmailer.transport.eventdispatcher'] = $app->share(function () {
return new \Swift_Events_SimpleEventDispatcher();
});
}
public function boot(Application $app)
{
if (isset($app['swiftmailer.class_path'])) {
require_once $app['swiftmailer.class_path'].'/Swift.php';
\Swift::registerAutoload($app['swiftmailer.class_path'].'/../swift_init.php');
}
}
public function boot(Application $app)
{
$app->finish(function () use ($app) {
$app['swiftmailer.spooltransport']->getSpool()->flushQueue($app['swiftmailer.transport']);
});
......
......@@ -26,13 +26,25 @@ class SwiftmailerServiceProviderTest extends \PHPUnit_Framework_TestCase
}
}
public function testSwiftMailerServiceWhenClassPathIsDefinedLate()
{
$app = new Application();
$app->register(new SwiftmailerServiceProvider());
$app['swiftmailer.class_path'] = __DIR__.'/../../../../vendor/swiftmailer/swiftmailer/lib/classes';
$app->boot();
$this->assertInstanceOf('Swift_Mailer', $app['mailer']);
}
public function testSwiftMailerServiceIsSwiftMailer()
{
$app = new Application();
$app->register(new SwiftmailerServiceProvider(), array(
'swiftmailer.class_path' => __DIR__.'/../../../../vendor/swiftmailer/swiftmailer/lib/classes',
'swiftmailer.class_path' => __DIR__.'/../../../../vendor/swiftmailer/swiftmailer/lib/classes',
));
$app->boot();
$this->assertInstanceOf('Swift_Mailer', $app['mailer']);
}
......@@ -44,6 +56,7 @@ class SwiftmailerServiceProviderTest extends \PHPUnit_Framework_TestCase
$app->register(new SwiftmailerServiceProvider(), array(
'swiftmailer.class_path' => __DIR__.'/../../../../vendor/swiftmailer/swiftmailer/lib/classes',
));
$app->boot();
$app['swiftmailer.spool'] = $app->share(function () {
return new SpoolStub();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment