Properly namespace tests

This commit is contained in:
Timothy Warren 2016-08-29 11:34:25 -04:00
parent 2adb02daaa
commit 8f2ec8d4ed
16 changed files with 80 additions and 53 deletions

View File

@ -1,8 +1,10 @@
<?php <?php
namespace Aviat\Ion\Tests;
use Aviat\Ion\Model as BaseModel; use Aviat\Ion\Model as BaseModel;
class BaseModelTest extends Ion_TestCase { class BaseModelTest extends \Ion_TestCase {
public function testBaseModelSanity() public function testBaseModelSanity()
{ {

View File

@ -1,5 +1,7 @@
<?php <?php
namespace Aviat\Ion\Tests\Cache\Driver;
trait CacheDriverBase { trait CacheDriverBase {
protected $foo = [ protected $foo = [

View File

@ -1,10 +1,10 @@
<?php <?php
require_once('CacheDriverBase.php'); namespace Aviat\Ion\Tests\Cache\Driver;
use Aviat\Ion\Cache\Driver\NullDriver; use Aviat\Ion\Cache\Driver\NullDriver;
class CacheNullDriverTest extends Ion_TestCase { class CacheNullDriverTest extends \Ion_TestCase {
use CacheDriverBase; use CacheDriverBase;
protected $driver; protected $driver;

View File

@ -1,11 +1,11 @@
<?php <?php
require_once('CacheDriverBase.php'); namespace Aviat\Ion\Tests\Cache\Driver;
use Aviat\Ion\Config; use Aviat\Ion\Config;
use Aviat\Ion\Cache\Driver\RedisDriver; use Aviat\Ion\Cache\Driver\RedisDriver;
class CacheRedisDriverTestTwo extends Ion_TestCase { class CacheRedisDriverTestTwo extends \Ion_TestCase {
use CacheDriverBase; use CacheDriverBase;
protected $driver; protected $driver;

View File

@ -1,10 +1,10 @@
<?php <?php
require_once('CacheDriverBase.php'); namespace Aviat\Ion\Tests\Cache\Driver;
use Aviat\Ion\Cache\Driver\RedisDriver; use Aviat\Ion\Cache\Driver\RedisDriver;
class CacheRedisDriverTest extends Ion_TestCase { class CacheRedisDriverTest extends \Ion_TestCase {
use CacheDriverBase; use CacheDriverBase;
protected $driver; protected $driver;

View File

@ -1,11 +1,11 @@
<?php <?php
require_once('CacheDriverBase.php'); namespace Aviat\Ion\Tests\Cache\Driver;
use Aviat\Ion\Friend; use Aviat\Ion\Friend;
use Aviat\Ion\Cache\Driver\SQLDriver; use Aviat\Ion\Cache\Driver\SQLDriver;
class CacheSQLDriverTest extends Ion_TestCase { class CacheSQLDriverTest extends \Ion_TestCase {
use CacheDriverBase; use CacheDriverBase;
protected $driver; protected $driver;

View File

@ -1,8 +1,10 @@
<?php <?php
namespace Aviat\Ion\Tests;
use Aviat\Ion\Config; use Aviat\Ion\Config;
class ConfigTest extends Ion_TestCase { class ConfigTest extends \Ion_TestCase {
public function setUp() public function setUp()
{ {
@ -37,7 +39,7 @@ class ConfigTest extends Ion_TestCase {
public function testConfigBadSet() public function testConfigBadSet()
{ {
$this->setExpectedException('InvalidArgumentException'); $this->expectException('InvalidArgumentException');
$this->config->set(NULL, FALSE); $this->config->set(NULL, FALSE);
} }

View File

@ -1,5 +1,7 @@
<?php <?php
namespace Aviat\Ion\Tests\Di;
use Aviat\Ion\Di\Container; use Aviat\Ion\Di\Container;
use Aviat\Ion\Di\ContainerAware; use Aviat\Ion\Di\ContainerAware;
use Aviat\Ion\Di\ContainerInterface; use Aviat\Ion\Di\ContainerInterface;
@ -15,7 +17,7 @@ class Aware {
} }
class ContainerAwareTest extends Ion_TestCase { class ContainerAwareTest extends \Ion_TestCase {
public function setUp() public function setUp()
{ {

View File

@ -1,5 +1,7 @@
<?php <?php
namespace Aviat\Ion\Tests\Di;
use Aviat\Ion\Di\Container; use Aviat\Ion\Di\Container;
use Aviat\Ion\Di\Exception\ContainerException; use Aviat\Ion\Di\Exception\ContainerException;
use Monolog\Logger; use Monolog\Logger;
@ -7,7 +9,7 @@ use Monolog\Handler\TestHandler;
use Monolog\Handler\NullHandler; use Monolog\Handler\NullHandler;
class ContainerTest extends Ion_TestCase { class ContainerTest extends \Ion_TestCase {
public function setUp() public function setUp()
{ {

View File

@ -1,8 +1,11 @@
<?php <?php
use Aviat\Ion\Enum; namespace Aviat\Ion\Tests;
class EnumTest extends Ion_TestCase { use Aviat\Ion\Enum;
use TestEnum;
class EnumTest extends \Ion_TestCase {
protected $expectedConstList = [ protected $expectedConstList = [
'FOO' => 'bar', 'FOO' => 'bar',

View File

@ -1,8 +1,10 @@
<?php <?php
namespace Aviat\Ion\Tests\Exception;
use Aviat\Ion\Exception\DoubleRenderException; use Aviat\Ion\Exception\DoubleRenderException;
class DoubleRenderExceptionTest extends Ion_TestCase { class DoubleRenderExceptionTest extends \Ion_TestCase {
public function testDefaultMessage() public function testDefaultMessage()
{ {

View File

@ -1,13 +1,15 @@
<?php <?php
namespace Aviat\Ion\Tests;
use Aviat\Ion\Friend; use Aviat\Ion\Friend;
class FriendTest extends Ion_TestCase { class FriendTest extends \Ion_TestCase {
public function setUp() public function setUp()
{ {
parent::setUp(); parent::setUp();
$obj = new FriendTestClass(); $obj = new \FriendTestClass();
$this->friend = new Friend($obj); $this->friend = new Friend($obj);
} }
@ -26,7 +28,7 @@ class FriendTest extends Ion_TestCase {
public function testGet() public function testGet()
{ {
$this->assertEquals(356, $this->friend->protected); $this->assertEquals(356, $this->friend->protected);
$this->assertNull($this->friend->foo); // Return NULL for non-existend properties $this->assertNull($this->friend->foo); // Return NULL for non-existent properties
$this->assertEquals(47, $this->friend->parentProtected); $this->assertEquals(47, $this->friend->parentProtected);
$this->assertEquals(84, $this->friend->grandParentProtected); $this->assertEquals(84, $this->friend->grandParentProtected);
$this->assertNull($this->friend->parentPrivate); // Can't get a parent's privates $this->assertNull($this->friend->parentPrivate); // Can't get a parent's privates
@ -43,14 +45,17 @@ class FriendTest extends Ion_TestCase {
public function testBadInvokation() public function testBadInvokation()
{ {
$this->setExpectedException('InvalidArgumentException', 'Friend must be an object'); $this->expectException('InvalidArgumentException');
$this->expectExceptionMessage('Friend must be an object');
$friend = new Friend('foo'); $friend = new Friend('foo');
} }
public function testBadMethod() public function testBadMethod()
{ {
$this->setExpectedException('BadMethodCallException', "Method 'foo' does not exist"); $this->expectException('BadMethodCallException');
$this->expectExceptionMessage("Method 'foo' does not exist");
$this->friend->foo(); $this->friend->foo();
} }
} }

View File

@ -60,11 +60,10 @@ class JsonTest extends \Ion_TestCase {
$this->assertEquals((object)$expected, Json::decode($json, false)); $this->assertEquals((object)$expected, Json::decode($json, false));
$badJson = '{foo:{1|2}}'; $badJson = '{foo:{1|2}}';
$this->setExpectedException( $this->expectException('Aviat\Ion\JsonException');
'Aviat\Ion\JsonException', $this->expectExceptionMessage('JSON_ERROR_SYNTAX - Syntax error');
'JSON_ERROR_SYNTAX - Syntax error', $this->expectExceptionCode(JSON_ERROR_SYNTAX);
JSON_ERROR_SYNTAX
);
Json::decode($badJson); Json::decode($badJson);
} }
} }

View File

@ -1,8 +1,10 @@
<?php <?php
namespace Aviat\Ion\Tests\Model;
use Aviat\Ion\Model\DB as BaseDBModel; use Aviat\Ion\Model\DB as BaseDBModel;
class BaseDBModelTest extends Ion_TestCase { class BaseDBModelTest extends \Ion_TestCase {
public function testBaseDBModelSanity() public function testBaseDBModelSanity()
{ {

View File

@ -1,13 +1,15 @@
<?php <?php
class AbstractTransformerTest extends Ion_TestCase { namespace Aviat\Ion\Tests\Transformer;
class AbstractTransformerTest extends \Ion_TestCase {
protected $transformer; protected $transformer;
public function setUp() public function setUp()
{ {
$this->transformer = new TestTransformer(); $this->transformer = new \TestTransformer();
} }
public function dataTransformCollection() public function dataTransformCollection()

View File

@ -1,7 +1,9 @@
<?php <?php
class ArrayTypeTest extends Ion_TestCase { namespace Aviat\Ion\Tests\Type;
use Aviat\Ion\ArrayWrapper;
class ArrayTypeTest extends \Ion_TestCase {
use \Aviat\Ion\ArrayWrapper;
public function setUp() public function setUp()
@ -124,7 +126,9 @@ class ArrayTypeTest extends Ion_TestCase {
{ {
$obj = $this->arr([]); $obj = $this->arr([]);
$this->setExpectedException('InvalidArgumentException', "Method 'foo' does not exist"); $this->expectException('InvalidArgumentException');
$this->expectExceptionMessage("Method 'foo' does not exist");
$obj->foo(); $obj->foo();
} }