Licitator 1.0
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

5.4 KiB

Introduction

Prometeo Commands is a symfony bundle that allows you to build automatically entities, sonata admins, unit test cases, functional test cases and user documentation. A demo site?

Installation

Minimum requirements

  • Symfony 4.0
  • PHP 7.1.3
  • Twig 2.0

Composer installation

You can install it through composer.

{
  .... 
   "require":{
       "prometeo/prometeo-command": "@dev"
    }
    ....
 "repositories": [
        {
            "type": "path",
            "url": "repositories/prometeo-commands",
            "options": {
                "symlink": true
            }
        }
    ],
  ....
}

Enable bundle

Then, enable the bundle by adding it to the list of registered bundles in the config/bundles.php file of your project:

<?php

return [
    // ...
    Prometeo\CommandsBundle\PrometeoCommandsBundle::class => ['all' => true],
];

Add services

Add to services.yml

 prometeo.admin.maker:
        class: Prometeo\CommandsBundle\Commands\MakeAdmin
        arguments:
            - '@doctrine.orm.entity_manager'
            - collection:
                  - maker.command
        tags:
            - { name: 'admin.maker.command', command: 'prometeo:make:admin' }
    prometeo.entities.maker:
        class: Prometeo\CommandsBundle\Commands\MakeEntities
        arguments: ['%kernel.project_dir%','@doctrine.orm.entity_manager', ['maker.command']]
        tags:
            - { name: 'entities.maker.command', command: 'prometeo:make:entities' }
    prometeo.usermanual.maker:
        class: Prometeo\CommandsBundle\Commands\MakeUserManual
        arguments: ['%kernel.project_dir%','@doctrine.orm.entity_manager']
        tags:
            - { name: 'usermanual.maker.command', command: 'prometeo:make:entities' }
    prometeo.skipper.generate:
        class: Prometeo\CommandsBundle\Commands\GenerateSkipper
        arguments: ["@service_container",'%kernel.project_dir%','@doctrine.orm.entity_manager']
        tags:
            - { name: 'skipper.generate.command', command: 'prometeo:skipper:generate' }
    prometeo.screenshots.generate:
        class: Prometeo\CommandsBundle\Commands\GenerateScreenshoots
        arguments: ["@service_container",'%kernel.project_dir%','@doctrine.orm.entity_manager']
        tags:
            - { name: 'screenshots.generate.command', command: 'prometeo:screenshots:generate' }
    prometeo.unittest.maker:
        class: Prometeo\CommandsBundle\Commands\MakeUnitTest
        arguments: ['%kernel.project_dir%','@doctrine.orm.entity_manager']
        tags:
            - { name: 'screenshots.generate.command', command: 'prometeo:make:unit-test' }
    prometeo.functionaltest.make:
        class: Prometeo\CommandsBundle\Commands\MakeFunctionalTest
        arguments: ['%kernel.project_dir%','@doctrine.orm.entity_manager']
        tags:
            - { name: 'screenshots.generate.command', command: 'prometeo:make:functional-test' }

PHPunit config

<!-- phpunit.xml.dist -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/6.0/phpunit.xsd"
         backupGlobals="false"
         colors="true"
         bootstrap="vendor/autoload.php"
>
    <php>
        <ini name="error_reporting" value="-1" />
        <env name="KERNEL_CLASS" value="App\Kernel" />
        <env name="APP_ENV" value="test" />
        <env name="APP_DEBUG" value="1" />
        <env name="SHELL_VERBOSITY" value="-1" />
        <env name="DATABASE_URL" value="mysql://[user:password]@127.0.0.1:3306/[database]?serverVersion=[version]" />
        <!-- define your env variables for the test env here -->
    </php>
    <!-- ... -->
    <testsuites>
        <testsuite name="Project Test Suite">
            <directory>tests</directory>
        </testsuite>
    </testsuites>
    <!-- Add this for PHPUnit 7.5 or higher -->
<!--    <extensions>-->
<!--        <extension class="DAMA\DoctrineTestBundle\PHPUnit\PHPUnitExtension"/>-->
<!--    </extensions>-->
    <listeners>
        <listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener"/>
    </listeners>
</phpunit>

Usage

How to use

Make entities

cd src/Entity
for file in *;
        do
                echo "../../bin/console make:entity App\\Entity\\${file::-4}";
                ../../bin/console make:entity --regenerate --overwrite  "App\\Entity\\${file::-4}";
        done

Make Sonata Admins

cd src/Entity

for file in *;
        do
	withoutext=${file::-4}
                echo "../../bin/console  make:sonata:admin \"App\\Entity\\${file::-4}\" --admin ${file::-4}Admin --controller ${file::-4}AdminController --services services.yaml --id admin.${withoutext,,}";
		../../bin/console  make:sonata:admin \"App\\Entity\\${file::-4}\" --admin ${file::-4}Admin --controller ${file::-4}AdminController --services services.yaml --id admin.${withoutext,,}
        done

Generate Screen Shoots

bin/console debug:router --raw >adminlist.txt
php filterlist.php
./phantomjs.exe --ssl-protocol=any --ignore-ssl-errors=yes phantomjs/testscripts/sonatatest.js acdr.test %1 %2 %3

Make Unit Test

cd src/Entity
for file in *;
        do
                echo "../../bin/console prometeo:make:unit-test Entity\\${file::-4} Entity";
                ../../bin/console prometeo:make:unit-test "Entity\\${file::-4}" Entity
        done

Make Functional Test

Make User Manual

That's it! Done!

Additional documentation: