Skip to content

Commit

Permalink
update the tests
Browse files Browse the repository at this point in the history
to affect this commit 6a0ed63 changes
  • Loading branch information
mahmoud committed Sep 19, 2014
1 parent 6a0ed63 commit 3ebee70
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
7 changes: 4 additions & 3 deletions src/Vinelab/Cdn/CdnFacade.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,10 @@ public function __construct
*/
public function asset($path)
{
return $this->preparePathAndGenerateUrl('asset', $path);
return $this->preparePathAndCallUrlGenerator('asset', $path);
}


/**
* this function will be called from the 'views' using the
* 'Cdn' facade {{Cdn::path('')}} to convert the path into
Expand All @@ -85,7 +86,7 @@ public function asset($path)
*/
public function path($path)
{
return $this->preparePathAndGenerateUrl('path', $path);
return $this->preparePathAndCallUrlGenerator('path', $path);
}

/**
Expand All @@ -97,7 +98,7 @@ public function path($path)
* @return mixed
* @throws Exceptions\EmptyPathException
*/
private function preparePathAndGenerateUrl($from, $path)
private function preparePathAndCallUrlGenerator($from, $path)
{
if ( ! isset($path))
throw new EmptyPathException('Path does not exist.');
Expand Down
15 changes: 4 additions & 11 deletions tests/Vinelab/Cdn/CdnFacadeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ public function setUp()

$this->helper = M::mock('Vinelab\Cdn\Contracts\CdnHelperInterface');
$this->helper->shouldReceive('getConfigurations')->once()->andReturn([]);
$this->helper->shouldReceive('cleanPath')->andReturn($this->asset_path);
$this->helper->shouldReceive('startsWith')->andReturn(true);

$this->validator = new \Vinelab\Cdn\Validators\CdnFacadeValidator;

Expand All @@ -44,21 +46,12 @@ public function testAssetIsCallingUrlGenerator()
assertEquals($result, $this->cdn_url);
}

public function testCleanPathIsCleaning()
{
$path = '/foo/bar/';
$cleaned_path = 'foo/bar';
// invoke the private function cleanPath()
$result = $this->invokeMethod($this->facade, 'cleanPath', array($path));
assertEquals($result, $cleaned_path);
}

/**
* @expectedException \Vinelab\Cdn\Exceptions\EmptyPathException
*/
public function testAssetThrowsExceptionWhenEmptyParameter()
public function testPreparePathThrowsExceptionWhenEmptyParameter()

This comment has been minimized.

Copy link
@Mulkave

Mulkave Sep 19, 2014

Member

Better call the function with the functionality we're testing instead of what we expect the function to actually do. Like testGeneratingUrlWith[Null,Empty,Invalid,Int,LongString,etc.]Path

{
$this->facade->asset(null);
$this->invokeMethod($this->facade, 'preparePathAndCallUrlGenerator', array(null, null));
}

}

0 comments on commit 3ebee70

Please sign in to comment.