diff --git a/README.md b/README.md index 11096d1..9d03182 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,28 @@ [![Latest Stable Version](https://img.shields.io/packagist/v/FriendsOfCake/fixturize.svg?style=flat-square)](https://packagist.org/packages/FriendsOfCake/fixturize) +# Introduction + +The fixturize plugin will help improve performance of your fixture based tests. + +This plugin currently only work with MySQL/MariaDB/Percona databases. + # Installation ``` composer require friendsofcake/fixturize ``` -# Introduction +Load the plugin in ``Application::bootstrap``, if you want to use the [themed Bake template](#themed-bake-template): -The fixturize plugin will help improve performance of your fixture based tests. - -This plugin currently only work with MySQL/MariaDB/Percona databases. +```` php +if (PHP_SAPI === 'cli') { + try { + $this->addPlugin('FriendsOfCake/Fixturize'); + } catch (MissingPluginException $e) { + // Do not halt if the plugin is missing + } +} +```` # Usage @@ -50,3 +62,16 @@ Re-run your tests and enjoy the speed! Feel free to submit your own results above. + +# Themed Bake Template + +To use the built-in [themed Bake template](https://book.cakephp.org/bake/2/en/development.html#creating-a-bake-theme), +execute: + +```` bash +php bin/cake.php bake fixture ModelName --theme FriendsOfCake/Fixturize +```` + +Make sure, you have [loaded the plugin](#installation). + +For more information, see the [Bake documentation](https://book.cakephp.org/bake/2/en/index.html). diff --git a/templates/bake/tests/fixture.twig b/templates/bake/tests/fixture.twig new file mode 100644 index 0000000..9467707 --- /dev/null +++ b/templates/bake/tests/fixture.twig @@ -0,0 +1,72 @@ +{# +/** + * Fixture Template file + * + * Fixture Template used when baking fixtures with bake + * + * CakePHP(tm) : Rapid Development Framework (http://cakephp.org) + * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) + * + * Licensed under The MIT License + * For full copyright and license information, please see the LICENSE.txt + * Redistributions of files must retain the above copyright notice. + * + * @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) + * @link http://cakephp.org CakePHP(tm) Project + * @since 2.0.0 + * @license http://www.opensource.org/licenses/mit-license.php MIT License + */ +#} +records = {{ records|raw }}; + parent::init(); + } +{% endif %} +}