Skip to content

Commit 66acffc

Browse files
authored
Merge pull request #144 from iMattPro/updates
Just some updates
2 parents 2370b06 + 0be72c0 commit 66acffc

10 files changed

Lines changed: 123 additions & 23 deletions

File tree

.github/workflows/tests.yml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
strategy:
2626
matrix:
2727
include:
28-
- php: '7.1'
28+
- php: '7.2'
2929
db: "none"
3030
NOTESTS: 1
3131

@@ -123,6 +123,8 @@ jobs:
123123
db: "mysql:5.7"
124124
- php: '8.1'
125125
db: "mysql:5.7"
126+
- php: '8.2'
127+
db: "mysql:5.7"
126128

127129
name: PHP ${{ matrix.php }} - ${{ matrix.db_alias != '' && matrix.db_alias || matrix.db }}
128130

@@ -221,6 +223,20 @@ jobs:
221223
db: "postgres:12"
222224
- php: '7.1'
223225
db: "postgres:13"
226+
- php: '7.2'
227+
db: "postgres:13"
228+
- php: '7.3'
229+
db: "postgres:13"
230+
- php: '7.4'
231+
db: "postgres:13"
232+
- php: '8.0'
233+
db: "postgres:12"
234+
- php: '8.0'
235+
db: "postgres:13"
236+
- php: '8.1'
237+
db: "postgres:14"
238+
- php: '8.2'
239+
db: "postgres:14"
224240

225241
name: PHP ${{ matrix.php }} - ${{ matrix.db }}
226242

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ The official Ideas Centre used at [phpBB.com](https://www.phpbb.com/ideas/). Thi
77

88
## Contribute
99

10-
We welcome contributions to help make this Ideas extension even better. Please fork this repository, install it to a local development copy of phpBB, and send us a pull request with your bug fixes or feature improvements.
10+
We welcome contributions to help make this extension even better. Please fork this repository, install it to a local development copy of phpBB, and send us a pull request with your bug fixes or feature improvements.
1111

1212
## Bugs and Support
1313

controller/index_controller.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,6 @@ public function index()
6161
// Display common ideas template vars
6262
$this->display_common_vars();
6363

64-
return $this->helper->render('index_body.html', $this->language->lang('IDEAS_TITLE'));
64+
return $this->helper->render('@phpbb_ideas/index_body.html', $this->language->lang('IDEAS_TITLE'));
6565
}
6666
}

controller/list_controller.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,6 @@ public function ideas_list($sort)
118118
// Display common ideas template vars
119119
$this->display_common_vars();
120120

121-
return $this->helper->render('list_body.html', $this->language->lang('IDEA_LIST'));
121+
return $this->helper->render('@phpbb_ideas/list_body.html', $this->language->lang('IDEA_LIST'));
122122
}
123123
}

