Commit 7cd9123c by Alexander Makarov

Tests cleanup

- Better names - Removed not used MySQLTestCase - Moved base testcase for DB to db namespace - Minor style fixes
parent 759c303a
<?php
namespace yiiunit;
class MysqlTestCase extends TestCase
{
protected function setUp()
{
parent::setUp();
if (!extension_loaded('pdo') || !extension_loaded('pdo_mysql')) {
$this->markTestSkipped('pdo and pdo_mysql extensions are required.');
}
}
/**
* @param bool $reset whether to clean up the test database
* @return \yii\db\Connection
*/
public function getConnection($reset = true)
{
$params = $this->getParam('mysql');
$db = new \yii\db\Connection;
$db->dsn = $params['dsn'];
$db->username = $params['username'];
$db->password = $params['password'];
if ($reset) {
$db->open();
$lines = explode(';', file_get_contents($params['fixture']));
foreach ($lines as $line) {
if (trim($line) !== '') {
$db->pdo->exec($line);
}
}
}
return $db;
}
}
...@@ -5,7 +5,7 @@ namespace yiiunit; ...@@ -5,7 +5,7 @@ namespace yiiunit;
/** /**
* This is the base class for all yii framework unit tests. * This is the base class for all yii framework unit tests.
*/ */
class TestCase extends \yii\test\TestCase abstract class TestCase extends \yii\test\TestCase
{ {
public static $params; public static $params;
......
<?php <?php
namespace yiiunit\framework\caching; namespace yiiunit\framework\caching;
use yii\caching\ApcCache; use yii\caching\ApcCache;
use yiiunit\TestCase;
/** /**
* Class for testing APC cache backend * Class for testing APC cache backend
*/ */
class ApcCacheTest extends CacheTest class ApcCacheTest extends CacheTestCase
{ {
private $_cacheInstance = null; private $_cacheInstance = null;
......
...@@ -7,7 +7,7 @@ namespace yii\caching; ...@@ -7,7 +7,7 @@ namespace yii\caching;
* @return int * @return int
*/ */
function time() { function time() {
return \yiiunit\framework\caching\CacheTest::$time ?: \time(); return \yiiunit\framework\caching\CacheTestCase::$time ?: \time();
} }
namespace yiiunit\framework\caching; namespace yiiunit\framework\caching;
...@@ -18,7 +18,7 @@ use yii\caching\Cache; ...@@ -18,7 +18,7 @@ use yii\caching\Cache;
/** /**
* Base class for testing cache backends * Base class for testing cache backends
*/ */
abstract class CacheTest extends TestCase abstract class CacheTestCase extends TestCase
{ {
/** /**
* @var int virtual time to be returned by mocked time() function. * @var int virtual time to be returned by mocked time() function.
......
...@@ -3,12 +3,11 @@ ...@@ -3,12 +3,11 @@
namespace yiiunit\framework\caching; namespace yiiunit\framework\caching;
use yii\caching\DbCache; use yii\caching\DbCache;
use yiiunit\TestCase;
/** /**
* Class for testing file cache backend * Class for testing file cache backend
*/ */
class DbCacheTest extends CacheTest class DbCacheTest extends CacheTestCase
{ {
private $_cacheInstance; private $_cacheInstance;
private $_connection; private $_connection;
......
<?php <?php
namespace yiiunit\framework\caching; namespace yiiunit\framework\caching;
use yii\caching\FileCache; use yii\caching\FileCache;
use yiiunit\TestCase;
/** /**
* Class for testing file cache backend * Class for testing file cache backend
*/ */
class FileCacheTest extends CacheTest class FileCacheTest extends CacheTestCase
{ {
private $_cacheInstance = null; private $_cacheInstance = null;
......
<?php <?php
namespace yiiunit\framework\caching; namespace yiiunit\framework\caching;
use yii\caching\MemCache; use yii\caching\MemCache;
use yiiunit\TestCase;
/** /**
* Class for testing memcache cache backend * Class for testing memcache cache backend
*/ */
class MemCacheTest extends CacheTest class MemCacheTest extends CacheTestCase
{ {
private $_cacheInstance = null; private $_cacheInstance = null;
......
<?php <?php
namespace yiiunit\framework\caching; namespace yiiunit\framework\caching;
use yii\caching\MemCache; use yii\caching\MemCache;
use yiiunit\TestCase;
/** /**
* Class for testing memcached cache backend * Class for testing memcached cache backend
*/ */
class MemCachedTest extends CacheTest class MemCachedTest extends CacheTestCase
{ {
private $_cacheInstance = null; private $_cacheInstance = null;
......
<?php <?php
namespace yiiunit\framework\caching; namespace yiiunit\framework\caching;
use yii\caching\FileCache; use yii\caching\WinCache;
use yiiunit\TestCase;
/** /**
* Class for testing wincache backend * Class for testing wincache backend
*/ */
class WinCacheTest extends CacheTest class WinCacheTest extends CacheTestCase
{ {
private $_cacheInstance = null; private $_cacheInstance = null;
......
<?php <?php
namespace yiiunit\framework\caching; namespace yiiunit\framework\caching;
use yii\caching\XCache; use yii\caching\XCache;
use yiiunit\TestCase;
/** /**
* Class for testing xcache backend * Class for testing xcache backend
*/ */
class XCacheTest extends CacheTest class XCacheTest extends CacheTestCase
{ {
private $_cacheInstance = null; private $_cacheInstance = null;
......
<?php <?php
namespace yiiunit\framework\caching; namespace yiiunit\framework\caching;
use yii\caching\Cache;
use yii\caching\ZendDataCache; use yii\caching\ZendDataCache;
use yiiunit\TestCase;
/** /**
* Class for testing Zend cache backend * Class for testing Zend cache backend
*/ */
class ZendDataCacheTest extends CacheTest class ZendDataCacheTest extends CacheTestCase
{ {
private $_cacheInstance = null; private $_cacheInstance = null;
......
<?php <?php
namespace yiiunit\framework\db; namespace yiiunit\framework\db;
use yii\db\Query; use yii\db\Query;
...@@ -10,7 +9,7 @@ use yiiunit\data\ar\OrderItem; ...@@ -10,7 +9,7 @@ use yiiunit\data\ar\OrderItem;
use yiiunit\data\ar\Order; use yiiunit\data\ar\Order;
use yiiunit\data\ar\Item; use yiiunit\data\ar\Item;
class ActiveRecordTest extends \yiiunit\DatabaseTestCase class ActiveRecordTest extends DatabaseTestCase
{ {
protected function setUp() protected function setUp()
{ {
......
...@@ -7,7 +7,7 @@ use yii\db\Command; ...@@ -7,7 +7,7 @@ use yii\db\Command;
use yii\db\Query; use yii\db\Query;
use yii\db\DataReader; use yii\db\DataReader;
class CommandTest extends \yiiunit\DatabaseTestCase class CommandTest extends DatabaseTestCase
{ {
function testConstruct() function testConstruct()
{ {
......
...@@ -4,7 +4,7 @@ namespace yiiunit\framework\db; ...@@ -4,7 +4,7 @@ namespace yiiunit\framework\db;
use yii\db\Connection; use yii\db\Connection;
class ConnectionTest extends \yiiunit\DatabaseTestCase class ConnectionTest extends DatabaseTestCase
{ {
function testConstruct() function testConstruct()
{ {
......
<?php <?php
namespace yiiunit\framework\db;
namespace yiiunit; use yiiunit\TestCase as TestCase;
class DatabaseTestCase extends TestCase abstract class DatabaseTestCase extends TestCase
{ {
protected $database; protected $database;
protected $driverName = 'mysql'; protected $driverName = 'mysql';
......
...@@ -7,7 +7,7 @@ use yii\db\Command; ...@@ -7,7 +7,7 @@ use yii\db\Command;
use yii\db\Query; use yii\db\Query;
use yii\db\DataReader; use yii\db\DataReader;
class QueryTest extends \yiiunit\DatabaseTestCase class QueryTest extends DatabaseTestCase
{ {
function testSelect() function testSelect()
{ {
......
...@@ -2,7 +2,9 @@ ...@@ -2,7 +2,9 @@
namespace yiiunit\framework\db\mssql; namespace yiiunit\framework\db\mssql;
class MssqlActiveRecordTest extends \yiiunit\framework\db\ActiveRecordTest use yiiunit\framework\db\ActiveRecordTest;
class MssqlActiveRecordTest extends ActiveRecordTest
{ {
protected function setUp() protected function setUp()
{ {
......
...@@ -2,7 +2,9 @@ ...@@ -2,7 +2,9 @@
namespace yiiunit\framework\db\mssql; namespace yiiunit\framework\db\mssql;
class MssqlCommandTest extends \yiiunit\framework\db\CommandTest use yiiunit\framework\db\CommandTest;
class MssqlCommandTest extends CommandTest
{ {
public function setUp() public function setUp()
{ {
......
...@@ -2,7 +2,9 @@ ...@@ -2,7 +2,9 @@
namespace yiiunit\framework\db\mssql; namespace yiiunit\framework\db\mssql;
class MssqlConnectionTest extends \yiiunit\framework\db\ConnectionTest use yiiunit\framework\db\ConnectionTest;
class MssqlConnectionTest extends ConnectionTest
{ {
public function setUp() public function setUp()
{ {
......
...@@ -2,7 +2,9 @@ ...@@ -2,7 +2,9 @@
namespace yiiunit\framework\db\mssql; namespace yiiunit\framework\db\mssql;
class MssqlQueryTest extends \yiiunit\framework\db\QueryTest use yiiunit\framework\db\QueryTest;
class MssqlQueryTest extends QueryTest
{ {
public function setUp() public function setUp()
{ {
......
<?php <?php
namespace yiiunit\framework\db\sqlite; namespace yiiunit\framework\db\sqlite;
class SqliteActiveRecordTest extends \yiiunit\framework\db\ActiveRecordTest use yiiunit\framework\db\ActiveRecordTest;
class SqliteActiveRecordTest extends ActiveRecordTest
{ {
protected function setUp() protected function setUp()
{ {
......
<?php <?php
namespace yiiunit\framework\db\sqlite; namespace yiiunit\framework\db\sqlite;
class SqliteCommandTest extends \yiiunit\framework\db\CommandTest use yiiunit\framework\db\CommandTest;
class SqliteCommandTest extends CommandTest
{ {
protected function setUp() protected function setUp()
{ {
......
<?php <?php
namespace yiiunit\framework\db\sqlite; namespace yiiunit\framework\db\sqlite;
class SqliteConnectionTest extends \yiiunit\framework\db\ConnectionTest use yiiunit\framework\db\ConnectionTest;
class SqliteConnectionTest extends ConnectionTest
{ {
protected function setUp() protected function setUp()
{ {
......
<?php <?php
/**
* Created by JetBrains PhpStorm.
* User: RusMaxim
* Date: 09.05.13
* Time: 21:41
* To change this template use File | Settings | File Templates.
*/
namespace yiiunit\framework\db\sqlite; namespace yiiunit\framework\db\sqlite;
use yiiunit\framework\db\QueryTest;
class SqliteQueryTest extends \yiiunit\framework\db\QueryTest class SqliteQueryTest extends QueryTest
{ {
protected function setUp() protected function setUp()
{ {
......
...@@ -3,10 +3,10 @@ ...@@ -3,10 +3,10 @@
namespace yiiunit\framework\helpers; namespace yiiunit\framework\helpers;
use yii\helpers\ArrayHelper; use yii\helpers\ArrayHelper;
use yii\helpers\VarDumper; use yii\test\TestCase;
use yii\web\Sort; use yii\web\Sort;
class ArrayHelperTest extends \yii\test\TestCase class ArrayHelperTest extends TestCase
{ {
public function testMerge() public function testMerge()
{ {
......
...@@ -4,9 +4,10 @@ ...@@ -4,9 +4,10 @@
namespace yiiunit\framework\helpers; namespace yiiunit\framework\helpers;
use yii\helpers\Json; use yii\helpers\Json;
use yii\test\TestCase;
use yii\web\JsExpression; use yii\web\JsExpression;
class JsonTest extends \yii\test\TestCase class JsonTest extends TestCase
{ {
public function testEncode() public function testEncode()
{ {
......
<?php <?php
namespace yiiunit\framework\helpers; namespace yiiunit\framework\helpers;
use \yii\helpers\StringHelper as StringHelper; use \yii\helpers\StringHelper as StringHelper;
use yii\test\TestCase;
/** /**
* StringHelperTest * StringHelperTest
*/ */
class StringHelperTest extends \yii\test\TestCase class StringHelperTest extends TestCase
{ {
public function testStrlen() public function testStrlen()
{ {
......
<?php <?php
namespace yiiunit\framework\helpers; namespace yiiunit\framework\helpers;
use \yii\helpers\VarDumper; use \yii\helpers\VarDumper;
use yii\test\TestCase;
class VarDumperTest extends \yii\test\TestCase class VarDumperTest extends TestCase
{ {
public function testDumpObject() public function testDumpObject()
{ {
......
...@@ -6,7 +6,7 @@ use yii\rbac\Assignment; ...@@ -6,7 +6,7 @@ use yii\rbac\Assignment;
use yii\rbac\Item; use yii\rbac\Item;
use yiiunit\TestCase; use yiiunit\TestCase;
abstract class ManagerTestBase extends TestCase abstract class ManagerTestCase extends TestCase
{ {
/** @var \yii\rbac\PhpManager|\yii\rbac\DbManager */ /** @var \yii\rbac\PhpManager|\yii\rbac\DbManager */
protected $auth; protected $auth;
......
...@@ -5,9 +5,7 @@ namespace yiiunit\framework\rbac; ...@@ -5,9 +5,7 @@ namespace yiiunit\framework\rbac;
use Yii; use Yii;
use yii\rbac\PhpManager; use yii\rbac\PhpManager;
//require_once(__DIR__ . '/ManagerTestBase.php'); class PhpManagerTest extends ManagerTestCase
class PhpManagerTest extends ManagerTestBase
{ {
protected function setUp() protected function setUp()
{ {
......
...@@ -3,8 +3,9 @@ namespace yiiunit\framework\web; ...@@ -3,8 +3,9 @@ namespace yiiunit\framework\web;
use yii\web\Request; use yii\web\Request;
use yii\web\UrlManager; use yii\web\UrlManager;
use yiiunit\TestCase;
class UrlManagerTest extends \yiiunit\TestCase class UrlManagerTest extends TestCase
{ {
public function testCreateUrl() public function testCreateUrl()
{ {
......
...@@ -5,8 +5,9 @@ namespace yiiunit\framework\web; ...@@ -5,8 +5,9 @@ namespace yiiunit\framework\web;
use yii\web\UrlManager; use yii\web\UrlManager;
use yii\web\UrlRule; use yii\web\UrlRule;
use yii\web\Request; use yii\web\Request;
use yiiunit\TestCase;
class UrlRuleTest extends \yiiunit\TestCase class UrlRuleTest extends TestCase
{ {
public function testCreateUrl() public function testCreateUrl()
{ {
......
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