mirror of
https://github.com/yiisoft/yii2.git
synced 2025-08-26 14:26:54 +08:00
Vendor testing support provided.
'swiftmailer' extension unit tests fixed.
This commit is contained in:
@ -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 @@
|
|||||||
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 @@
|
|||||||
|
|
||||||
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
Normal file
30
tests/unit/VendorTestCase.php
Normal file
@ -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.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -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;
|
|||||||
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());
|
]
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user