-
Notifications
You must be signed in to change notification settings - Fork 3
/
AbstractTestCase.php
46 lines (40 loc) · 1.44 KB
/
AbstractTestCase.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php declare(strict_types=1);
namespace My;
use Lmc\Steward\ConfigProvider;
/**
* Abstract class for custom tests, could eg. define some properties or instantiate some common components
* using @before annotated methods.
*/
abstract class AbstractTestCase extends \Lmc\Steward\Test\AbstractTestCase
{
/** @var int Default width of browser window (Steward's default is 1280) */
public const BROWSER_WIDTH = 1024;
/** @var int Default height of browser window (Steward's default is 1024) */
public const BROWSER_HEIGHT = 768;
/** @var string */
public static $baseUrl;
/**
* @before
*/
public function initBaseUrl()
{
// Set base url according to environment
switch (ConfigProvider::getInstance()->env) {
case 'production':
self::$baseUrl = 'https://www.w3.org/';
break;
case 'staging':
self::$baseUrl = 'http://some-staging-url/';
break;
case 'local':
self::$baseUrl = 'http://localhost/';
break;
default:
throw new \RuntimeException(sprintf('Unknown environment "%s"', ConfigProvider::getInstance()->env));
}
$this->debug('Base URL set to "%s"', self::$baseUrl);
if (ConfigProvider::getInstance()->env === 'production') {
$this->warn('The tests are run against production, so be careful!');
}
}
}