本文整理汇总了PHP中eZSys::setInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP eZSys::setInstance方法的具体用法?PHP eZSys::setInstance怎么用?PHP eZSys::setInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZSys
的用法示例。
在下文中一共展示了eZSys::setInstance方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testRunRegression
/**
* Runs the $file (.request file from $this->files) as a PHPUnit test.
*
* Steps performed:
* - setUp() is called automatically before this function
* - skip the test $file if declared. See {@link skip()}
* - load data from file, create eZSys instance and run init
* - check that misc os / vh variables where as expected
* - tearDown() is called automatically after this function
*
* @param string $file
*/
protected function testRunRegression( $file )
{
if ( $this->skip( $file ) )
return;
$testData = include $file;
$instance = new eZSys( $testData );
eZSys::setInstance( $instance );
eZSys::init();// 'index.php', strpos( $file, 'server/vh/' ) !== false );
// OS tests
if ( $testData['PHP_OS'] === 'WINNT' )
{
$os = 'Windows';
$this->assertEquals( "win32", $instance->OSType, "Did not get correct $os 'OSType' value" );
$this->assertEquals( "windows", $instance->OS, "Did not get correct $os 'OS' value" );
$this->assertEquals( "win32", $instance->FileSystemType, "Did not get correct $os 'FileSystemType' value" );
$this->assertEquals( "\\", $instance->FileSeparator, "Did not get correct $os 'FileSeparator' value" );
$this->assertEquals( "\r\n", $instance->LineSeparator, "Did not get correct $os 'LineSeparator' value" );
$this->assertEquals( ";", $instance->EnvSeparator, "Did not get correct $os 'EnvSeparator' value" );
$this->assertEquals( '"', $instance->ShellEscapeCharacter, "Did not get correct $os 'ShellEscapeCharacter' value" );
$this->assertEquals( '.bak', $instance->BackupFilename, "Did not get correct $os 'BackupFilename' value" );
}
else // unix (incl Darwin)
{
$os = 'Unix';
$this->assertEquals( "unix", $instance->OSType, "Did not get correct $os 'OSType' value" );
if ( $testData['PHP_OS'] === 'Linux' )
$this->assertEquals( "linux", $instance->OS, "Did not get correct $os 'OS' value" );
else if ( $testData['PHP_OS'] === 'FreeBSD' )
$this->assertEquals( "freebsd", $instance->OS, "Did not get correct $os 'OS' value" );
else if ( $testData['PHP_OS'] === 'Darwin' )
$this->assertEquals( "darwin", $instance->OS, "Did not get correct $os 'OS' value" );
else
$this->assertEquals( false, $instance->OS, "Did not get correct $os 'OS' value" );
$this->assertEquals( "unix", $instance->FileSystemType, "Did not get correct $os 'FileSystemType' value" );
$this->assertEquals( "/", $instance->FileSeparator, "Did not get correct $os 'FileSeparator' value" );
$this->assertEquals( "\n", $instance->LineSeparator, "Did not get correct $os 'LineSeparator' value" );
$this->assertEquals( ":", $instance->EnvSeparator, "Did not get correct $os 'EnvSeparator' value" );
$this->assertEquals( "'", $instance->ShellEscapeCharacter, "Did not get correct $os 'ShellEscapeCharacter' value" );
$this->assertEquals( '~', $instance->BackupFilename, "Did not get correct $os 'BackupFilename' value" );
}
// Uri test: vh / nvh part
if ( strpos( $file, 'server/nvh/' ) )
$expected = '/index.php';
else
$expected = '';
$this->assertEquals( $expected, $instance->IndexFile, "The IndexFile was not expected value" );
// Uri test: sub path part
if ( isset( $testData['__out']['WWWDir'] ) )
$wwwDir = $testData['__out']['WWWDir'];
elseif ( strpos( $testData['_SERVER']['SCRIPT_NAME'], 'index.php' ) !== false )// .htaccess or nvh
$wwwDir = rtrim( str_replace( 'index.php', '', $testData['_SERVER']['SCRIPT_NAME'] ), '\/' );
else
$wwwDir = '';
$this->assertEquals( $wwwDir, $instance->WWWDir, "The WWWDir was not expected value" );
$this->assertEquals( rtrim( str_replace( 'index.php', '', $testData['_SERVER']['SCRIPT_FILENAME'] ), '\/' ) . '/', $instance->SiteDir, "The SiteDir was not expected value" );
// Uri test: uri part
if ( isset( $testData['__out']['RequestURI'] ) )
$expected = $testData['__out']['RequestURI'];
else if ( strpos( $file, 'vh/utf8' ) )
$expected = '/News/Blåbær-Øl-med-d\'or-新闻军事社会体育中超';
elseif ( strpos( $file, 'vh/view' ) )
$expected = '/content/view/full/44';
else
$expected = '';
$this->assertEquals( $expected, $instance->RequestURI, "The RequestURI was not expected value" );
}
示例2: tearDown
public function tearDown()
{
// Make sure to restore eZSys instance in case other tests depends on it
eZSys::setInstance($this->oldSysInstance);
parent::tearDown();
}