Browse Source

Vendor testing support provided.

'swiftmailer' extension unit tests fixed.
tags/2.0.0-beta
Paul Klimov 11 years ago
parent
commit
c7c32659b0
  1. 2
      .travis.yml
  2. 2
      extensions/swiftmailer/yii/swiftmailer/Mailer.php
  3. 2
      extensions/swiftmailer/yii/swiftmailer/Message.php
  4. 30
      tests/unit/VendorTestCase.php
  5. 14
      tests/unit/extensions/swiftmailer/MailerTest.php
  6. 14
      tests/unit/extensions/swiftmailer/MessageTest.php

2
.travis.yml

@ -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

2
extensions/swiftmailer/yii/swiftmailer/Mailer.php

@ -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.

2
extensions/swiftmailer/yii/swiftmailer/Message.php

@ -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.

30
tests/unit/VendorTestCase.php

@ -0,0 +1,30 @@
<?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.");
}
}
}

14
tests/unit/extensions/swiftmailer/MailerTest.php

@ -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()); ]
]);
} }
/** /**

14
tests/unit/extensions/swiftmailer/MessageTest.php

@ -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
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()); ]
]);
} }
/** /**

Loading…
Cancel
Save