From 1e24d60bcd5fa2a483f1ad92fcc0e97e75430946 Mon Sep 17 00:00:00 2001 From: Mark Date: Fri, 13 Dec 2013 19:38:25 +0400 Subject: [PATCH] added new extension yii2-codeception, modified composer settings --- apps/basic/composer.json | 1 + composer.json | 2 ++ extensions/codeception/BasePage.php | 45 +++++++++++++++++++++++++++++++ extensions/codeception/TestCase.php | 54 +++++++++++++++++++++++++++++++++++++ 4 files changed, 102 insertions(+) create mode 100644 extensions/codeception/BasePage.php create mode 100644 extensions/codeception/TestCase.php diff --git a/apps/basic/composer.json b/apps/basic/composer.json index a794341..a248d05 100644 --- a/apps/basic/composer.json +++ b/apps/basic/composer.json @@ -18,6 +18,7 @@ "yiisoft/yii2": "*", "yiisoft/yii2-swiftmailer": "*", "yiisoft/yii2-bootstrap": "*", + "yiisoft/yii2-codeception": "*", "yiisoft/yii2-debug": "*", "yiisoft/yii2-gii": "*" }, diff --git a/composer.json b/composer.json index ad521cc..994cd10 100644 --- a/composer.json +++ b/composer.json @@ -51,6 +51,7 @@ "minimum-stability": "dev", "replace": { "yiisoft/yii2-bootstrap": "self.version", + "yiisoft/yii2-codeception": "self.version", "yiisoft/yii2-debug": "self.version", "yiisoft/yii2-elasticsearch": "self.version", "yiisoft/yii2-gii": "self.version", @@ -79,6 +80,7 @@ "autoload": { "psr-0": { "yii\\bootstrap\\": "extensions/bootstrap/", + "yii\\codeception\\": "extensions/codeception/", "yii\\debug\\": "extensions/debug/", "yii\\elasticsearch\\": "extensions/elasticsearch/", "yii\\gii\\": "extensions/gii/", diff --git a/extensions/codeception/BasePage.php b/extensions/codeception/BasePage.php new file mode 100644 index 0000000..ae976a7 --- /dev/null +++ b/extensions/codeception/BasePage.php @@ -0,0 +1,45 @@ +guy = $I; + } + + /** + * @return $this + */ + public static function of($I) + { + return new static($I); + } + +} diff --git a/extensions/codeception/TestCase.php b/extensions/codeception/TestCase.php new file mode 100644 index 0000000..e340185 --- /dev/null +++ b/extensions/codeception/TestCase.php @@ -0,0 +1,54 @@ +mockApplication(); + } + + protected function tearDown() + { + $this->destroyApplication(); + parent::tearDown(); + } + + protected function mockApplication() + { + $baseConfig = is_array($this->baseConfig)? $this->baseConfig : require(Yii::getAlias($this->baseConfig, true)); + $config = is_array($this->config)? $this->config : require(Yii::getAlias($this->config, true)); + new $this->appClass(\yii\helpers\ArrayHelper::merge($baseConfig,$config)); + } + + protected function destroyApplication() + { + \Yii::$app = null; + } + +}