Skip to content

Commit

Permalink
asset test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
Michal Piotrowski authored and fabpot committed Nov 4, 2015
1 parent 399b1d5 commit 5a6c1f2
Show file tree
Hide file tree
Showing 3 changed files with 127 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/Symfony/Component/Asset/Tests/Context/NullContextTest.php
@@ -0,0 +1,31 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Component\Asset\Tests\Context;

use Symfony\Component\Asset\Context\NullContext;

class NullContextTest extends \PHPUnit_Framework_TestCase
{
public function testGetBasePath()
{
$nullContext = new NullContext();

$this->assertEmpty($nullContext->getBasePath());
}

public function testIsSecure()
{
$nullContext = new NullContext();

$this->assertFalse($nullContext->isSecure());
}
}
@@ -0,0 +1,63 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Component\Asset\Tests\Context;

use Symfony\Component\Asset\Context\RequestStackContext;

class RequestStackContextTest extends \PHPUnit_Framework_TestCase
{
public function testGetBasePathEmpty()
{
$requestStack = $this->getMock('Symfony\Component\HttpFoundation\RequestStack');
$requestStackContext = new RequestStackContext($requestStack);

$this->assertEmpty($requestStackContext->getBasePath());
}

public function testGetBasePathSet()
{
$testBasePath = 'test-path';

$request = $this->getMock('Symfony\Component\HttpFoundation\Request');
$request->method('getBasePath')
->willReturn($testBasePath);
$requestStack = $this->getMock('Symfony\Component\HttpFoundation\RequestStack');
$requestStack->method('getMasterRequest')
->willReturn($request);

$requestStackContext = new RequestStackContext($requestStack);

$this->assertEquals($testBasePath, $requestStackContext->getBasePath());
}

public function testIsSecureFalse()
{
$requestStack = $this->getMock('Symfony\Component\HttpFoundation\RequestStack');
$requestStackContext = new RequestStackContext($requestStack);

$this->assertFalse($requestStackContext->isSecure());
}

public function testIsSecureTrue()
{
$request = $this->getMock('Symfony\Component\HttpFoundation\Request');
$request->method('isSecure')
->willReturn(true);
$requestStack = $this->getMock('Symfony\Component\HttpFoundation\RequestStack');
$requestStack->method('getMasterRequest')
->willReturn($request);

$requestStackContext = new RequestStackContext($requestStack);

$this->assertTrue($requestStackContext->isSecure());
}
}
@@ -0,0 +1,33 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Component\Asset\Tests\VersionStrategy;

use Symfony\Component\Asset\VersionStrategy\EmptyVersionStrategy;

class EmptyVersionStrategyTest extends \PHPUnit_Framework_TestCase
{
public function testGetVersion()
{
$emptyVersionStrategy = new EmptyVersionStrategy();
$path = 'test-path';

$this->assertEmpty($emptyVersionStrategy->getVersion($path));
}

public function testApplyVersion()
{
$emptyVersionStrategy = new EmptyVersionStrategy();
$path = 'test-path';

$this->assertEquals($path, $emptyVersionStrategy->applyVersion($path));
}
}

0 comments on commit 5a6c1f2

Please sign in to comment.