From c7c32659b0d0dec85d63b75eedc6dfc303deae03 Mon Sep 17 00:00:00 2001 From: Paul Klimov Date: Fri, 25 Oct 2013 14:49:43 +0300 Subject: [PATCH] Vendor testing support provided. 'swiftmailer' extension unit tests fixed. --- .travis.yml | 2 +- extensions/swiftmailer/yii/swiftmailer/Mailer.php | 2 +- extensions/swiftmailer/yii/swiftmailer/Message.php | 2 +- tests/unit/VendorTestCase.php | 30 ++++++++++++++++++++++ tests/unit/extensions/swiftmailer/MailerTest.php | 14 +++++----- tests/unit/extensions/swiftmailer/MessageTest.php | 14 +++++----- 6 files changed, 49 insertions(+), 15 deletions(-) create mode 100644 tests/unit/VendorTestCase.php diff --git a/.travis.yml b/.travis.yml index 0218654..99ff95a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,7 +18,7 @@ before_script: - tests/unit/data/travis/cubrid-setup.sh 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: - php vendor/bin/coveralls diff --git a/extensions/swiftmailer/yii/swiftmailer/Mailer.php b/extensions/swiftmailer/yii/swiftmailer/Mailer.php index 2f8bbe7..1d5bc5c 100644 --- a/extensions/swiftmailer/yii/swiftmailer/Mailer.php +++ b/extensions/swiftmailer/yii/swiftmailer/Mailer.php @@ -8,7 +8,7 @@ namespace yii\swiftmailer; use yii\base\InvalidConfigException; -use yii\email\BaseMailer; +use yii\mail\BaseMailer; /** * Mailer based on SwiftMailer library. diff --git a/extensions/swiftmailer/yii/swiftmailer/Message.php b/extensions/swiftmailer/yii/swiftmailer/Message.php index e850208..7cf3032 100644 --- a/extensions/swiftmailer/yii/swiftmailer/Message.php +++ b/extensions/swiftmailer/yii/swiftmailer/Message.php @@ -7,7 +7,7 @@ namespace yii\swiftmailer; -use yii\email\BaseMessage; +use yii\mail\BaseMessage; /** * Email message based on SwiftMailer library. diff --git a/tests/unit/VendorTestCase.php b/tests/unit/VendorTestCase.php new file mode 100644 index 0000000..d633d02 --- /dev/null +++ b/tests/unit/VendorTestCase.php @@ -0,0 +1,30 @@ +mockApplication(array( - 'vendorPath' => Yii::getAlias('@yiiunit/vendor') - )); - Yii::$app->setComponent('email', $this->createTestEmailComponent()); + $this->mockApplication([ + 'components' => [ + 'email' => $this->createTestEmailComponent() + ] + ]); } /** diff --git a/tests/unit/extensions/swiftmailer/MessageTest.php b/tests/unit/extensions/swiftmailer/MessageTest.php index cabf22a..530d725 100644 --- a/tests/unit/extensions/swiftmailer/MessageTest.php +++ b/tests/unit/extensions/swiftmailer/MessageTest.php @@ -5,13 +5,14 @@ namespace yiiunit\extensions\swiftmailer; use Yii; use yii\swiftmailer\Mailer; use yii\swiftmailer\Message; -use yiiunit\TestCase; +use yiiunit\VendorTestCase; /** + * @group vendor * @group email * @group swiftmailer */ -class MessageTest extends TestCase +class MessageTest extends VendorTestCase { /** * @var string test email address, which will be used as receiver for the messages. @@ -20,10 +21,11 @@ class MessageTest extends TestCase public function setUp() { - $this->mockApplication(array( - 'vendorPath' => Yii::getAlias('@yiiunit/vendor') - )); - Yii::$app->setComponent('email', $this->createTestEmailComponent()); + $this->mockApplication([ + 'components' => [ + 'email' => $this->createTestEmailComponent() + ] + ]); } /**