From 75258f6607f37df50602ae5ff36006aeec06a8f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20W=C3=BCrth?= Date: Mon, 5 Aug 2019 16:01:13 +0200 Subject: [PATCH 1/7] Add original fixture template from CakePHP --- src/Template/Bake/Template/tests/fixture.twig | 72 +++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 src/Template/Bake/Template/tests/fixture.twig diff --git a/src/Template/Bake/Template/tests/fixture.twig b/src/Template/Bake/Template/tests/fixture.twig new file mode 100644 index 0000000..63e5b40 --- /dev/null +++ b/src/Template/Bake/Template/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 %} +} From 76c1c3bacffc7c64ef09502634dab332e9e5a512 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20W=C3=BCrth?= Date: Mon, 5 Aug 2019 16:01:29 +0200 Subject: [PATCH 2/7] Replace class import as documented --- src/Template/Bake/Template/tests/fixture.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Template/Bake/Template/tests/fixture.twig b/src/Template/Bake/Template/tests/fixture.twig index 63e5b40..57a0abf 100644 --- a/src/Template/Bake/Template/tests/fixture.twig +++ b/src/Template/Bake/Template/tests/fixture.twig @@ -20,7 +20,7 @@ Date: Mon, 5 Aug 2019 16:08:39 +0200 Subject: [PATCH 3/7] Move introduction up --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 11096d1..3142e83 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,17 @@ [![Latest Stable Version](https://img.shields.io/packagist/v/FriendsOfCake/fixturize.svg?style=flat-square)](https://packagist.org/packages/FriendsOfCake/fixturize) -# Installation - -``` -composer require 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 +``` + # Usage Instead of From 85a88bd451b78206b153a19308acb15664e0dc1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20W=C3=BCrth?= Date: Mon, 5 Aug 2019 16:17:43 +0200 Subject: [PATCH 4/7] Add documentation for the themed Bake template --- README.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/README.md b/README.md index 3142e83..a7a7b86 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,18 @@ This plugin currently only work with MySQL/MariaDB/Percona databases. composer require friendsofcake/fixturize ``` +Load the plugin in ``Application::bootstrap``, if you want to use the [themed Bake template](#themed-bake-template): + +```` php +if (PHP_SAPI === 'cli') { + try { + $this->addPlugin('FriendsOfCake/Fixturize'); + } catch (MissingPluginException $e) { + // Do not halt if the plugin is missing + } +} +```` + # Usage Instead of @@ -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/1.x/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/1.x/en/index.html). From 183211d8f0661bc86108b511c8935afe12c28d1a Mon Sep 17 00:00:00 2001 From: "marc.wuerth" Date: Thu, 13 Apr 2023 15:19:00 +0200 Subject: [PATCH 5/7] Update bake plugin documentation links to V2 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a7a7b86..9d03182 100644 --- a/README.md +++ b/README.md @@ -65,7 +65,7 @@ Feel free to submit your own results above. # Themed Bake Template -To use the built-in [themed Bake template](https://book.cakephp.org/bake/1.x/en/development.html#creating-a-bake-theme), +To use the built-in [themed Bake template](https://book.cakephp.org/bake/2/en/development.html#creating-a-bake-theme), execute: ```` bash @@ -74,4 +74,4 @@ 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/1.x/en/index.html). +For more information, see the [Bake documentation](https://book.cakephp.org/bake/2/en/index.html). From ef55fd54b04c659aa7055cfa46627ef3233bbcc8 Mon Sep 17 00:00:00 2001 From: "marc.wuerth" Date: Thu, 13 Apr 2023 15:24:49 +0200 Subject: [PATCH 6/7] Move fixture bake template to new CakePHP 4 template location --- {src/Template/Bake/Template => templates/bake}/tests/fixture.twig | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {src/Template/Bake/Template => templates/bake}/tests/fixture.twig (100%) diff --git a/src/Template/Bake/Template/tests/fixture.twig b/templates/bake/tests/fixture.twig similarity index 100% rename from src/Template/Bake/Template/tests/fixture.twig rename to templates/bake/tests/fixture.twig From a4a435ee8e32c8a4eb569330d664f499a77118a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20W=C3=BCrth?= Date: Thu, 13 Apr 2023 15:45:39 +0200 Subject: [PATCH 7/7] Add type hint Co-authored-by: ADmad --- templates/bake/tests/fixture.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/bake/tests/fixture.twig b/templates/bake/tests/fixture.twig index 57a0abf..9467707 100644 --- a/templates/bake/tests/fixture.twig +++ b/templates/bake/tests/fixture.twig @@ -63,7 +63,7 @@ class {{ name }}Fixture extends TestFixture * * @return void */ - public function init() + public function init(): void { $this->records = {{ records|raw }}; parent::init();