1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the ONGR package. |
5
|
|
|
* |
6
|
|
|
* (c) NFQ Technologies UAB <[email protected]> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace ONGR\SettingsBundle\Tests\Unit\Settings\Personal; |
13
|
|
|
|
14
|
|
|
use ONGR\ElasticsearchBundle\Test\AbstractElasticsearchTestCase; |
15
|
|
|
use ONGR\SettingsBundle\Settings\Personal\PersonalProfilesProvider; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Test how PersonalProfilesProvider collects General settings from ES. |
19
|
|
|
*/ |
20
|
|
|
class PersonalProfilesProviderTest extends AbstractElasticsearchTestCase |
21
|
|
|
{ |
22
|
|
|
/** |
23
|
|
|
* Test method getSettings. |
24
|
|
|
*/ |
25
|
|
|
public function testGetSettings() |
26
|
|
|
{ |
27
|
|
|
$manager = new PersonalProfilesProvider(); |
28
|
|
|
$manager->setProfileManager($this->getProfilesManagerMock()); |
29
|
|
|
|
30
|
|
|
$expectedArray = [ |
31
|
|
|
'ongr_settings_profile_profile' => [ |
32
|
|
|
'name' => 'profile', |
33
|
|
|
'category' => 'ongr_settings_profiles', |
34
|
|
|
], |
35
|
|
|
'ongr_settings_profile_profile2' => [ |
36
|
|
|
'name' => 'profile2', |
37
|
|
|
'category' => 'ongr_settings_profiles', |
38
|
|
|
], |
39
|
|
|
'ongr_settings_profile_profile3' => [ |
40
|
|
|
'name' => 'profile3', |
41
|
|
|
'category' => 'ongr_settings_profiles', |
42
|
|
|
], |
43
|
|
|
'ongr_settings_profile_profile4' => [ |
44
|
|
|
'name' => 'profile4', |
45
|
|
|
'category' => 'ongr_settings_profiles', |
46
|
|
|
], |
47
|
|
|
]; |
48
|
|
|
$this->assertEquals($manager->getSettings(), $expectedArray); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* Returns mock of Profiles Manager. |
53
|
|
|
* |
54
|
|
|
* @return ProfileManager |
55
|
|
|
*/ |
56
|
|
|
protected function getProfilesManagerMock() |
57
|
|
|
{ |
58
|
|
|
$profileSettingsProvider = $this |
59
|
|
|
->getMockBuilder('ONGR\SettingsBundle\Service\ProfileManager') |
60
|
|
|
->disableOriginalConstructor() |
61
|
|
|
->getMock(); |
62
|
|
|
|
63
|
|
|
$profileSettingsProvider->expects( |
64
|
|
|
$this->once() |
65
|
|
|
)->method('getAllProfiles') |
66
|
|
|
->willReturn( |
67
|
|
|
[ |
68
|
|
|
['name' => 'profile'], |
69
|
|
|
['name' => 'profile2'], |
70
|
|
|
['name' => 'profile3'], |
71
|
|
|
['name' => 'profile4'], |
72
|
|
|
] |
73
|
|
|
); |
74
|
|
|
|
75
|
|
|
return $profileSettingsProvider; |
76
|
|
|
} |
77
|
|
|
} |
78
|
|
|
|