yiiapi/tests/framework/web/auth/CDbAuthManagerTest.php

(完整代码) 1KB

<?php

require_once(dirname(__FILE__).'/AuthManagerTestBase.php');

class CDbAuthManagerTest extends AuthManagerTestBase
{
	private $db;

	public function setUp()
	{
		if(!extension_loaded('pdo') || !extension_loaded('pdo_pgsql'))
			$this->markTestSkipped('PDO and PostgreSQL extensions are required.');

		$schemaFile=realpath(Yii::getPathOfAlias('system.web.auth.schema-pgsql').'.sql');

		$this->db=new CDbConnection('pgsql:host=localhost;dbname=yii','test','test');
		try
		{
			$this->db->active=true;
		}
		catch(Exception $e)
		{
			$this->markTestSkipped("Please read $schemaFile for details on setting up the test environment for PostgreSQL test case.");
		}

		$sqls=preg_replace('/\/\*.*\*\//s', '', file_get_contents($schemaFile));
		foreach(explode(';',$sqls) as $sql)
		{
			if(trim($sql)!=='')
				$this->db->createCommand($sql)->execute();
		}
		$this->db->active=false;

		$this->auth=new CDbAuthManager;
		$this->auth->db=$this->db;
		$this->auth->init();
		$this->prepareData();
	}

	public function tearDown()
	{
		if($this->db)
			$this->db->active=false;
	}
}

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。