本文整理汇总了PHP中ezcBaseFeatures::os方法的典型用法代码示例。如果您正苦于以下问题:PHP ezcBaseFeatures::os方法的具体用法?PHP ezcBaseFeatures::os怎么用?PHP ezcBaseFeatures::os使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ezcBaseFeatures
的用法示例。
在下文中一共展示了ezcBaseFeatures::os方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Constructs a handler object from the parameters $dbParams.
*
* Supported database parameters are:
* - dbname|database: Database name
* - port: If "memory" is used then the driver will use an
* in-memory database, and the database name is ignored.
*
* @throws ezcDbMissingParameterException if the database name was not specified.
* @param array $dbParams Database connection parameters (key=>value pairs).
*/
public function __construct($dbParams)
{
$database = false;
foreach ($dbParams as $key => $val) {
switch ($key) {
case 'database':
case 'dbname':
$database = $val;
if (!empty($database) && $database[0] != '/' && ezcBaseFeatures::os() != 'Windows') {
$database = '/' . $database;
}
break;
}
}
// If the "port" is set then we use "sqlite::memory:" as DSN, otherwise we fallback
// to the database name.
if (!empty($dbParams['port']) && $dbParams['port'] == 'memory') {
$dsn = "sqlite::memory:";
} else {
if ($database === false) {
throw new ezcDbMissingParameterException('database', 'dbParams');
}
$dsn = "sqlite:{$database}";
}
parent::__construct($dbParams, $dsn);
/* Register PHP implementations of missing functions in SQLite */
$this->sqliteCreateFunction('md5', array('ezcQuerySqliteFunctions', 'md5Impl'), 1);
$this->sqliteCreateFunction('mod', array('ezcQuerySqliteFunctions', 'modImpl'), 2);
$this->sqliteCreateFunction('locate', array('ezcQuerySqliteFunctions', 'positionImpl'), 2);
$this->sqliteCreateFunction('floor', array('ezcQuerySqliteFunctions', 'floorImpl'), 1);
$this->sqliteCreateFunction('ceil', array('ezcQuerySqliteFunctions', 'ceilImpl'), 1);
$this->sqliteCreateFunction('concat', array('ezcQuerySqliteFunctions', 'concatImpl'));
$this->sqliteCreateFunction('toUnixTimestamp', array('ezcQuerySqliteFunctions', 'toUnixTimestampImpl'), 1);
$this->sqliteCreateFunction('now', 'time', 0);
}
示例2: setUp
protected function setUp()
{
$this->dataDir = dirname(__FILE__) . "/data/" . (ezcBaseFeatures::os() === "windows" ? "windows" : "posix");
$this->phpPath = isset($_SERVER["_"]) ? $_SERVER["_"] : "/bin/env php";
$this->output = new ezcConsoleOutput();
$this->output->formats->test->color = "blue";
}
示例3: determinePhpPath
protected function determinePhpPath()
{
if (isset($_SERVER["_"])) {
$this->phpPath = $_SERVER["_"];
} else {
if (ezcBaseFeatures::os() === 'Windows') {
$this->phpPath = 'php.exe';
} else {
$this->phpPath = '/bin/env php';
}
}
}
示例4: testConstructFailureInvalidSettings
public function testConstructFailureInvalidSettings()
{
$conversionsIn = array("image/gif" => "image/png", "image/xpm" => "image/jpeg", "image/wbmp" => "image/jpeg");
if (ezcBaseFeatures::os() === 'Windows') {
unset($conversionsIn["image/xpm"]);
}
try {
$settings = new ezcImageConverterSettings(array(new stdClass()), $conversionsIn);
$converter = new ezcImageConverter($settings);
$this->fail('Exception not thrown on invalid handler settings.');
} catch (ezcImageHandlerSettingsInvalidException $e) {
}
}
示例5: testStatusbar2
public function testStatusbar2()
{
$out = new ezcConsoleOutput();
$out->options->useFormats = false;
$status = new ezcConsoleStatusbar($out);
ob_start();
foreach ($this->stati as $statusVal) {
$status->add($statusVal);
}
$res = ob_get_contents();
ob_end_clean();
$this->assertEquals(file_get_contents(dirname(__FILE__) . '/data/' . (ezcBaseFeatures::os() === "Windows" ? "windows/" : "posix/") . 'testStatusbar2.dat'), $res, "Unformated statusbar not generated correctly.");
// To prepare test files use this:
// file_put_contents( dirname( __FILE__ ) . '/data/' . ( ezcBaseFeatures::os() === "Windows" ? "windows/" : "posix/" ) . 'testStatusbar2.dat', $res );
}
示例6: setUp
protected function setUp()
{
try {
$this->testFiltersSuccess = array(0 => array(0 => new ezcImageFilter("scaleExact", array("width" => 50, "height" => 50, "direction" => ezcImageGeometryFilters::SCALE_BOTH)), 1 => new ezcImageFilter("crop", array("x" => 10, "width" => 30, "y" => 10, "height" => 30)), 2 => new ezcImageFilter("colorspace", array("space" => ezcImageColorspaceFilters::COLORSPACE_GREY))), 1 => array(0 => new ezcImageFilter("scale", array("width" => 50, "height" => 1000, "direction" => ezcImageGeometryFilters::SCALE_DOWN)), 2 => new ezcImageFilter("colorspace", array("space" => ezcImageColorspaceFilters::COLORSPACE_MONOCHROME))), 2 => array(0 => new ezcImageFilter("scaleHeight", array("height" => 70, "direction" => ezcImageGeometryFilters::SCALE_BOTH)), 2 => new ezcImageFilter("colorspace", array("space" => ezcImageColorspaceFilters::COLORSPACE_SEPIA))), 3 => array(0 => new ezcImageFilter("scale", array("width" => 50, "height" => 50))));
$this->testFiltersFailure = array(0 => array(0 => new ezcImageFilter("toby", array("width" => 50, "height" => 50, "direction" => ezcImageGeometryFilters::SCALE_BOTH)), 1 => new ezcImageFilter("crop", array("x" => 10, "width" => 30, "y" => 10, "height" => 30)), 2 => new ezcImageFilter("colorspace", array("space" => ezcImageColorspaceFilters::COLORSPACE_GREY))), 1 => array(0 => new ezcImageFilter("scale", array()), 2 => new ezcImageFilter("colorspace", array("space" => ezcImageColorspaceFilters::COLORSPACE_MONOCHROME))));
$conversionsIn = array("image/gif" => "image/png", "image/xpm" => "image/jpeg", "image/wbmp" => "image/jpeg");
if (ezcBaseFeatures::os() === 'Windows') {
unset($conversionsIn["image/xpm"]);
}
$settings = new ezcImageConverterSettings(array(new ezcImageHandlerSettings("GD", "ezcImageGdHandler")), $conversionsIn);
$this->converter = new ezcImageConverter($settings);
} catch (Exception $e) {
$this->markTestSkipped($e->getMessage());
}
}
示例7: testProgressMonitor4
public function testProgressMonitor4()
{
$out = new ezcConsoleOutput();
$out->formats->tag->color = 'red';
$out->formats->percent->color = 'blue';
$out->formats->percent->style = array('bold');
$out->formats->data->color = 'green';
$status = new ezcConsoleProgressMonitor($out, 7, array('formatString' => $out->formatText('%2$10s', 'tag') . ' ' . $out->formatText('%1$6.2f%%', 'percent') . ' ' . $out->formatText('%3$s', 'data')));
ob_start();
for ($i = 0; $i < 7; $i++) {
$status->addEntry($this->stati[$i][0], $this->stati[$i][1]);
}
$res = ob_get_contents();
ob_end_clean();
// To prepare test files use this:
// file_put_contents( dirname( __FILE__ ) . '/data/' . ( ezcBaseFeatures::os() === "Windows" ? "windows/" : "posix/" ) . 'testProgressMonitor4.dat', $res );
$this->assertEquals(file_get_contents(dirname(__FILE__) . '/data/' . (ezcBaseFeatures::os() === "Windows" ? "windows/" : "posix/") . 'testProgressMonitor4.dat'), $res, "Formated statusbar not generated correctly.");
}
示例8: __construct
/**
* Constructs a handler object from the parameters $dbParams.
*
* Supported database parameters are:
* - dbname|database: Database name
* - host|hostspec: Name of the host database is running on
* - port: TCP port
* - user|username: Database user name
* - pass|password: Database user password
*
* @param mixed $dbParams Database connection parameters (key=>value pairs).
* @throws ezcDbMissingParameterException if the database name was not specified.
*/
public function __construct($dbParams)
{
if ($dbParams instanceof PDO) {
parent::__construct($dbParams);
return;
}
$database = null;
$host = null;
$port = null;
foreach ($dbParams as $key => $val) {
switch ($key) {
case 'database':
case 'dbname':
$database = $val;
break;
case 'host':
case 'hostspec':
$host = $val;
break;
case 'port':
$port = $val;
break;
}
}
if (!isset($database)) {
throw new ezcDbMissingParameterException('database', 'dbParams');
}
if (ezcBaseFeatures::os() === 'Windows') {
$dsn = "mssql:dbname={$database}";
} else {
// uses FreeTDS
$dsn = "dblib:dbname={$database}";
}
if (isset($host) && $host) {
$dsn .= ";host={$host}";
if (isset($port) && $port) {
$dsn .= ":{$port}";
}
}
$db = parent::createPDO($dbParams, $dsn);
parent::__construct($db);
// setup options
$this->setOptions(new ezcDbMssqlOptions());
}
示例9: testTempDirNonWindows
/**
* Test for bug #12844.
*/
public function testTempDirNonWindows()
{
if (ezcBaseFeatures::os() === 'Windows') {
self::markTestSkipped('Test is for non-Windows only');
}
ezcMailParser::setTmpDir(null);
$this->assertEquals('/tmp/', ezcMailParser::getTmpDir());
}
示例10: testOutputTextAutobreak
/**
* testOutputTextAutobreak
*
* @access public
*/
public function testOutputTextAutobreak()
{
$this->consoleOutput->options->autobreak = 20;
$testText = 'Some text which is obviously longer than 20 characters and should be broken.';
$testResText = <<<EOT
Some text which is
obviously longer
than 20 characters
and should be
broken.
EOT;
foreach ($this->testFormats as $name => $inout) {
ob_start();
$this->consoleOutput->outputText($testText, $name);
$realRes = ob_get_contents();
ob_end_clean();
$fakeRes = ezcBaseFeatures::os() !== "Windows" ? sprintf($inout['out'], $testResText) : $testResText;
$this->assertEquals($fakeRes, $realRes, 'Test "' . $name . ' failed. String <' . $realRes . '> (real) is not equal to <' . $fakeRes . '> (fake).');
}
}
示例11: assertTableOutputEquals
protected function assertTableOutputEquals($expectedRef, $actualContent)
{
$refFile = dirname(__FILE__) . '/data/' . (ezcBaseFeatures::os() === "Windows" ? "windows/" : "posix/") . $expectedRef . '.dat';
// To prepare test files, uncomment this block
// file_put_contents( $refFile, $actualContent );
if (!file_exists($refFile)) {
// Default assert for new files.
$this->assertEquals('', $actualContent, "Asserted against empty string, since reference file '{$refFile}' does not exist.");
} else {
$this->assertEquals(file_get_contents($refFile), $actualContent, 'Table not correctly generated for ' . $expectedRef . '.');
}
}
示例12: reset
/**
* Reset the cached information.
*
* @return void
* @access private
* @ignore
*/
public static function reset()
{
self::$imageIdentify = null;
self::$imageConvert = null;
self::$os = null;
}
示例13: testCannotReadCompiled
public function testCannotReadCompiled()
{
if (ezcBaseFeatures::os() === 'Windows') {
self::markTestSkipped('Test is for non-Windows only - permission system is not the same on Windows.');
}
$temp = $this->createTempDir("ezcTemplate");
file_put_contents($temp . "/myFile", "bla");
chmod($temp . "/myFile", 0200);
// Write only for the owner of the file.
$conf = new ezcTemplateCompiledCode('8efb', $temp . "/myFile");
$conf->template = new ezcTemplate();
$conf->context = new ezcTemplateXhtmlContext();
try {
$conf->execute();
self::fail("No exception thrown");
} catch (ezcTemplateInvalidCompiledFileException $e) {
}
$this->removeTempDir();
}
示例14: testSqliteDSN4
public function testSqliteDSN4()
{
if (!ezcBaseFeatures::hasExtensionSupport('pdo_sqlite') || ezcBaseFeatures::os() !== 'Windows') {
$this->markTestSkipped('Windows only test');
return;
}
$db = ezcDbFactory::create('sqlite:///c:\\tmp\\foo.sqlite');
$this->assertEquals(true, file_exists('c:\\tmp\\foo.sqlite'));
unlink('c:\\tmp\\foo.sqlite');
}
示例15: os
/**
* Returns the operating system on which PHP is running.
*
* This method returns a sanitized form of the OS name, example
* return values are "Windows", "Mac", "Linux" and "FreeBSD". In
* all other cases it returns the value of the internal PHP constant
* PHP_OS.
*
* @return string
*/
public static function os()
{
if (is_null(self::$os)) {
$uname = php_uname('s');
if (substr($uname, 0, 7) == 'Windows') {
self::$os = 'Windows';
} elseif (substr($uname, 0, 3) == 'Mac') {
self::$os = 'Mac';
} elseif (strtolower($uname) == 'linux') {
self::$os = 'Linux';
} elseif (strtolower(substr($uname, 0, 7)) == 'freebsd') {
self::$os = 'FreeBSD';
} else {
self::$os = PHP_OS;
}
}
return self::$os;
}