diff options
author | Tristan Darricau <tristan.darricau@sensiolabs.com> | 2015-04-26 21:30:50 +0200 |
---|---|---|
committer | Nicofuma <github@nicofuma.fr> | 2015-05-14 23:04:18 +0200 |
commit | 549fe66d90eed1d6a4fee6f5f706c73455d73596 (patch) | |
tree | acbc96aacef03fdb6e7d324d79d2592ab52d4dce | |
parent | c96e7ef1711932c2236620903bc256b346514dfc (diff) | |
download | forums-549fe66d90eed1d6a4fee6f5f706c73455d73596.tar forums-549fe66d90eed1d6a4fee6f5f706c73455d73596.tar.gz forums-549fe66d90eed1d6a4fee6f5f706c73455d73596.tar.bz2 forums-549fe66d90eed1d6a4fee6f5f706c73455d73596.tar.xz forums-549fe66d90eed1d6a4fee6f5f706c73455d73596.zip |
[ticket/13770] Update tests
PHPBB3-13770
-rw-r--r-- | phpBB/install/index.php | 1 | ||||
-rw-r--r-- | phpBB/phpbb/di/container_builder.php | 5 | ||||
-rw-r--r-- | tests/di/create_container_test.php | 89 | ||||
-rw-r--r-- | tests/di/fixtures/config.php | 2 | ||||
-rw-r--r-- | tests/di/fixtures/config/production/config.yml | 2 | ||||
-rw-r--r-- | tests/di/fixtures/config/production/container/environment.yml | 17 |
6 files changed, 44 insertions, 72 deletions
diff --git a/phpBB/install/index.php b/phpBB/install/index.php index 19cf27940b..f935e3d08c 100644 --- a/phpBB/install/index.php +++ b/phpBB/install/index.php @@ -118,7 +118,6 @@ $phpbb_class_loader_ext->register(); $phpbb_config_php_file = new \phpbb\config_php_file($phpbb_root_path, $phpEx); $phpbb_container_builder = new \phpbb\di\container_builder($phpbb_root_path, $phpEx); $phpbb_container = $phpbb_container_builder - ->with_config($phpbb_config_php_file) ->without_extensions() ->without_cache() ->without_compiled_container() diff --git a/phpBB/phpbb/di/container_builder.php b/phpBB/phpbb/di/container_builder.php index 33eb4e59a8..3886bfdd5d 100644 --- a/phpBB/phpbb/di/container_builder.php +++ b/phpBB/phpbb/di/container_builder.php @@ -142,7 +142,10 @@ class container_builder } // Inject the config - $this->container_extensions[] = new extension\config($this->config_php_file); + if ($this->config_php_file) + { + $this->container_extensions[] = new extension\config($this->config_php_file); + } $this->container = $this->create_container($this->container_extensions); diff --git a/tests/di/create_container_test.php b/tests/di/create_container_test.php index d52fb6b085..2d94f1d778 100644 --- a/tests/di/create_container_test.php +++ b/tests/di/create_container_test.php @@ -31,7 +31,8 @@ namespace { $this->phpbb_root_path = dirname(__FILE__) . '/'; $this->config_php = new \phpbb\config_php_file($this->phpbb_root_path . 'fixtures/', 'php'); - $this->builder = new phpbb_mock_phpbb_di_container_builder($this->config_php, $this->phpbb_root_path . 'fixtures/', 'php'); + $this->builder = new phpbb_mock_phpbb_di_container_builder($this->phpbb_root_path . 'fixtures/', 'php'); + $this->builder->with_config($this->config_php); $this->filename = $this->phpbb_root_path . '../tmp/container.php'; if (is_file($this->filename)) @@ -78,9 +79,9 @@ namespace $this->assertTrue($container->isFrozen()); } - public function test_dump_container() + public function test_without_cache() { - $this->builder->set_dump_container(false); + $this->builder->without_cache(); $container = $this->builder->get_container(); $this->assertInstanceOf('Symfony\Component\DependencyInjection\ContainerBuilder', $container); @@ -94,9 +95,9 @@ namespace $this->assertTrue($container->isFrozen()); } - public function test_use_extensions() + public function test_without_extensions() { - $this->builder->set_use_extensions(false); + $this->builder->without_extensions(); $container = $this->builder->get_container(); $this->assertInstanceOf('Symfony\Component\DependencyInjection\ContainerBuilder', $container); @@ -109,9 +110,9 @@ namespace $this->assertFalse($container->hasParameter('available')); } - public function test_compile_container() + public function test_without_compiled_container() { - $this->builder->set_compile_container(false); + $this->builder->without_compiled_container(); $container = $this->builder->get_container(); $this->assertInstanceOf('Symfony\Component\DependencyInjection\ContainerBuilder', $container); @@ -119,19 +120,9 @@ namespace $this->assertFalse($container->isFrozen()); } - public function test_inject_config() + public function test_with_config_path() { - $this->builder->set_inject_config(false); - $container = $this->builder->get_container(); - $this->assertInstanceOf('Symfony\Component\DependencyInjection\ContainerBuilder', $container); - - // Checks inject_config - $this->assertFalse($container->hasParameter('dbal.dbhost')); - } - - public function test_set_config_path() - { - $this->builder->set_config_path($this->phpbb_root_path . 'fixtures/other_config/'); + $this->builder->with_config_path($this->phpbb_root_path . 'fixtures/other_config/'); $container = $this->builder->get_container(); $this->assertInstanceOf('Symfony\Component\DependencyInjection\ContainerBuilder', $container); @@ -139,9 +130,9 @@ namespace $this->assertFalse($container->hasParameter('core')); } - public function test_set_custom_parameters() + public function test_with_custom_parameters() { - $this->builder->set_custom_parameters(array('my_parameter' => true)); + $this->builder->with_custom_parameters(array('my_parameter' => true)); $container = $this->builder->get_container(); $this->assertInstanceOf('Symfony\Component\DependencyInjection\ContainerBuilder', $container); @@ -150,61 +141,21 @@ namespace } } -namespace phpbb\db\driver +namespace phpbb\extension { - class container_mock extends \phpbb\db\driver\driver + class manager_mock extends \phpbb\extension\manager { - public function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port = false, $persistency = false, $new_link = false) - { - } - - public function sql_query($query = '', $cache_ttl = 0) - { - } - - public function sql_fetchrow($query_id = false) - { - } - - public function sql_freeresult($query_id = false) - { - } - - function sql_server_info($raw = false, $use_cache = true) - { - } - - function sql_affectedrows() - { - } - - function sql_rowseek($rownum, &$query_id) - { - } - - function sql_nextid() - { - } - - function sql_escape($msg) - { - } - - function sql_like_expression($expression) - { - } - - function sql_not_like_expression($expression) + public function __construct() { } - function sql_fetchrowset($query_id = false) + public function all_enabled($phpbb_relative = true) { return array( - array('ext_name' => 'vendor/enabled'), - array('ext_name' => 'vendor/enabled-2'), - array('ext_name' => 'vendor/enabled-3'), - array('ext_name' => 'vendor/enabled_4'), + 'vendor/enabled' => dirname(__FILE__) . '/fixtures/ext/vendor/enabled/', + 'vendor/enabled-2' => dirname(__FILE__) . '/fixtures/ext/vendor/enabled-2/', + 'vendor/enabled-3' => dirname(__FILE__) . '/fixtures/ext/vendor/enabled-3/', + 'vendor/enabled_4' => dirname(__FILE__) . '/fixtures/ext/vendor/enabled_4/', ); } } diff --git a/tests/di/fixtures/config.php b/tests/di/fixtures/config.php index f2e1145efa..1e9207d924 100644 --- a/tests/di/fixtures/config.php +++ b/tests/di/fixtures/config.php @@ -1,7 +1,7 @@ <?php // phpBB 3.1.x auto-generated configuration file // Do not change anything in this file! -$dbms = 'container_mock'; +$dbms = 'mysql'; $dbhost = '127.0.0.1'; $dbport = ''; $dbname = 'phpbb'; diff --git a/tests/di/fixtures/config/production/config.yml b/tests/di/fixtures/config/production/config.yml new file mode 100644 index 0000000000..fcfa84f68b --- /dev/null +++ b/tests/di/fixtures/config/production/config.yml @@ -0,0 +1,2 @@ +core: + require_dev_dependencies: true diff --git a/tests/di/fixtures/config/production/container/environment.yml b/tests/di/fixtures/config/production/container/environment.yml new file mode 100644 index 0000000000..6ac07a44d9 --- /dev/null +++ b/tests/di/fixtures/config/production/container/environment.yml @@ -0,0 +1,17 @@ +parameters: + core: true + +services: + config.php: + synthetic: true + + dbal.conn: + class: phpbb\db\driver\factory + arguments: + - @service_container + + dispatcher: + class: phpbb\db\driver\container_mock + + ext.manager: + class: phpbb\extension\manager_mock |