BaseYiiTest.php 1.58 KB
Newer Older
Alexander Makarov committed
1 2 3
<?php
namespace yiiunit\framework;

4
use Yii;
Alexander Makarov committed
5 6 7
use yiiunit\TestCase;

/**
8
 * BaseYiiTest
9
 * @group base
Alexander Makarov committed
10
 */
11
class BaseYiiTest extends TestCase
Alexander Makarov committed
12
{
13 14
	public $aliases;

Carsten Brandt committed
15
	protected function setUp()
16
	{
Carsten Brandt committed
17
		parent::setUp();
18 19 20
		$this->aliases = Yii::$aliases;
	}

Carsten Brandt committed
21
	protected function tearDown()
22
	{
Carsten Brandt committed
23
		parent::tearDown();
24 25 26
		Yii::$aliases = $this->aliases;
	}

Alexander Makarov committed
27 28
	public function testAlias()
	{
29 30
		$this->assertEquals(YII_PATH, Yii::getAlias('@yii'));

Alexander Makarov committed
31
		Yii::$aliases = [];
32 33 34 35 36 37 38 39 40 41 42 43 44
		$this->assertFalse(Yii::getAlias('@yii', false));

		Yii::setAlias('@yii', '/yii/framework');
		$this->assertEquals('/yii/framework', Yii::getAlias('@yii'));
		$this->assertEquals('/yii/framework/test/file', Yii::getAlias('@yii/test/file'));
		Yii::setAlias('@yii/gii', '/yii/gii');
		$this->assertEquals('/yii/framework', Yii::getAlias('@yii'));
		$this->assertEquals('/yii/framework/test/file', Yii::getAlias('@yii/test/file'));
		$this->assertEquals('/yii/gii', Yii::getAlias('@yii/gii'));
		$this->assertEquals('/yii/gii/file', Yii::getAlias('@yii/gii/file'));

		Yii::setAlias('@tii', '@yii/test');
		$this->assertEquals('/yii/framework/test', Yii::getAlias('@tii'));
Alexander Makarov committed
45

46 47 48
		Yii::setAlias('@yii', null);
		$this->assertFalse(Yii::getAlias('@yii', false));
		$this->assertEquals('/yii/gii/file', Yii::getAlias('@yii/gii/file'));
Qiang Xue committed
49 50 51

		Yii::setAlias('@some/alias', '/www');
		$this->assertEquals('/www', Yii::getAlias('@some/alias'));
Alexander Makarov committed
52 53 54 55 56 57 58 59 60
	}

	public function testGetVersion()
	{
		$this->assertTrue((boolean)preg_match('~\d+\.\d+(?:\.\d+)?(?:-\w+)?~', \Yii::getVersion()));
	}

	public function testPowered()
	{
61
		$this->assertTrue(is_string(Yii::powered()));
Alexander Makarov committed
62 63
	}
}