diff options
Diffstat (limited to 'tests/di')
-rw-r--r-- | tests/di/create_container_test.php | 78 | ||||
-rw-r--r-- | tests/di/fixtures/config.php | 11 |
2 files changed, 89 insertions, 0 deletions
diff --git a/tests/di/create_container_test.php b/tests/di/create_container_test.php new file mode 100644 index 0000000000..a3a1ad3597 --- /dev/null +++ b/tests/di/create_container_test.php @@ -0,0 +1,78 @@ +<?php +/** +* +* @package testing +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* +*/ + +namespace +{ + require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; + require_once dirname(__FILE__) . '/../../phpBB/includes/functions_container.php'; + + class phpbb_di_container_test extends phpbb_test_case + { + public function test_phpbb_create_container() + { + $phpbb_root_path = __DIR__ . '/../../phpBB/'; + $extensions = array( + new \phpbb\di\extension\config(__DIR__ . '/fixtures/config.php'), + new \phpbb\di\extension\core($phpbb_root_path . 'config'), + ); + $container = phpbb_create_container($extensions, $phpbb_root_path, 'php'); + + $this->assertInstanceOf('Symfony\Component\DependencyInjection\ContainerBuilder', $container); + } + + public function test_phpbb_create_install_container() + { + $phpbb_root_path = __DIR__ . '/../../phpBB/'; + $extensions = array( + new \phpbb\di\extension\config(__DIR__ . '/fixtures/config.php'), + new \phpbb\di\extension\core($phpbb_root_path . 'config'), + ); + $container = phpbb_create_install_container($phpbb_root_path, 'php'); + + $this->assertInstanceOf('Symfony\Component\DependencyInjection\ContainerBuilder', $container); + $this->assertTrue($container->isFrozen()); + } + + public function test_phpbb_create_compiled_container() + { + $phpbb_root_path = __DIR__ . '/../../phpBB/'; + $config_file = __DIR__ . '/fixtures/config.php'; + $extensions = array( + new \phpbb\di\extension\config(__DIR__ . '/fixtures/config.php'), + new \phpbb\di\extension\core($phpbb_root_path . 'config'), + ); + $container = phpbb_create_compiled_container($config_file, $extensions, array(), $phpbb_root_path, 'php'); + + $this->assertInstanceOf('Symfony\Component\DependencyInjection\ContainerBuilder', $container); + $this->assertTrue($container->isFrozen()); + } + } +} + +namespace phpbb\db\driver +{ + class container_mock extends \phpbb\db\driver\driver + { + public function sql_connect() + { + } + + public function sql_query() + { + } + + public function sql_fetchrow() + { + } + + public function sql_freeresult() + { + } + } +} diff --git a/tests/di/fixtures/config.php b/tests/di/fixtures/config.php new file mode 100644 index 0000000000..04e20f63d8 --- /dev/null +++ b/tests/di/fixtures/config.php @@ -0,0 +1,11 @@ +<?php +// phpBB 3.1.x auto-generated configuration file +// Do not change anything in this file! +$dbms = 'container_mock'; +$dbhost = '127.0.0.1'; +$dbport = ''; +$dbname = 'phpbb'; +$dbuser = 'root'; +$dbpasswd = ''; +$table_prefix = 'phpbb_'; +$acm_type = '\phpbb\cache\driver\null'; |