-
-
Save qiangxue/89ab1d196570dcebd1ef to your computer and use it in GitHub Desktop.
Fixture design
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
<?php | |
class Fixture extends Component | |
{ | |
public $depends = []; | |
public function load() | |
{ | |
} | |
public function unload() | |
{ | |
} | |
} | |
class DbFixture extends Fixture | |
{ | |
public $db = 'db'; | |
public $modelClass; | |
public $tableName; | |
private $_rows; | |
public function load() | |
{ | |
// ...determine $table | |
$this->_rows = $this->loadData($table); | |
} | |
protected function loadData() | |
{ | |
return []; | |
} | |
public function getModel($name) | |
{ | |
} | |
public function getRows() | |
{ | |
return $this->_rows; | |
} | |
} | |
class TestCase extends \Codeception\TestCase\Test | |
{ | |
public $fixtures; | |
protected function setUp() | |
{ | |
parent::setUp(); | |
$this->mockApplication(); | |
$this->loadFixtures(); | |
} | |
protected function tearDown() | |
{ | |
$this->unloadFixtures(); | |
$this->destroyApplication(); | |
parent::tearDown(); | |
} | |
protected function getFixture($name) | |
{ | |
// return the named fixture object | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment