Skip to content

Commit 2f16e91

Browse files
committed
Added tests for rebuild index command when using queue.
1 parent deaeefb commit 2f16e91

File tree

2 files changed

+49
-5
lines changed

2 files changed

+49
-5
lines changed

src/Nqxcode/LuceneSearch/Console/RebuildCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ private function rebuild()
119119
$this->search->destroyConnection();
120120

121121
if ($queue) {
122-
Queue::push('Nqxcode\LuceneSearch\Job\RotateSearchIndex', $queue);
122+
Queue::push('Nqxcode\LuceneSearch\Job\RotateSearchIndex', [], $queue);
123123

124124
} else {
125125
$this->searchIndexRotator->rotate();

tests/functional/Console/RebuildCommandTest.php

Lines changed: 48 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,12 @@ public function tearDown()
4141
* @dataProvider getOutputDataProvider
4242
* @param $expected
4343
* @param $config
44+
* @param $queue
4445
*/
45-
public function testForceRebuildCommand($expected, $config)
46+
public function testForceRebuildCommand($expected, $config, $queue)
4647
{
4748
Config::set('laravel-lucene-search::index.models', $config);
49+
Config::set('laravel-lucene-search::queue', $queue);
4850

4951
$output = new BufferedOutput();
5052
$this->artisan->call('search:rebuild', ['--verbose' => true, '--force' => true], $output);
@@ -56,10 +58,12 @@ public function testForceRebuildCommand($expected, $config)
5658
* @dataProvider getOutputDataProvider
5759
* @param $expected
5860
* @param $config
61+
* @param $queue
5962
*/
60-
public function testSoftRebuildCommand($expected, $config)
63+
public function testSoftRebuildCommand($expected, $config, $queue)
6164
{
6265
Config::set('laravel-lucene-search::index.models', $config);
66+
Config::set('laravel-lucene-search::queue', $queue);
6367

6468
$output = new BufferedOutput();
6569
$this->artisan->call('search:rebuild', ['--verbose' => true], $output);
@@ -88,7 +92,45 @@ public function getOutputDataProvider()
8892
'tests\models\Tool' => [
8993
'fields' => ['name', 'description'],
9094
],
91-
]
95+
],
96+
97+
false,
98+
],
99+
[
100+
'Creating index for model: "tests\models\Tool"
101+
No available models found.
102+
103+
Operation is fully complete!
104+
',
105+
[
106+
'tests\models\Tool' => [
107+
'fields' => ['name', 'description'],
108+
],
109+
],
110+
111+
false,
112+
],
113+
[
114+
'Creating index for model: "tests\models\Product"
115+
0 [>---------------------------]
116+
1 [->--------------------------]
117+
118+
Creating index for model: "tests\models\Tool"
119+
No available models found.
120+
121+
Operation is fully complete!
122+
',
123+
[
124+
'tests\models\Product' => [
125+
'fields' => ['name', 'description'],
126+
],
127+
128+
'tests\models\Tool' => [
129+
'fields' => ['name', 'description'],
130+
],
131+
],
132+
133+
'search-sync-queue',
92134
],
93135
[
94136
'Creating index for model: "tests\models\Tool"
@@ -100,7 +142,9 @@ public function getOutputDataProvider()
100142
'tests\models\Tool' => [
101143
'fields' => ['name', 'description'],
102144
],
103-
]
145+
],
146+
147+
'search-sync-queue',
104148
],
105149
];
106150
}

0 commit comments

Comments
 (0)