From 2e9a0839ddf330d2d88d7506b5a4ac206374631e Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Sun, 24 Aug 2014 15:26:57 +0400 Subject: [PATCH] Added faker to basic app console commands, adjusted readme to mention database setup --- tests/README.md | 26 +++++++++++++++++++++++--- tests/codeception/bin/yii_acceptance | 7 +++++++ tests/codeception/bin/yii_functional | 7 +++++++ tests/codeception/bin/yii_unit | 7 +++++++ tests/codeception/fixtures/.gitignore | 2 ++ tests/codeception/templates/.gitignore | 2 ++ 6 files changed, 48 insertions(+), 3 deletions(-) create mode 100644 tests/codeception/fixtures/.gitignore create mode 100644 tests/codeception/templates/.gitignore diff --git a/tests/README.md b/tests/README.md index 1c4b50b..34439f8 100644 --- a/tests/README.md +++ b/tests/README.md @@ -21,20 +21,40 @@ Changed current directory to Then add `/vendor/bin` to you `PATH` environment variable. Now we're able to use `codecept` from command line globally. -2. Build the test suites: +2. Install faker extension by running the following from template root directory where `composer.json` is: + +``` +composer require --dev yiisoft/yii2-faker:* +``` + +3. Create three databases that are used in tests: + +* `yii2_basic_unit` - for unit tests; +* `yii2_basic_functional` - for functional tests; +* `yii2_basic_acceptance` - for acceptance tests. + +Then update databases by applying migrations: + +``` +codeception/bin/yii_acceptance migrate +codeception/bin/yii_functional migrate +codeception/bin/yii_unit migrate +``` + +4. Build the test suites: ``` codecept build ``` -3. In order to be able to run acceptance tests you need to start a webserver. The simplest way is to use PHP built in +5. In order to be able to run acceptance tests you need to start a webserver. The simplest way is to use PHP built in webserver. In the `web` directory execute the following: ``` php -S localhost:8080 ``` -4. Now you can run the tests with the following commands: +6. Now you can run the tests with the following commands: ``` # run all available tests diff --git a/tests/codeception/bin/yii_acceptance b/tests/codeception/bin/yii_acceptance index f67a47f..99ac417 100644 --- a/tests/codeception/bin/yii_acceptance +++ b/tests/codeception/bin/yii_acceptance @@ -14,6 +14,13 @@ $config = yii\helpers\ArrayHelper::merge( require(YII_APP_BASE_PATH . '/config/console.php'), require(__DIR__ . '/../config/config.php'), [ + 'controllerMap' => [ + 'fixture' => [ + 'class' => 'yii\faker\FixtureController', + 'fixtureDataPath' => dirname(__DIR__) . 'fixtures', + 'templatePath' => dirname(__DIR__) . 'templates' + ], + ], 'components' => [ 'db' => [ 'dsn' => 'mysql:host=localhost;dbname=yii2_basic_acceptance', diff --git a/tests/codeception/bin/yii_functional b/tests/codeception/bin/yii_functional index f6e3988..39efa98 100644 --- a/tests/codeception/bin/yii_functional +++ b/tests/codeception/bin/yii_functional @@ -14,6 +14,13 @@ $config = yii\helpers\ArrayHelper::merge( require(YII_APP_BASE_PATH . '/config/console.php'), require(__DIR__ . '/../config/config.php'), [ + 'controllerMap' => [ + 'fixture' => [ + 'class' => 'yii\faker\FixtureController', + 'fixtureDataPath' => dirname(__DIR__) . 'fixtures', + 'templatePath' => dirname(__DIR__) . 'templates' + ], + ], 'components' => [ 'db' => [ 'dsn' => 'mysql:host=localhost;dbname=yii2_basic_functional', diff --git a/tests/codeception/bin/yii_unit b/tests/codeception/bin/yii_unit index 1ab8e1f..f99ec53 100644 --- a/tests/codeception/bin/yii_unit +++ b/tests/codeception/bin/yii_unit @@ -14,6 +14,13 @@ $config = yii\helpers\ArrayHelper::merge( require(YII_APP_BASE_PATH . '/config/console.php'), require(__DIR__ . '/../config/config.php'), [ + 'controllerMap' => [ + 'fixture' => [ + 'class' => 'yii\faker\FixtureController', + 'fixtureDataPath' => dirname(__DIR__) . 'fixtures', + 'templatePath' => dirname(__DIR__) . 'templates' + ], + ], 'components' => [ 'db' => [ 'dsn' => 'mysql:host=localhost;dbname=yii2_basic_unit', diff --git a/tests/codeception/fixtures/.gitignore b/tests/codeception/fixtures/.gitignore new file mode 100644 index 0000000..c96a04f --- /dev/null +++ b/tests/codeception/fixtures/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore \ No newline at end of file diff --git a/tests/codeception/templates/.gitignore b/tests/codeception/templates/.gitignore new file mode 100644 index 0000000..c96a04f --- /dev/null +++ b/tests/codeception/templates/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore \ No newline at end of file