|
| 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 | +} |
0 commit comments