Browse Source

Tests cleanup

- Better names
- Removed not used MySQLTestCase
- Moved base testcase for DB to db namespace
- Minor style fixes
tags/2.0.0-beta
Alexander Makarov 12 years ago
parent
commit
7cd9123c3b
  1. 37
      tests/unit/MysqlTestCase.php
  2. 2
      tests/unit/TestCase.php
  3. 3
      tests/unit/framework/caching/ApcCacheTest.php
  4. 4
      tests/unit/framework/caching/CacheTestCase.php
  5. 3
      tests/unit/framework/caching/DbCacheTest.php
  6. 3
      tests/unit/framework/caching/FileCacheTest.php
  7. 3
      tests/unit/framework/caching/MemCacheTest.php
  8. 3
      tests/unit/framework/caching/MemCachedTest.php
  9. 5
      tests/unit/framework/caching/WinCacheTest.php
  10. 3
      tests/unit/framework/caching/XCacheTest.php
  11. 4
      tests/unit/framework/caching/ZendDataCacheTest.php
  12. 3
      tests/unit/framework/db/ActiveRecordTest.php
  13. 2
      tests/unit/framework/db/CommandTest.php
  14. 2
      tests/unit/framework/db/ConnectionTest.php
  15. 5
      tests/unit/framework/db/DatabaseTestCase.php
  16. 2
      tests/unit/framework/db/QueryTest.php
  17. 4
      tests/unit/framework/db/mssql/MssqlActiveRecordTest.php
  18. 4
      tests/unit/framework/db/mssql/MssqlCommandTest.php
  19. 4
      tests/unit/framework/db/mssql/MssqlConnectionTest.php
  20. 4
      tests/unit/framework/db/mssql/MssqlQueryTest.php
  21. 5
      tests/unit/framework/db/sqlite/SqliteActiveRecordTest.php
  22. 5
      tests/unit/framework/db/sqlite/SqliteCommandTest.php
  23. 5
      tests/unit/framework/db/sqlite/SqliteConnectionTest.php
  24. 11
      tests/unit/framework/db/sqlite/SqliteQueryTest.php
  25. 4
      tests/unit/framework/helpers/ArrayHelperTest.php
  26. 3
      tests/unit/framework/helpers/JsonTest.php
  27. 3
      tests/unit/framework/helpers/StringHelperTest.php
  28. 3
      tests/unit/framework/helpers/VarDumperTest.php
  29. 2
      tests/unit/framework/rbac/ManagerTestCase.php
  30. 4
      tests/unit/framework/rbac/PhpManagerTest.php
  31. 3
      tests/unit/framework/web/UrlManagerTest.php
  32. 3
      tests/unit/framework/web/UrlRuleTest.php

37
tests/unit/MysqlTestCase.php

@ -1,37 +0,0 @@
<?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;
}
}

2
tests/unit/TestCase.php

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

3
tests/unit/framework/caching/ApcCacheTest.php

@ -1,12 +1,11 @@
<?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;

4
tests/unit/framework/caching/CacheTest.php → tests/unit/framework/caching/CacheTestCase.php

@ -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;
/** /**
* 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
tests/unit/framework/caching/DbCacheTest.php

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

3
tests/unit/framework/caching/FileCacheTest.php

@ -1,12 +1,11 @@
<?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;

3
tests/unit/framework/caching/MemCacheTest.php

@ -1,12 +1,11 @@
<?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;

3
tests/unit/framework/caching/MemCachedTest.php

@ -1,12 +1,11 @@
<?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;

5
tests/unit/framework/caching/WinCacheTest.php

@ -1,12 +1,11 @@
<?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;

3
tests/unit/framework/caching/XCacheTest.php

@ -1,12 +1,11 @@
<?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;

4
tests/unit/framework/caching/ZendDataCacheTest.php

@ -1,12 +1,12 @@
<?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;

3
tests/unit/framework/db/ActiveRecordTest.php

@ -1,5 +1,4 @@
<?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;
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()
{ {

2
tests/unit/framework/db/CommandTest.php

@ -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()
{ {

2
tests/unit/framework/db/ConnectionTest.php

@ -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()
{ {

5
tests/unit/DatabaseTestCase.php → tests/unit/framework/db/DatabaseTestCase.php

@ -1,8 +1,9 @@
<?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';

2
tests/unit/framework/db/QueryTest.php

@ -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()
{ {

4
tests/unit/framework/db/mssql/MssqlActiveRecordTest.php

@ -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()
{ {

4
tests/unit/framework/db/mssql/MssqlCommandTest.php

@ -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()
{ {

4
tests/unit/framework/db/mssql/MssqlConnectionTest.php

@ -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()
{ {

4
tests/unit/framework/db/mssql/MssqlQueryTest.php

@ -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()
{ {

5
tests/unit/framework/db/sqlite/SqliteActiveRecordTest.php

@ -1,8 +1,9 @@
<?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()
{ {

5
tests/unit/framework/db/sqlite/SqliteCommandTest.php

@ -1,8 +1,9 @@
<?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()
{ {

5
tests/unit/framework/db/sqlite/SqliteConnectionTest.php

@ -1,8 +1,9 @@
<?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()
{ {

11
tests/unit/framework/db/sqlite/SqliteQueryTest.php

@ -1,16 +1,9 @@
<?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()
{ {

4
tests/unit/framework/helpers/ArrayHelperTest.php

@ -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()
{ {

3
tests/unit/framework/helpers/JsonTest.php

@ -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()
{ {

3
tests/unit/framework/helpers/StringHelperTest.php

@ -1,11 +1,12 @@
<?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()
{ {

3
tests/unit/framework/helpers/VarDumperTest.php

@ -1,8 +1,9 @@
<?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()
{ {

2
tests/unit/framework/rbac/ManagerTestBase.php → tests/unit/framework/rbac/ManagerTestCase.php

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

4
tests/unit/framework/rbac/PhpManagerTest.php

@ -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
tests/unit/framework/web/UrlManagerTest.php

@ -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()
{ {

3
tests/unit/framework/web/UrlRuleTest.php

@ -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()
{ {

Loading…
Cancel
Save