<commit_before><?php

namespace Crud;

use Crud\FunctionalTester;
use Crud\Page\Functional\Generate as Page;

class GeneratedFilesCest
{
    public function _before(FunctionalTester $I)
    {
        new Page($I);
        $I->amLoggedAs(Page::$adminUser);

        $I->amOnPage(Page::route('?table_name='.Page::$tableName));
        $I->see(Page::$title, Page::$titleElem);
    }

    public function checkPortoContainerFilesGeneration(FunctionalTester $I)
    {
        $I->wantTo('generate a Porto Container');

        $data = Page::$formData;
        $data['app_type'] = 'porto_container';
        
        $I->submitForm('form[name=CRUD-form]', $data);

        $package = studly_case(str_singular($data['is_part_of_package']));

        // los directorios deben estar creados correctamente
        $I->assertTrue(file_exists(app_path('Containers')), 'Containers folder');
        $I->assertTrue(file_exists(app_path('Containers/'.$package)), 'package container folder');
        $I->assertTrue(file_exists(app_path('Containers/'.$package.'/Actions')), 'Actions folder');
        // Data folders
        $I->assertTrue(file_exists(app_path('Containers/'.$package.'/Data')), 'Data folder');
        $I->assertTrue(file_exists(app_path('Containers/'.$package.'/Data/Criterias')), 'Data/Criterias folder');
        $I->assertTrue(file_exists(app_path('Containers/'.$package.'/Data/Factories')), 'Data/Factories folder');
        $I->assertTrue(file_exists(app_path('Containers/'.$package.'/Data/Migrations')), 'Data/Migrations folder');
        $I->assertTrue(file_exists(app_path('Containers/'.$package.'/Data/Repositories')), 'Data/Repositories folder');
        $I->assertTrue(file_exists(app_path('Containers/'.$package.'/Data/Seeders')), 'Data/Seeders folder');

        $I->assertTrue(file_exists(app_path('Containers/'.$package.'/Models')), 'Models folder');
        $I->assertTrue(file_exists(app_path('Containers/'.$package.'/Tasks')), 'Tasks folder');
        $I->assertTrue(file_exists(app_path('Containers/'.$package.'/UI')), 'UI folder');
        $I->assertTrue(file_exists(app_path('Containers/'.$package.'/Tests')), 'Tests folder');
        // API folders
        $I->assertTrue(file_exists(app_path('Containers/'.$package.'/UI/API')), 'UI/API folder');
        $I->assertTrue(file_exists(app_path('Containers/'.$package.'/UI/API/Controllers')), 'API/Controllers folder');
        $I->assertTrue(file_exists(app_path('Containers/'.$package.'/UI/API/Requests')), 'API/Requests folder');
        $I->assertTrue(file_exists(app_path('Containers/'.$package.'/UI/API/Routes')), 'API/Routes folder');
        $I->assertTrue(file_exists(app_path('Containers/'.$package.'/UI/API/Transformers')), 'API/Transformers folder');
        // WEB folders
        $I->assertTrue(file_exists(app_path('Containers/'.$package.'/UI/WEB')), 'UI/WEB folder');
        $I->assertTrue(file_exists(app_path('Containers/'.$package.'/UI/WEB/Controllers')), 'WEB/Controllers folder');
        $I->assertTrue(file_exists(app_path('Containers/'.$package.'/UI/WEB/Requests')), 'WEB/Requests folder');
        $I->assertTrue(file_exists(app_path('Containers/'.$package.'/UI/WEB/Routes')), 'WEB/Routes folder');
        $I->assertTrue(file_exists(app_path('Containers/'.$package.'/UI/WEB/Views')), 'WEB/Views folder');
        // CLI folders
        $I->assertTrue(file_exists(app_path('Containers/'.$package.'/UI/CLI')), 'UI/CLI folder');

        // generated Actions files/clases
        $I->seeFileFound('composer.json', app_path('Containers/'.$package));
        $I->seeFileFound('ListAndSearchBooksAction.php', app_path('Containers/'.$package.'/Actions'));
        $I->seeFileFound('CreateBookAction.php', app_path('Containers/'.$package.'/Actions'));
        $I->seeFileFound('UpdateBookAction.php', app_path('Containers/'.$package.'/Actions'));
        $I->seeFileFound('DeleteBookAction.php', app_path('Containers/'.$package.'/Actions'));
        $I->seeFileFound('RestoreBookAction.php', app_path('Containers/'.$package.'/Actions'));

        $I->seeFileFound('composer.json', app_path('Containers/'.$package));

        // generated Actions files/clases
        $I->seeFileFound('ListAndSearchBooksAction.php', app_path('Containers/'.$package.'/Actions'));
        $I->seeFileFound('CreateBookAction.php', app_path('Containers/'.$package.'/Actions'));
        $I->seeFileFound('UpdateBookAction.php', app_path('Containers/'.$package.'/Actions'));
        $I->seeFileFound('DeleteBookAction.php', app_path('Containers/'.$package.'/Actions'));
        $I->seeFileFound('RestoreBookAction.php', app_path('Containers/'.$package.'/Actions'));

        // generated Tasks files/clases
        $I->seeFileFound('ListBooksTask.php', app_path('Containers/'.$package.'/Tasks'));
        $I->seeFileFound('CreateBookTask.php', app_path('Containers/'.$package.'/Tasks'));
        $I->seeFileFound('UpdateBookTask.php', app_path('Containers/'.$package.'/Tasks'));
        $I->seeFileFound('DeleteBookTask.php', app_path('Containers/'.$package.'/Tasks'));
        $I->seeFileFound('RestoreBookTask.php', app_path('Containers/'.$package.'/Tasks'));

        // generated API route files
        $I->seeFileFound('ListBooks.v1.private.php', app_path('Containers/'.$package.'/UI/API/Routes'));
        $I->seeFileFound('CreateBook.v1.private.php', app_path('Containers/'.$package.'/UI/API/Routes'));
        $I->seeFileFound('UpdateBook.v1.private.php', app_path('Containers/'.$package.'/UI/API/Routes'));
        $I->seeFileFound('DeleteBook.v1.private.php', app_path('Containers/'.$package.'/UI/API/Routes'));
        $I->seeFileFound('RestoreBook.v1.private.php', app_path('Containers/'.$package.'/UI/API/Routes'));

        // generated API request files
        $I->seeFileFound('ListAllBooksRequest.php', app_path('Containers/'.$package.'/UI/API/Requests'));
        $I->seeFileFound('CreateBookRequest.php', app_path('Containers/'.$package.'/UI/API/Requests'));
        $I->seeFileFound('UpdateBookRequest.php', app_path('Containers/'.$package.'/UI/API/Requests'));
        $I->seeFileFound('DeleteBookRequest.php', app_path('Containers/'.$package.'/UI/API/Requests'));
        $I->seeFileFound('RestoreBookRequest.php', app_path('Containers/'.$package.'/UI/API/Requests'));
    }

