Skip to content

Instantly share code, notes, and snippets.

@simkimsia
Created November 16, 2013 07:13
Show Gist options
  • Save simkimsia/7497019 to your computer and use it in GitHub Desktop.
Save simkimsia/7497019 to your computer and use it in GitHub Desktop.
Template of a Fixture for unit testing purposes in CakePHP Plugin
<?php
/**
* {ExampleModel}Fixture
*
* Fixtures for a {ExampleModel} model that belongsTo {AnotherExampleModel} as the relationship {AnotherExampleModel}
*
* Copyright {copyright year}, {maintainer}
* {Location}
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright {copyright year}, {maintainer}
* @link {website}
* @author {maintainer} <{maintainer email}>
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
* @package {PluginName}
* @subpackage {PluginName}.Test.Fixture
* @version 0.1.0
*/
class {ExampleModel}Fixture extends CakeTestFixture {
/** feel free to change the fields and records **/
public $fields = array(
'id' => array('type' => 'integer', 'key' => 'primary'),
'username' => array('type' => 'string', 'length' => 255, 'null' => false),
'group_id' => array('type' => 'integer', 'length' => 11, 'null' => false)
);
public $records = array(
array('id' => 1, 'username' => 'CakePHP', 'group_id' => 1),
array('id' => 2, 'username' => 'Zend', 'group_id' => 2),
array('id' => 3, 'username' => 'Symfony', 'group_id' => 1),
array('id' => 4, 'username' => 'CodeIgniter', 'group_id' => 2)
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment