当前位置: 首页>>代码示例>>PHP>>正文


PHP Archive::factory方法代码示例

本文整理汇总了PHP中Archive::factory方法的典型用法代码示例。如果您正苦于以下问题:PHP Archive::factory方法的具体用法?PHP Archive::factory怎么用?PHP Archive::factory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Archive的用法示例。


在下文中一共展示了Archive::factory方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: action_report

 /**
  * Handles report generation
  */
 public function action_report()
 {
     // We don't want to use the HTML layout, we're sending the user 100111011100110010101100
     $this->auto_render = FALSE;
     $suite = Kohana_Tests::suite();
     $temp_path = rtrim($this->config->temp_path, '/') . '/';
     $group = (array) Arr::get($_GET, 'group', array());
     $report_format = Arr::get($_POST, 'format', 'PHP_Util_Report');
     // Fairly foolproof
     if ($report_format !== 'PHP_Util_Report' && !class_exists('Archive')) {
         throw new Kohana_Exception('The Archive module is needed to package the reports');
     }
     // Stop phpunit from interpretting "all groups" as "no groups"
     if (empty($group) or empty($group[0])) {
         $group = array();
     }
     if (Arr::get($_GET, 'use_whitelist', FALSE)) {
         $this->whitelist(Arr::get($_GET, 'whitelist', array()));
     }
     $runner = new Kohana_PHPUnit($suite);
     if ($report_format === 'PHP_Util_Report') {
         $file_handler = opendir($this->config->temp_path);
         while (false !== ($dirname = readdir($file_handler))) {
             if (0 !== strpos($dirname, '.') && is_dir($this->config->temp_path . $dirname)) {
                 $this->rmdir_recursive($this->config->temp_path . $dirname);
             }
         }
     }
     // $report is the actual directory of the report,
     // $folder is the name component of directory
     list($report, $folder) = $runner->generate_report($group, $temp_path, $report_format);
     if ($report_format !== 'PHP_Util_Report') {
         $archive = Archive::factory('zip');
         // TODO: Include the test results?
         $archive->add($report, 'report', TRUE);
         $filename = $folder . '.zip';
         $archive->save($temp_path . $filename);
         $this->request->send_file($temp_path . $filename, $filename);
     } else {
         Request::instance()->redirect($this->config->coverage_url . $folder . '/index.html');
     }
 }
开发者ID:pcraciunoiu,项目名称:unittest,代码行数:45,代码来源:phpunit.php

示例2: action_report

 /**
  * Handles report generation
  */
 public function action_report()
 {
     // Fairly foolproof
     if (!$this->config->cc_report_path and !class_exists('Archive')) {
         throw new Kohana_Exception('Cannot generate report');
     }
     // We don't want to use the HTML layout, we're sending the user 100111011100110010101100
     $this->auto_render = FALSE;
     $suite = Unittest_tests::suite();
     $temp_path = rtrim($this->config->temp_path, '/') . '/';
     $group = (array) Arr::get($_GET, 'group', array());
     // Stop unittest from interpretting "all groups" as "no groups"
     if (empty($group) or empty($group[0])) {
         $group = array();
     }
     if (Arr::get($_GET, 'use_whitelist', FALSE)) {
         $this->whitelist(Arr::get($_GET, 'whitelist', array()));
     }
     $runner = new Kohana_Unittest_Runner($suite);
     // If the user wants to download a report
     if ($this->cc_archive_enabled and Arr::get($_GET, 'archive') === '1') {
         // $report is the actual directory of the report,
         // $folder is the name component of directory
         list($report, $folder) = $runner->generate_report($group, $temp_path);
         $archive = Archive::factory('zip');
         // TODO: Include the test results?
         $archive->add($report, 'report', TRUE);
         $filename = $folder . '.zip';
         $archive->save($temp_path . $filename);
         // It'd be nice to clear up afterwards but by deleting the report dir we corrupt the archive
         // And once the archive has been sent to the user Request stops the script so we can't delete anything
         // It'll be up to the user to delete files periodically
         $this->request->send_file($temp_path . $filename, $filename);
     } else {
         $folder = trim($this->config->cc_report_path, '/') . '/';
         $path = DOCROOT . $folder;
         if (!file_exists($path)) {
             throw new Kohana_Exception('Report directory :dir does not exist', array(':dir' => $path));
         }
         if (!is_writable($path)) {
             throw new Kohana_Exception('Script doesn\'t have permission to write to report dir :dir ', array(':dir' => $path));
         }
         $runner->generate_report($group, $path, FALSE);
         $this->request->redirect(URL::site($folder . 'index.html', $this->request));
     }
 }
开发者ID:sysdevbol,项目名称:entidad,代码行数:49,代码来源:unittest.php

示例3: action_report

 /**
  * Handles report generation
  */
 public function action_report()
 {
     // Fairly foolproof
     if (!class_exists('Archive')) {
         throw new Kohana_Exception('The Archive module is needed to package the reports');
     }
     // We don't want to use the HTML layout, we're sending the user 100111011100110010101100
     $this->auto_render = FALSE;
     $suite = Kohana_Tests::suite();
     $temp_path = rtrim($this->config->temp_path, '/') . '/';
     $group = (array) Arr::get($_GET, 'group', array());
     $report_format = Arr::get($_POST, 'format', 'PHP_Util_Report');
     // Stop phpunit from interpretting "all groups" as "no groups"
     if (empty($group) or empty($group[0])) {
         $group = array();
     }
     if (Arr::get($_GET, 'use_whitelist', FALSE)) {
         $this->whitelist(Arr::get($_GET, 'whitelist', array()));
     }
     $runner = new Kohana_PHPUnit($suite);
     // $report is the actual directory of the report,
     // $folder is the name component of directory
     list($report, $folder) = $runner->generate_report($group, $temp_path, $report_format);
     $archive = Archive::factory('zip');
     // TODO: Include the test results?
     $archive->add($report, 'report', TRUE);
     $filename = $folder . '.zip';
     $archive->save($temp_path . $filename);
     // It'd be nice to clear up afterwards but by deleting the report dir we corrupt the archive
     // And once the archive has been sent to the user Request stops the script so we can't delete anything
     // It'll be up to the user to delete files periodically
     $this->request->send_file($temp_path . $filename, $filename);
 }
开发者ID:kierangraham,项目名称:unittest,代码行数:36,代码来源:phpunit.php


注:本文中的Archive::factory方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。