Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
91.53% covered (success)
91.53%
54 / 59
75.00% covered (warning)
75.00%
3 / 4
CRAP
0.00% covered (danger)
0.00%
0 / 1
phpbb_feed_attachments_base_test
91.53% covered (success)
91.53%
54 / 59
75.00% covered (warning)
75.00%
3 / 4
5.02
0.00% covered (danger)
0.00%
0 / 1
 getDataSet
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setUp
100.00% covered (success)
100.00%
47 / 47
100.00% covered (success)
100.00%
1 / 1
1
 data_fetch_attachments
0.00% covered (danger)
0.00%
0 / 5
0.00% covered (danger)
0.00%
0 / 1
2
 test_fetch_attachments
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
1 / 1
2
1<?php
2/**
3 *
4 * This file is part of the phpBB Forum Software package.
5 *
6 * @copyright (c) phpBB Limited <https://www.phpbb.com>
7 * @license GNU General Public License, version 2 (GPL-2.0)
8 *
9 * For full copyright and license information, please see
10 * the docs/CREDITS.txt file.
11 *
12 */
13
14require_once(__DIR__ . '/attachments_mock_feed.php');
15
16class phpbb_feed_attachments_base_test extends phpbb_database_test_case
17{
18    /** @var \phpbb_feed_attachments_mock_feed */
19    protected $attachments_mocks_feed;
20
21    public function getDataSet()
22    {
23        return $this->createXMLDataSet(__DIR__ . '/../extension/fixtures/extensions.xml');
24    }
25
26    protected function setUp(): void
27    {
28        global $phpbb_root_path, $phpEx;
29
30        $config = new \phpbb\config\config(array());
31        $path_helper = new \phpbb\path_helper(
32            new \phpbb\symfony_request(
33                new phpbb_mock_request()
34            ),
35            $this->createMock('\phpbb\request\request'),
36            $phpbb_root_path,
37            'php'
38        );
39        $user = new \phpbb\user(
40            new \phpbb\language\language(
41                new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)
42            ),
43            '\phpbb\datetime'
44        );
45        $container = new phpbb_mock_container_builder();
46        $this->get_test_case_helpers()->set_s9e_services($container);
47        $container->set('feed.quote_helper', new \phpbb\feed\quote_helper($user, $phpbb_root_path, 'php'));
48        $db = $this->new_dbal();
49        $cache = new \phpbb_mock_cache();
50        $auth = new \phpbb\auth\auth();
51        $feed_helper = new \phpbb\feed\helper($auth, $config, $container, $path_helper, $container->get('text_formatter.renderer'), $user);
52        $content_visibility = new \phpbb\content_visibility(
53            $auth,
54            $config,
55            new \phpbb_mock_event_dispatcher(),
56            $db,
57            $user,
58            $phpbb_root_path,
59            $phpEx,
60            FORUMS_TABLE,
61            POSTS_TABLE,
62            TOPICS_TABLE,
63            USERS_TABLE
64        );
65
66        $this->attachments_mocks_feed = new \phpbb_feed_attachments_mock_feed(
67            $feed_helper,
68            $config,
69            $db,
70            $cache,
71            $user,
72            $auth,
73            $content_visibility,
74            new \phpbb_mock_event_dispatcher(),
75            $phpEx
76        );
77    }
78
79    public static function data_fetch_attachments()
80    {
81        return array(
82            array(array(0), array(0)),
83            array(array(), array(1)),
84            array(array(), array(), 'RuntimeException')
85        );
86    }
87
88    /**
89     * @dataProvider data_fetch_attachments
90     */
91    public function test_fetch_attachments($post_ids, $topic_ids, $expected_exception = false)
92    {
93        $this->attachments_mocks_feed->post_ids = $post_ids;
94        $this->attachments_mocks_feed->topic_ids = $topic_ids;
95
96        if ($expected_exception !== false)
97        {
98            $this->expectException($expected_exception);
99
100            $this->attachments_mocks_feed->get_sql();
101        }
102        else
103        {
104            $this->assertTrue($this->attachments_mocks_feed->get_sql());
105        }
106    }
107}