+
{{ row.name }} |
+
{{ row.description }} |
+
{{ row.type }} |
+
+
diff --git a/Resources/views/Settings/settings.html.twig b/Resources/views/Settings/settings.html.twig
index 246bb2a..cf990af 100644
--- a/Resources/views/Settings/settings.html.twig
+++ b/Resources/views/Settings/settings.html.twig
@@ -9,7 +9,19 @@
- Settings
+
+
+ Personal Settings
+
+
+
+
diff --git a/Resources/views/layout.html.twig b/Resources/views/layout.html.twig
index 1cfb211..5c52cae 100644
--- a/Resources/views/layout.html.twig
+++ b/Resources/views/layout.html.twig
@@ -3,7 +3,7 @@
- {% block title -%}{{ "ONGR Settings"|trans }}{%- endblock %}
+ {% block title -%}{{ "Settings"|trans }}{%- endblock %}
{% block stylesheets %}
diff --git a/Tests/Functional/DependencyInjection/Compiler/ProviderPassTest.php b/Tests/Functional/DependencyInjection/Compiler/ProviderPassTest.php
index 1689c01..402854e 100644
--- a/Tests/Functional/DependencyInjection/Compiler/ProviderPassTest.php
+++ b/Tests/Functional/DependencyInjection/Compiler/ProviderPassTest.php
@@ -29,6 +29,7 @@ public function testProcess()
'ongr_settings.settings_provider.class',
'ONGR\\SettingsBundle\\Settings\\Personal\\Provider\\ManagerAwareSettingProvider.php'
);
+ $container->setParameter('ongr_settings.connection.repository', 'es.manager.setting');
$definition = new Definition();
$definition->addTag('ongr_settings.ongr_settings', ['profile' => 'custom']);
diff --git a/Tests/Unit/Controller/PersonalSettingsControllerTest.php b/Tests/Unit/Controller/PersonalSettingsControllerTest.php
deleted file mode 100644
index 0d5fdb4..0000000
--- a/Tests/Unit/Controller/PersonalSettingsControllerTest.php
+++ /dev/null
@@ -1,136 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace ONGR\SettingsBundle\Tests\Unit\Controller;
-
-use ONGR\SettingsBundle\Controller\PersonalSettingsController;
-use ONGR\SettingsBundle\Settings\Personal\SettingsStructure;
-use ONGR\SettingsBundle\Settings\SettingsCookieService;
-use Symfony\Component\DependencyInjection\ContainerBuilder;
-use Symfony\Component\HttpFoundation\Request;
-use Symfony\Component\HttpFoundation\Response;
-
-class PersonalSettingsControllerTest extends \PHPUnit_Framework_TestCase
-{
- /**
- * Data provider for testSetSettingAction.
- *
- * @return array
- */
- public function getSetSettingActionData()
- {
- $out = [];
-
- // Case #0 OK.
- $out[0] = [
- [
- 'encoded_testA' => [
- 'name' => 'test_name',
- 'category' => 'test_category',
- 'cookie' => 'ongr_settings.settings.settings_cookie',
- ],
- 'encoded_test' => [
- 'name' => 'test_name',
- 'category' => 'test_category',
- 'cookie' => 'ongr_settings.settings.settings_cookie',
- ],
- ],
- true,
- ];
-
- // Case #0 Should fail.
- $out[1] = [
- [
- 'encoded_test' => [
- 'name' => 'test_name',
- 'category' => 'test_category',
- 'cookie' => 'ongr_settings.settings.settings_cookie',
- ],
- ],
- false,
- ];
-
- return $out;
- }
-
- /**
- * Test changeSettingAction.
- *
- * @param array $testData
- * @param bool $expected
- *
- * @dataProvider getSetSettingActionData
- */
- public function testChangeSettingAction($testData, $expected)
- {
- $container = new ContainerBuilder();
-
- $container->set('ongr_settings.settings.personal_settings_manager', $this->getManagerMock($testData));
- $container->set('ongr_settings.settings.settings_cookie', $this->getCookiesServiceMock());
-
- $controller = new PersonalSettingsController();
- $controller->setContainer($container);
- $response = $controller->changeSettingAction(new Request(), base64_encode('encoded_testA'));
-
- if ($expected) {
- $statusCode = Response::HTTP_OK;
- } else {
- $statusCode = Response::HTTP_FORBIDDEN;
- }
-
- $this->assertEquals(
- $statusCode,
- $response->getStatusCode()
- );
- }
-
- /**
- * @param array $testData
- *
- * @return \PHPUnit_Framework_MockObject_MockObject
- */
- public function getManagerMock($testData)
- {
- $securityContextInterfaceMock = $this->getMock('Symfony\Component\Security\Core\SecurityContextInterface');
- $settingsStructure = $this->getMock(
- 'ONGR\SettingsBundle\Settings\Personal\SettingsStructure',
- [],
- [
- [
- ['settingsParameterMock'],
- ],
- [
- ['categoriesParameterMock'],
- ],
- ]
- );
-
- $mock = $this->getMock(
- 'ONGR\SettingsBundle\Settings\Personal\PersonalSettingsManager',
- [],
- [$securityContextInterfaceMock, $settingsStructure]
- );
- $mock->method('getSettingsMap')->willReturn($testData);
- $mock->method('getSettings')->willReturn(['encoded_test' => 'encoded_test', 'encoded_test' => 'encoded_testA']);
-
- return $mock;
- }
-
- /**
- * @return \PHPUnit_Framework_MockObject_MockObject
- */
- public function getCookiesServiceMock()
- {
- $mock = $this->getMock('ONGR\SettingsBundle\Settings\SettingsCookieService', ['setValue']);
-
- return $mock;
- }
-}
diff --git a/Tests/Unit/Controller/SettingsListControllerTest.php b/Tests/Unit/Controller/SettingsListControllerTest.php
deleted file mode 100644
index 6f60be9..0000000
--- a/Tests/Unit/Controller/SettingsListControllerTest.php
+++ /dev/null
@@ -1,91 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace ONGR\SettingsBundle\Tests\Unit\Controller;
-
-use ONGR\SettingsBundle\Controller\SettingsListController;
-use ONGR\SettingsBundle\Tests\Fixtures\ElasticSearch\RepositoryTrait;
-use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface;
-use Symfony\Component\DependencyInjection\ContainerBuilder;
-use Symfony\Component\HttpFoundation\Request;
-
-class SettingsListControllerTest extends \PHPUnit_Framework_TestCase
-{
- use RepositoryTrait;
-
- /**
- * @return \PHPUnit_Framework_MockObject_MockObject|EngineInterface
- */
- public function getTemplateEngine()
- {
- $template = $this->getMock('Symfony\Bundle\FrameworkBundle\Templating\EngineInterface');
- $template->expects($this->any())->method('renderResponse')->will($this->returnArgument(1));
-
- return $template;
- }
-
- /**
- * Test for list action.
- */
- public function testListAction()
- {
- $container = new ContainerBuilder();
-
- $container->set('es.manager', $this->getManagerWithRepositoryMock());
- $container->set('templating', $this->getTemplateEngine());
- $container->set('router', $this->getMock('Symfony\\Component\\Routing\\RouterInterface'));
-
- $controller = new SettingsListController();
-
- $controller->setContainer($container);
- $requestQuery = ['q' => 'testName'];
- $result = $controller->listAction(new Request($requestQuery));
- $this->assertArrayHasKey('data', $result);
- $this->assertEquals('testName', $result['filters']['search']->getState()->getValue());
- }
-
- /**
- * Returns manager instance with injected connection if does not exist creates new one.
- *
- * @return Manager
- */
- protected function getManagerWithRepositoryMock()
- {
- $managerMock = $this->getOrmManagerMock();
-
- $repositoryMock = $this->getOrmRepositoryMock();
- $repositoryMock->expects(
- $this->once()
- )->method('execute')
- ->willReturn($this->getDocumentIteratorMock());
-
- $managerMock->expects(
- $this->once()
- )->method('getRepository')
- ->willReturn($repositoryMock);
-
- return $managerMock;
- }
-
- /**
- * Returns mock of Document Iterator.
- *
- * @return Manager
- */
- protected function getDocumentIteratorMock()
- {
- return $this->getMock(
- 'ONGR\ElasticsearchBundle\Result\DocumentIterator',
- null,
- [ null, null, [], [] ]
- );
- }
-}
diff --git a/Tests/Unit/Controller/SettingsManagerControllerTest.php b/Tests/Unit/Controller/SettingsManagerControllerTest.php
deleted file mode 100644
index 7a9d0d2..0000000
--- a/Tests/Unit/Controller/SettingsManagerControllerTest.php
+++ /dev/null
@@ -1,166 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace ONGR\SettingsBundle\Tests\Unit\Controller;
-
-use ONGR\SettingsBundle\Controller\SettingsManagerController;
-use ONGR\SettingsBundle\Document\Setting;
-use Symfony\Component\DependencyInjection\ContainerBuilder;
-use Symfony\Component\HttpFoundation\Request;
-use Symfony\Component\HttpFoundation\Response;
-
-class SettingsManagerControllerTest extends \PHPUnit_Framework_TestCase
-{
- /**
- * Data provider for testSetSettingAction.
- *
- * @return array
- */
- public function getSetSettingActionData()
- {
- $out = [];
-
- // Case #0: string.
- $out[] = ['name1', json_encode('value1')];
-
- // Case #1: json.
- $out[] = ['name2', json_encode(['value2', 'value3'])];
-
- // Case #2: invalid json.
- $out[] = ['name3', serialize(['value4', 'value5']), Response::HTTP_NOT_ACCEPTABLE];
-
- return $out;
- }
-
- /**
- * Test for set setting action.
- *
- * @param string $name
- * @param string $value
- * @param int $status
- *
- * @dataProvider getSetSettingActionData
- */
- public function testSetSettingAction($name, $value, $status = Response::HTTP_OK)
- {
- $manager = $this
- ->getMockBuilder('ONGR\SettingsBundle\Settings\General\SettingsManager')
- ->disableOriginalConstructor()
- ->getMock();
-
- if ($status == Response::HTTP_OK) {
- $manager
- ->expects($this->once())
- ->method('set')
- ->with($name, json_decode($value));
- }
-
- $container = new ContainerBuilder();
- $container->set('ongr_settings.settings_manager', $manager);
-
- $controller = new SettingsManagerController();
- $controller->setContainer($container);
-
- $request = new Request(
- [],
- ['value' => $value]
- );
-
- $response = $controller->setSettingAction($request, $name);
- $this->assertEquals($status, $response->getStatusCode());
- }
-
- /**
- * Test if ng edit action works as expected.
- */
- public function testNgEditAction()
- {
- $request = $this->getMock('Symfony\Component\HttpFoundation\Request');
- $request
- ->expects($this->once())
- ->method('getContent')
- ->will($this->returnValue(json_encode(['setting' => ['data' => ['value' => 'foobaz']]])));
-
- $manager = $this
- ->getMockBuilder('ONGR\SettingsBundle\Settings\General\SettingsManager')
- ->disableOriginalConstructor()
- ->getMock();
-
- $manager
- ->expects($this->once())
- ->method('get')
- ->with('fooname', 'profile')
- ->will($this->returnValue(new Setting()));
-
- $setting = new Setting();
- $setting->setData(['value' => 'foobaz']);
-
- $manager
- ->expects($this->once())
- ->method('save')
- ->with($setting);
-
- $container = new ContainerBuilder();
- $container->set('ongr_settings.settings_manager', $manager);
-
- $controller = new SettingsManagerController();
- $controller->setContainer($container);
-
- $this->assertEquals(
- Response::HTTP_OK,
- $controller->ngEditAction($request, 'fooname', 'profile')->getStatusCode()
- );
- }
-
- /**
- * Test if getting 400 status code with wrong content data.
- *
- * @param string $content
- *
- * @dataProvider getNgEditActionFailData
- */
- public function testNgEditActionFailValue($content)
- {
- $request = $this->getMock('Symfony\Component\HttpFoundation\Request');
- $request
- ->expects($this->once())
- ->method('getContent')
- ->will($this->returnValue($content));
-
- $controller = new SettingsManagerController();
- $response = $controller->ngEditAction($request, 'foobaz', 'default');
- $this->assertEquals(
- Response::HTTP_BAD_REQUEST,
- $response->getStatusCode()
- );
- }
-
- /**
- * Data provider for testNgEditActionFail.
- *
- * @return array
- */
- public function getNgEditActionFailData()
- {
- $out = [];
-
- // Case #0: empty.
- $out[] = [''];
-
- // Case #1: non json.
- $out[] = ['data' => 'data'];
-
- // Case #2: invalid json.
- $out[] = [json_encode(['data' => 'wrong_data'])];
-
- return $out;
- }
-}
diff --git a/Tests/Unit/DependencyInjection/Compiler/ProviderPassTest.php b/Tests/Unit/DependencyInjection/Compiler/ProviderPassTest.php
index b9374e0..7da25e0 100644
--- a/Tests/Unit/DependencyInjection/Compiler/ProviderPassTest.php
+++ b/Tests/Unit/DependencyInjection/Compiler/ProviderPassTest.php
@@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/
-namespace ONGR\SettingsBundle\Tests\Integration\DependencyInjection\Compiler;
+namespace ONGR\SettingsBundle\Tests\Unit\DependencyInjection\Compiler;
use ONGR\SettingsBundle\DependencyInjection\Compiler\ProviderPass;
use Symfony\Component\DependencyInjection\ContainerBuilder;
@@ -29,6 +29,7 @@ public function testProcess()
'ongr_settings.settings_provider.class',
'ONGR\\SettingsBundle\\Settings\\Personal\\Provider\\ManagerAwareSettingProvider'
);
+ $container->setParameter('ongr_settings.connection.repository', 'es.manager.default.setting');
$definition = new Definition();
$definition->addTag('ongr_settings.settings_provider', ['profile' => 'custom', 'priority' => 9]);
diff --git a/Tests/Unit/DependencyInjection/ConfigurationTest.php b/Tests/Unit/DependencyInjection/ConfigurationTest.php
index 585093e..6db1d32 100644
--- a/Tests/Unit/DependencyInjection/ConfigurationTest.php
+++ b/Tests/Unit/DependencyInjection/ConfigurationTest.php
@@ -12,7 +12,6 @@
namespace ONGR\SettingsBundle\Tests\Functional\DependencyInjection;
use ONGR\SettingsBundle\DependencyInjection\Configuration;
-use ONGR\ElasticsearchBundle\Test\ElasticsearchTestCase;
use Symfony\Component\Config\Definition\Processor;
class ConfigurationTest extends \PHPUnit_Framework_TestCase
@@ -28,6 +27,7 @@ public function configurationData()
'index_name' => 'ongr-settings',
'host' => '127.0.0.1',
'port' => 9200,
+ 'repository' => 'es.manager.settings.setting',
];
// A #0 test default values.
@@ -46,6 +46,7 @@ public function configurationData()
'index_name' => 'ongr-test',
'host' => '127.5.0.1',
'port' => 9205,
+ 'repository' => 'es.manager.settings.setting',
];
$out[] = [
['connection' => $config],
diff --git a/Tests/Unit/DependencyInjection/Security/SessionlessAuthenticationFactoryTest.php b/Tests/Unit/DependencyInjection/Security/SessionlessAuthenticationFactoryTest.php
index 5a1d903..3ba5c4a 100644
--- a/Tests/Unit/DependencyInjection/Security/SessionlessAuthenticationFactoryTest.php
+++ b/Tests/Unit/DependencyInjection/Security/SessionlessAuthenticationFactoryTest.php
@@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/
-namespace ONGR\SettingsBundle\Tests\Functional\DependencyInjection;
+namespace ONGR\SettingsBundle\Tests\Unit\DependencyInjection\Security;
use ONGR\ElasticsearchBundle\Test\ElasticsearchTestCase;
use ONGR\SettingsBundle\DependencyInjection\Security\SessionlessAuthenticationFactory;
diff --git a/Tests/app/AppKernel.php b/Tests/app/AppKernel.php
index b7bf044..19e759c 100755
--- a/Tests/app/AppKernel.php
+++ b/Tests/app/AppKernel.php
@@ -35,7 +35,6 @@ public function registerBundles()
new ONGR\ElasticsearchBundle\ONGRElasticsearchBundle(),
new Tedivm\StashBundle\TedivmStashBundle(),
- new ONGR\PagerBundle\ONGRPagerBundle(),
new ONGR\CookiesBundle\ONGRCookiesBundle(),
new ONGR\SettingsBundle\Tests\Fixtures\Acme\TestBundle\AcmeTestBundle(),
new ONGR\SettingsBundle\ONGRSettingsBundle(),
diff --git a/Tests/app/config/config_test.yml b/Tests/app/config/config_test.yml
index 785cff3..7d4b10c 100644
--- a/Tests/app/config/config_test.yml
+++ b/Tests/app/config/config_test.yml
@@ -54,40 +54,7 @@ ongr_elasticsearch:
number_of_replicas: 0
index:
refresh_interval: -1
- analysis:
- tokenizer:
- pathTokenizer:
- type : path_hierarchy
- buffer_size: 2024
- skip: 0
- delimiter: /
- filter:
- incremental_filter:
- type: edge_ngram
- min_gram: 1
- max_gram: 20
- analyzer:
- indexAnalyzer:
- type: snowball
- language: German2
- stopwords: "der,die,das,mit,und,für"
- searchAnalyzer:
- type: snowball
- language: German2
- stopwords: "der,die,das,mit,und,für"
- pathAnalyzer:
- type: custom
- tokenizer: pathTokenizer
- urlAnalyzer:
- type: custom
- tokenizer: keyword
- filter: [lowercase]
- incrementalAnalyzer:
- type: custom
- tokenizer: standard
- filter:
- - lowercase
- - incremental_filter
+
managers:
default:
connection: default
@@ -130,8 +97,41 @@ services:
calls:
- [setManager, [@es.manager]]
+ ongr_settings.settings_manager:
+ class: %ongr_settings.settings_manager.class%
+ arguments:
+ - @translator
+ - @event_dispatcher
+ - @es.manager
+
+ ongr_settings.listener.cookie_profile:
+ class: %ongr_settings.listener.cookie_profile.class%
+ calls:
+ - [ setSettingsContainer, [ @ongr_settings.settings_container ] ]
+ - [ setPersonalSettingsManager, [ @ongr_settings.settings.personal_settings_manager ] ]
+ - [ setManager, [ @es.manager ] ]
+ tags:
+ - { name: kernel.event_listener, event: kernel.request, method: onKernelRequest }
+
+ ongr_settings.profiles_manager:
+ class: %ongr_settings.profiles_manager.class%
+ arguments:
+ - @es.manager
+
+ ongr_settings.settings_provider:
+ class: %ongr_settings.profiles_manager.class%
+ arguments:
+ - @es.manager
+
+ ongr_settings.pair_storage:
+ class: %ongr_settings.pair_storage.class%
+ arguments:
+ - @es.manager
+
ongr_settings:
profiles: [ test1, test2, default, meh ]
+ connection:
+ repository: es.manager.default.setting
admin_user:
categories:
category_1:
diff --git a/Tests/app/config/config_test_container_creation.yml b/Tests/app/config/config_test_container_creation.yml
index 06d2420..fc79164 100644
--- a/Tests/app/config/config_test_container_creation.yml
+++ b/Tests/app/config/config_test_container_creation.yml
@@ -93,3 +93,40 @@ ongr_elasticsearch:
connection: default
mappings:
- ONGRSettingsBundle
+
+ongr_settings:
+ connection:
+ repository: es.manager.default.setting
+
+services:
+ ongr_settings.settings_manager:
+ class: %ongr_settings.settings_manager.class%
+ arguments:
+ - @translator
+ - @event_dispatcher
+ - @es.manager
+
+ ongr_settings.listener.cookie_profile:
+ class: %ongr_settings.listener.cookie_profile.class%
+ calls:
+ - [ setSettingsContainer, [ @ongr_settings.settings_container ] ]
+ - [ setPersonalSettingsManager, [ @ongr_settings.settings.personal_settings_manager ] ]
+ - [ setManager, [ @es.manager ] ]
+ tags:
+ - { name: kernel.event_listener, event: kernel.request, method: onKernelRequest }
+
+ ongr_settings.profiles_manager:
+ class: %ongr_settings.profiles_manager.class%
+ arguments:
+ - @es.manager
+
+ ongr_settings.settings_provider:
+ class: %ongr_settings.profiles_manager.class%
+ arguments:
+ - @es.manager
+
+ ongr_settings.pair_storage:
+ class: %ongr_settings.pair_storage.class%
+ arguments:
+ - @es.manager
+
diff --git a/Tests/app/config/parameters_test.yml b/Tests/app/config/parameters_test.yml
index a07da36..c44a77c 100644
--- a/Tests/app/config/parameters_test.yml
+++ b/Tests/app/config/parameters_test.yml
@@ -15,4 +15,4 @@ parameters:
cdn_url: 'http:%cdn_base_url%'
cdn_url_ssl: 'https:%cdn_base_url%'
- ongr_settings.environment_variables_pass_test_param: unchanged_param
\ No newline at end of file
+ ongr_settings.environment_variables_pass_test_param: unchanged_param
diff --git a/Tests/app/config/parameters_test_container_creation.yml b/Tests/app/config/parameters_test_container_creation.yml
index 6fed0f1..8afd9ad 100644
--- a/Tests/app/config/parameters_test_container_creation.yml
+++ b/Tests/app/config/parameters_test_container_creation.yml
@@ -22,3 +22,4 @@ parameters:
password: 'foo_password'
ongr_settings.authentication.secret: O0EKwvq8Sv30O3ImKdXT7aT
+
diff --git a/composer.json b/composer.json
index 558779c..2ef4918 100644
--- a/composer.json
+++ b/composer.json
@@ -21,16 +21,12 @@
"ongr/elasticsearch-bundle": ">=0.2,<2",
"ongr/content-bundle": "~0.1",
"ongr/cookies-bundle": "~0.1",
- "ongr/filter-manager-bundle": "~0.1",
- "ongr/pager-bundle": "~0.1"
+ "ongr/filter-manager-bundle": "~0.1"
},
"require-dev": {
"phpunit/phpunit": "~4.2",
"squizlabs/php_codesniffer": "~1.5",
- "ongr/ongr-strict-standard": "~1.0.0-beta"
- },
- "suggest": {
- "ongr/oxid-bundle": "Allows to transfer shop data from OXID to ONGR"
+ "ongr/ongr-strict-standard": "~1.0"
},
"autoload": {
"psr-4": { "ONGR\\SettingsBundle\\": "" }
|