ext.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
/**
1414
* This ext class is optional and can be omitted if left empty.
15-
* However you can add special (un)installation commands in the
15+
* However, you can add special (un)installation commands in the
1616
* methods enable_step(), disable_step() and purge_step(). As it is,
1717
* these methods are defined in \phpbb\extension\base, which this
1818
* class extends, but you can overwrite them to give special
@@ -55,7 +55,7 @@ public static function status_name($id)
5555
}
5656

5757
/**
58-
* Check whether or not the extension can be enabled.
58+
* Check whether the extension can be enabled.
5959
*
6060
* Requires phpBB >= 3.2.3 due to removal of deprecated Twig functions (ie Twig_SimpleFunction)
6161
* Also incompatible with SQLite which does not support SQRT in SQL queries

styles/prosilver/template/index_body.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<h2>{{ lang('IDEAS_TITLE') }}</h2>
66

7-
{% include 'action_bar_top.html' %}
7+
{% include '@phpbb_ideas/action_bar_top.html' %}
88

99
{# TOP IDEAS #}
1010
<div class="flex-box flex-align-end flex-justify">
@@ -24,7 +24,7 @@ <h2>{{ lang('TOP_IDEAS') }}</h2>
2424
</li>
2525
</ul>
2626
{% set ideas = top_ideas %}
27-
{% include 'index_list.html' %}
27+
{% include '@phpbb_ideas/index_list.html' %}
2828
</div>
2929
</div>
3030

@@ -46,7 +46,7 @@ <h2>{{ lang('LATEST_IDEAS') }}</h2>
4646
</li>
4747
</ul>
4848
{% set ideas = latest_ideas %}
49-
{% include 'index_list.html' %}
49+
{% include '@phpbb_ideas/index_list.html' %}
5050
</div>
5151
</div>
5252

@@ -68,7 +68,7 @@ <h2>{{ lang('IMPLEMENTED_IDEAS') }}</h2>
6868
</li>
6969
</ul>
7070
{% set ideas = implemented_ideas %}
71-
{% include 'index_list.html' %}
71+
{% include '@phpbb_ideas/index_list.html' %}
7272
</div>
7373
</div>
7474

styles/prosilver/template/list_body.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<h2>{{ lang('IDEAS_TITLE') }} <i class="icon fa-fw fa-angle-double-right"></i>{{ STATUS_NAME }}</h2>
66

7-
{% include 'action_bar_top.html' %}
7+
{% include '@phpbb_ideas/action_bar_top.html' %}
88

99
<div class="forumbg">
1010
<div class="inner">
@@ -16,7 +16,7 @@ <h2>{{ lang('IDEAS_TITLE') }} <i class="icon fa-fw fa-angle-double-right"></i>{{
1616
</dl>
1717
</li>
1818
</ul>
19-
{% include 'index_list.html' %}
19+
{% include '@phpbb_ideas/index_list.html' %}
2020
</div>
2121
</div>
2222

tests/controller/index_controller_test.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class index_controller_test extends controller_base
2020
public function controller_test_data()
2121
{
2222
return array(
23-
array(200, 'index_body.html'),
23+
array(200, '@phpbb_ideas/index_body.html'),
2424
);
2525
}
2626

tests/controller/list_controller_test.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public function controller_test_data()
2424
// Call top ideas list
2525
array(
2626
200,
27-
'list_body.html',
27+
'@phpbb_ideas/list_body.html',
2828
array(
2929
'sort' => \phpbb\ideas\ext::SORT_TOP,
3030
'status' => 0,
@@ -37,7 +37,7 @@ public function controller_test_data()
3737
// Call latest ideas list
3838
array(
3939
200,
40-
'list_body.html',
40+
'@phpbb_ideas/list_body.html',
4141
array(
4242
'sort' => '',
4343
'status' => 0,
@@ -50,7 +50,7 @@ public function controller_test_data()
5050
// Call implemented ideas list
5151
array(
5252
200,
53-
'list_body.html',
53+
'@phpbb_ideas/list_body.html',
5454
array(
5555
'sort' => \phpbb\ideas\ext::SORT_DATE,
5656
'status' => \phpbb\ideas\ext::$statuses['IMPLEMENTED'],
@@ -65,7 +65,7 @@ public function controller_test_data()
6565
// New ideas sorted by date
6666
array(
6767
200,
68-
'list_body.html',
68+
'@phpbb_ideas/list_body.html',
6969
array(
7070
'sort' => \phpbb\ideas\ext::SORT_NEW,
7171
'status' => \phpbb\ideas\ext::$statuses['NEW'],
@@ -78,7 +78,7 @@ public function controller_test_data()
7878
// In progress ideas sorted by score
7979
array(
8080
200,
81-
'list_body.html',
81+
'@phpbb_ideas/list_body.html',
8282
array(
8383
'sort' => \phpbb\ideas\ext::SORT_SCORE,
8484
'status' => \phpbb\ideas\ext::$statuses['IN_PROGRESS'],
@@ -91,7 +91,7 @@ public function controller_test_data()
9191
// Duplicate ideas sorted by author
9292
array(
9393
200,
94-
'list_body.html',
94+
'@phpbb_ideas/list_body.html',
9595
array(
9696
'sort' => \phpbb\ideas\ext::SORT_AUTHOR,
9797
'status' => \phpbb\ideas\ext::$statuses['DUPLICATE'],
@@ -104,7 +104,7 @@ public function controller_test_data()
104104
// Invalid ideas sorted by date
105105
array(
106106
200,
107-
'list_body.html',
107+
'@phpbb_ideas/list_body.html',
108108
array(
109109
'sort' => \phpbb\ideas\ext::SORT_DATE,
110110
'status' => \phpbb\ideas\ext::$statuses['INVALID'],
@@ -117,7 +117,7 @@ public function controller_test_data()
117117
// Implemented ideas sorted by top
118118
array(
119119
200,
120-
'list_body.html',
120+
'@phpbb_ideas/list_body.html',
121121
array(
122122
'sort' => \phpbb\ideas\ext::SORT_TOP,
123123
'status' => \phpbb\ideas\ext::$statuses['IMPLEMENTED'],
@@ -130,7 +130,7 @@ public function controller_test_data()
130130
// All ideas sorted by date
131131
array(
132132
200,
133-
'list_body.html',
133+
'@phpbb_ideas/list_body.html',
134134
array(
135135
'sort' => \phpbb\ideas\ext::SORT_NEW,
136136
'status' => -1,
@@ -143,7 +143,7 @@ public function controller_test_data()
143143
// My ideas list
144144
array(
145145
200,
146-
'list_body.html',
146+
'@phpbb_ideas/list_body.html',
147147
array(
148148
'sort' => \phpbb\ideas\ext::SORT_MYIDEAS,
149149
'status' => -1,

tests/cron/cron_test.php

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
<?php
2+
/**
3+
*
4+
* Ideas extension for 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+
*/
10+
11+
namespace phpbb\ideas\tests\cron;
12+
13+
class cron_test extends \phpbb_test_case
14+
{
15+
/** @var \phpbb\config\config */
16+
protected $config;
17+
18+
/** @var \phpbb\ideas\cron\prune_orphaned_ideas */
19+
protected $cron_task;
20+
21+
/** @var \phpbb\ideas\factory\ideas|\PHPUnit\Framework\MockObject\MockObject */
22+
protected $ideas;
23+
24+
protected function setUp(): void
25+
{
26+
parent::setUp();
27+
28+
$this->config = new \phpbb\config\config(['ideas_cron_last_run' => 0]);
29+
30+
$this->ideas = $this->getMockBuilder('\phpbb\ideas\factory\ideas')
31+
->disableOriginalConstructor()
32+
->getMock();
33+
34+
$this->cron_task = new \phpbb\ideas\cron\prune_orphaned_ideas($this->config, $this->ideas);
35+
}
36+
37+
/**
38+
* Test the cron task runs correctly
39+
*/
40+
public function test_run()
41+
{
42+
// Get last run time stored for cron
43+
$cron_last_run = $this->config['ideas_cron_last_run'];
44+
45+
// Expect ideas method delete_orphans is called once
46+
$this->ideas->expects(self::once())
47+
->method('delete_orphans');
48+
49+
// Run the cron task
50+
$this->cron_task->run();
51+
52+
// Now the last run time should be greater than before the test
53+
self::assertGreaterThan($cron_last_run, $this->config['ideas_cron_last_run']);
54+
}
55+
56+
/**
57+
* Data set for test_should_run
58+
*
59+
* @return array Array of test data
60+
*/
61+
public function should_run_data()
62+
{
63+
return array(
64+
array(time(), false),
65+
array(strtotime('1 day ago'), false),
66+
array(strtotime('8 days ago'), true),
67+
array('', true),
68+
array(0, true),
69+
array(null, true),
70+
);
71+
}
72+
73+
/**
74+
* Test cron task should run after 1 week (7 days)
75+
*
76+
* @dataProvider should_run_data
77+
*/
78+
public function test_should_run($time, $expected)
79+
{
80+
$this->config['ideas_cron_last_run'] = $time;
81+
82+
self::assertSame($expected, $this->cron_task->should_run());
83+
}
84+
}

0 commit comments

Comments
 (0)