8000 asset test coverage by eventhorizonpl · Pull Request #16428 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

asset test coverage #16428

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions src/Symfony/Component/Asset/Tests/Context/NullContextTest.php
Original file line number Diff line number Diff line change
@@ -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());
}
}
Original file line number Diff line number Diff line change
@@ -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());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, this should be the end of the test case. Following code is a separate one.

}

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());
}
}
Original file line number Diff line number Diff line change
@@ -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