    /**
     * Comprueba la funcionalidad de crear los ficheros requeridos para la CRUD app.
     *
     * @param FunctionalTester $I
     */
    public function checkLaravelAppFilesGeneration(FunctionalTester $I)
    {
        $I->wantTo('crear aplicacion Laravel App CRUD');
<commit_msg>cleaning up<commit_after><?php

namespace Crud;

use Crud\FunctionalTester;
use Crud\Page\Functional\Generate as Page;

class GeneratedFilesCest
{
    public function _before(FunctionalTester $I)
    {
        new Page($I);
        $I->amLoggedAs(Page::$adminUser);

        $I->amOnPage(Page::route('?table_name='.Page::$tableName));
        $I->see(Page::$title, Page::$titleElem);
    }

    public function checkPortoContainerFilesGeneration(FunctionalTester $I)
    {
        $I->wantTo('generate a Porto Container');

        $data = Page::$formData;
        $data['app_type'] = 'porto_container';
        
        $I->submitForm('form[name=CRUD-form]', $data);

        $package = studly_case(str_singular($data['is_part_of_package']));

        // los directorios deben estar creados correctamente
        $I->assertTrue(file_exists(app_path('Containers')), 'Containers folder');
        $I->assertTrue(file_exists(app_path('Containers/'.$package)), 'package container folder');
        
        // generated Actions
        $I->assertTrue(file_exists(app_path('Containers/'.$package.'/Actions')), 'Actions folder');
        $I->seeFileFound('composer.json', app_path('Containers/'.$package));
        $I->seeFileFound('ListAndSearchBooksAction.php', app_path('Containers/'.$package.'/Actions'));
        $I->seeFileFound('CreateBookAction.php', app_path('Containers/'.$package.'/Actions'));
        $I->seeFileFound('UpdateBookAction.php', app_path('Containers/'.$package.'/Actions'));
        $I->seeFileFound('DeleteBookAction.php', app_path('Containers/'.$package.'/Actions'));
        $I->seeFileFound('RestoreBookAction.php', app_path('Containers/'.$package.'/Actions'));

        // Data folders
        $I->assertTrue(file_exists(app_path('Containers/'.$package.'/Data')), 'Data folder');
        $I->assertTrue(file_exists(app_path('Containers/'.$package.'/Data/Criterias')), 'Data/Criterias folder');
        $I->assertTrue(file_exists(app_path('Containers/'.$package.'/Data/Factories')), 'Data/Factories folder');
        $I->assertTrue(file_exists(app_path('Containers/'.$package.'/Data/Migrations')), 'Data/Migrations folder');
        $I->assertTrue(file_exists(app_path('Containers/'.$package.'/Data/Repositories')), 'Data/Repositories folder');
        $I->assertTrue(file_exists(app_path('Containers/'.$package.'/Data/Seeders')), 'Data/Seeders folder');

        // generated Models
        $I->assertTrue(file_exists(app_path('Containers/'.$package.'/Models')), 'Models folder');

        // generated Tasks files/clases
        $I->assertTrue(file_exists(app_path('Containers/'.$package.'/Tasks')), 'Tasks folder');
        $I->seeFileFound('ListBooksTask.php', app_path('Containers/'.$package.'/Tasks'));
        $I->seeFileFound('CreateBookTask.php', app_path('Containers/'.$package.'/Tasks'));
        $I->seeFileFound('UpdateBookTask.php', app_path('Containers/'.$package.'/Tasks'));
        $I->seeFileFound('DeleteBookTask.php', app_path('Containers/'.$package.'/Tasks'));
        $I->seeFileFound('RestoreBookTask.php', app_path('Containers/'.$package.'/Tasks'));
        $I->assertTrue(file_exists(app_path('Containers/'.$package.'/UI')), 'UI folder');

        // tests folders
        $I->assertTrue(file_exists(app_path('Containers/'.$package.'/tests')), 'tests folder');
        $I->assertTrue(file_exists(app_path('Containers/'.$package.'/tests/acceptance')), 'tests/acceptance folder');
        $I->assertTrue(file_exists(app_path('Containers/'.$package.'/tests/functional')), 'tests/functional folder');
        $I->assertTrue(file_exists(app_path('Containers/'.$package.'/tests/unit')), 'tests/unit folder');

        // API folders
        $I->assertTrue(file_exists(app_path('Containers/'.$package.'/UI/API')), 'UI/API folder');
        $I->assertTrue(file_exists(app_path('Containers/'.$package.'/UI/API/Controllers')), 'API/Controllers folder');

        // generated API requests
        $I->assertTrue(file_exists(app_path('Containers/'.$package.'/UI/API/Requests')), 'API/Requests folder');
        $I->seeFileFound('ListAllBooksRequest.php', app_path('Containers/'.$package.'/UI/API/Requests'));
        $I->seeFileFound('CreateBookRequest.php', app_path('Containers/'.$package.'/UI/API/Requests'));
        $I->seeFileFound('UpdateBookRequest.php', app_path('Containers/'.$package.'/UI/API/Requests'));
        $I->seeFileFound('DeleteBookRequest.php', app_path('Containers/'.$package.'/UI/API/Requests'));
        $I->seeFileFound('RestoreBookRequest.php', app_path('Containers/'.$package.'/UI/API/Requests'));
        
        // generated API routes
        $I->assertTrue(file_exists(app_path('Containers/'.$package.'/UI/API/Routes')), 'API/Routes folder');
        $I->seeFileFound('ListBooks.v1.private.php', app_path('Containers/'.$package.'/UI/API/Routes'));
        $I->seeFileFound('CreateBook.v1.private.php', app_path('Containers/'.$package.'/UI/API/Routes'));
        $I->seeFileFound('UpdateBook.v1.private.php', app_path('Containers/'.$package.'/UI/API/Routes'));
        $I->seeFileFound('DeleteBook.v1.private.php', app_path('Containers/'.$package.'/UI/API/Routes'));
        $I->seeFileFound('RestoreBook.v1.private.php', app_path('Containers/'.$package.'/UI/API/Routes'));

        $I->assertTrue(file_exists(app_path('Containers/'.$package.'/UI/API/Transformers')), 'API/Transformers folder');

        // WEB folders
        $I->assertTrue(file_exists(app_path('Containers/'.$package.'/UI/WEB')), 'UI/WEB folder');
        $I->assertTrue(file_exists(app_path('Containers/'.$package.'/UI/WEB/Controllers')), 'WEB/Controllers folder');
        $I->assertTrue(file_exists(app_path('Containers/'.$package.'/UI/WEB/Requests')), 'WEB/Requests folder');
        $I->assertTrue(file_exists(app_path('Containers/'.$package.'/UI/WEB/Routes')), 'WEB/Routes folder');
        $I->assertTrue(file_exists(app_path('Containers/'.$package.'/UI/WEB/Views')), 'WEB/Views folder');

        // CLI folders
        $I->assertTrue(file_exists(app_path('Containers/'.$package.'/UI/CLI')), 'UI/CLI folder');

        // Other files
        $I->seeFileFound('composer.json', app_path('Containers/'.$package));
    }

    /**
     * Comprueba la funcionalidad de crear los ficheros requeridos para la CRUD app.
     *
     * @param FunctionalTester $I
     */
    public function checkLaravelAppFilesGeneration(FunctionalTester $I)
    {
        $I->wantTo('crear aplicacion Laravel App CRUD');

{'fraction_non_alphanumeric': 0.1988767502692722, 'fraction_numerical': 0.0007693491306354824, 'mean_word_length': 4.075751659508005, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 115, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '354610', 'n_tokens_mistral': 4104, 'n_tokens_neox': 4225, 'n_words': 438}