Last active
August 29, 2015 14:11
-
-
Save tanakahisateru/3e5483ca0c15837ca29f to your computer and use it in GitHub Desktop.
Yii2のAcceptanceなしテストこんな構成にしてみた
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
. | |
├── codeception | |
│ ├── _output | |
│ ├── _support | |
│ │ └── FixtureLoader.php --- フィクスチャ全部ロードするやつ | |
│ ├── bin | |
│ │ ├── _bootstrap.php | |
│ │ ├── yii | |
│ │ └── yii.bat | |
│ ├── config | |
│ │ ├── config.php | |
│ │ ├── functional.php --- $config['components']['log']['targets'] = [] してログを吐かせないように | |
│ │ └── unit.php --- 上と同じ | |
│ ├── fixtures --- 共通のフィクスチャ | |
│ │ ├── UserFixture.php | |
│ │ ├── data --- templatesから生成したdataはgit addしちゃう。 | |
│ │ │ └── user.php | |
│ │ └── templates --- yiit fixture/generate-all で Faker -> data 生成 | |
│ │ ├── README.md --- これは data を書き換えちゃうためのソースなので注意って書いてある | |
│ │ └── user.php | |
│ ├── functional | |
│ │ ├── FunctionalTester.php --- codecept build で生成 | |
│ │ ├── _bootstrap.php | |
│ │ ├── _pages | |
│ │ │ └── group_a | |
│ │ │ └── LoginPage.php | |
│ │ ├── fixture-map.php --- functional.suite.yml で設定して _support/FixtureLoader にこれを読ませてる | |
│ │ └── group_a | |
│ │ └── LoginCept.php | |
│ ├── unit | |
│ │ ├── UnitTester.php --- codecept build で生成 | |
│ │ ├── _bootstrap.php | |
│ │ └── group_a | |
│ │ └── LoginFormTest.php --- UserFixture だけ個別にロードしてテスト | |
│ ├── _bootstrap.php | |
│ ├── functional.suite.yml | |
│ └── unit.suite.yml | |
├── README.md | |
├── codeception.yml | |
├── codecept -> ../vendor/codeception/codeception/codecept | |
└── yiit -> codeception/bin/yii |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
actor: Tester | |
paths: | |
tests: codeception | |
log: codeception/_output | |
data: codeception/_data | |
helpers: codeception/_support | |
settings: | |
bootstrap: _bootstrap.php | |
suite_class: \PHPUnit_Framework_TestSuite | |
memory_limit: 1024M | |
log: true | |
colors: true | |
config: | |
# the entry script URL (without host info) for functional and acceptance tests | |
# PLEASE ADJUST IT TO THE ACTUAL ENTRY SCRIPT URL | |
test_entry_url: /index-test.php |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
return [ | |
'user_student' => [ | |
'class' => 'tests\codeception\fixtures\UserStudentFixture', | |
'dataFile' => '@tests/codeception/fixtures/data/user_student.php', | |
], | |
// ファンクショナルテスト時に一括ロードしたいフィクスチャはここに登録 | |
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace tests\codeception\_support; | |
use Codeception\Module; | |
use yii\test\FixtureTrait; | |
class FixtureLoader extends Module | |
{ | |
use FixtureTrait; | |
protected $config = [ | |
'mappingPath' => '@tests/fixture-map.php', // 要カスタマイズ | |
]; | |
public function _beforeSuite($settings = []) | |
{ | |
$this->loadFixtures(); | |
} | |
public function _afterSuite() | |
{ | |
$this->unloadFixtures(); | |
} | |
public function fixtures() | |
{ | |
/** @noinspection PhpIncludeInspection */ | |
return require \Yii::getAlias($this->config['mappingPath']); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class_name: FunctionalTester | |
modules: | |
enabled: | |
- Filesystem | |
- Yii2 | |
- tests\codeception\_support\FixtureLoader | |
config: | |
Yii2: | |
configFile: 'codeception/config/functional.php' | |
tests\codeception\_support\FixtureLoader: | |
mappingPath: '@tests/codeception/functional/fixture-map.php' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment