本文整理汇总了PHP中ezcBaseFeatures类的典型用法代码示例。如果您正苦于以下问题:PHP ezcBaseFeatures类的具体用法?PHP ezcBaseFeatures怎么用?PHP ezcBaseFeatures使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ezcBaseFeatures类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getDriver
/**
* Get driver to test
*
* @return ezcDocumentPdfDriver
*/
protected function getDriver()
{
if (!ezcBaseFeatures::hasExtensionSupport('haru')) {
$this->markTestSkipped('This test requires pecl/haru installed.');
}
return new ezcDocumentPdfHaruDriver();
}
示例2: __construct
/**
* Construct converter
*
* Construct converter from XSLT file, which is used for the actual
* conversion.
*
* @param ezcDocumentXsltConverterOptions $options
* @return void
*/
public function __construct(ezcDocumentXsltConverterOptions $options = null)
{
if (!ezcBaseFeatures::hasExtensionSupport('xsl')) {
throw new ezcBaseExtensionNotFoundException('xsl');
}
parent::__construct($options === null ? new ezcDocumentXsltConverterOptions() : $options);
}
示例3: setup
protected function setup()
{
if (!self::$stackInitialized) {
if (ezcBaseFeatures::hasExtensionSupport('apc')) {
$memoryStorage = new ezcCacheStorageApcPlain();
} else {
if (ezcBaseFeatures::hasExtensionSupport('memcache')) {
$memoryStorage = new ezcCacheStorageMemcachePlain('foo');
} else {
$this->markTestSkipped('APC or Memcached needed to run this test.');
}
}
// Start cleanly
$memoryStorage->reset();
$tmpDir = $this->createTempDir(__CLASS__);
$tmpDirEvalArray = "{$tmpDir}/plain";
$tmpDirArray = "{$tmpDir}/array";
mkdir($tmpDirEvalArray);
mkdir($tmpDirArray);
$fileStorageEvalArray = new ezcCacheStorageFileEvalArray($tmpDirEvalArray);
$fileStorageArray = new ezcCacheStorageFileArray($tmpDirArray);
ezcCacheStackTestConfigurator::reset();
ezcCacheStackTestConfigurator::$storages = array(new ezcCacheStackStorageConfiguration('eval_array_storage', $fileStorageEvalArray, 10, 0.8), new ezcCacheStackStorageConfiguration('array_storage', $fileStorageArray, 8, 0.5), new ezcCacheStackStorageConfiguration('memory_storage', $memoryStorage, 5, 0.5));
ezcCacheStackTestConfigurator::$metaStorage = $fileStorageArray;
ezcCacheManager::createCache(__CLASS__, null, 'ezcCacheStack', new ezcCacheStackOptions(array('configurator' => 'ezcCacheStackTestConfigurator', 'replacementStrategy' => 'ezcCacheStackLfuReplacementStrategy')));
self::$stackInitialized = true;
}
$this->testDataArray = array(array('id_1', 'id_1_content', array('lang' => 'en', 'area' => 'news')), array('id_2', 'id_2_content', array('lang' => 'en', 'area' => 'news')), array('id_3', 'id_3_content', array('lang' => 'de', 'area' => 'news')), array('id_4', 'id_4_content', array('lang' => 'no', 'area' => 'news')), array('id_5', 'id_5_content', array('lang' => 'de', 'area' => 'news')));
}
示例4: 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";
}
示例5: checkImageMagickComposite
private function checkImageMagickComposite()
{
if (!isset($settings->options['binary_composite'])) {
$this->binary_composite = ezcBaseFeatures::findExecutableInPath('composite');
} else {
if (file_exists($settings->options['binary_composite'])) {
$this->binary_composite = $settings->options['binary_composite'];
}
}
if ($this->binary_composite === null) {
throw new ezcImageHandlerNotAvailableException('ezcImageImagemagickHandler', 'ImageMagick not installed or not available in PATH variable.');
}
// Prepare to run ImageMagick command
$descriptors = array(array('pipe', 'r'), array('pipe', 'w'), array('pipe', 'w'));
// Open ImageMagick process
$imageProcess = proc_open($this->binary_composite, $descriptors, $pipes);
// Close STDIN pipe
fclose($pipes[0]);
$outputString = '';
// Read STDOUT
do {
$outputString .= rtrim(fgets($pipes[1], 1024), "\n");
} while (!feof($pipes[1]));
$errorString = '';
// Read STDERR
do {
$errorString .= rtrim(fgets($pipes[2], 1024), "\n");
} while (!feof($pipes[2]));
// Wait for process to terminate and store return value
$return = proc_close($imageProcess);
// Process potential errors
if (strlen($errorString) > 0 || strpos($outputString, 'ImageMagick') === false) {
throw new ezcImageHandlerNotAvailableException('ezcImageImagemagickHandler', 'ImageMagick not installed or not available in PATH variable.');
}
}
示例6: setUp
public function setUp()
{
if (!ezcBaseFeatures::hasExtensionSupport('haru')) {
$this->markTestSkipped('This test requires pecl/haru installed.');
}
parent::setUp();
}
示例7: __construct
/**
* Constructs a new ezcCacheMemcacheBackend object.
*
* For options for this backend see {@link ezcCacheStorageMemcacheOptions}.
*
* @throws ezcBaseExtensionNotFoundException
* If the PHP memcache and zlib extensions are not installed.
* @throws ezcCacheMemcacheException
* If the connection to the Memcache host did not succeed.
*
* @param array(string=>mixed) $options
*/
public function __construct(array $options = array())
{
if (!ezcBaseFeatures::hasExtensionSupport('memcache')) {
throw new ezcBaseExtensionNotFoundException('memcache', null, "PHP does not have Memcache support.");
}
if (!ezcBaseFeatures::hasExtensionSupport('zlib')) {
throw new ezcBaseExtensionNotFoundException('zlib', null, "PHP not configured with --with-zlib.");
}
$this->options = new ezcCacheStorageMemcacheOptions($options);
$this->connectionIdentifier = $this->options->host . ':' . $this->options->port;
if (!isset(self::$connections[$this->connectionIdentifier])) {
self::$connections[$this->connectionIdentifier] = new Memcache();
// Currently 0 backends use the connection
self::$connectionCounter[$this->connectionIdentifier] = 0;
}
$this->memcache = self::$connections[$this->connectionIdentifier];
// Now 1 backend uses it
self::$connectionCounter[$this->connectionIdentifier]++;
if ($this->options->persistent === true) {
if (!@$this->memcache->pconnect($this->options->host, $this->options->port, $this->options->ttl)) {
throw new ezcCacheMemcacheException('Could not connect to Memcache using a persistent connection.');
}
} else {
if (!@$this->memcache->connect($this->options->host, $this->options->port, $this->options->ttl)) {
throw new ezcCacheMemcacheException('Could not connect to Memcache.');
}
}
$this->memcache->setCompressThreshold(self::COMPRESS_THRESHOLD);
}
示例8: createBignumLibrary
/**
* Creates a new big number library which uses the PHP extension $lib.
*
* If $lib is null then an autodetection of the library is tried. If neither
* gmp or bcmath are installed then an exception will be thrown.
*
* If $lib is specified, then that library will be used (if it is installed),
* otherwise an exception will be thrown.
*
* @throws ezcBaseExtensionNotFoundException
* if neither of the PHP gmp and bcmath extensions are installed ($lib === null),
* or if the specified $lib is not installed
* @throws ezcBaseValueException
* if the value provided for $lib is not correct
* @param string $lib The PHP library to use for big number support. Default
* is null, which means the available library is autodetected.
* @return ezcAuthenticationBignumLibrary
*/
public static function createBignumLibrary($lib = null)
{
$library = null;
switch ($lib) {
case null:
if (!ezcBaseFeatures::hasExtensionSupport('bcmath')) {
if (!ezcBaseFeatures::hasExtensionSupport('gmp')) {
throw new ezcBaseExtensionNotFoundException('gmp | bcmath', null, "PHP not compiled with --enable-bcmath or --with-gmp.");
} else {
$library = new ezcAuthenticationGmpLibrary();
}
} else {
$library = new ezcAuthenticationBcmathLibrary();
}
break;
case 'gmp':
if (!ezcBaseFeatures::hasExtensionSupport('gmp')) {
throw new ezcBaseExtensionNotFoundException('gmp', null, "PHP not compiled with --with-gmp.");
}
$library = new ezcAuthenticationGmpLibrary();
break;
case 'bcmath':
if (!ezcBaseFeatures::hasExtensionSupport('bcmath')) {
throw new ezcBaseExtensionNotFoundException('bcmath', null, "PHP not compiled with --enable-bcmath.");
}
$library = new ezcAuthenticationBcmathLibrary();
break;
default:
throw new ezcBaseValueException('library', $lib, '"gmp" || "bcmath" || null');
}
return $library;
}
示例9: setUp
protected function setUp()
{
if (!ezcBaseFeatures::hasExtensionSupport('posix')) {
$this->markTestSkipped('ext/posix is required for this test.');
}
$this->tempDir = $this->createTempDir('ezcConfigurationArrayWriterTest');
}
示例10: setUp
protected function setUp()
{
if (!ezcBaseFeatures::hasExtensionSupport('exif')) {
$this->markTestSkipped('ext/exif is required to run this test.');
}
$this->basePath = dirname(__FILE__) . '/data/';
}
示例11: setUp
public function setUp()
{
if (!ezcBaseFeatures::hasExtensionSupport('pdo_sqlite')) {
$this->markTestSkipped();
return;
}
}
示例12: __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);
}
示例13: setUp
protected function setUp()
{
if (!ezcBaseFeatures::hasExtensionSupport('apc')) {
$this->markTestSkipped("PHP must have APC support.");
}
// Class name == <inheriting class> - "Test"
$storageClass = $this->storageClass = substr(get_class($this), 0, strlen(get_class($this)) - 4);
$this->storage = new $storageClass($this->createTempDir('ezcCacheTest'), array('ttl' => 10));
}
示例14: testInitFromSetBinary
public function testInitFromSetBinary()
{
$settings = ezcImageImagemagickHandler::defaultSettings();
$settings->options['binary'] = ezcBaseFeatures::getImageConvertExecutable();
$handler = new ezcImageImagemagickHandler($settings);
$filePath = $this->testFiles["jpeg"];
$ref = $handler->load($filePath);
$handler->close($ref);
}
示例15: swfCompare
/**
* Compares to flash files comparing the output of `swftophp`
*
* @param string $generated Filename of generated image
* @param string $compare Filename of stored image
* @return void
*/
protected function swfCompare($generated, $compare)
{
$this->assertTrue(file_exists($generated), 'No image file has been created.');
$this->assertTrue(file_exists($compare), 'Comparision image does not exist.');
$executeable = ezcBaseFeatures::findExecutableInPath('swftophp');
if (!$executeable) {
$this->markTestSkipped('Could not find swftophp executeable to compare flash files. Please check your $PATH.');
}
$this->assertEquals($this->normalizeFlashCode(shell_exec($executeable . ' ' . escapeshellarg($compare))), $this->normalizeFlashCode(shell_exec($executeable . ' ' . escapeshellarg($generated))), 'Rendered image is not correct.');
}