aboutsummaryrefslogtreecommitdiffstats
path: root/tests/di/create_container_test.php
blob: 8bf9f636faca8981508f0a10685ee3cc56b8f29b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<?php
/**
*
* This file is part of the phpBB Forum Software package.
*
* @copyright (c) phpBB Limited <https://www.phpbb.com>
* @license GNU General Public License, version 2 (GPL-2.0)
*
* For full copyright and license information, please see
* the docs/CREDITS.txt file.
*
*/

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($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)
		{
		}
	}
}