Skip to content

Commit b32d35e

Browse files
committed
Tweak unittests and added validation test for #174
1 parent 5b7f335 commit b32d35e

15 files changed

+98
-102
lines changed

composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@
1616
"illuminate/events": "4.1.x"
1717
},
1818
"require-dev": {
19-
"illuminate/cache": "4.1.x",
20-
"illuminate/auth": "4.1.x",
19+
"orchestra/testbench": "2.1.*",
2120
"mockery/mockery": "*"
2221
},
2322
"autoload": {

phpunit.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,8 @@
3939
<directory>tests/RelationsTest.php</directory>
4040
<directory>tests/MysqlRelationsTest.php</directory>
4141
</testsuite>
42+
<testsuite name="validation">
43+
<directory>tests/ValidationTest.php</directory>
44+
</testsuite>
4245
</testsuites>
4346
</phpunit>

tests/CacheTest.php

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,19 @@
11
<?php
22

3-
use Illuminate\Support\Facades\DB;
4-
5-
class CacheTest extends PHPUnit_Framework_TestCase {
6-
7-
protected $cache;
8-
9-
public function setUp()
10-
{
11-
global $app;
12-
$this->cache = $app['cache'];
13-
14-
User::create(array('name' => 'John Doe', 'age' => 35, 'title' => 'admin'));
15-
User::create(array('name' => 'Jane Doe', 'age' => 33, 'title' => 'admin'));
16-
User::create(array('name' => 'Harry Hoe', 'age' => 13, 'title' => 'user'));
17-
}
3+
class CacheTest extends TestCase {
184

195
public function tearDown()
206
{
217
User::truncate();
22-
$this->cache->forget('db.users');
8+
Cache::forget('db.users');
239
}
2410

2511
public function testCache()
2612
{
13+
User::create(array('name' => 'John Doe', 'age' => 35, 'title' => 'admin'));
14+
User::create(array('name' => 'Jane Doe', 'age' => 33, 'title' => 'admin'));
15+
User::create(array('name' => 'Harry Hoe', 'age' => 13, 'title' => 'user'));
16+
2717
$users = DB::collection('users')->where('age', '>', 10)->remember(10)->get();
2818
$this->assertEquals(3, count($users));
2919

@@ -33,7 +23,7 @@ public function testCache()
3323
$users = User::where('age', '>', 10)->remember(10, 'db.users')->get();
3424
$this->assertEquals(3, count($users));
3525

36-
$users = $this->cache->get('db.users');
26+
$users = Cache::get('db.users');
3727
$this->assertEquals(3, count($users));
3828
}
3929

tests/ConnectionTest.php

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
<?php
2-
use Illuminate\Support\Facades\DB;
3-
use Jenssegers\Mongodb\Connection;
42

5-
class ConnectionTest extends PHPUnit_Framework_TestCase {
6-
7-
public function setUp() {}
8-
9-
public function tearDown() {}
3+
class ConnectionTest extends TestCase {
104

115
public function testConnection()
126
{
@@ -15,11 +9,11 @@ public function testConnection()
159

1610
$c1 = DB::connection('mongodb');
1711
$c2 = DB::connection('mongodb');
18-
$this->assertEquals($c1, $c2);
12+
$this->assertEquals(spl_object_hash($c1), spl_object_hash($c2));
1913

2014
$c1 = DB::connection('mongodb');
2115
$c2 = DB::reconnect('mongodb');
22-
$this->assertNotEquals($c1, $c2);
16+
$this->assertNotEquals(spl_object_hash($c1), spl_object_hash($c2));
2317
}
2418

2519
public function testDb()

tests/ModelTest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
<?php
22

3-
class ModelTest extends PHPUnit_Framework_TestCase {
4-
5-
public function setUp() {}
3+
class ModelTest extends TestCase {
64

75
public function tearDown()
86
{

tests/MysqlRelationsTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
<?php
22

3-
class MysqlRelationsTest extends PHPUnit_Framework_TestCase {
3+
class MysqlRelationsTest extends TestCase {
44

55
public function setUp()
66
{
7+
parent::setUp();
8+
79
MysqlUser::executeSchema();
810
MysqlBook::executeSchema();
911
MysqlRole::executeSchema();

tests/QueryBuilderTest.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
<?php
22

3-
use Illuminate\Support\Facades\DB;
4-
5-
class QueryBuilderTest extends PHPUnit_Framework_TestCase {
6-
7-
public function setUp() {}
3+
class QueryBuilderTest extends TestCase {
84

95
public function tearDown()
106
{

tests/QueryTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
<?php
22

3-
class QueryTest extends PHPUnit_Framework_TestCase {
3+
class QueryTest extends TestCase {
44

55
protected static $started = false;
66

77
public function setUp()
88
{
9+
parent::setUp();
10+
11+
// only run this stuff once
912
if (self::$started) return;
1013

1114
User::create(array('name' => 'John Doe', 'age' => 35, 'title' => 'admin'));

tests/RelationsTest.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
<?php
22

3-
use Illuminate\Database\Eloquent\Collection;
4-
5-
class RelationsTest extends PHPUnit_Framework_TestCase {
6-
7-
public function setUp() {
8-
}
3+
class RelationsTest extends TestCase {
94

105
public function tearDown()
116
{
@@ -148,8 +143,8 @@ public function testBelongsToMany()
148143
$this->assertTrue(array_key_exists('user_ids', $client->getAttributes()));
149144
$this->assertTrue(array_key_exists('client_ids', $user->getAttributes()));
150145

151-
$users = $client->getRelation('users');
152146
$clients = $user->getRelation('clients');
147+
$users = $client->getRelation('users');
153148

154149
$this->assertInstanceOf('Illuminate\Database\Eloquent\Collection', $users);
155150
$this->assertInstanceOf('Illuminate\Database\Eloquent\Collection', $clients);

tests/SchemaTest.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
<?php
22

3-
use Illuminate\Support\Facades\DB;
4-
use Illuminate\Support\Facades\Schema;
5-
6-
class SchemaTest extends PHPUnit_Framework_TestCase {
7-
8-
public function setUp() {}
3+
class SchemaTest extends TestCase {
94

105
public function tearDown()
116
{

0 commit comments

Comments
 (0)