Permalink
Browse files

Added tests

  • Loading branch information...
1 parent 7117a01 commit 684b96cd1b8825d470fdaa9835315a4150ac006f @javiereguiluz committed Jan 10, 2017
@@ -44,6 +44,8 @@ private function processRtlLanguages(array $backendConfig)
// ar = Arabic, fa = Persian, he = Hebrew
if (in_array(substr($this->locale, 0, 2), array('ar', 'fa', 'he'))) {
$backendConfig['design']['rtl'] = true;
+ } else {
+ $backendConfig['design']['rtl'] = false;
}
}
@@ -244,8 +244,6 @@ private function addDesignSection(ArrayNodeDefinition $rootNode)
->booleanNode('rtl')
->info('If true, the interface uses RTL (right-to-left) writing (needed for Arabic, Hebrew and Persian).')
- ->defaultFalse()
- ->treatNullLike(false)
->end()
->scalarNode('brand_color')
@@ -42,6 +42,17 @@ public function testLanguageDefinedByLayout()
$this->assertSame('en', trim($crawler->filter('html')->attr('lang')));
}
+ public function testRtlIsDisabledByDefault()
+ {
+ $crawler = $this->getBackendHomepage();
+
+ $backendConfig = $this->client->getContainer()->get('easyadmin.config.manager')->getBackendConfig();
+ $this->assertFalse($backendConfig['design']['rtl'], 'RTL is disabled by default.');
+
+ $this->assertNotContains('bootstrap-rtl.min.css', $crawler->filter('head')->text());
+ $this->assertNotContains('adminlte-rtl.min.css', $crawler->filter('head')->text());
+ }
+
public function testDefaultCssStylesAreLinked()
{
$crawler = $this->getBackendHomepage();
@@ -0,0 +1,52 @@
+<?php
+
+/*
+ * This file is part of the EasyAdminBundle.
+ *
+ * (c) Javier Eguiluz <javier.eguiluz@gmail.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace JavierEguiluz\Bundle\EasyAdminBundle\Tests\Controller;
+
+use JavierEguiluz\Bundle\EasyAdminBundle\Tests\Fixtures\AbstractTestCase;
+
+class RtlTest extends AbstractTestCase
+{
+ public function setUp()
+ {
+ parent::setUp();
+
+ $this->initClient(array('environment' => 'rtl'));
+ }
+
+ public function testRtlAutodetection()
+ {
+ $this->getBackendHomepage();
+
+ $backendConfig = $this->client->getContainer()->get('easyadmin.config.manager')->getBackendConfig();
+ $this->assertTrue($backendConfig['design']['rtl'], 'RTL is enabled automatically for the "ar" locale.');
+ }
+
+ public function testRtlWebAssets()
+ {
+ $crawler = $this->getBackendHomepage();
+
+ $this->assertSame(
+ '/bundles/easyadmin/stylesheet/easyadmin-all.min.css',
+ $crawler->filter('link[rel="stylesheet"]')->eq(0)->attr('href')
+ );
+
+ $this->assertSame(
+ '/bundles/easyadmin/stylesheet/bootstrap-rtl.min.css',
+ $crawler->filter('link[rel="stylesheet"]')->eq(1)->attr('href')
+ );
+
+ $this->assertSame(
+ '/bundles/easyadmin/stylesheet/adminlte-rtl.min.css',
+ $crawler->filter('link[rel="stylesheet"]')->eq(2)->attr('href')
+ );
+ }
+}
@@ -0,0 +1,12 @@
+imports:
+ - { resource: config.yml }
+
+# use 'ar' (Arabic) as the locale of the app to force the detection of RTL languages
+parameters:
+ locale: ar
+framework:
+ default_locale: ar
+
+easy_admin:
+ entities:
+ Category: AppTestBundle\Entity\FunctionalTests\Category

0 comments on commit 684b96c

Please sign in to comment.