BasePage.php 1.02 KB
Newer Older
1 2 3 4
<?php

namespace yii\codeception;

5
/**
6 7 8 9 10 11
 * Represents a web page to test
 *
 * Pages extend from this class and declare UI map for this page via
 * static properties. CSS or XPath allowed.
 *
 * Here is an example:
12
 *
13
 * ```php
14 15
 * public static $usernameField = '#username';
 * public static $formSubmitButton = "#mainForm input[type=submit]";
16
 * ```
17 18 19 20 21
 *
 * @author Mark Jebri <mark.github@yandex.ru>
 * @since 2.0
 */
abstract class BasePage
22
{
23 24 25
	/**
	 * @var string include url of current page. This property has to be overwritten by subclasses
	 */
26 27
	public static $URL = '';
	/**
28
	 * @var \Codeception\AbstractGuy
29
	 */
30 31 32 33 34 35
	protected $guy;

	public function __construct($I)
	{
		$this->guy = $I;
	}
36 37 38 39 40 41 42 43 44 45 46 47

	/**
	 * 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;
	}

	/**
48 49
	 * @param $I
	 * @return static
50 51 52 53 54 55
	 */
	public static function of($I)
	{
		return new static($I);
	}
}