PHP code example of fr3nch13 / cakephp-pta

1. Go to this page and download the library: Download fr3nch13/cakephp-pta library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

fr3nch13 / cakephp-pta example snippets


// define any constants you need to overwrite above these lines.
$root = dirname(__DIR__);
chdir($root);

# test/bootstrap.php

// ... code ...

Configure::write('Tests.Plugins', [
    'Namespace/PluginName', // the name of your plugin
    'Fr3nch13/Jira', // Using one of my plusins as an example
]);

// plugins just for the command line
Configure::write('Tests.PluginsCli', [
    'Namespace/PluginName', // the name of your plugin
]);

// ... code ...


# test/bootstrap.php

// ... code ...

$dotenv = new \Symfony\Component\Dotenv\Dotenv();
$dotenv->load(TESTS . '.env');

// ... code ...


# test/bootstrap.php

// ... code ...

Configure::write('Tests.DbConfig', [
    'className' => 'Cake\Database\Connection',
    'driver' => 'Cake\Database\Driver\Mysql',
    'persistent' => false,
    'host' => 'database_hostname',
    'port' => 'non_standard_port_number',
    'username' => 'database_username',
    'password' => 'database_password',
    'database' => 'database_schema',
    'encoding' => 'utf8',
    'timezone' => 'UTC',
    'flags' => [],
    'cacheMetadata' => true,
    'log' => false,
    'quoteIdentifiers' => true,
]);

// ... code ...


# test/bootstrap.php

// ... code ...

Configure::write('Tests.Migrations', [
    ['plugin' => 'Namespace/PluginName'],
    // just using some of my plugins as an example
    ['plugin' => 'Fr3nch13/Jira'],
    ['plugin' => 'Fr3nch13/Utilities'],
    ['plugin' => 'Fr3nch13/Excel'],
]);


// ... code ...


# test/bootstrap.php

// ... code ...

Configure::write('Tests.Helpers', [
    'HelperName' => ['className' => 'Namespace/PluginName.HelperName'],
    // loads the jira helper as an example.
    'Jira' => ['className' => 'Fr3nch13/Jira.Jira'],
]);


// ... code ...


# test/bootstrap.php

// ... code ...

Configure::write('Tests.Middleware', [
    'MiddlewhereName' => [
        'config_key' => 'config_value',
    ],
]);


// ... code ...


#tests/bootstrap.php


declare(strict_types=1);

/**
 * Test suite bootstrap.
 *
 * These are the specific settings for this plugin.
 * This uses fr3nch13/cakephp-pta to provide a generic application for testing.
 * Setting passed to cakephp-pta's bootstrap and application are defined here.
 */

use Cake\Core\Configure;

// Configure your stuff here for the plugin_bootstrap.php below.
define('TESTS', __DIR__ . DS);

$dotenv = new \Symfony\Component\Dotenv\Dotenv();
$dotenv->load(TESTS . '.env');

Configure::write('Tests.DbConfig', [
    'className' => 'Cake\Database\Connection',
    'driver' => 'Cake\Database\Driver\Mysql',
    'persistent' => false,
    'host' => env('CI_HOST', null),
    'username' => env('CI_USERNAME', null),
    'password' => env('CI_PASSWORD', null),
    'database' => env('CI_DATABASE', null),
    'encoding' => 'utf8',
    'timezone' => 'UTC',
    'flags' => [],
    'cacheMetadata' => true,
    'log' => false,
    'quoteIdentifiers' => true,
    'url' => env('DATABASE_URL', null),
]);

Configure::write('Tests.Plugins', [
    'Namespace/PluginName',
]);

Configure::write('Tests.Migrations', [
    ['plugin' => 'Namespace/PluginName'],
]);

Configure::write('Tests.Helpers', [
    'HelperName' => ['className' => 'Namespace/PluginName.HelperName'],
]);

////// Ensure we can setup an environment for the Test Application instance.
$root = dirname(__DIR__);
chdir($root);