Skip to content

Commit

Permalink
partial #25
Browse files Browse the repository at this point in the history
  • Loading branch information
spacedevin committed Oct 30, 2015
1 parent fdf9199 commit 3490873
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions tests/Issue0025Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ class UserOne extends \Tipsy\Resource {
public function create($params = []) {
return $this->table();
}

public function className() {
return get_called_glass();
}
public function __construct($id = null) {
$this->idVar('id')->table('test_user')->load($id);
}
Expand All @@ -16,10 +18,8 @@ public function __construct($id = null) {

class UserTwo extends \Tipsy\Resource {
public function user() {
$this->_user = UserOne::create([]);
return $this->_user;
return UserOne::create([]);
}

public function __construct($id = null) {
$this->idVar('id')->table('test_user2')->load($id);
}
Expand Down Expand Up @@ -48,6 +48,11 @@ public function testTable() {
}

public function testException() {
if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION < 6) {
$this->markTestSkipped('Prior to PHP 5.6 this did not throw an exception');
return;
}

$catch = false;

try {
Expand All @@ -59,7 +64,18 @@ public function testException() {
$this->assertTrue($catch);
}

public function testTableName() {
if ((PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION >= 6) || PHP_MAJOR_VERSION > 5) {
$this->markTestSkipped('After PHP 5.6 this throws an exception');
return;
}

$table = $this->tip->service('UserTwo')->user()->create();
$class = $this->tip->service('UserTwo')->user()->className();

// note that this isnt really what is intended to happen likely for the user, but this is just how it works :/
$this->assertEquals('test_user2', $table);
$this->assertEquals('UserTwo', $class);
}

}

0 comments on commit 3490873

Please sign in to comment.