예제 #1
0
 /**
  * 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
0
 /**
  * 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
0
 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
0
 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";
 }
 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.');
     }
 }
 public function setUp()
 {
     if (!ezcBaseFeatures::hasExtensionSupport('haru')) {
         $this->markTestSkipped('This test requires pecl/haru installed.');
     }
     parent::setUp();
 }
예제 #7
0
 /**
  * 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
0
 /**
  * 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;
 }
 protected function setUp()
 {
     if (!ezcBaseFeatures::hasExtensionSupport('posix')) {
         $this->markTestSkipped('ext/posix is required for this test.');
     }
     $this->tempDir = $this->createTempDir('ezcConfigurationArrayWriterTest');
 }
예제 #10
0
 protected function setUp()
 {
     if (!ezcBaseFeatures::hasExtensionSupport('exif')) {
         $this->markTestSkipped('ext/exif is required to run this test.');
     }
     $this->basePath = dirname(__FILE__) . '/data/';
 }
예제 #11
0
 public function setUp()
 {
     if (!ezcBaseFeatures::hasExtensionSupport('pdo_sqlite')) {
         $this->markTestSkipped();
         return;
     }
 }
예제 #12
0
 /**
  * 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
0
 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
0
 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
0
 /**
  * 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.');
 }
 public function setUp()
 {
     if (!ezcBaseFeatures::hasExtensionSupport('haru')) {
         $this->markTestSkipped('This test requires pecl/haru installed.');
     }
     parent::setUp();
     // Change error reporting - this is evil, but otherwise TCPDF will
     // abort the tests, because it throws lots of E_NOTICE and
     // E_DEPRECATED.
     $this->oldErrorReporting = error_reporting(E_PARSE | E_ERROR | E_WARNING);
 }
예제 #17
0
 protected function determinePhpPath()
 {
     if (isset($_SERVER["_"])) {
         $this->phpPath = $_SERVER["_"];
     } else {
         if (ezcBaseFeatures::os() === 'Windows') {
             $this->phpPath = 'php.exe';
         } else {
             $this->phpPath = '/bin/env php';
         }
     }
 }
예제 #18
0
 /**
  * (non-PHPdoc)
  * @see lib/ezc/MvcTools/src/ezcMvcRouter::createRoutes()
  */
 public function createRoutes()
 {
     if (empty($this->routes)) {
         // Check if route caching is enabled and if APC is available
         $isRouteCacheEnabled = eZINI::instance('rest.ini')->variable('CacheSettings', 'RouteApcCache') === 'enabled';
         if ($isRouteCacheEnabled && ezcBaseFeatures::hasExtensionSupport('apc')) {
             $this->routes = $this->getCachedRoutes();
         } else {
             $this->routes = $this->doCreateRoutes();
         }
     }
     return $this->routes;
 }
예제 #19
0
 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) {
     }
 }
예제 #20
0
 protected function setUp()
 {
     if (!ezcBaseFeatures::hasExtensionSupport('cairo')) {
         $this->markTestSkipped('This test needs pecl/cairo support.');
     }
     static $i = 0;
     $this->tempDir = $this->createTempDir('ezcGraphCairoDriverTest' . sprintf('_%03d_', ++$i)) . '/';
     $this->basePath = dirname(__FILE__) . '/data/';
     $this->driver = new ezcGraphCairoOODriver();
     $this->driver->options->width = 200;
     $this->driver->options->height = 100;
     $this->driver->options->font->path = $this->basePath . 'font.ttf';
 }
예제 #21
0
 public function testRenderLongTextWithInternalLinks()
 {
     if (!ezcBaseFeatures::hasExtensionSupport('haru')) {
         $this->markTestSkipped('This test requires pecl/haru installed.');
     }
     $docbook = new ezcDocumentDocbook();
     $docbook->loadFile(dirname(__FILE__) . '/../files/pdf/internal_links.xml');
     $style = new ezcDocumentPcssStyleInferencer();
     $style->appendStyleDirectives(array(new ezcDocumentPcssLayoutDirective(array('page'), array('page-size' => 'A6'))));
     $renderer = new ezcDocumentPdfMainRenderer(new ezcDocumentPdfHaruDriver(), $style);
     $pdf = $renderer->render($docbook, new ezcDocumentPdfDefaultHyphenator());
     $this->assertPdfDocumentsSimilar($pdf, __CLASS__ . '_' . __FUNCTION__);
 }
