Skip to content

Commit

Permalink
Removed DeviceDetection where it can be optionable.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ruslan Zavacky committed Aug 29, 2014
1 parent 085103b commit f61de31
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 27 deletions.
6 changes: 3 additions & 3 deletions Tests/ActiveThemeTest.php
Expand Up @@ -22,7 +22,7 @@ class ActiveThemeTest extends \PHPUnit_Framework_TestCase
*/
public function testGetName()
{
$theme = new ActiveTheme("foo", array("foo"), new DeviceDetection());
$theme = new ActiveTheme("foo", array("foo"));

$this->assertEquals("foo", $theme->getName());
}
Expand Down Expand Up @@ -53,7 +53,7 @@ public function testDevicePhone()
*/
public function testConstructInvalidName()
{
$theme = new ActiveTheme("foo", array("bar"), new DeviceDetection());
$theme = new ActiveTheme("foo", array("bar"));
}

/**
Expand All @@ -62,7 +62,7 @@ public function testConstructInvalidName()
*/
public function testSetInvalidName()
{
$theme = new ActiveTheme("foo", array("foo"), new DeviceDetection());
$theme = new ActiveTheme("foo", array("foo"));
$theme->setName("bar");
}
}
3 changes: 1 addition & 2 deletions Tests/EventListener/ThemeRequestListenerTest.php
Expand Up @@ -11,7 +11,6 @@
*/
namespace Liip\Tests\EventListener;

use Liip\ThemeBundle\Helper\DeviceDetection;
use Symfony\Component\HttpKernel\HttpKernelInterface;

