aboutsummaryrefslogtreecommitdiffstats
path: root/tests/notification/submit_post_base.php
diff options
context:
space:
mode:
authorTristan Darricau <tristan.darricau@sensiolabs.com>2015-07-09 17:04:40 +0200
committerTristan Darricau <tristan.darricau@sensiolabs.com>2015-07-13 22:41:14 +0200
commitfc34057f288c6b8c656a0ed1ac2cb5a86f86206d (patch)
treee1fead9c675d649708d7540c3d6e4bbf9d97abd2 /tests/notification/submit_post_base.php
parentf29b12e35397ef4a4996ea7d212f0ab5a7a1dba6 (diff)
downloadforums-fc34057f288c6b8c656a0ed1ac2cb5a86f86206d.tar
forums-fc34057f288c6b8c656a0ed1ac2cb5a86f86206d.tar.gz
forums-fc34057f288c6b8c656a0ed1ac2cb5a86f86206d.tar.bz2
forums-fc34057f288c6b8c656a0ed1ac2cb5a86f86206d.tar.xz
forums-fc34057f288c6b8c656a0ed1ac2cb5a86f86206d.zip
[ticket/11444] Update tests and cleanup types/methods
PHPBB3-11444
Diffstat (limited to 'tests/notification/submit_post_base.php')
-rw-r--r--tests/notification/submit_post_base.php71
1 files changed, 30 insertions, 41 deletions
diff --git a/tests/notification/submit_post_base.php b/tests/notification/submit_post_base.php
index 73711369ed..72b25abf0a 100644
--- a/tests/notification/submit_post_base.php
+++ b/tests/notification/submit_post_base.php
@@ -11,6 +11,10 @@
*
*/
+use Symfony\Component\Config\FileLocator;
+use Symfony\Component\DependencyInjection\ContainerBuilder;
+use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
+
require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
require_once dirname(__FILE__) . '/../../phpBB/includes/functions_content.php';
require_once dirname(__FILE__) . '/../../phpBB/includes/functions_posting.php';
@@ -75,8 +79,9 @@ abstract class phpbb_notification_submit_post_base extends phpbb_database_test_c
'allow_board_notifications' => true,
));
+ $cache_driver = new \phpbb\cache\driver\dummy();
$cache = new \phpbb\cache\service(
- new \phpbb\cache\driver\dummy(),
+ $cache_driver,
$config,
$db,
$phpbb_root_path,
@@ -103,58 +108,49 @@ abstract class phpbb_notification_submit_post_base extends phpbb_database_test_c
$type_cast_helper = $this->getMock('\phpbb\request\type_cast_helper_interface');
$request = $this->getMock('\phpbb\request\request');
- // Container
- $phpbb_container = new phpbb_mock_container_builder();
$phpbb_dispatcher = new phpbb_mock_event_dispatcher();
- $phpbb_container->set('content.visibility', new \phpbb\content_visibility($auth, $config, $phpbb_dispatcher, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE));
-
$user_loader = new \phpbb\user_loader($db, $phpbb_root_path, $phpEx, USERS_TABLE);
+ // Container
+ $phpbb_container = new ContainerBuilder();
+ $loader = new YamlFileLoader($phpbb_container, new FileLocator(__DIR__ . '/fixtures'));
+ $loader->load('services_notification.yml');
+ $phpbb_container->set('user_loader', $user_loader);
+ $phpbb_container->set('user', $user);
+ $phpbb_container->set('config', $config);
+ $phpbb_container->set('dbal.conn', $db);
+ $phpbb_container->set('auth', $auth);
+ $phpbb_container->set('cache.driver', $cache_driver);
+ $phpbb_container->set('cache', $cache);
+ $phpbb_container->set('text_formatter.utils', new \phpbb\textformatter\s9e\utils());
+ $phpbb_container->set('dispatcher', $phpbb_dispatcher);
+ $phpbb_container->setParameter('core.root_path', $phpbb_root_path);
+ $phpbb_container->setParameter('core.php_ext', $phpEx);
+ $phpbb_container->setParameter('tables.notifications', 'phpbb_notifications');
+ $phpbb_container->setParameter('tables.user_notifications', 'phpbb_user_notifications');
+ $phpbb_container->setParameter('tables.notification_types', 'phpbb_notification_types');
+ $phpbb_container->set('content.visibility', new \phpbb\content_visibility($auth, $config, $phpbb_dispatcher, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE));
+ $phpbb_container->compile();
+
// Notification Types
$notification_types = array('quote', 'bookmark', 'post', 'post_in_queue', 'topic', 'topic_in_queue', 'approve_topic', 'approve_post');
$notification_types_array = array();
foreach ($notification_types as $type)
{
- $class = $this->build_type($type);
- $phpbb_container->set('notification.type.' . $type, array(array($this, 'build_type'), array($type)));
+ $class = $phpbb_container->get('notification.type.' . $type);
$notification_types_array['notification.type.' . $type] = $class;
}
// Methods Types
- $class_name = 'phpbb\notification\method\board';
- $class = new $class_name(
- $user_loader, $db, $cache->get_driver(), $user, $auth, $config,
- $phpbb_root_path, $phpEx,
- NOTIFICATION_TYPES_TABLE, NOTIFICATIONS_TABLE);
- $phpbb_container->set('notification.method.board', $class);
- $notification_methods_array = array('notification.method.board' => $class);
+ $notification_methods_array = array('notification.method.board' => $phpbb_container->get('notification.method.board'));
// Notification Manager
$phpbb_notifications = new \phpbb\notification\manager($notification_types_array, $notification_methods_array,
- $phpbb_container, $user_loader, $config, $phpbb_dispatcher, $db, $cache, $user,
- $phpbb_root_path, $phpEx,
+ $phpbb_container, $user_loader, $phpbb_dispatcher, $db, $cache, $user,
NOTIFICATION_TYPES_TABLE, USER_NOTIFICATIONS_TABLE);
$phpbb_container->set('notification_manager', $phpbb_notifications);
}
- public function build_type($type)
- {
- global $auth, $cache, $config, $db, $phpbb_container, $phpbb_dispatcher, $user, $request, $phpEx, $phpbb_root_path, $user_loader;
-
- $class_name = '\phpbb\notification\type\\' . $type;
- $class = new $class_name(
- $user_loader, $db, $cache->get_driver(), $user, $auth, $config,
- $phpbb_root_path, $phpEx,
- NOTIFICATION_TYPES_TABLE, USER_NOTIFICATIONS_TABLE);
-
- if ($type === 'quote')
- {
- $class->set_utils(new \phpbb\textformatter\s9e\utils);
- }
-
- return $class;
- }
-
/**
* @dataProvider submit_post_data
*/
@@ -177,11 +173,4 @@ abstract class phpbb_notification_submit_post_base extends phpbb_database_test_c
$this->assertEquals($expected_after, $this->db->sql_fetchrowset($result));
$this->db->sql_freeresult($result);
}
-
- protected function build_method($method)
- {
- global $phpbb_root_path, $phpEx;
-
- return new $method($this->user_loader, $this->db, $this->cache->get_driver(), $this->user, $this->auth, $this->config, $phpbb_root_path, $phpEx, 'phpbb_notification_types', 'phpbb_notifications', 'phpbb_user_notifications');
- }
}