2017 © Pedro Peláez
 

yii2-extension yii2-pgsqltester

Extends Yii2 framework with a powerful console controller for tests requiring a postgres database.

image

branchonline/yii2-pgsqltester

Extends Yii2 framework with a powerful console controller for tests requiring a postgres database.

  • Sunday, March 26, 2017
  • by JapMul
  • Repository
  • 2 Watchers
  • 0 Stars
  • 521 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 1 Open issues
  • 13 Versions
  • 4 % Grown

The README.md

Yii2 PostgreSQL automated testing setup

Automated setup of empty database and powerful console control of available tests., (*1)

Example usage

First set up the environment using the instructions in example setup below., (*2)

Run all tests:, (*3)

./yii_test test/run or ./yii_test test (action run is default), (*4)

Run all unit tests using (only when you are not using modules, otherwise you have to specify the module):, (*5)

./yii_test test -s=unit, (*6)

Run all unit tests in module admin using:, (*7)

./yii_test test -m=admin, (*8)

Run all unit tests in module admin from suite acceptance:, (*9)

./yii_test test -s=acceptance -m=admin, (*10)

Run specific test by name:, (*11)

./yii_test test TestName, (*12)

Force to remigrate the test database:, (*13)

./yii_test test/prepare-db true, (*14)

Example setup

Read carefully and make sure you understand what you're doing before setting anything up!, (*15)

Databases

This package provides a clean separation of databases so your tests can always run on an empty database that is in the correct state. To see how it works we identify 4 databases: - The dev database. This database is not touched by the testing mechanism, but should remain accessible for developing. - The template database. This is the database that is migrated to the correct version by the testing system, and may contain all kinds of data that your migrations add by default. - The test databse. This is the database that the actual tests run on. It is prepared by the testing mechanism to be a completely empty copy of the template database. - The postgres databse. This is the default database provided by postgres, that is used by the tester to automatically setup both template and test database., (*16)

Yii setup

You need 2 config files for this setup to work: - test.php should contain credentials for the postgres and test database. - test-setup.php should overwrite the credentials of test with that of template and make the test controller available through the controller map., (*17)

An example for test.php:, (*18)

<?php
return [
    'id' => 'basic-tests',
    'basePath' => dirname(__DIR__),
    'language' => 'en-US',
    'components' => [
        'config_db' => [
            'class' => 'yii\db\Connection',
            'dsn' => 'pgsql:host=localhost;port=5432;dbname=postgres',
        ],
        'db' => [
            'class' => 'yii\db\Connection',
            'dsn' => 'pgsql:host=localhost;port=5432;dbname=testing',
        ],
    ],
];

An example for test-setup.php", (*19)

<?php
return [
    'components' => [
        'db' => [
            'dsn' => 'pgsql:host=localhost;port=5432;dbname=testing_template'
        ],
    ],
    'controllerMap' => [
        'test' => [
            'class' => 'branchonline\pgsqltester\TestController',
        ]
    ],
];

Make sure you have a access point for running the tests, for instance ./yii_test., (*20)

yii_test example (adjust to your liking):, (*21)

<?php

defined('YII_DEBUG') or define('YII_DEBUG', true);
defined('YII_ENV') or define('YII_ENV', 'test');

require(__DIR__ . '/vendor/autoload.php');
require(__DIR__ . '/vendor/yiisoft/yii2/Yii.php');

$config = yii\helpers\ArrayHelper::merge(
    require(__DIR__ . '/path/to/test.php'),
    require(__DIR__ . '/path/to/test-setup.php')
);

$application = new yii\console\Application($config);
$exitCode = $application->run();
exit($exitCode);

Make sure the YII_ENV is initialized to 'test'. Also make sure you include test-setup.php and test.php in that order., (*22)

Codeception setup

Codeception is run using the codeception.yml file as configuration, make sure to configure the Yii module and include test.php as the access point., (*23)

modules:
    config:
        Yii2:
            configFile: 'path/to/test.php'

The Versions

26/03 2017

dev-master

9999999-dev

Extends Yii2 framework with a powerful console controller for tests requiring a postgres database.

  Sources   Download

BSD-3-Clause

The Requires

 

by Roelof Ruis

test testing postgresql postgres yii2 pgsql codeception

16/03 2017

1.0.9

1.0.9.0

Extends Yii2 framework with a powerful console controller for tests requiring a postgres database.

  Sources   Download

BSD-3-Clause

The Requires

 

by Roelof Ruis

test testing postgresql postgres yii2 pgsql codeception

06/03 2017

dev-verbose

dev-verbose

Extends Yii2 framework with a powerful console controller for tests requiring a postgres database.

  Sources   Download

BSD-3-Clause

The Requires

 

by Roelof Ruis

test testing postgresql postgres yii2 pgsql codeception

27/02 2017

1.0.8

1.0.8.0

Extends Yii2 framework with a powerful console controller for tests requiring a postgres database.

  Sources   Download

BSD-3-Clause

The Requires

 

by Roelof Ruis

test testing postgresql postgres yii2 pgsql codeception

27/02 2017

1.08

1.08.0.0

Extends Yii2 framework with a powerful console controller for tests requiring a postgres database.

  Sources   Download

BSD-3-Clause

The Requires

 

by Roelof Ruis

test testing postgresql postgres yii2 pgsql codeception

17/02 2017

1.0.7

1.0.7.0

Extends Yii2 framework with a powerful console controller for tests requiring a postgres database.

  Sources   Download

BSD-3-Clause

The Requires

 

by Roelof Ruis

test testing postgresql postgres yii2 pgsql codeception

16/02 2017

1.0.6

1.0.6.0

Extends Yii2 framework with a powerful console controller for tests requiring a postgres database.

  Sources   Download

BSD-3-Clause

The Requires

 

by Roelof Ruis

test testing postgresql postgres yii2 pgsql codeception

09/02 2017

1.0.5

1.0.5.0

Extends Yii2 framework with a powerful console controller for tests requiring a postgres database.

  Sources   Download

BSD-3-Clause

The Requires

 

by Roelof Ruis

test testing postgresql postgres yii2 pgsql codeception

23/01 2017

1.0.4

1.0.4.0

Extends Yii2 framework with a powerful console controller for tests requiring a postgres database.

  Sources   Download

BSD-3-Clause

The Requires

 

by Roelof Ruis

test testing postgresql postgres yii2 pgsql codeception

20/01 2017

1.0.3

1.0.3.0

Extends Yii2 framework with a powerful console controller for tests requiring a postgres database.

  Sources   Download

BSD-3-Clause

The Requires

 

by Roelof Ruis

test testing postgresql postgres yii2 pgsql codeception

20/01 2017

1.0.2

1.0.2.0

Extends Yii2 framework with a powerful console controller for tests requiring a postgres database.

  Sources   Download

BSD-3-Clause

The Requires

 

by Roelof Ruis

test testing postgresql postgres yii2 pgsql codeception

19/01 2017

1.0.1

1.0.1.0

Extends Yii2 framework with a powerful console controller for tests requiring a postgres database.

  Sources   Download

BSD-3-Clause

The Requires

 

by Roelof Ruis

test testing postgresql postgres yii2 pgsql codeception

17/01 2017

1.0

1.0.0.0

Extends Yii2 framework with a powerful console controller for tests requiring a postgres database.

  Sources   Download

BSD-3-Clause

The Requires

 

by Roelof Ruis

test testing postgresql postgres yii2 pgsql codeception