use Liip\ThemeBundle\EventListener\ThemeRequestListener;
Expand All @@ -29,7 +28,7 @@ class ThemeRequestListenerTest extends \PHPUnit_Framework_TestCase
protected function getActiveThemeStub()
{
$activeTheme = $this->getMockBuilder('Liip\ThemeBundle\ActiveTheme')
->setConstructorArgs(array('desktop', array('desktop', 'tablet', 'mobile'), new DeviceDetection()))
->setConstructorArgs(array('desktop', array('desktop', 'tablet', 'mobile')))
->getMock();
$activeTheme->expects($this->any())
->method('getThemes')
Expand Down
39 changes: 19 additions & 20 deletions Tests/Locator/FileLocatorTest.php
Expand Up @@ -11,7 +11,6 @@

namespace Liip\Tests\Locator;

use Liip\ThemeBundle\Helper\DeviceDetection;
use Liip\ThemeBundle\Locator\FileLocator;
use Liip\ThemeBundle\ActiveTheme;

Expand Down Expand Up @@ -65,7 +64,7 @@ protected function getFixturePath()
public function testConstructor()
{
$kernel = $this->getKernelMock();
$activeTheme = new ActiveTheme('bar', array('foo', 'bar', 'foobar'), new DeviceDetection());
$activeTheme = new ActiveTheme('bar', array('foo', 'bar', 'foobar'));
new FileLocator($kernel, $activeTheme, $this->getFixturePath() . '/rootdir/Resources');
}

Expand All @@ -75,7 +74,7 @@ public function testConstructor()
public function testConstructorFallbackPathMerge()
{
$kernel = $this->getKernelMock();
$activeTheme = new ActiveTheme('bar', array('foo', 'bar', 'foobar'), new DeviceDetection());
$activeTheme = new ActiveTheme('bar', array('foo', 'bar', 'foobar'));
$property = new \ReflectionProperty('Liip\ThemeBundle\Locator\FileLocator', 'pathPatterns');
$property->setAccessible(true);

Expand Down Expand Up @@ -150,7 +149,7 @@ public function testConstructorFallbackPathMerge()
public function testLocate()
{
$kernel = $this->getKernelMock();
$activeTheme = new ActiveTheme('foo', array('foo', 'bar', 'foobar'), new DeviceDetection());
$activeTheme = new ActiveTheme('foo', array('foo', 'bar', 'foobar'));
$fileLocator = new FileLocator($kernel, $activeTheme, $this->getFixturePath() . '/rootdir/Resources');

$file = $fileLocator->locate('@ThemeBundle/Resources/views/template', $this->getFixturePath(), true);
Expand All @@ -164,7 +163,7 @@ public function testLocate()
public function testLocateWithOverriddenPathPattern()
{
$kernel = $this->getKernelMock();
$activeTheme = new ActiveTheme('foo', array('foo', 'bar', 'foobar'), new DeviceDetection());
$activeTheme = new ActiveTheme('foo', array('foo', 'bar', 'foobar'));

$pathPatterns = array(
'bundle_resource' => array(
Expand All @@ -178,7 +177,7 @@ public function testLocateWithOverriddenPathPattern()
$this->assertEquals($this->getFixturePath().'/Resources/views/themes/foo/template', $file);

// Fall through user-configured cascade order - /Resources/views/themes/bar will not be found.
$activeTheme = new ActiveTheme('bar', array('foo', 'bar', 'foobar'), new DeviceDetection());
$activeTheme = new ActiveTheme('bar', array('foo', 'bar', 'foobar'));

$fileLocator = new FileLocator($kernel, $activeTheme, $this->getFixturePath() . '/rootdir/Resources', array(), $pathPatterns);

Expand All @@ -193,7 +192,7 @@ public function testLocateWithOverriddenPathPattern()
public function testLocateAppThemeOverridesAll()
{
$kernel = $this->getKernelMock();
$activeTheme = new ActiveTheme('foo', array('foo', 'bar', 'foobar'), new DeviceDetection());
$activeTheme = new ActiveTheme('foo', array('foo', 'bar', 'foobar'));
$fileLocator = new FileLocator($kernel, $activeTheme, $this->getFixturePath() . '/rootdir/Resources');

$file = $fileLocator->locate('@ThemeBundle/Resources/views/foo', $this->getFixturePath(), true);
Expand All @@ -207,7 +206,7 @@ public function testLocateAppThemeOverridesAll()
public function testLocateApp()
{
$kernel = $this->getKernelMock();
$activeTheme = new ActiveTheme('foo', array('foo', 'bar', 'foobar'), new DeviceDetection());
$activeTheme = new ActiveTheme('foo', array('foo', 'bar', 'foobar'));
$fileLocator = new FileLocator($kernel, $activeTheme, $this->getFixturePath() . '/rootdir/Resources');

$file = $fileLocator->locate('views/template2', $this->getFixturePath().'/rootdir', true);
Expand All @@ -220,7 +219,7 @@ public function testLocateApp()
public function testLocateActiveThemeUpdate()
{
$kernel = $this->getKernelMock();
$activeTheme = new ActiveTheme('foo', array('foo', 'bar', 'foobar'), new DeviceDetection());
$activeTheme = new ActiveTheme('foo', array('foo', 'bar', 'foobar'));
$fileLocator = new FileLocatorFake($kernel, $activeTheme, $this->getFixturePath() . '/rootdir/Resources');

$this->assertEquals('foo', $fileLocator->lastTheme);
Expand All @@ -235,7 +234,7 @@ public function testLocateActiveThemeUpdate()
public function testLocateActiveDeviceTypeUpdate()
{
$kernel = $this->getKernelMock();
$activeTheme = new ActiveTheme('foo', array('foo', 'bar', 'foobar'), new DeviceDetection());
$activeTheme = new ActiveTheme('foo', array('foo', 'bar', 'foobar'));
$fileLocator = new FileLocatorFake($kernel, $activeTheme, $this->getFixturePath() . '/rootdir/Resources');

$this->assertEquals('foo', $fileLocator->lastTheme);
Expand All @@ -254,7 +253,7 @@ public function testLocateActiveDeviceTypeUpdate()
public function testLocateViewFallback()
{
$kernel = $this->getKernelMock();
$activeTheme = new ActiveTheme('bar', array('foo', 'bar', 'foobar'), new DeviceDetection());
$activeTheme = new ActiveTheme('bar', array('foo', 'bar', 'foobar'));
$fileLocator = new FileLocator($kernel, $activeTheme, $this->getFixturePath() . '/rootdir/Resources');

$file = $fileLocator->locate('@ThemeBundle/Resources/views/defaultTemplate', $this->getFixturePath(), true);
Expand All @@ -268,7 +267,7 @@ public function testLocateViewFallback()
public function testLocateAllFiles()
{
$kernel = $this->getKernelMock();
$activeTheme = new ActiveTheme('foobar', array('foo', 'bar', 'foobar'), new DeviceDetection());
$activeTheme = new ActiveTheme('foobar', array('foo', 'bar', 'foobar'));
$fileLocator = new FileLocator($kernel, $activeTheme, $this->getFixturePath() . '/rootdir/Resources');

$expectedFiles = array(
Expand All @@ -287,7 +286,7 @@ public function testLocateAllFiles()
public function testLocateAllFilesApp()
{
$kernel = $this->getKernelMock();
$activeTheme = new ActiveTheme('foo', array('foo', 'bar', 'foobar'), new DeviceDetection());
$activeTheme = new ActiveTheme('foo', array('foo', 'bar', 'foobar'));
$fileLocator = new FileLocator($kernel, $activeTheme, $this->getFixturePath() . '/rootdir/Resources');

$expectedFiles = array(
Expand All @@ -305,7 +304,7 @@ public function testLocateAllFilesApp()
public function testLocateParentDelegation()
{
$kernel = $this->getKernelMock();
$activeTheme = new ActiveTheme('bar', array('foo', 'bar', 'foobar'), new DeviceDetection());
$activeTheme = new ActiveTheme('bar', array('foo', 'bar', 'foobar'));
$fileLocator = new FileLocator($kernel, $activeTheme, $this->getFixturePath() . '/rootdir/Resources');

$file = $fileLocator->locate('Resources/themes/foo/template', $this->getFixturePath(), true);
Expand All @@ -319,7 +318,7 @@ public function testLocateParentDelegation()
public function testLocateRootDirectory()
{
$kernel = $this->getKernelMock();
$activeTheme = new ActiveTheme('foo', array('foo', 'bar', 'foobar'), new DeviceDetection());
$activeTheme = new ActiveTheme('foo', array('foo', 'bar', 'foobar'));
$fileLocator = new FileLocator($kernel, $activeTheme, $this->getFixturePath() . '/rootdir/Resources');

$file = $fileLocator->locate('@ThemeBundle/Resources/views/rootTemplate', $this->getFixturePath(), true);
Expand All @@ -333,7 +332,7 @@ public function testLocateRootDirectory()
public function testLocateOverrideDirectory()
{
$kernel = $this->getKernelMock();
$activeTheme = new ActiveTheme('bar', array('foo', 'bar', 'foobar'), new DeviceDetection());
$activeTheme = new ActiveTheme('bar', array('foo', 'bar', 'foobar'));
$fileLocator = new FileLocator($kernel, $activeTheme, $this->getFixturePath() . '/rootdir/Resources');

$file = $fileLocator->locate('@ThemeBundle/Resources/views/override', $this->getFixturePath(), true);
Expand All @@ -348,7 +347,7 @@ public function testLocateOverrideDirectory()
public function testLocateInvalidCharacter()
{
$kernel = $this->getKernelMock();
$activeTheme = new ActiveTheme('bar', array('foo', 'bar', 'foobar'), new DeviceDetection());
$activeTheme = new ActiveTheme('bar', array('foo', 'bar', 'foobar'));
$fileLocator = new FileLocator($kernel, $activeTheme, $this->getFixturePath() . '/rootdir/Resources');

$file = $fileLocator->locate('@ThemeBundle/Resources/../views/template', $this->getFixturePath(), true);
Expand All @@ -362,7 +361,7 @@ public function testLocateInvalidCharacter()
public function testLocateNoResource()
{
$kernel = $this->getKernelMock();
$activeTheme = new ActiveTheme('bar', array('foo', 'bar', 'foobar'), new DeviceDetection());
$activeTheme = new ActiveTheme('bar', array('foo', 'bar', 'foobar'));
$fileLocator = new FileLocator($kernel, $activeTheme, $this->getFixturePath() . '/rootdir/Resources');

$file = $fileLocator->locate('@ThemeBundle/bogus', $this->getFixturePath(), true);
Expand All @@ -376,7 +375,7 @@ public function testLocateNoResource()
public function testLocateNotFound()
{
$kernel = $this->getKernelMock();
$activeTheme = new ActiveTheme('bar', array('foo', 'bar', 'foobar'), new DeviceDetection());
$activeTheme = new ActiveTheme('bar', array('foo', 'bar', 'foobar'));
$fileLocator = new FileLocator($kernel, $activeTheme, $this->getFixturePath() . '/rootdir/Resources');

$file = $fileLocator->locate('@ThemeBundle/Resources/nonExistant', $this->getFixturePath(), true);
Expand All @@ -390,7 +389,7 @@ public function testLocateNotFound()
public function testLocateBundleInheritance()
{
$kernel = $this->getKernelMock(true);
$activeTheme = new ActiveTheme('bar', array('foo', 'bar', 'foobar'), new DeviceDetection());
$activeTheme = new ActiveTheme('bar', array('foo', 'bar', 'foobar'));

$fileLocator = $this->getMock(
'Liip\ThemeBundle\Locator\FileLocator',
Expand Down
3 changes: 1 addition & 2 deletions Tests/UseCaseTest.php
Expand Up @@ -11,7 +11,6 @@
*/
namespace Liip\Tests\EventListener;

use Liip\ThemeBundle\Helper\DeviceDetection;
use Symfony\Component\HttpKernel\HttpKernelInterface;

use Liip\ThemeBundle\EventListener\ThemeRequestListener;
Expand Down Expand Up @@ -122,7 +121,7 @@ private function assertCookieValue($response, $cookieValue)
*/
public function testThemeAction($config, $assertion, $hasAlreadyACookie = true)
{
$activeTheme = new ActiveTheme($config['active_theme'], $config['themes'], new DeviceDetection());
$activeTheme = new ActiveTheme($config['active_theme'], $config['themes']);

$device = null;
if ($config['autodetect_theme']) {
Expand Down

0 comments on commit f61de31

Please sign in to comment.