Commit c7c32659 by Paul Klimov

Vendor testing support provided.

'swiftmailer' extension unit tests fixed.
parent 2a326c7d
...@@ -18,7 +18,7 @@ before_script: ...@@ -18,7 +18,7 @@ before_script:
- tests/unit/data/travis/cubrid-setup.sh - tests/unit/data/travis/cubrid-setup.sh
script: script:
- phpunit --coverage-clover tests/unit/runtime/coveralls/clover.xml --verbose --exclude-group mssql,oci,wincache,xcache,zenddata,swiftmailer - phpunit --coverage-clover tests/unit/runtime/coveralls/clover.xml --verbose --exclude-group mssql,oci,wincache,xcache,zenddata,vendor
after_script: after_script:
- php vendor/bin/coveralls - php vendor/bin/coveralls
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
namespace yii\swiftmailer; namespace yii\swiftmailer;
use yii\base\InvalidConfigException; use yii\base\InvalidConfigException;
use yii\email\BaseMailer; use yii\mail\BaseMailer;
/** /**
* Mailer based on SwiftMailer library. * Mailer based on SwiftMailer library.
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
namespace yii\swiftmailer; namespace yii\swiftmailer;
use yii\email\BaseMessage; use yii\mail\BaseMessage;
/** /**
* Email message based on SwiftMailer library. * Email message based on SwiftMailer library.
......
<?php
namespace yiiunit;
use yii\base\NotSupportedException;
use Yii;
/**
* This is the base class for all yii framework unit tests, which requires
* external vendor libraries to function.
*/
class VendorTestCase extends TestCase
{
/**
* This method is called before the first test of this test class is run.
* Attempts to load vendor autoloader.
* @throws \yii\base\NotSupportedException
*/
public static function setUpBeforeClass()
{
$vendorDir = __DIR__ . '/vendor';
Yii::setAlias('@vendor', $vendorDir);
$vendorAutoload = $vendorDir . '/autoload.php';
if (file_exists($vendorAutoload)) {
require_once($vendorAutoload);
} else {
throw new NotSupportedException("Vendor autoload file '{$vendorAutoload}' is missing.");
}
}
}
\ No newline at end of file
...@@ -5,20 +5,22 @@ namespace yiiunit\extensions\swiftmailer; ...@@ -5,20 +5,22 @@ namespace yiiunit\extensions\swiftmailer;
use Yii; use Yii;
use yii\swiftmailer\Mailer; use yii\swiftmailer\Mailer;
use yii\swiftmailer\Message; use yii\swiftmailer\Message;
use yiiunit\TestCase; use yiiunit\VendorTestCase;
/** /**
* @group vendor
* @group email * @group email
* @group swiftmailer * @group swiftmailer
*/ */
class MailerTest extends TestCase class MailerTest extends VendorTestCase
{ {
public function setUp() public function setUp()
{ {
$this->mockApplication(array( $this->mockApplication([
'vendorPath' => Yii::getAlias('@yiiunit/vendor') 'components' => [
)); 'email' => $this->createTestEmailComponent()
Yii::$app->setComponent('email', $this->createTestEmailComponent()); ]
]);
} }
/** /**
......
...@@ -5,13 +5,14 @@ namespace yiiunit\extensions\swiftmailer; ...@@ -5,13 +5,14 @@ namespace yiiunit\extensions\swiftmailer;
use Yii; use Yii;
use yii\swiftmailer\Mailer; use yii\swiftmailer\Mailer;
use yii\swiftmailer\Message; use yii\swiftmailer\Message;
use yiiunit\TestCase; use yiiunit\VendorTestCase;
/** /**
* @group vendor
* @group email * @group email
* @group swiftmailer * @group swiftmailer
*/ */
class MessageTest extends TestCase class MessageTest extends VendorTestCase
{ {
/** /**
* @var string test email address, which will be used as receiver for the messages. * @var string test email address, which will be used as receiver for the messages.
...@@ -20,10 +21,11 @@ class MessageTest extends TestCase ...@@ -20,10 +21,11 @@ class MessageTest extends TestCase
public function setUp() public function setUp()
{ {
$this->mockApplication(array( $this->mockApplication([
'vendorPath' => Yii::getAlias('@yiiunit/vendor') 'components' => [
)); 'email' => $this->createTestEmailComponent()
Yii::$app->setComponent('email', $this->createTestEmailComponent()); ]
]);
} }
/** /**
......
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