예제 #22
0
 protected function setUp()
 {
     if (!ezcBaseFeatures::hasExtensionSupport('ming')) {
         $this->markTestSkipped('This test needs ext/ming support.');
     }
     static $i = 0;
     $this->tempDir = $this->createTempDir(__CLASS__ . sprintf('_%03d_', ++$i)) . '/';
     $this->basePath = dirname(__FILE__) . '/data/';
     $this->driver = new ezcGraphFlashDriver();
     $this->driver->options->width = 200;
     $this->driver->options->height = 100;
     $this->driver->options->font->path = $this->basePath . 'fdb_font.fdb';
 }
예제 #23
0
 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 );
 }
 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());
     }
 }
예제 #25
0
 protected function setUp()
 {
     if (!ezcBaseFeatures::hasExtensionSupport('memcache')) {
         $this->markTestSkipped('PHP must have Memcache support.');
     }
     if (!ezcBaseFeatures::hasExtensionSupport('zlib')) {
         $this->markTestSkipped('PHP must be compiled with --with-zlib.');
     }
     $testMemcache = new Memcache();
     if (@$testMemcache->connect('localhost', 11211) === false) {
         $this->markTestSkipped('No Memcache server running on port 11211 found.');
     }
     $testMemcache->close();
     $this->memcacheBackend = new ezcCacheMemcacheBackend();
 }
예제 #26
0
파일: bzip2_test.php 프로젝트: bmdevel/ezc
 public function testCreateBzip2TarWithTwoFiles()
 {
     if (!ezcBaseFeatures::hasExtensionSupport('bz2')) {
         $this->markTestSkipped();
     }
     $dir = $this->getTempDir();
     $archive = ezcArchive::open("compress.bzip2://{$dir}/mytar.tar.bz2", ezcArchive::TAR_USTAR);
     file_put_contents("{$dir}/a.txt", "Hello world!");
     file_put_contents("{$dir}/b.txt", "BBBBBBBBBBBB");
     $archive->append("{$dir}/a.txt", $dir);
     $archive->append("{$dir}/b.txt", $dir);
     $archive->close();
     exec("tar -cf {$dir}/gnutar.tar --format=ustar -C {$dir} a.txt b.txt");
     exec("bunzip2 {$dir}/mytar.tar.bz2");
     $this->assertEquals(file_get_contents("{$dir}/gnutar.tar"), file_get_contents("{$dir}/mytar.tar"));
 }
예제 #27
0
 public function setUp()
 {
     if (!ezcBaseFeatures::hasExtensionSupport('ldap')) {
         $this->markTestSkipped("PHP must be compiled with --with-ldap.");
     }
     try {
         $credentials = new ezcAuthenticationPasswordCredentials('zhang.san', 'asdfgh');
         $ldap = new ezcAuthenticationLdapInfo(self::$host, self::$format, self::$base, self::$port);
         $authentication = new ezcAuthentication($credentials);
         $authentication->addFilter(new ezcAuthenticationLdapFilter($ldap));
         $authentication->run();
     } catch (ezcAuthenticationLdapException $e) {
         // this will be changed later when we will have a test server with LDAP
         $this->markTestSkipped("Cannot connect to LDAP. Probably you didn't setup the LDAP enviroment: " . $e->getMessage());
     }
 }
예제 #28
0
 /**
  * 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.');
     }
     $generatedCode = shell_exec($executeable . ' ' . escapeshellarg($generated));
     $compareCode = shell_exec($executeable . ' ' . escapeshellarg($compare));
     foreach (array('generatedCode' => $generatedCode, 'compareCode' => $compareCode) as $var => $content) {
         $content = preg_replace('/\\$[sf]\\d+/', '$var', $content);
         $content = preg_replace('[/\\*.*\\*/]i', '/* Comment irrelevant */', $content);
         ${$var} = $content;
     }
     $this->assertEquals($generatedCode, $compareCode, 'Rendered image is not correct.');
 }
 protected function setUp()
 {
     if (!ezcBaseFeatures::hasExtensionSupport('memcache')) {
         $this->markTestSkipped('PHP must have Memcache support.');
     }
     if (!ezcBaseFeatures::hasExtensionSupport('zlib')) {
         $this->markTestSkipped('PHP must be compiled with --with-zlib.');
     }
     $testMemcache = new Memcache();
     if (@$testMemcache->connect('localhost', 11211) === false) {
         $this->markTestSkipped('No Memcache server running on port 11211 found.');
     }
     // 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('host' => 'localhost', 'port' => 11211, 'ttl' => 10));
     $this->testData = array(1 => "Test 1 2 3 4 5 6 7 8\\\\", 2 => 'La la la 02064 lololo', 3 => 12345, 4 => 12.3746);
 }
예제 #30
0
 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.");
 }