Skip to content

Commit 5a6c1f2

Browse files
Michal Piotrowskifabpot
Michal Piotrowski
authored andcommitted
asset test coverage
1 parent 399b1d5 commit 5a6c1f2

File tree

3 files changed

+127
-0
lines changed

3 files changed

+127
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Asset\Tests\Context;
13+
14+
use Symfony\Component\Asset\Context\NullContext;
15+
16+
class NullContextTest extends \PHPUnit_Framework_TestCase
17+
{
18+
public function testGetBasePath()
19+
{
20+
$nullContext = new NullContext();
21+
22+
$this->assertEmpty($nullContext->getBasePath());
23+
}
24+
25+
public function testIsSecure()
26+
{
27+
$nullContext = new NullContext();
28+
29+
$this->assertFalse($nullContext->isSecure());
30+
}
31+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Asset\Tests\Context;
13+
14+
use Symfony\Component\Asset\Context\RequestStackContext;
15+
16+
class RequestStackContextTest extends \PHPUnit_Framework_TestCase
17+
{
18+
public function testGetBasePathEmpty()
19+
{
20+
$requestStack = $this->getMock('Symfony\Component\HttpFoundation\RequestStack');
21+
$requestStackContext = new RequestStackContext($requestStack);
22+
23+
$this->assertEmpty($requestStackContext->getBasePath());
24+
}
25+
26+
public function testGetBasePathSet()
27+
{
28+
$testBasePath = 'test-path';
29+
30+
$request = $this->getMock('Symfony\Component\HttpFoundation\Request');
31+
$request->method('getBasePath')
32+
->willReturn($testBasePath);
33+
$requestStack = $this->getMock('Symfony\Component\HttpFoundation\RequestStack');
34+
$requestStack->method('getMasterRequest')
35+
->willReturn($request);
36+
37+
$requestStackContext = new RequestStackContext($requestStack);
38+
39+
$this->assertEquals($testBasePath, $requestStackContext->getBasePath());
40+
}
41+
42+
public function testIsSecureFalse()
43+
{
44+
$requestStack = $this->getMock('Symfony\Component\HttpFoundation\RequestStack');
45+
$requestStackContext = new RequestStackContext($requestStack);
46+
47+
$this->assertFalse($requestStackContext->isSecure());
48+
}
49+
50+
public function testIsSecureTrue()
51+
{
52+
$request = $this->getMock('Symfony\Component\HttpFoundation\Request');
53+
$request->method('isSecure')
54+
->willReturn(true);
55+
$requestStack = $this->getMock('Symfony\Component\HttpFoundation\RequestStack');
56+
$requestStack->method('getMasterRequest')
57+
->willReturn($request);
58+
59+
$requestStackContext = new RequestStackContext($requestStack);
60+
61+
$this->assertTrue($requestStackContext->isSecure());
62+
}
63+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Asset\Tests\VersionStrategy;
13+
14+
use Symfony\Component\Asset\VersionStrategy\EmptyVersionStrategy;
15+
16+
class EmptyVersionStrategyTest extends \PHPUnit_Framework_TestCase
17+
{
18+
public function testGetVersion()
19+
{
20+
$emptyVersionStrategy = new EmptyVersionStrategy();
21+
$path = 'test-path';
22+
23+
$this->assertEmpty($emptyVersionStrategy->getVersion($path));
24+
}
25+
26+
public function testApplyVersion()
27+
{
28+
$emptyVersionStrategy = new EmptyVersionStrategy();
29+
$path = 'test-path';
30+
31+
$this->assertEquals($path, $emptyVersionStrategy->applyVersion($path));
32+
}
33+
}

0 commit comments

Comments
 (0)