mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-27 21:58:52 +00:00
Merge branch 'develop' of git://github.com/phpbb/phpbb3 into ticket/11103
Conflicts: phpBB/config/services.yml
This commit is contained in:
commit
0d7f49892a
15 changed files with 224 additions and 27 deletions
|
@ -100,13 +100,6 @@ $processor->process($phpbb_container);
|
|||
$phpbb_class_loader = $phpbb_container->get('class_loader');
|
||||
$phpbb_class_loader_ext = $phpbb_container->get('class_loader.ext');
|
||||
|
||||
$ids = array_keys($phpbb_container->findTaggedServiceIds('container.processor'));
|
||||
foreach ($ids as $id)
|
||||
{
|
||||
$processor = $phpbb_container->get($id);
|
||||
$processor->process($phpbb_container);
|
||||
}
|
||||
|
||||
// set up caching
|
||||
$cache = $phpbb_container->get('cache');
|
||||
|
||||
|
@ -132,6 +125,13 @@ $phpbb_subscriber_loader = $phpbb_container->get('event.subscriber_loader');
|
|||
$template = $phpbb_container->get('template');
|
||||
$phpbb_style = $phpbb_container->get('style');
|
||||
|
||||
$ids = array_keys($phpbb_container->findTaggedServiceIds('container.processor'));
|
||||
foreach ($ids as $id)
|
||||
{
|
||||
$processor = $phpbb_container->get($id);
|
||||
$processor->process($phpbb_container);
|
||||
}
|
||||
|
||||
// Add own hook handler
|
||||
require($phpbb_root_path . 'includes/hooks/index.' . $phpEx);
|
||||
$phpbb_hook = new phpbb_hook(array('exit_handler', 'phpbb_user_session_handler', 'append_sid', array('phpbb_template', 'display')));
|
||||
|
|
|
@ -94,7 +94,7 @@ services:
|
|||
arguments:
|
||||
- @container
|
||||
|
||||
processor.config:
|
||||
processor.ext:
|
||||
class: phpbb_di_processor_ext
|
||||
arguments:
|
||||
- @ext.manager
|
||||
|
|
|
@ -61,13 +61,6 @@ if (isset($_GET['avatar']))
|
|||
$phpbb_class_loader = $phpbb_container->get('class_loader');
|
||||
$phpbb_class_loader_ext = $phpbb_container->get('class_loader.ext');
|
||||
|
||||
$ids = array_keys($phpbb_container->findTaggedServiceIds('container.processor'));
|
||||
foreach ($ids as $id)
|
||||
{
|
||||
$processor = $phpbb_container->get($id);
|
||||
$processor->process($phpbb_container);
|
||||
}
|
||||
|
||||
// set up caching
|
||||
$cache = $phpbb_container->get('cache');
|
||||
|
||||
|
@ -92,6 +85,13 @@ if (isset($_GET['avatar']))
|
|||
$phpbb_extension_manager = $phpbb_container->get('ext.manager');
|
||||
$phpbb_subscriber_loader = $phpbb_container->get('event.subscriber_loader');
|
||||
|
||||
$ids = array_keys($phpbb_container->findTaggedServiceIds('container.processor'));
|
||||
foreach ($ids as $id)
|
||||
{
|
||||
$processor = $phpbb_container->get($id);
|
||||
$processor->process($phpbb_container);
|
||||
}
|
||||
|
||||
// worst-case default
|
||||
$browser = strtolower($request->header('User-Agent', 'msie 6.0'));
|
||||
|
||||
|
|
|
@ -7,6 +7,10 @@
|
|||
*
|
||||
*/
|
||||
|
||||
use Symfony\Component\Config\FileLocator;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
|
||||
|
||||
define('UPDATES_TO_VERSION', '3.1.0-dev');
|
||||
|
||||
// Enter any version to update from to test updates. The version within the db will not be updated.
|
||||
|
@ -115,21 +119,37 @@ if (!defined('USER_NOTIFICATIONS_TABLE'))
|
|||
define('USER_NOTIFICATIONS_TABLE', $table_prefix . 'user_notifications');
|
||||
}
|
||||
|
||||
$phpbb_class_loader_ext = new phpbb_class_loader('phpbb_ext_', $phpbb_root_path . 'ext/', ".$phpEx");
|
||||
$phpbb_class_loader_ext->register();
|
||||
$phpbb_class_loader = new phpbb_class_loader('phpbb_', $phpbb_root_path . 'includes/', ".$phpEx");
|
||||
$phpbb_class_loader->register();
|
||||
$phpbb_container = new ContainerBuilder();
|
||||
$loader = new YamlFileLoader($phpbb_container, new FileLocator(__DIR__.'/../config'));
|
||||
$loader->load('services.yml');
|
||||
|
||||
// We must include the DI processor class files because the class loader
|
||||
// is not yet set up
|
||||
require($phpbb_root_path . 'includes/di/processor/interface.' . $phpEx);
|
||||
require($phpbb_root_path . 'includes/di/processor/config.' . $phpEx);
|
||||
$processor = new phpbb_di_processor_config($phpbb_root_path . 'config.' . $phpEx, $phpbb_root_path, $phpEx);
|
||||
$processor->process($phpbb_container);
|
||||
|
||||
// Setup class loader first
|
||||
$phpbb_class_loader = $phpbb_container->get('class_loader');
|
||||
$phpbb_class_loader_ext = $phpbb_container->get('class_loader.ext');
|
||||
|
||||
// set up caching
|
||||
$cache_factory = new phpbb_cache_factory($acm_type);
|
||||
$cache = $cache_factory->get_service();
|
||||
$phpbb_class_loader_ext->set_cache($cache->get_driver());
|
||||
$phpbb_class_loader->set_cache($cache->get_driver());
|
||||
$cache = $phpbb_container->get('cache');
|
||||
|
||||
$phpbb_dispatcher = new phpbb_event_dispatcher();
|
||||
$request = new phpbb_request();
|
||||
$user = new phpbb_user();
|
||||
$db = new $sql_db();
|
||||
// Instantiate some basic classes
|
||||
$phpbb_dispatcher = $phpbb_container->get('dispatcher');
|
||||
$request = $phpbb_container->get('request');
|
||||
$user = $phpbb_container->get('user');
|
||||
$auth = $phpbb_container->get('auth');
|
||||
$db = $phpbb_container->get('dbal.conn');
|
||||
|
||||
$ids = array_keys($phpbb_container->findTaggedServiceIds('container.processor'));
|
||||
foreach ($ids as $id)
|
||||
{
|
||||
$processor = $phpbb_container->get($id);
|
||||
$processor->process($phpbb_container);
|
||||
}
|
||||
|
||||
// make sure request_var uses this request instance
|
||||
request_var('', 0, false, false, $request); // "dependency injection" for a function
|
||||
|
|
0
tests/compress/archive/.gitkeep
Normal file
0
tests/compress/archive/.gitkeep
Normal file
173
tests/compress/compress_test.php
Normal file
173
tests/compress/compress_test.php
Normal file
|
@ -0,0 +1,173 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* @package testing
|
||||
* @copyright (c) 2012 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
|
||||
require_once dirname(__FILE__) . '/../../phpBB/includes/functions_admin.php';
|
||||
require_once dirname(__FILE__) . '/../../phpBB/includes/functions_compress.php';
|
||||
|
||||
class phpbb_compress_test extends phpbb_test_case
|
||||
{
|
||||
const EXTRACT_DIR = '/extract/';
|
||||
const ARCHIVE_DIR = '/archive/';
|
||||
|
||||
private $path;
|
||||
|
||||
protected $filelist = array(
|
||||
'1.txt',
|
||||
'dir/2.txt',
|
||||
'dir/3.txt',
|
||||
'dir/subdir/4.txt',
|
||||
);
|
||||
|
||||
protected $conflicts = array(
|
||||
'1_1.txt',
|
||||
'1_2.txt',
|
||||
'dir/2_1.txt',
|
||||
);
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
// Required for compress::add_file
|
||||
global $phpbb_root_path;
|
||||
$phpbb_root_path = '';
|
||||
|
||||
$this->path = dirname(__FILE__) . '/fixtures/';
|
||||
|
||||
if (!@extension_loaded('zlib') || !@extension_loaded('bz2'))
|
||||
{
|
||||
$this->markTestSkipped('PHP needs to be compiled with --with-zlib and --with-bz2 in order to run these tests');
|
||||
}
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
{
|
||||
foreach (array(dirname(__FILE__) . self::EXTRACT_DIR, dirname(__FILE__) . self::ARCHIVE_DIR) as $dir)
|
||||
{
|
||||
$this->clear_dir($dir);
|
||||
}
|
||||
}
|
||||
|
||||
protected function clear_dir($dir)
|
||||
{
|
||||
$iterator = new DirectoryIterator($dir);
|
||||
foreach ($iterator as $fileinfo)
|
||||
{
|
||||
$name = $fileinfo->getFilename();
|
||||
$path = $fileinfo->getPathname();
|
||||
|
||||
if ($name[0] !== '.')
|
||||
{
|
||||
if ($fileinfo->isDir())
|
||||
{
|
||||
$this->clear_dir($path);
|
||||
rmdir($path);
|
||||
}
|
||||
else
|
||||
{
|
||||
unlink($path);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected function archive_files($compress)
|
||||
{
|
||||
$compress->add_file($this->path . '1.txt', $this->path);
|
||||
$compress->add_file(
|
||||
'tests/compress/fixtures/dir/',
|
||||
'tests/compress/fixtures/',
|
||||
'',
|
||||
// The comma here is not an error, this is a comma-separated list
|
||||
'subdir/4.txt,3.txt'
|
||||
);
|
||||
$compress->add_custom_file($this->path . 'dir/3.txt', 'dir/3.txt');
|
||||
$compress->add_data(file_get_contents($this->path . 'dir/subdir/4.txt'), 'dir/subdir/4.txt');
|
||||
|
||||
// Add multiples of the same file to check conflicts are handled
|
||||
$compress->add_file($this->path . '1.txt', $this->path);
|
||||
$compress->add_file($this->path . '1.txt', $this->path);
|
||||
$compress->add_file($this->path . 'dir/2.txt', $this->path);
|
||||
}
|
||||
|
||||
protected function valid_extraction($extra = array())
|
||||
{
|
||||
$filelist = array_merge($this->filelist, $extra);
|
||||
|
||||
foreach ($filelist as $filename)
|
||||
{
|
||||
$path = dirname(__FILE__) . self::EXTRACT_DIR . $filename;
|
||||
$this->assertTrue(file_exists($path));
|
||||
|
||||
// Check the file's contents is correct
|
||||
$contents = explode('_', basename($filename, '.txt'));
|
||||
$contents = $contents[0];
|
||||
$this->assertEquals($contents . "\n", file_get_contents($path));
|
||||
}
|
||||
}
|
||||
|
||||
public function tar_archive_list()
|
||||
{
|
||||
return array(
|
||||
array('archive.tar', '.tar'),
|
||||
array('archive.tar.gz', '.tar.gz'),
|
||||
array('archive.tar.bz2', '.tar.bz2'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider tar_archive_list
|
||||
*/
|
||||
public function test_extract_tar($filename, $type)
|
||||
{
|
||||
$compress = new compress_tar('r', $this->path . $filename);
|
||||
$compress->extract('tests/compress/' . self::EXTRACT_DIR);
|
||||
$this->valid_extraction();
|
||||
}
|
||||
|
||||
public function test_extract_zip()
|
||||
{
|
||||
$compress = new compress_zip('r', $this->path . 'archive.zip');
|
||||
$compress->extract('tests/compress/' . self::EXTRACT_DIR);
|
||||
$this->valid_extraction();
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends test_extract_tar
|
||||
* @dataProvider tar_archive_list
|
||||
*/
|
||||
public function test_compress_tar($filename, $type)
|
||||
{
|
||||
$tar = dirname(__FILE__) . self::ARCHIVE_DIR . $filename;
|
||||
$compress = new compress_tar('w', $tar);
|
||||
$this->archive_files($compress);
|
||||
$compress->close();
|
||||
$this->assertTrue(file_exists($tar));
|
||||
|
||||
$compress->mode = 'r';
|
||||
$compress->open();
|
||||
$compress->extract('tests/compress/' . self::EXTRACT_DIR);
|
||||
$this->valid_extraction($this->conflicts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends test_extract_zip
|
||||
*/
|
||||
public function test_compress_zip()
|
||||
{
|
||||
$zip = dirname(__FILE__) . self::ARCHIVE_DIR . 'archive.zip';
|
||||
$compress = new compress_zip('w', $zip);
|
||||
$this->archive_files($compress);
|
||||
$compress->close();
|
||||
$this->assertTrue(file_exists($zip));
|
||||
|
||||
$compress = new compress_zip('r', $zip);
|
||||
$compress->extract('tests/compress/' . self::EXTRACT_DIR);
|
||||
$this->valid_extraction($this->conflicts);
|
||||
}
|
||||
}
|
0
tests/compress/extract/.gitkeep
Normal file
0
tests/compress/extract/.gitkeep
Normal file
1
tests/compress/fixtures/1.txt
Normal file
1
tests/compress/fixtures/1.txt
Normal file
|
@ -0,0 +1 @@
|
|||
1
|
BIN
tests/compress/fixtures/archive.tar
Normal file
BIN
tests/compress/fixtures/archive.tar
Normal file
Binary file not shown.
BIN
tests/compress/fixtures/archive.tar.bz2
Normal file
BIN
tests/compress/fixtures/archive.tar.bz2
Normal file
Binary file not shown.
BIN
tests/compress/fixtures/archive.tar.gz
Normal file
BIN
tests/compress/fixtures/archive.tar.gz
Normal file
Binary file not shown.
BIN
tests/compress/fixtures/archive.zip
Normal file
BIN
tests/compress/fixtures/archive.zip
Normal file
Binary file not shown.
1
tests/compress/fixtures/dir/2.txt
Normal file
1
tests/compress/fixtures/dir/2.txt
Normal file
|
@ -0,0 +1 @@
|
|||
2
|
1
tests/compress/fixtures/dir/3.txt
Normal file
1
tests/compress/fixtures/dir/3.txt
Normal file
|
@ -0,0 +1 @@
|
|||
3
|
1
tests/compress/fixtures/dir/subdir/4.txt
Normal file
1
tests/compress/fixtures/dir/subdir/4.txt
Normal file
|
@ -0,0 +1 @@
|
|||
4
|
Loading…
Add table
Reference in a new issue