Skip to content

Commit

Permalink
Feature/more unit tests (#71)
Browse files Browse the repository at this point in the history
* Test commit

* Updated config with prefix

* Updated config with prefix

* Updated config with new prefix

* Updated config with new prefix

* Added facrory to load varialbles model

* Removed test badge and added compilation to test

* Revemod the codeclimate test script

* Added enable all, updated version

* Added the memory limit for compilation
  • Loading branch information
eadesignro authored Dec 15, 2018
1 parent 649ecaf commit d5e107b
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 36 deletions.
22 changes: 6 additions & 16 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,11 @@ jobs:
path: app/code/Eadesigndev/Pdfgenerator

- run:
name: Install code climate
command: composer create-project codeclimate/php-test-reporter codeclimate
name: Enable all module
command: php bin/magento module:enable --all
- run:
name: Run compilation
command: php -d memory_limit=6G bin/magento setup:di:compile
- run:
name: Install marketplace qulity tools
command: composer create-project --repository=https://repo.magento.com magento/marketplace-eqp magento-coding-standard
Expand All @@ -62,17 +65,4 @@ jobs:
command: php vendor/bin/phpmd app/code/Eadesigndev/Pdfgenerator/Api/,app/code/Eadesigndev/Pdfgenerator/Block/,app/code/Eadesigndev/Pdfgenerator/Controller/,app/code/Eadesigndev/Pdfgenerator/Helper/,app/code/Eadesigndev/Pdfgenerator/Model/,app/code/Eadesigndev/Pdfgenerator/Setup/,app/code/Eadesigndev/Pdfgenerator/Ui/,app/code/Eadesigndev/Pdfgenerator/view/ text app/code/Eadesigndev/Pdfgenerator/Test/Php/_files/phpmd/ruleset.xml
- run:
name: Run unit tests
command: php vendor/bin/phpunit app/code/Eadesigndev/Pdfgenerator/Test/ --config dev/tests/unit/phpunit.xml.dist --coverage-clover=app/code/Eadesigndev/Pdfgenerator/build/logs/clover.xml

- run:
name: Get the reporter script
command: cd app/code/Eadesigndev/Pdfgenerator && curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
- run:
name: Make the executable
command: cd app/code/Eadesigndev/Pdfgenerator && chmod +x ./cc-test-reporter
- run:
name: Run the before script
command: cd app/code/Eadesigndev/Pdfgenerator && ./cc-test-reporter before-build
- run:
name: Rune the reporter
command: cd app/code/Eadesigndev/Pdfgenerator && ./cc-test-reporter after-build -r $CC_TEST_REPORTER_ID --coverage-input-type clover --exit-code $?
command: php vendor/bin/phpunit app/code/Eadesigndev/Pdfgenerator/Test/ --config dev/tests/unit/phpunit.xml.dist --coverage-clover=app/code/Eadesigndev/Pdfgenerator/build/logs/clover.xml
11 changes: 6 additions & 5 deletions Controller/Adminhtml/Variable/Template.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use Magento\Framework\Json\Helper\Data as JsonHelperData;
use Magento\Variable\Model\Variable as VariableModel;
use Magento\Email\Model\Source\Variables as EmailVariables;
use Eadesigndev\Pdfgenerator\Model\Email\VariablesFacrory;
use Magento\Email\Model\BackendTemplate as EmailBackendTemplate;
use Zend_Json;

Expand Down Expand Up @@ -64,7 +65,7 @@ class Template extends Action
/**
* @var EmailVariables
*/
private $emailVariables;
private $variablesFacrory;

/**
* @var EmailBackendTemplate
Expand All @@ -79,7 +80,7 @@ class Template extends Action
* @param JsonFactory $resultJsonFactory
* @param JsonHelperData $jsonHelperData
* @param VariableModel $variableModel
* @param EmailVariables $emailVariables
* @param VariablesFacrory $variablesFacrory
* @param EmailBackendTemplate $emailBackendTemplate
*/
public function __construct(
Expand All @@ -89,7 +90,7 @@ public function __construct(
JsonFactory $resultJsonFactory,
JsonHelperData $jsonHelperData,
VariableModel $variableModel,
EmailVariables $emailVariables,
VariablesFacrory $variablesFacrory,
EmailBackendTemplate $emailBackendTemplate
) {

Expand All @@ -99,7 +100,7 @@ public function __construct(
$this->resultJsonFactory = $resultJsonFactory;
$this->jsonHelperData = $jsonHelperData;
$this->variableModel = $variableModel;
$this->emailVariables = $emailVariables;
$this->variablesFacrory = $variablesFacrory;
$this->emailBackendTemplate = $emailBackendTemplate;
}

Expand Down Expand Up @@ -149,7 +150,7 @@ public function execute()

$customVariables = $this->variableModel
->getVariablesOptionArray(true);
$storeContactVariables = $this->emailVariables->toOptionArray(true);
$storeContactVariables = $this->variablesFacrory->create()->toOptionArray(true);
/** @var Json $resultJson */
$resultJson = $this->resultJsonFactory->create();
return $resultJson->setData([
Expand Down
39 changes: 39 additions & 0 deletions Model/Email/VariablesFacrory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php
/**
* Copyright © EAdesign by Eco Active S.R.L.,All rights reserved.
* See LICENSE for license details.
*/

namespace Eadesigndev\Pdfgenerator\Model\Email;

use Eadesigndev\Pdfgenerator\Model\FactoryInterface;
use Magento\Framework\ObjectManagerInterface;

/**
* Class VariablesFacrory
* @package Eadesigndev\Pdfgenerator\Model\Email
* @deprecated
*/
class VariablesFacrory implements FactoryInterface
{
private $objectManager = null;

private $instanceName = null;

public function __construct(ObjectManagerInterface $objectManager)
{
$this->objectManager = $objectManager;
if (class_exists(\Magento\Email\Model\Source\Variables::class)) {
$this->instanceName = \Magento\Email\Model\Source\Variables::class;
}

if (class_exists(\Magento\Variable\Model\Source\Variables::class)) {
$this->instanceName = \Magento\Variable\Model\Source\Variables::class;
}
}

public function create(array $data = [])
{
return $this->objectManager->create($this->instanceName, $data);
}
}
13 changes: 1 addition & 12 deletions Model/Template/DataProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,7 @@ public function __construct(
$this->collection = $templateCollectionFactory->create();
$this->dataPersistor = $dataPersistor;
parent::__construct($name, $primaryFieldName, $requestFieldName, $meta, $data);
$this->meta = $this->prepareMeta($this->meta);
}

/**
* Prepares Meta
*
* @param array $meta
* @return array
*/
public function prepareMeta(array $meta)
{
return $meta;
$this->meta = $meta;
}

/**
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@


[![Maintainability](https://api.codeclimate.com/v1/badges/a0e292336dc421b6c903/maintainability)](https://codeclimate.com/github/EaDesgin/magento2-pdf-generator2/maintainability)
[![Test Coverage](https://api.codeclimate.com/v1/badges/a0e292336dc421b6c903/test_coverage)](https://codeclimate.com/github/EaDesgin/magento2-pdf-generator2/test_coverage)

[![](https://img.shields.io/packagist/v/eadesignro/module-pdfgenerator.svg)](https://packagist.org/packages/eadesignro/module-pdfgenerator) [![](https://img.shields.io/packagist/dt/eadesignro/module-pdfgenerator.svg)](https://packagist.org/packages/eadesignro/module-pdfgenerator)

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "eadesignro/module-pdfgenerator",
"description": "The best pdf generator for Magento. EaDesign PDF Generator",
"type": "magento2-module",
"version": "1.2.5",
"version": "1.2.6",
"autoload": {
"files": [
"registration.php"
Expand Down
2 changes: 1 addition & 1 deletion etc/module.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Eadesigndev_Pdfgenerator" setup_version="1.2.5"/>
<module name="Eadesigndev_Pdfgenerator" setup_version="1.2.6"/>
</config>

0 comments on commit d5e107b

Please sign in to comment.