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
namespace Aviat\Ion\Tests;
use Aviat\Ion\Model as BaseModel;
class BaseModelTest extends Ion_TestCase {
class BaseModelTest extends \Ion_TestCase {
public function testBaseModelSanity()
{

View File

@ -1,20 +1,22 @@
<?php
namespace Aviat\Ion\Tests\Cache\Driver;
trait CacheDriverBase {
protected $foo = [
'bar' => [
'baz' => 'foobar'
]
];
protected $bar = 'secondvalue';
public function testHasCacheDriver()
{
$this->assertTrue((bool) $this->driver);
}
public function testDriverGetSet()
{
$this->driver->set('foo', $this->foo);
@ -22,21 +24,21 @@ trait CacheDriverBase {
$this->assertEquals($this->driver->get('foo'), $this->foo);
$this->assertEquals($this->driver->get('bar'), 'baz');
}
public function testInvalidate()
{
$this->driver->set('foo', $this->foo);
$this->driver->invalidate('foo');
$this->assertEmpty($this->driver->get('foo'));
}
public function testInvalidateAll()
{
$this->driver->set('foo', $this->foo);
$this->driver->set('bar', $this->bar);
$this->driver->invalidateAll();
$this->assertEmpty($this->driver->get('foo'));
$this->assertEmpty($this->driver->get('bar'));
}

View File

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

View File

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

View File

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

View File

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

View File

@ -1,8 +1,10 @@
<?php
namespace Aviat\Ion\Tests;
use Aviat\Ion\Config;
class ConfigTest extends Ion_TestCase {
class ConfigTest extends \Ion_TestCase {
public function setUp()
{
@ -30,14 +32,14 @@ class ConfigTest extends Ion_TestCase {
$this->config->set(['apple', 'sauce', 'is'], 'great');
$apple = $this->config->get('apple');
$this->assertEquals('great', $apple['sauce']['is'], "Config value not set correctly");
$this->assertEquals('great', $this->config->get(['apple', 'sauce', 'is']), "Array argument get for config failed.");
}
public function testConfigBadSet()
{
$this->setExpectedException('InvalidArgumentException');
$this->expectException('InvalidArgumentException');
$this->config->set(NULL, FALSE);
}

View File

@ -1,5 +1,7 @@
<?php
namespace Aviat\Ion\Tests\Di;
use Aviat\Ion\Di\Container;
use Aviat\Ion\Di\ContainerAware;
use Aviat\Ion\Di\ContainerInterface;
@ -7,7 +9,7 @@ use Aviat\Ion\Di\Exception\ContainerException;
class Aware {
use ContainerAware;
public function __construct(ContainerInterface $container)
{
$this->container = $container;
@ -15,20 +17,20 @@ class Aware {
}
class ContainerAwareTest extends Ion_TestCase {
class ContainerAwareTest extends \Ion_TestCase {
public function setUp()
{
$this->container = new Container();
$this->aware = new Aware($this->container);
}
public function testContainerAwareTrait()
{
// The container was set in setup
// check that the get method returns the same
$this->assertSame($this->container, $this->aware->getContainer());
$container2 = new Container([
'foo' => 'bar',
'baz' => 'foobar'

View File

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

View File

@ -1,8 +1,11 @@
<?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 = [
'FOO' => 'bar',

View File

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

View File

@ -1,13 +1,15 @@
<?php
namespace Aviat\Ion\Tests;
use Aviat\Ion\Friend;
class FriendTest extends Ion_TestCase {
class FriendTest extends \Ion_TestCase {
public function setUp()
{
parent::setUp();
$obj = new FriendTestClass();
$obj = new \FriendTestClass();
$this->friend = new Friend($obj);
}
@ -26,7 +28,7 @@ class FriendTest extends Ion_TestCase {
public function testGet()
{
$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(84, $this->friend->grandParentProtected);
$this->assertNull($this->friend->parentPrivate); // Can't get a parent's privates
@ -43,14 +45,17 @@ class FriendTest extends Ion_TestCase {
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');
}
public function testBadMethod()
{
$this->setExpectedException('BadMethodCallException', "Method 'foo' does not exist");
$this->expectException('BadMethodCallException');
$this->expectExceptionMessage("Method 'foo' does not exist");
$this->friend->foo();
}
}

View File

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

View File

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

View File

@ -1,15 +1,17 @@
<?php
class AbstractTransformerTest extends Ion_TestCase {
namespace Aviat\Ion\Tests\Transformer;
class AbstractTransformerTest extends \Ion_TestCase {
protected $transformer;
public function setUp()
{
$this->transformer = new TestTransformer();
$this->transformer = new \TestTransformer();
}
public function dataTransformCollection()
{
return [
@ -67,13 +69,13 @@ class AbstractTransformerTest extends Ion_TestCase {
],
];
}
public function testTransform()
{
$data = $this->dataTransformCollection();
$original = $data['object']['original'][0];
$expected = $data['object']['expected'][0];
$actual = $this->transformer->transform($original);
$this->assertEquals($expected, $actual);
}

View File

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