PHP code example of satthi / plugin-test-support

1. Go to this page and download the library: Download satthi/plugin-test-support 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/ */

    

satthi / plugin-test-support example snippets



namespace EncryptionSupport\Test\TestCase\Model\Table;

use App\Model\Table\AccountsTable;
use Cake\ORM\TableRegistry;
use Cake\TestSuite\TestCase;
//以下をuse
use PluginTestSupport\Test\TestCase\AppTestCase;

/**
 * App\Model\Table\AccountsTable Test Case
 */
//AppTestCaseをextendsする
class AccountsTableTest extends AppTestCase
{

    /**
     * Fixtures
     *
     * @var array
     */
    public $fixtures = [
        'plugin.encryption_support.accounts',
    ];

    /**
     * setUpBeforeClass method
     * setUpBeforeClassをオーバーライドする
     * @return void
     */
    public static function setUpBeforeClass(){
        //データベースの接続情報
        $info = [
            'className' => 'Cake\Database\Connection',
            'driver' => 'Cake\Database\Driver\Postgres',
            'persistent' => false,
            'host' => 'localhost',
            //'port' => 'nonstandard_port_number',
            'username' => 'postgres',
            'password' => '',
            'database' => 'cakephp_test',
            'encoding' => 'utf8',
            'timezone' => 'Asia/Tokyo',
            'cacheMetadata' => false,
            'quoteIdentifiers' => false,
        ];
        parent::setConnectionInfo($info);
        
        parent::setUpBeforeClass();
    }

    /**
     * setUp method
     *
     * @return void
     */
    public function setUp()
    {
        parent::setUp();
        //fixtureManagerを呼び出し、fixtureを実行する
        $this->fixtureManager->fixturize($this);
        $this->fixtureManager->loadSingle('Accounts');
    }
}