Skip to content

Instantly share code, notes, and snippets.

@qiangxue
Last active January 3, 2016 10:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save qiangxue/89ab1d196570dcebd1ef to your computer and use it in GitHub Desktop.
Save qiangxue/89ab1d196570dcebd1ef to your computer and use it in GitHub Desktop.
Fixture design
<?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