Allow to rename tags from the web interface.
new WhiteOctober\PagerfantaBundle\WhiteOctoberPagerfantaBundle(),
new FOS\JsRoutingBundle\FOSJsRoutingBundle(),
new BD\GuzzleSiteAuthenticatorBundle\BDGuzzleSiteAuthenticatorBundle(),
+ new OldSound\RabbitMqBundle\OldSoundRabbitMqBundle(),
// wallabag bundles
new Wallabag\CoreBundle\WallabagCoreBundle(),
new Wallabag\UserBundle\WallabagUserBundle(),
new Wallabag\ImportBundle\WallabagImportBundle(),
new Wallabag\AnnotationBundle\WallabagAnnotationBundle(),
- new OldSound\RabbitMqBundle\OldSoundRabbitMqBundle(),
];
if (in_array($this->getEnvironment(), ['dev', 'test'], true)) {
# Swiftmailer Configuration
swiftmailer:
- transport: "%mailer_transport%"
- host: "%mailer_host%"
- username: "%mailer_user%"
- password: "%mailer_password%"
+ transport: "%mailer_transport%"
+ username: "%mailer_user%"
+ password: "%mailer_password%"
+ host: "%mailer_host%"
+ port: "%mailer_port%"
+ encryption: "%mailer_encryption%"
+ auth_mode: "%mailer_auth_mode%"
spool:
type: memory
# see: https://github.com/schmittjoh/JMSSerializerBundle/pull/494
datetime:
default_format: "Y-m-d\\TH:i:sO" # ATOM
+
+# see https://github.com/symfony/symfony-standard/pull/1133
+sensio_framework_extra:
+ router:
+ annotations: false
imports:
- { resource: config_dev.yml }
- { resource: parameters_test.yml }
+ - { resource: services_test.yml }
framework:
test: ~
domain_name: https://your-wallabag-url-instance.com
- mailer_transport: smtp
- mailer_host: 127.0.0.1
- mailer_user: ~
- mailer_password: ~
+ mailer_transport: smtp
+ mailer_user: ~
+ mailer_password: ~
+ mailer_host: 127.0.0.1
+ mailer_port: false
+ mailer_encryption: ~
+ mailer_auth_mode: ~
locale: en
fos_oauth: true
stateless: true
anonymous: true
+ provider: fos_userbundle
login_firewall:
+ logout_on_user_change: true
pattern: ^/login$
anonymous: ~
secured_area:
+ logout_on_user_change: true
pattern: ^/
form_login:
provider: fos_userbundle
- { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: /(unread|starred|archive|all).xml$, roles: IS_AUTHENTICATED_ANONYMOUSLY }
+ - { path: ^/locale, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: /tags/(.*).xml$, roles: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/share, roles: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/settings, roles: ROLE_SUPER_ADMIN }
lexik_form_filter.get_filter.doctrine_orm.class: Wallabag\CoreBundle\Event\Subscriber\CustomDoctrineORMSubscriber
services:
- # used for tests
- filesystem_cache:
- class: Doctrine\Common\Cache\FilesystemCache
- arguments:
- - "%kernel.cache_dir%/doctrine/metadata"
-
twig.extension.text:
class: Twig_Extensions_Extension_Text
tags:
--- /dev/null
+services:
+ # see https://github.com/symfony/symfony/issues/24543
+ fos_user.user_manager.test:
+ alias: fos_user.user_manager
+ public: true
+
+ fos_user.security.login_manager.test:
+ alias: fos_user.security.login_manager
+ public: true
+
+ wallabag_core.entry_repository.test:
+ alias: wallabag_core.entry_repository
+ public: true
+
+ wallabag_user.user_repository.test:
+ alias: wallabag_user.user_repository
+ public: true
+
+ filesystem_cache:
+ class: Doctrine\Common\Cache\FilesystemCache
+ arguments:
+ - "%kernel.cache_dir%/doctrine/metadata"
+
+ # fixtures
+ Wallabag\AnnotationBundle\DataFixtures\ORM\:
+ resource: '../../src/Wallabag/AnnotationBundle/DataFixtures/ORM/*'
+ tags: ['doctrine.fixture.orm']
+ autowire: true
+
+ Wallabag\CoreBundle\DataFixtures\ORM\:
+ resource: '../../src/Wallabag/CoreBundle/DataFixtures/ORM/*'
+ tags: ['doctrine.fixture.orm']
+ autowire: true
+
+ Wallabag\UserBundle\DataFixtures\ORM\:
+ resource: '../../src/Wallabag/UserBundle/DataFixtures/ORM/*'
+ tags: ['doctrine.fixture.orm']
+ autowire: true
"ext-iconv": "*",
"ext-tokenizer": "*",
"ext-pdo": "*",
- "symfony/symfony": "~3.3.13",
+ "symfony/symfony": "3.4.*",
"doctrine/orm": "^2.5.12",
"doctrine/doctrine-bundle": "^1.8.0",
"doctrine/doctrine-cache-bundle": "^1.3.2",
"symfony/swiftmailer-bundle": "^2.6.7",
"symfony/monolog-bundle": "^3.1.2",
"sensio/distribution-bundle": "^5.0.21",
- "sensio/framework-extra-bundle": "^3.0.28",
+ "sensio/framework-extra-bundle": "^5.2.1",
"incenteev/composer-parameter-handler": "^2.1.2",
"nelmio/cors-bundle": "~1.5",
"friendsofsymfony/rest-bundle": "~2.1",
"predis/predis": "^1.1.1",
"javibravo/simpleue": "^2.0",
"symfony/dom-crawler": "^3.3.13",
- "friendsofsymfony/jsrouting-bundle": "^1.6.3",
+ "friendsofsymfony/jsrouting-bundle": "^2.2.1",
"bdunogier/guzzle-site-authenticator": "^1.0.0@dev",
"defuse/php-encryption": "^2.1",
"html2text/html2text": "^4.1"
},
"require-dev": {
- "doctrine/doctrine-fixtures-bundle": "~2.2",
- "doctrine/data-fixtures": "~1.1",
+ "doctrine/doctrine-fixtures-bundle": "~3.0",
"sensio/generator-bundle": "^3.0",
"symfony/phpunit-bridge": "^3.3",
"friendsofphp/php-cs-fixer": "~2.0",
namespace Wallabag\ApiBundle\Controller;
-use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
+use Symfony\Component\Routing\Annotation\Route;
use Wallabag\ApiBundle\Entity\Client;
use Wallabag\ApiBundle\Form\Type\ClientType;
namespace Wallabag\CoreBundle\Controller;
-use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
+use Symfony\Component\Routing\Annotation\Route;
+use Symfony\Component\Validator\Constraints\Locale as LocaleConstraint;
use Wallabag\CoreBundle\Entity\Config;
use Wallabag\CoreBundle\Entity\TaggingRule;
use Wallabag\CoreBundle\Form\Type\ChangePasswordType;
return $this->redirect($request->headers->get('referer'));
}
+ /**
+ * Change the locale for the current user.
+ *
+ * @param Request $request
+ * @param string $language
+ *
+ * @Route("/locale/{language}", name="changeLocale")
+ *
+ * @return \Symfony\Component\HttpFoundation\RedirectResponse
+ */
+ public function setLocaleAction(Request $request, $language = null)
+ {
+ $errors = $this->get('validator')->validate($language, (new LocaleConstraint()));
+
+ if (0 === \count($errors)) {
+ $request->getSession()->set('_locale', $language);
+ }
+
+ return $this->redirect($request->headers->get('referer', $this->generateUrl('homepage')));
+ }
+
/**
* Remove all tags for given tags and a given user and cleanup orphan tags.
*
use Pagerfanta\Adapter\DoctrineORMAdapter;
use Pagerfanta\Exception\OutOfRangeCurrentPageException;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Cache;
-use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
+use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Wallabag\CoreBundle\Entity\Entry;
use Wallabag\CoreBundle\Event\EntryDeletedEvent;
namespace Wallabag\CoreBundle\Controller;
-use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
+use Symfony\Component\Routing\Annotation\Route;
use Wallabag\CoreBundle\Entity\Entry;
/**
use Pagerfanta\Exception\OutOfRangeCurrentPageException;
use Pagerfanta\Pagerfanta;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
-use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
+use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Wallabag\CoreBundle\Entity\Tag;
use Wallabag\UserBundle\Entity\User;
namespace Wallabag\CoreBundle\Controller;
-use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
-use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
+use Symfony\Component\Routing\Annotation\Route;
use Wallabag\CoreBundle\Entity\SiteCredential;
use Wallabag\UserBundle\Entity\User;
/**
* Lists all User entities.
*
- * @Route("/", name="site_credentials_index")
- * @Method("GET")
+ * @Route("/", name="site_credentials_index", methods={"GET"})
*/
public function indexAction()
{
/**
* Creates a new site credential entity.
*
- * @Route("/new", name="site_credentials_new")
- * @Method({"GET", "POST"})
+ * @Route("/new", name="site_credentials_new", methods={"GET", "POST"})
*
* @param Request $request
*
/**
* Displays a form to edit an existing site credential entity.
*
- * @Route("/{id}/edit", name="site_credentials_edit")
- * @Method({"GET", "POST"})
+ * @Route("/{id}/edit", name="site_credentials_edit", methods={"GET", "POST"})
*
* @param Request $request
* @param SiteCredential $siteCredential
/**
* Deletes a site credential entity.
*
- * @Route("/{id}", name="site_credentials_delete")
- * @Method("DELETE")
+ * @Route("/{id}", name="site_credentials_delete", methods={"DELETE"})
*
* @param Request $request
* @param SiteCredential $siteCredential
namespace Wallabag\CoreBundle\Controller;
-use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
+use Symfony\Component\Routing\Annotation\Route;
class StaticController extends Controller
{
use Pagerfanta\Adapter\ArrayAdapter;
use Pagerfanta\Exception\OutOfRangeCurrentPageException;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
-use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
+use Symfony\Component\Routing\Annotation\Route;
use Wallabag\CoreBundle\Entity\Entry;
use Wallabag\CoreBundle\Entity\Tag;
use Wallabag\CoreBundle\Form\Type\NewTagType;
use Symfony\Component\Security\Http\Event\InteractiveLoginEvent;
/**
- * Stores the locale of the user in the session after the
- * login. This can be used by the LocaleListener afterwards.
+ * Stores the locale of the user in the session after the login.
+ * If no locale are defined (if user doesn't change it from the login screen), override it with the user's config one.
+ *
+ * This can be used by the LocaleListener afterwards.
*
* @see http://symfony.com/doc/master/cookbook/session/locale_sticky_session.html
*/
{
$user = $event->getAuthenticationToken()->getUser();
- if (null !== $user->getConfig()->getLanguage()) {
+ if (null !== $user->getConfig()->getLanguage() && null === $this->session->get('_locale')) {
$this->session->set('_locale', $user->getConfig()->getLanguage());
}
}
wallabag_core.exception_controller:
class: Wallabag\CoreBundle\Controller\ExceptionController
+ public: true
arguments:
- '@twig'
- '%kernel.debug%'
arguments:
- "%wallabag_core.site_credentials.encryption_key_path%"
- "@logger"
+
+ wallabag_core.command.clean_duplicates:
+ class: Wallabag\CoreBundle\Command\CleanDuplicatesCommand
+ tags: ['console.command']
+
+ wallabag_core.command.export:
+ class: Wallabag\CoreBundle\Command\ExportCommand
+ tags: ['console.command']
+
+ wallabag_core.command.install:
+ class: Wallabag\CoreBundle\Command\InstallCommand
+ tags: ['console.command']
+
+ wallabag_core.command.list_user:
+ class: Wallabag\CoreBundle\Command\ListUserCommand
+ tags: ['console.command']
+
+ wallabag_core.command.reload_entry:
+ class: Wallabag\CoreBundle\Command\ReloadEntryCommand
+ tags: ['console.command']
+
+ wallabag_core.command.show_user:
+ class: Wallabag\CoreBundle\Command\ShowUserCommand
+ tags: ['console.command']
+
+ wallabag_core.command.tag_all:
+ class: Wallabag\CoreBundle\Command\TagAllCommand
+ tags: ['console.command']
namespace Wallabag\ImportBundle\Controller;
-use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
+use Symfony\Component\Routing\Annotation\Route;
use Wallabag\ImportBundle\Form\Type\UploadImportType;
abstract class BrowserController extends Controller
namespace Wallabag\ImportBundle\Controller;
-use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Component\HttpFoundation\Request;
+use Symfony\Component\Routing\Annotation\Route;
class ChromeController extends BrowserController
{
namespace Wallabag\ImportBundle\Controller;
-use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Component\HttpFoundation\Request;
+use Symfony\Component\Routing\Annotation\Route;
class FirefoxController extends BrowserController
{
namespace Wallabag\ImportBundle\Controller;
-use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
+use Symfony\Component\Routing\Annotation\Route;
class ImportController extends Controller
{
namespace Wallabag\ImportBundle\Controller;
-use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
+use Symfony\Component\Routing\Annotation\Route;
use Wallabag\ImportBundle\Form\Type\UploadImportType;
class InstapaperController extends Controller
namespace Wallabag\ImportBundle\Controller;
-use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
+use Symfony\Component\Routing\Annotation\Route;
use Wallabag\ImportBundle\Form\Type\UploadImportType;
class PinboardController extends Controller
namespace Wallabag\ImportBundle\Controller;
-use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\HttpFoundation\Request;
+use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
class PocketController extends Controller
namespace Wallabag\ImportBundle\Controller;
-use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
+use Symfony\Component\Routing\Annotation\Route;
use Wallabag\ImportBundle\Form\Type\UploadImportType;
class ReadabilityController extends Controller
namespace Wallabag\ImportBundle\Controller;
-use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Component\HttpFoundation\Request;
+use Symfony\Component\Routing\Annotation\Route;
class WallabagV1Controller extends WallabagController
{
namespace Wallabag\ImportBundle\Controller;
-use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Component\HttpFoundation\Request;
+use Symfony\Component\Routing\Annotation\Route;
class WallabagV2Controller extends WallabagController
{
- [ setLogger, [ "@logger" ]]
tags:
- { name: wallabag_import.import, alias: chrome }
+
+ wallabag_import.command.import:
+ class: Wallabag\ImportBundle\Command\ImportCommand
+ tags: ['console.command']
+
+ wallabag_import.command.redis_worker:
+ class: Wallabag\ImportBundle\Command\RedisWorkerCommand
+ tags: ['console.command']
use Pagerfanta\Adapter\DoctrineORMAdapter;
use Pagerfanta\Exception\OutOfRangeCurrentPageException;
use Pagerfanta\Pagerfanta;
-use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
-use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
+use Symfony\Component\Routing\Annotation\Route;
use Wallabag\UserBundle\Entity\User;
use Wallabag\UserBundle\Form\SearchUserType;
/**
* Creates a new User entity.
*
- * @Route("/new", name="user_new")
- * @Method({"GET", "POST"})
+ * @Route("/new", name="user_new", methods={"GET", "POST"})
*/
public function newAction(Request $request)
{
/**
* Displays a form to edit an existing User entity.
*
- * @Route("/{id}/edit", name="user_edit")
- * @Method({"GET", "POST"})
+ * @Route("/{id}/edit", name="user_edit", methods={"GET", "POST"})
*/
public function editAction(Request $request, User $user)
{
/**
* Deletes a User entity.
*
- * @Route("/{id}", name="user_delete")
- * @Method("DELETE")
+ * @Route("/{id}", name="user_delete", methods={"DELETE"})
*/
public function deleteAction(Request $request, User $user)
{
use FOS\UserBundle\Event\UserEvent;
use FOS\UserBundle\FOSUserEvents;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
+use Symfony\Component\HttpFoundation\Session\Session;
use Wallabag\CoreBundle\Entity\Config;
/**
private $readingSpeed;
private $actionMarkAsRead;
private $listMode;
+ private $session;
- public function __construct(EntityManager $em, $theme, $itemsOnPage, $rssLimit, $language, $readingSpeed, $actionMarkAsRead, $listMode)
+ public function __construct(EntityManager $em, $theme, $itemsOnPage, $rssLimit, $language, $readingSpeed, $actionMarkAsRead, $listMode, Session $session)
{
$this->em = $em;
$this->theme = $theme;
$this->readingSpeed = $readingSpeed;
$this->actionMarkAsRead = $actionMarkAsRead;
$this->listMode = $listMode;
+ $this->session = $session;
}
public static function getSubscribedEvents()
$config->setTheme($this->theme);
$config->setItemsPerPage($this->itemsOnPage);
$config->setRssLimit($this->rssLimit);
- $config->setLanguage($this->language);
+ $config->setLanguage($this->session->get('_locale', $this->language));
$config->setReadingSpeed($this->readingSpeed);
$config->setActionMarkAsRead($this->actionMarkAsRead);
$config->setListMode($this->listMode);
- "%wallabag_core.reading_speed%"
- "%wallabag_core.action_mark_as_read%"
- "%wallabag_core.list_mode%"
+ - "@session"
tags:
- { name: kernel.event_subscriber }
{{ form_start(form, {'method': 'post', 'action': path('fos_user_registration_register'), 'attr': {'class': 'fos_user_registration_register'}}) }}
<div class="card-content">
<div class="row">
-
{{ form_widget(form._token) }}
{% for flashMessage in app.session.flashbag.get('notice') %}
{% block fos_user_content %}
{% endblock fos_user_content %}
</div>
+ <div class="center">
+ <a href="{{ path('changeLocale', {'language': 'de'}) }}">Deutsch</a> –
+ <a href="{{ path('changeLocale', {'language': 'en'}) }}">English</a> –
+ <a href="{{ path('changeLocale', {'language': 'fr'}) }}">Français</a>
+ </div>
</div>
</main>
{% endblock %}
$container = $client->getContainer();
/** @var $userManager \FOS\UserBundle\Doctrine\UserManager */
- $userManager = $container->get('fos_user.user_manager');
+ $userManager = $container->get('fos_user.user_manager.test');
/** @var $loginManager \FOS\UserBundle\Security\LoginManager */
- $loginManager = $container->get('fos_user.security.login_manager');
+ $loginManager = $container->get('fos_user.security.login_manager.test');
$firewallName = $container->getParameter('fos_user.firewall_name');
$this->user = $userManager->findUserBy(['username' => 'admin']);
{
$client = $this->getClient();
$em = $client->getContainer()->get('doctrine.orm.entity_manager');
- $userManager = $client->getContainer()->get('fos_user.user_manager');
+ $userManager = $client->getContainer()->get('fos_user.user_manager.test');
$user = $userManager->findUserBy(['username' => $username]);
$apiClient = new Client($user);
$apiClient->setName('My app');
$container = $client->getContainer();
/** @var $userManager \FOS\UserBundle\Doctrine\UserManager */
- $userManager = $container->get('fos_user.user_manager');
+ $userManager = $container->get('fos_user.user_manager.test');
/** @var $loginManager \FOS\UserBundle\Security\LoginManager */
- $loginManager = $container->get('fos_user.security.login_manager');
+ $loginManager = $container->get('fos_user.security.login_manager.test');
$firewallName = $container->getParameter('fos_user.firewall_name');
$this->user = $userManager->findUserBy(['username' => 'admin']);
{
parent::setUp();
- $userRepository = $this->getClient()->getContainer()->get('wallabag_user.user_repository');
+ $userRepository = $this->getClient()->getContainer()->get('wallabag_user.user_repository.test');
$user = $userRepository->findOneByUserName('admin');
$this->adminEntry = new Entry($user);
$reloadedEntries = $this->getClient()
->getContainer()
- ->get('wallabag_core.entry_repository')
+ ->get('wallabag_core.entry_repository.test')
->findById([$this->adminEntry->getId(), $this->bobEntry->getId()]);
foreach ($reloadedEntries as $reloadedEntry) {
'interactive' => false,
]);
- $entryRepository = $this->getClient()->getContainer()->get('wallabag_core.entry_repository');
+ $entryRepository = $this->getClient()->getContainer()->get('wallabag_core.entry_repository.test');
$reloadedAdminEntry = $entryRepository->find($this->adminEntry->getId());
$this->assertNotEmpty($reloadedAdminEntry->getContent());
$client->request('GET', '/config/view-mode');
}
+
+ public function testChangeLocaleWithoutReferer()
+ {
+ $client = $this->getClient();
+
+ $client->request('GET', '/locale/de');
+ $client->followRedirect();
+
+ $this->assertSame('de', $client->getRequest()->getLocale());
+ $this->assertSame('de', $client->getContainer()->get('session')->get('_locale'));
+ }
+
+ public function testChangeLocaleWithReferer()
+ {
+ $client = $this->getClient();
+
+ $client->request('GET', '/login');
+ $client->request('GET', '/locale/de');
+ $client->followRedirect();
+
+ $this->assertSame('de', $client->getRequest()->getLocale());
+ $this->assertSame('de', $client->getContainer()->get('session')->get('_locale'));
+ }
+
+ public function testChangeLocaleToBadLocale()
+ {
+ $client = $this->getClient();
+
+ $client->request('GET', '/login');
+ $client->request('GET', '/locale/yuyuyuyu');
+ $client->followRedirect();
+
+ $this->assertNotSame('yuyuyuyu', $client->getRequest()->getLocale());
+ $this->assertNotSame('yuyuyuyu', $client->getContainer()->get('session')->get('_locale'));
+ }
}
$client->request('GET', '/share/' . $content->getId());
$this->assertSame(302, $client->getResponse()->getStatusCode());
- // follow link with uid
- $crawler = $client->followRedirect();
+ $shareUrl = $client->getResponse()->getTargetUrl();
+
+ // use a new client to have a fresh empty session (instead of a logged one from the previous client)
+ $client->restart();
+
+ $client->request('GET', $shareUrl);
+
$this->assertSame(200, $client->getResponse()->getStatusCode());
$this->assertContains('max-age=25200', $client->getResponse()->headers->get('cache-control'));
$this->assertContains('public', $client->getResponse()->headers->get('cache-control'));
$client->request('GET', '/share/' . $content->getUid());
$this->assertSame(404, $client->getResponse()->getStatusCode());
- $client->request('GET', '/view/' . $content->getId());
- $this->assertContains('no-cache', $client->getResponse()->headers->get('cache-control'));
-
// removing the share
$client->request('GET', '/share/delete/' . $content->getId());
$this->assertSame(302, $client->getResponse()->getStatusCode());
$this->assertNull($session->get('_locale'));
}
+
+ public function testWithLanguageFromSession()
+ {
+ $session = new Session(new MockArraySessionStorage());
+ $listener = new UserLocaleListener($session);
+ $session->set('_locale', 'de');
+
+ $user = new User();
+ $user->setEnabled(true);
+
+ $config = new Config($user);
+ $config->setLanguage('fr');
+
+ $user->setConfig($config);
+
+ $userToken = new UsernamePasswordToken($user, '', 'test');
+ $request = Request::create('/');
+ $event = new InteractiveLoginEvent($request, $userToken);
+
+ $listener->onInteractiveLogin($event);
+
+ $this->assertSame('de', $session->get('_locale'));
+ }
}
$container = $this->client->getContainer();
$session = $container->get('session');
- $userManager = $container->get('fos_user.user_manager');
- $loginManager = $container->get('fos_user.security.login_manager');
+ $userManager = $container->get('fos_user.user_manager.test');
+ $loginManager = $container->get('fos_user.security.login_manager.test');
$firewallName = $container->getParameter('fos_user.firewall_name');
$user = $userManager->findUserBy(['username' => $username]);
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
+use Symfony\Component\HttpFoundation\Session\Session;
+use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage;
use Wallabag\CoreBundle\Entity\Config;
use Wallabag\UserBundle\Entity\User;
use Wallabag\UserBundle\EventListener\CreateConfigListener;
protected function setUp()
{
+ $session = new Session(new MockArraySessionStorage());
$this->em = $this->getMockBuilder('Doctrine\ORM\EntityManager')
->disableOriginalConstructor()
->getMock();
'fr',
1,
1,
- 1
+ 1,
+ $session
);
$this->dispatcher = new EventDispatcher();