-
-
-
- {{ form_rest(form) }}
-
- {{ form_end(form) }}
{% endblock %}
diff --git a/src/Resources/templates/generate_module_command/module/controller/form.php.twig b/src/Resources/templates/generate_module_command/module/form/form.php.twig
similarity index 70%
rename from src/Resources/templates/generate_module_command/module/controller/form.php.twig
rename to src/Resources/templates/generate_module_command/module/form/form.php.twig
index ae617caa..917f3595 100644
--- a/src/Resources/templates/generate_module_command/module/controller/form.php.twig
+++ b/src/Resources/templates/generate_module_command/module/form/form.php.twig
@@ -3,14 +3,13 @@
*
*/
-namespace {{ name_space }}\Form\Type;
+namespace {{ nameSpace }}\Form;
-use PrestaShopBundle\Form\Admin\Type\SwitchType;
-use Symfony\Component\Form\AbstractType;
+use PrestaShopBundle\Form\Admin\Type\TranslatorAwareType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
-class {{ class_name }} extends AbstractType
+class {{ className }}Type extends TranslatorAwareType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
diff --git a/src/Resources/templates/generate_module_command/module/front_controller/ajax_front_controller.js.twig b/src/Resources/templates/generate_module_command/module/front_controller/ajax_front_controller.js.twig
new file mode 100644
index 00000000..6c27dcea
--- /dev/null
+++ b/src/Resources/templates/generate_module_command/module/front_controller/ajax_front_controller.js.twig
@@ -0,0 +1,23 @@
+
+(function () {
+
+ $.ajax({
+ type: 'GET',
+ headers: {"cache-control": "no-cache"},
+ url: prestashop.urls.shop_domain_url,
+ async: true,
+ data: {
+ fc: 'module',
+ module: '{{ moduleName }}',
+ controller: '{{ frontControllerName }}',
+ action: '{{ frontControllerName }}',
+ ajax: true,
+ },
+ success: function (data) {
+ alert('success');
+ },
+ error: function (jqXHR, statusText, errorThrown) {
+ alert('error');
+ }
+ });
+})()
diff --git a/src/Resources/templates/generate_module_command/module/front_controller/front_controllerajax.php.twig b/src/Resources/templates/generate_module_command/module/front_controller/front_controllerajax.php.twig
new file mode 100644
index 00000000..d27bb724
--- /dev/null
+++ b/src/Resources/templates/generate_module_command/module/front_controller/front_controllerajax.php.twig
@@ -0,0 +1,21 @@
+ajaxRender('your html here');
+ }
+
+ public function init()
+ {
+ return parent::init();
+ }
+
+}
\ No newline at end of file
diff --git a/src/Resources/templates/generate_module_command/module/grid/code_controller.php.twig b/src/Resources/templates/generate_module_command/module/grid/code_controller.php.twig
new file mode 100644
index 00000000..c899d950
--- /dev/null
+++ b/src/Resources/templates/generate_module_command/module/grid/code_controller.php.twig
@@ -0,0 +1,16 @@
+
+
+>>>>> please, copy this code to your controller file <<<<<
+
+public function displayGridAction(Request $request)
+{
+ $gridFactory = $this->get('{{serviceNameSpace}}_grid_{{ serviceName }}_factory');
+ $grid = $gridFactory->getGrid(new SearchCriteria());
+
+ return $this->render(
+ '@Modules/{{ moduleName }}/views/templates/admin/controller/{{ serviceName }}_grid.html.twig', [
+ 'grid' => $this->presentGrid($grid),
+ ]
+ );
+
+}}
\ No newline at end of file
diff --git a/src/Resources/templates/generate_module_command/module/grid/grid.yml.twig b/src/Resources/templates/generate_module_command/module/grid/grid.yml.twig
new file mode 100644
index 00000000..03faaf89
--- /dev/null
+++ b/src/Resources/templates/generate_module_command/module/grid/grid.yml.twig
@@ -0,0 +1,29 @@
+services:
+ {{ serviceNameSpace }}_grid_query_{{ serviceName }}:
+ class: {{ nameSpace }}\Grid\Query\{{ className }}QueryBuilder
+ parent: 'prestashop.core.grid.abstract_query_builder'
+
+
+
+ {{ serviceNameSpace }}_grid_definition_factory_{{ serviceName }}:
+ class: {{ nameSpace }}\Grid\Definition\Factory\{{ className }}GridDefinitionFactory
+ parent: 'prestashop.core.grid.definition.factory.abstract_grid_definition'
+ public: true
+
+ {{ serviceNameSpace }}_grid_data_factory_{{ serviceName }}:
+ class: PrestaShop\PrestaShop\Core\Grid\Data\Factory\DoctrineGridDataFactory
+ arguments:
+ - '@{{ serviceNameSpace }}_grid_query_{{ serviceName }}' # service id of our query builder
+ - '@prestashop.core.hook.dispatcher' # every doctrine query builder needs the hook dispatcher
+ - '@prestashop.core.grid.query.doctrine_query_parser' # parser to get the raw SQL query
+ - '{{ serviceName }}' # this should match your grid id, in our case it's "products"
+
+
+ {{ serviceNameSpace }}_grid_{{ serviceName }}_factory:
+ class: PrestaShop\PrestaShop\Core\Grid\GridFactory
+ arguments:
+ - '@{{ serviceNameSpace }}_grid_definition_factory_{{ serviceName }}'
+ - '@{{ serviceNameSpace }}_grid_data_factory_{{ serviceName }}'
+ - '@prestashop.core.grid.filter.form_factory'
+ - '@prestashop.core.hook.dispatcher'
+ public: true
\ No newline at end of file
diff --git a/src/Resources/templates/generate_module_command/module/grid/grid_definition.php.twig b/src/Resources/templates/generate_module_command/module/grid/grid_definition.php.twig
new file mode 100644
index 00000000..f6f18db5
--- /dev/null
+++ b/src/Resources/templates/generate_module_command/module/grid/grid_definition.php.twig
@@ -0,0 +1,98 @@
+trans('xxxx', [], 'Module.{{ moduleName }}.Admin');
+ }
+
+ protected function getColumns()
+ {
+ // example of columns
+ return (new ColumnCollection())
+ ->add((new BulkActionColumn('bulk'))
+ ->setOptions([
+ 'bulk_field' => 'id_product',
+ ])
+ )
+ ->add((new DataColumn('id_product'))
+ ->setName($this->trans('ID', [], 'Admin.Global'))
+ ->setOptions([
+ 'field' => 'id_product',
+ ])
+ )
+ ->add((new DataColumn('reference'))
+ ->setName($this->trans('Reference', [], 'Admin.xxxx.Feature'))
+ ->setOptions([
+ 'field' => 'reference',
+ ])
+ )
+ // uncomment and add actions
+ // ->add(
+ // (new ActionColumn('actions'))
+ // ->setName($this->trans('Actions', [], 'Admin.Global'))
+ // ->setOptions([
+ // 'actions' => $this->getRowActions(),
+ // ])
+ // )
+ ;
+ }
+
+ private function getRowActions()
+ {
+ return (new RowActionCollection('actions'))
+ ->add(
+ (new LinkRowAction('edit'))
+ ->setName($this->trans('Edit', [], 'Admin.Actions'))
+ ->setIcon('edit')
+ ->setOptions([
+ 'route' => '...........', // create edti route
+ 'route_param_name' => '......', // route param name
+ 'route_param_field' => '.........', // route param field
+ 'clickable_row' => true,
+ ])
+ )
+ ->add(
+ (new SubmitRowAction('delete'))
+ ->setName($this->trans('Delete', [], 'Admin.Actions'))
+ ->setIcon('delete')
+ ->setOptions([
+ 'method' => 'delete',
+ 'route' => '............', // create delete route
+ 'route_param_name' => '......', // route param name
+ 'route_param_field' => '.........', // route param field
+ 'confirm_message' => $this->trans(
+ 'Delete selected item?',
+ [],
+ 'Admin.Notifications.Warning'
+ ),
+ ])
+ )
+ ;
+ }
+}
\ No newline at end of file
diff --git a/src/Resources/templates/generate_module_command/module/grid/grid_query.php.twig b/src/Resources/templates/generate_module_command/module/grid/grid_query.php.twig
new file mode 100644
index 00000000..03a45511
--- /dev/null
+++ b/src/Resources/templates/generate_module_command/module/grid/grid_query.php.twig
@@ -0,0 +1,38 @@
+getBaseQuery();
+ $qb->select('p.*');
+ return $qb;
+ }
+
+ public function getCountQueryBuilder(SearchCriteriaInterface $searchCriteria)
+ {
+ // example to count records
+ $qb = $this->getBaseQuery();
+ $qb->select('COUNT(p.id_product)');
+
+ return $qb;
+ }
+
+ // Base query can be used for both Search and Count query builders
+ private function getBaseQuery()
+ {
+ // example to get query builder
+ return $this->connection
+ ->createQueryBuilder()
+ ->from($this->dbPrefix.'product', 'p')
+ ;
+ }
+}
diff --git a/src/Resources/templates/generate_module_command/module/grid/template_grid.twig b/src/Resources/templates/generate_module_command/module/grid/template_grid.twig
new file mode 100644
index 00000000..de37388e
--- /dev/null
+++ b/src/Resources/templates/generate_module_command/module/grid/template_grid.twig
@@ -0,0 +1,13 @@
+{% extends '@PrestaShop/Admin/layout.html.twig' %}
+{% set layoutTitle = 'xxxxxx'| trans({},'Admin.xxxxx.Shipping') %}
+
+{#{% set layoutHeaderToolbarBtn = {#}
+{# add_shipping_cost: {#}
+{# href: path('admin_marketplace_seller_shipping_create'),#}
+{# desc: 'Add new cost'|trans({}, 'Admin.Marketplace.Shipping'),#}
+{# icon: 'add_circle_outline',#}
+{# }#}
+{#} %}#}
+{% block content %}
+ {% include '@PrestaShop/Admin/Common/Grid/grid_panel.html.twig' with {'grid': grid} %}
+{% endblock %}
\ No newline at end of file
diff --git a/src/Resources/templates/generate_module_command/module/index.php b/src/Resources/templates/generate_module_command/module/index.php
new file mode 100644
index 00000000..250c8949
--- /dev/null
+++ b/src/Resources/templates/generate_module_command/module/index.php
@@ -0,0 +1,35 @@
+
+ * @copyright Since 2007 PrestaShop SA and Contributors
+ * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
+ */
+
+header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
+header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
+
+header('Cache-Control: no-store, no-cache, must-revalidate');
+header('Cache-Control: post-check=0, pre-check=0', false);
+header('Pragma: no-cache');
+
+header('Location: ../');
+exit;
diff --git a/src/Resources/templates/generate_module_command/module/main.php.twig b/src/Resources/templates/generate_module_command/module/main.php.twig
index 2aada76e..1183906d 100644
--- a/src/Resources/templates/generate_module_command/module/main.php.twig
+++ b/src/Resources/templates/generate_module_command/module/main.php.twig
@@ -1,18 +1,16 @@
-*/
+
if (!defined('_PS_VERSION_')) {
exit;
}
-require_once _PS_MODULE_DIR_.'{{ module_name }}'.DIRECTORY_SEPARATOR.'vendor'.DIRECTORY_SEPARATOR.'autoload.php';
-class {{ module_name|capitalize }} extends Module
+require_once _PS_MODULE_DIR_.'{{ moduleName }}'.DIRECTORY_SEPARATOR.'vendor'.DIRECTORY_SEPARATOR.'autoload.php';
+class {{ moduleName|capitalize }} extends Module
{
protected $config_form = false;
public function __construct()
{
- $this->name = '{{ module_name }}';
+ $this->name = '{{ moduleName }}';
$this->version = '1.0.0';
$this->author = 'Your name'; //TODO edit
@@ -26,12 +24,12 @@ class {{ module_name|capitalize }} extends Module
parent::__construct();
//TODO: Edit 'module name here'
- $this->displayName = $this->trans('module name here',[],'Modules.{{ module_name|capitalize }}.Admin');
+ $this->displayName = $this->trans('module name here',[],'Modules.{{ moduleName|capitalize }}.Admin');
//TODO: Edit ''description here'
- $this->description = $this->trans('description here',[], 'Modules.{{ module_name|capitalize }}.Admin');
- $this->confirmUninstall = $this->trans('Are you sure?',[], 'Modules.{{ module_name|capitalize }}.Admin');
+ $this->description = $this->trans('description here',[], 'Modules.{{ moduleName|capitalize }}.Admin');
+ $this->confirmUninstall = $this->trans('Are you sure?',[], 'Modules.{{ moduleName|capitalize }}.Admin');
- $this->ps_versions_compliancy = array('min' => '1.7', 'max' => _PS_VERSION_);
+ $this->ps_versions_compliancy = array('min' => '1.7.8', 'max' => _PS_VERSION_);
}
public function install()
@@ -48,13 +46,18 @@ class {{ module_name|capitalize }} extends Module
public function getContent()
{
- Tools::redirectAdmin(
- $this->context->link->getAdminLink(
- 'Admin{{ module_name|capitalize }}',
- true,
- ['route' => 'admin_{{ module_name }}_configuration']
- )
- );
+ // TODO edit
+ // Tools::redirectAdmin(
+ // $this->context->link->getAdminLink(
+ // 'Admin{{ moduleName|capitalize }}',
+ // true,
+ // ['route' => 'admin_{{ moduleName }}_configuration']
+ // )
+ // );
}
+ public function isUsingNewTranslationSystem()
+ {
+ return true;
+ }
}
diff --git a/src/Resources/templates/generate_module_command/module/phpunit.admin.xml.twig b/src/Resources/templates/generate_module_command/module/phpunit.admin.xml.twig
new file mode 100644
index 00000000..a0c98cec
--- /dev/null
+++ b/src/Resources/templates/generate_module_command/module/phpunit.admin.xml.twig
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ tests
+
+
+
diff --git a/src/Resources/templates/generate_module_command/module/phpunit.front.xml.twig b/src/Resources/templates/generate_module_command/module/phpunit.front.xml.twig
new file mode 100644
index 00000000..ddd20489
--- /dev/null
+++ b/src/Resources/templates/generate_module_command/module/phpunit.front.xml.twig
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ tests/front
+
+
+
diff --git a/src/Resources/templates/generate_module_command/module/routes.yml.twig b/src/Resources/templates/generate_module_command/module/routes.yml.twig
new file mode 100644
index 00000000..e69de29b
diff --git a/src/Resources/templates/generate_module_command/module/controller/services.yml b/src/Resources/templates/generate_module_command/module/services.yml.twig
similarity index 100%
rename from src/Resources/templates/generate_module_command/module/controller/services.yml
rename to src/Resources/templates/generate_module_command/module/services.yml.twig
diff --git a/src/Resources/templates/generate_module_command/module/test/index.php b/src/Resources/templates/generate_module_command/module/test/index.php
new file mode 100644
index 00000000..250c8949
--- /dev/null
+++ b/src/Resources/templates/generate_module_command/module/test/index.php
@@ -0,0 +1,35 @@
+
+ * @copyright Since 2007 PrestaShop SA and Contributors
+ * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
+ */
+
+header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
+header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
+
+header('Cache-Control: no-store, no-cache, must-revalidate');
+header('Cache-Control: post-check=0, pre-check=0', false);
+header('Pragma: no-cache');
+
+header('Location: ../');
+exit;
diff --git a/src/Resources/templates/generate_module_command/module/test/phpunit.xml.twig b/src/Resources/templates/generate_module_command/module/test/phpunit.xml.twig
deleted file mode 100644
index e6e69ca2..00000000
--- a/src/Resources/templates/generate_module_command/module/test/phpunit.xml.twig
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
-
-
-
-
-
- test
-
-
-
diff --git a/src/Resources/templates/generate_module_command/module/views/index.php b/src/Resources/templates/generate_module_command/module/views/index.php
new file mode 100644
index 00000000..250c8949
--- /dev/null
+++ b/src/Resources/templates/generate_module_command/module/views/index.php
@@ -0,0 +1,35 @@
+
+ * @copyright Since 2007 PrestaShop SA and Contributors
+ * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
+ */
+
+header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
+header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
+
+header('Cache-Control: no-store, no-cache, must-revalidate');
+header('Cache-Control: post-check=0, pre-check=0', false);
+header('Pragma: no-cache');
+
+header('Location: ../');
+exit;
diff --git a/src/Resources/templates/generate_module_command/module/views/js/index.php b/src/Resources/templates/generate_module_command/module/views/js/index.php
new file mode 100644
index 00000000..250c8949
--- /dev/null
+++ b/src/Resources/templates/generate_module_command/module/views/js/index.php
@@ -0,0 +1,35 @@
+
+ * @copyright Since 2007 PrestaShop SA and Contributors
+ * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
+ */
+
+header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
+header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
+
+header('Cache-Control: no-store, no-cache, must-revalidate');
+header('Cache-Control: post-check=0, pre-check=0', false);
+header('Pragma: no-cache');
+
+header('Location: ../');
+exit;
diff --git a/src/Resources/templates/index.php b/src/Resources/templates/index.php
new file mode 100644
index 00000000..250c8949
--- /dev/null
+++ b/src/Resources/templates/index.php
@@ -0,0 +1,35 @@
+
+ * @copyright Since 2007 PrestaShop SA and Contributors
+ * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
+ */
+
+header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
+header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
+
+header('Cache-Control: no-store, no-cache, must-revalidate');
+header('Cache-Control: post-check=0, pre-check=0', false);
+header('Pragma: no-cache');
+
+header('Location: ../');
+exit;
diff --git a/src/Tools/index.php b/src/Tools/index.php
new file mode 100644
index 00000000..250c8949
--- /dev/null
+++ b/src/Tools/index.php
@@ -0,0 +1,35 @@
+
+ * @copyright Since 2007 PrestaShop SA and Contributors
+ * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
+ */
+
+header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
+header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
+
+header('Cache-Control: no-store, no-cache, must-revalidate');
+header('Cache-Control: post-check=0, pre-check=0', false);
+header('Pragma: no-cache');
+
+header('Location: ../');
+exit;
diff --git a/src/index.php b/src/index.php
new file mode 100644
index 00000000..250c8949
--- /dev/null
+++ b/src/index.php
@@ -0,0 +1,35 @@
+
+ * @copyright Since 2007 PrestaShop SA and Contributors
+ * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
+ */
+
+header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
+header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
+
+header('Cache-Control: no-store, no-cache, must-revalidate');
+header('Cache-Control: post-check=0, pre-check=0', false);
+header('Pragma: no-cache');
+
+header('Location: ../');
+exit;
diff --git a/tests/Resources/Commands/Domain/index.php b/tests/Resources/Commands/Domain/index.php
new file mode 100644
index 00000000..250c8949
--- /dev/null
+++ b/tests/Resources/Commands/Domain/index.php
@@ -0,0 +1,35 @@
+
+ * @copyright Since 2007 PrestaShop SA and Contributors
+ * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
+ */
+
+header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
+header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
+
+header('Cache-Control: no-store, no-cache, must-revalidate');
+header('Cache-Control: post-check=0, pre-check=0', false);
+header('Pragma: no-cache');
+
+header('Location: ../');
+exit;
diff --git a/tests/Resources/Commands/index.php b/tests/Resources/Commands/index.php
new file mode 100644
index 00000000..250c8949
--- /dev/null
+++ b/tests/Resources/Commands/index.php
@@ -0,0 +1,35 @@
+
+ * @copyright Since 2007 PrestaShop SA and Contributors
+ * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
+ */
+
+header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
+header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
+
+header('Cache-Control: no-store, no-cache, must-revalidate');
+header('Cache-Control: post-check=0, pre-check=0', false);
+header('Pragma: no-cache');
+
+header('Location: ../');
+exit;
diff --git a/tests/Resources/csv/cased-replace-pairs/index.php b/tests/Resources/csv/cased-replace-pairs/index.php
new file mode 100644
index 00000000..250c8949
--- /dev/null
+++ b/tests/Resources/csv/cased-replace-pairs/index.php
@@ -0,0 +1,35 @@
+
+ * @copyright Since 2007 PrestaShop SA and Contributors
+ * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
+ */
+
+header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
+header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
+
+header('Cache-Control: no-store, no-cache, must-revalidate');
+header('Cache-Control: post-check=0, pre-check=0', false);
+header('Pragma: no-cache');
+
+header('Location: ../');
+exit;
diff --git a/tests/Resources/csv/files-replace-pairs/index.php b/tests/Resources/csv/files-replace-pairs/index.php
new file mode 100644
index 00000000..250c8949
--- /dev/null
+++ b/tests/Resources/csv/files-replace-pairs/index.php
@@ -0,0 +1,35 @@
+
+ * @copyright Since 2007 PrestaShop SA and Contributors
+ * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
+ */
+
+header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
+header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
+
+header('Cache-Control: no-store, no-cache, must-revalidate');
+header('Cache-Control: post-check=0, pre-check=0', false);
+header('Pragma: no-cache');
+
+header('Location: ../');
+exit;
diff --git a/tests/Resources/csv/files-replace-pairs/kjmodulebedrock/index.php b/tests/Resources/csv/files-replace-pairs/kjmodulebedrock/index.php
new file mode 100644
index 00000000..250c8949
--- /dev/null
+++ b/tests/Resources/csv/files-replace-pairs/kjmodulebedrock/index.php
@@ -0,0 +1,35 @@
+
+ * @copyright Since 2007 PrestaShop SA and Contributors
+ * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
+ */
+
+header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
+header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
+
+header('Cache-Control: no-store, no-cache, must-revalidate');
+header('Cache-Control: post-check=0, pre-check=0', false);
+header('Pragma: no-cache');
+
+header('Location: ../');
+exit;
diff --git a/tests/Resources/csv/index.php b/tests/Resources/csv/index.php
new file mode 100644
index 00000000..250c8949
--- /dev/null
+++ b/tests/Resources/csv/index.php
@@ -0,0 +1,35 @@
+
+ * @copyright Since 2007 PrestaShop SA and Contributors
+ * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
+ */
+
+header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
+header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
+
+header('Cache-Control: no-store, no-cache, must-revalidate');
+header('Cache-Control: post-check=0, pre-check=0', false);
+header('Pragma: no-cache');
+
+header('Location: ../');
+exit;
diff --git a/tests/Resources/index.php b/tests/Resources/index.php
new file mode 100644
index 00000000..250c8949
--- /dev/null
+++ b/tests/Resources/index.php
@@ -0,0 +1,35 @@
+
+ * @copyright Since 2007 PrestaShop SA and Contributors
+ * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
+ */
+
+header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
+header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
+
+header('Cache-Control: no-store, no-cache, must-revalidate');
+header('Cache-Control: post-check=0, pre-check=0', false);
+header('Pragma: no-cache');
+
+header('Location: ../');
+exit;
diff --git a/tests/Resources/modules/README.md b/tests/Resources/modules/README.md
deleted file mode 100644
index a57758b4..00000000
--- a/tests/Resources/modules/README.md
+++ /dev/null
@@ -1,4 +0,0 @@
-## Test modules
-
-Test modules repositories will be checkout in this folder during PHPUnit workflow.
-You can also clone the repositories manually with `git clone` to run the tests locally.
\ No newline at end of file
diff --git a/tests/Unit/Generator/AssetFileGeneratorTest.php b/tests/Unit/Generator/AssetFileGeneratorTest.php
new file mode 100644
index 00000000..c6bd0f81
--- /dev/null
+++ b/tests/Unit/Generator/AssetFileGeneratorTest.php
@@ -0,0 +1,40 @@
+moduleName = '';
+ $twigValues->className = '';
+ $twigValues->fileNameModule = '';
+
+ $twig = $this->createMock(Environment::class);
+ $twig->method('render')->with('@Modules/twig_template_file_name.js')->willReturn('test');
+ $g = new AssetsFileGenerator($twig);
+ $g->setTemplatesBaseFolder('');
+ $g->setTwigValues($twigValues);
+
+ $g->setModuleName('modulename');
+ $g->setTemplateName('twig_template_file_name.js');
+ $g->setClassFolderName('views/js/');
+ $g->setFileNameModule('file.js');
+ $g->setFileNameSeparator('');
+ $g->generate();
+
+
+ $this->assertTrue(file_exists(_PS_MODULE_DIR_.'/modulename/views/js/file.js'));
+
+ (new Filesystem())->remove(_PS_MODULE_DIR_);
+ }
+}
diff --git a/tests/Unit/Generator/ClassFileGeneratorTest.php b/tests/Unit/Generator/ClassFileGeneratorTest.php
new file mode 100644
index 00000000..09aeb24a
--- /dev/null
+++ b/tests/Unit/Generator/ClassFileGeneratorTest.php
@@ -0,0 +1,48 @@
+createMock(Environment::class);
+
+ $g = new ClassFileGenerator($twig);
+ $g->setTemplatesBaseFolder('');
+ $g->setTemplateName('twig_template_file_name.js');
+
+ $g->setModuleName('modulename');
+ $g->setClassFolderName('src/Classes/');
+
+ $twigValues = new ContentFileDTO();
+ $twigValues->moduleName = '';
+ $twigValues->fileNameModule = '';
+
+
+ //this create the file name MyClassNameBackOffice.php
+ $twigValues->className = 'MyClassName';
+ $g->setFileNameModule('BackOffice.php');
+
+ $g->setTwigValues($twigValues);
+
+ $twig->method('render')->with('@Modules/twig_template_file_name.js', (array)$twigValues)->willReturn('test');
+
+ // $g->setFileNameSeparator('');
+ $g->generate();
+
+
+ $file = _PS_MODULE_DIR_.'/modulename/src/Classes/MyClassNameBackOffice.php';
+ $this->assertTrue(file_exists($file));
+
+ (new Filesystem())->remove(_PS_MODULE_DIR_);
+ }
+}
diff --git a/tests/Unit/Generator/CodeDisplayGeneratorTest.php b/tests/Unit/Generator/CodeDisplayGeneratorTest.php
new file mode 100644
index 00000000..254cab7b
--- /dev/null
+++ b/tests/Unit/Generator/CodeDisplayGeneratorTest.php
@@ -0,0 +1,43 @@
+moduleName = '';
+ $twigValues->className = '';
+ $twigValues->fileNameModule = '';
+
+ $twig = $this->createMock(Environment::class);
+ $twig->method('render')->with('@Modules/twig_template_file_name.js')->willReturn('test');
+ $g = new CodeDisplayGenerator($twig);
+ $g->setTemplatesBaseFolder('');
+ $g->setTwigValues($twigValues);
+
+ $g->setModuleName('modulename');
+ $g->setTemplateName('twig_template_file_name.js');
+
+ //it's not necessary to set these values beacouse content is displayed in shell
+ // $g->setClassFolderName('');
+ // $g->setFileNameModule('');
+ // $g->setFileNameSeparator('');
+ ob_start();
+ $g->generate();
+ $content = ob_get_contents();
+ ob_end_flush();
+ $this->assertEquals('test'.PHP_EOL, $content);
+
+ (new Filesystem())->remove(_PS_MODULE_DIR_);
+ }
+}
diff --git a/tests/Unit/Generator/MainModuleFileGeneratorTest.php b/tests/Unit/Generator/MainModuleFileGeneratorTest.php
new file mode 100644
index 00000000..f699355d
--- /dev/null
+++ b/tests/Unit/Generator/MainModuleFileGeneratorTest.php
@@ -0,0 +1,40 @@
+moduleName = '';
+ $twigValues->className = '';
+ $twigValues->fileNameModule = '';
+
+ $twig = $this->createMock(Environment::class);
+ $twig->method('render')->with('@Modules/main.php.twig')->willReturn('test');
+ $g = new MainModuleFileGenerator($twig);
+ $g->setTemplatesBaseFolder('');
+ $g->setTwigValues($twigValues);
+
+ $g->setModuleName('modulename');
+ $g->setTemplateName('main.php.twig');
+ //this is the file of class name
+ $g->setFileNameModule('main.php');
+ // insert the file in module root
+ $g->setModuleFolder('/');
+ $g->generate();
+
+ $this->assertTrue(file_exists(_PS_MODULE_DIR_ . '/modulename/main.php'));
+
+ (new Filesystem())->remove(_PS_MODULE_DIR_);
+ }
+}
diff --git a/tests/Unit/Generator/StaticFileGeneratorTest.php b/tests/Unit/Generator/StaticFileGeneratorTest.php
new file mode 100644
index 00000000..e530aa6b
--- /dev/null
+++ b/tests/Unit/Generator/StaticFileGeneratorTest.php
@@ -0,0 +1,40 @@
+moduleName = '';
+ $twigValues->className = '';
+ $twigValues->fileNameModule = '';
+
+ $twig = $this->createMock(Environment::class);
+ $twig->method('render')->with('@Modules/composer.json.twig')->willReturn('test');
+ $g = new StaticFileGenerator($twig);
+ $g->setTemplatesBaseFolder('');
+ $g->setTwigValues($twigValues);
+
+ $g->setModuleName('modulename');
+ $g->setTemplateName('composer.json.twig');
+ //this is the file of class name
+ $g->setFileNameModule('composer.json');
+ // insert the file in module root
+ $g->generate();
+
+ $this->assertTrue(file_exists(_PS_MODULE_DIR_ . '/modulename/main.php'));
+
+ (new Filesystem())->remove(_PS_MODULE_DIR_);
+ }
+}
diff --git a/tests/Unit/Generator/TwigFileGeneratorTest.php b/tests/Unit/Generator/TwigFileGeneratorTest.php
new file mode 100644
index 00000000..7ffd7872
--- /dev/null
+++ b/tests/Unit/Generator/TwigFileGeneratorTest.php
@@ -0,0 +1,56 @@
+moduleName = '';
+ $twigValues->className = '';
+ $twigValues->fileNameModule = '';
+
+ $twig = $this->createMock(Environment::class);
+ $twig->method('render')->with('@Modules/twig_template_file_name.js')->willReturn('test');
+
+
+ $g = new TwigFileGenerator($twig);
+ $g->setTwigValues($twigValues);
+ $g->setTemplatesBaseFolder('');
+
+
+ //service name is used as a prefix for the file name
+ $twigValues->serviceName = 'prova';
+ $g->setFileNameModule('new_twig_file.html.twig');
+
+ $g->setTemplateName('twigfile.html.twig');
+ $g->setModuleName('modulename');
+ $g->setModuleFolder('views/templates/admin/');
+ $g->setFileNameSeparator('_');
+
+ $g->generate();
+
+
+ $this->assertTrue(
+ file_exists(__DIR__.'/modulename/views/templates/admin/prova_new_twig_file.html.twig')
+ );
+
+ (new Filesystem())->remove(FileGenerator::$PSMODULEDIR.'/modulename');
+ }
+
+ protected function setUp(): void
+ {
+ parent::setUp();
+ FileGenerator::$PSMODULEDIR = __DIR__.'/';
+ }
+}
diff --git a/tests/Unit/Generator/twigfile.html.twig b/tests/Unit/Generator/twigfile.html.twig
new file mode 100644
index 00000000..e69de29b
diff --git a/tests/Unit/PhpStanNamesConsistencyRuleTest.php b/tests/Unit/PhpStanNamesConsistencyRuleTest.php
index d3f6a20d..b2ebd4d4 100644
--- a/tests/Unit/PhpStanNamesConsistencyRuleTest.php
+++ b/tests/Unit/PhpStanNamesConsistencyRuleTest.php
@@ -53,7 +53,7 @@ protected function getRule(): \PHPStan\Rules\Rule
// this is because PhpStanNamesConsistencyRule::nodeIsInClassFopCommand() checks the FQDN and therefore it needs to be changed
// with the namespace of the tested class (FOP\Console\Tests\Resources\Commands\Domain).
/* @phpstan-ignore-next-line */
- return new class($mockedValidatorService) extends PhpStanNamesConsistencyRule {
+ return new class ($mockedValidatorService) extends PhpStanNamesConsistencyRule {
public const FOP_BASE_COMMAND_CLASS_NAME = 'FOP\Console\Tests\Resources\Commands\Command';
};
}
diff --git a/tests/Unit/Tools/index.php b/tests/Unit/Tools/index.php
new file mode 100644
index 00000000..250c8949
--- /dev/null
+++ b/tests/Unit/Tools/index.php
@@ -0,0 +1,35 @@
+
+ * @copyright Since 2007 PrestaShop SA and Contributors
+ * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
+ */
+
+header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
+header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
+
+header('Cache-Control: no-store, no-cache, must-revalidate');
+header('Cache-Control: post-check=0, pre-check=0', false);
+header('Pragma: no-cache');
+
+header('Location: ../');
+exit;
diff --git a/tests/Unit/index.php b/tests/Unit/index.php
new file mode 100644
index 00000000..250c8949
--- /dev/null
+++ b/tests/Unit/index.php
@@ -0,0 +1,35 @@
+
+ * @copyright Since 2007 PrestaShop SA and Contributors
+ * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
+ */
+
+header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
+header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
+
+header('Cache-Control: no-store, no-cache, must-revalidate');
+header('Cache-Control: post-check=0, pre-check=0', false);
+header('Pragma: no-cache');
+
+header('Location: ../');
+exit;
diff --git a/tests/Validator/Exception/index.php b/tests/Validator/Exception/index.php
new file mode 100644
index 00000000..250c8949
--- /dev/null
+++ b/tests/Validator/Exception/index.php
@@ -0,0 +1,35 @@
+
+ * @copyright Since 2007 PrestaShop SA and Contributors
+ * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
+ */
+
+header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
+header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
+
+header('Cache-Control: no-store, no-cache, must-revalidate');
+header('Cache-Control: post-check=0, pre-check=0', false);
+header('Pragma: no-cache');
+
+header('Location: ../');
+exit;
diff --git a/tests/Validator/FOPCommandFormatsValidator.php b/tests/Validator/FOPCommandFormatsValidator.php
index c821c64e..06aea084 100755
--- a/tests/Validator/FOPCommandFormatsValidator.php
+++ b/tests/Validator/FOPCommandFormatsValidator.php
@@ -31,6 +31,7 @@
* - command name (symfony command name) is consistent with and
* - service name (symfony service declaration) is consistent with and
*/
+
class FOPCommandFormatsValidator
{
/**
diff --git a/tests/Validator/index.php b/tests/Validator/index.php
new file mode 100644
index 00000000..250c8949
--- /dev/null
+++ b/tests/Validator/index.php
@@ -0,0 +1,35 @@
+
+ * @copyright Since 2007 PrestaShop SA and Contributors
+ * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
+ */
+
+header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
+header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
+
+header('Cache-Control: no-store, no-cache, must-revalidate');
+header('Cache-Control: post-check=0, pre-check=0', false);
+header('Pragma: no-cache');
+
+header('Location: ../');
+exit;
diff --git a/tests/index.php b/tests/index.php
new file mode 100644
index 00000000..250c8949
--- /dev/null
+++ b/tests/index.php
@@ -0,0 +1,35 @@
+
+ * @copyright Since 2007 PrestaShop SA and Contributors
+ * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
+ */
+
+header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
+header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
+
+header('Cache-Control: no-store, no-cache, must-revalidate');
+header('Cache-Control: post-check=0, pre-check=0', false);
+header('Pragma: no-cache');
+
+header('Location: ../');
+exit;