|
- <?php
-
-
- namespace yii\codeception;
-
- use Yii;
- use yii\base\Component;
- use yii\base\InvalidConfigException;
-
-
- abstract class BasePage extends Component
- {
-
-
- public $route;
-
-
-
- protected $actor;
-
-
-
-
- public function __construct($I)
- {
- $this->actor = $I;
- }
-
-
-
- public function getUrl($params = [])
- {
- if (is_string($this->route)) {
- $params[0] = $this->route;
-
- return Yii::$app->getUrlManager()->createUrl($params);
- } elseif (is_array($this->route) && isset($this->route[0])) {
- return Yii::$app->getUrlManager()->createUrl(array_merge($this->route, $params));
- } else {
- throw new InvalidConfigException('The "route" property must be set.');
- }
- }
-
-
-
- public static function openBy($I, $params = [])
- {
- $page = new static($I);
- $I->amOnPage($page->getUrl($params));
-
- return $page;
- }
- }
|