Browse Source

added new extension yii2-codeception, modified composer settings

tags/2.0.0-beta
Mark 11 years ago
parent
commit
1e24d60bcd
  1. 1
      apps/basic/composer.json
  2. 2
      composer.json
  3. 45
      extensions/codeception/BasePage.php
  4. 54
      extensions/codeception/TestCase.php

1
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": "*"
},

2
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/",

45
extensions/codeception/BasePage.php

@ -0,0 +1,45 @@
<?php
namespace yii\codeception;
class BasePage
{
// include url of current page
public static $URL = '';
/**
* Declare UI map for this page here. CSS or XPath allowed.
* public static $usernameField = '#username';
* public static $formSubmitButton = "#mainForm input[type=submit]";
*/
/**
* Basic route example for your current URL
* You can append any additional parameter to URL
* and use it in tests like: EditPage::route('/123-post');
*/
public static function route($param)
{
return static::$URL.$param;
}
/**
* @var
*/
protected $guy;
public function __construct($I)
{
$this->guy = $I;
}
/**
* @return $this
*/
public static function of($I)
{
return new static($I);
}
}

54
extensions/codeception/TestCase.php

@ -0,0 +1,54 @@
<?php
namespace yii\codeception;
use Yii;
class TestCase extends \PHPUnit_Framework_TestCase
{
/**
* Your application base config that will be used for creating application each time before test.
* This can be an array or alias, pointing to the config file. For example for console application it can be
* '@tests/unit/console_bootstrap.php' that can be similar to existing unit tests bootstrap file.
* @var mixed
*/
protected $baseConfig = '@tests/unit/_bootstrap.php';
/**
* Your application config, will be merged with base config when creating application. Can be an alias too.
* @var mixed
*/
protected $config = array();
/**
* Created application class
* @var string
*/
protected $appClass = '\yii\web\Application';
protected function setUp()
{
parent::setUp();
$this->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;
}
}
Loading…
Cancel
Save