-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use class variables + get_class() or get_called_class() instead of st…
…atic function variables The latter appears to be buggy in PHP when overriding a function and using parent::.
- Loading branch information
Showing
9 changed files
with
105 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
namespace lvl\staticactiverecord\unit; | ||
|
||
use lvl\staticactiverecord\unit\models\ActiveRecord; | ||
use lvl\staticactiverecord\unit\models\Animal; | ||
use lvl\staticactiverecord\unit\models\Customer; | ||
|
||
class InheritanceTest extends \yiiunit\framework\db\DatabaseTestCase | ||
{ | ||
protected function setUp() | ||
{ | ||
static::$params = require(__DIR__ . '/data/config.php'); | ||
parent::setUp(); | ||
ActiveRecord::$db = $this->getConnection(); | ||
} | ||
|
||
public function testInheritance() | ||
{ | ||
$animal = new Animal; | ||
$customer = new Customer; | ||
|
||
$animalAttr = $animal->attributes(); | ||
$customerAttr = $customer->attributes(); | ||
|
||
$this->assertNotEquals($animalAttr, $customerAttr, 'Animal and Customer should have a different set of attributes'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
namespace lvl\staticactiverecord\unit\models; | ||
|
||
class ActiveRecord extends \lvl\staticactiverecord\db\ActiveRecord | ||
{ | ||
public static $db; | ||
|
||
public static function getDb() | ||
{ | ||
return self::$db; | ||
} | ||
|
||
public function attributes() | ||
{ | ||
$attributes = parent::attributes(); | ||
|
||
return $attributes; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
|
||
namespace lvl\staticactiverecord\unit\models; | ||
|
||
class Animal extends ActiveRecord | ||
{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
|
||
namespace lvl\staticactiverecord\unit\models; | ||
|
||
class Customer extends ActiveRecord | ||
{ | ||
|
||
} |