-
-
Notifications
You must be signed in to change notification settings - Fork 137
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: crynobone <crynobone@gmail.com>
- Loading branch information
Showing
3 changed files
with
96 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
<?php namespace Orchestra\Testbench\Testing; | ||
|
||
use Illuminate\Support\Fluent; | ||
use Illuminate\View\View; | ||
use Mockery as m; | ||
|
||
trait UnitAssertionTrait | ||
{ | ||
public function testAssertResponseOkMethod() | ||
{ | ||
$this->client = $client = m::mock('\Illuminate\Foundation\Testing\Client'); | ||
|
||
$client->shouldReceive('getResponse')->once()->andReturnSelf() | ||
->shouldReceive('getStatusCode')->once()->andReturn(200) | ||
->shouldReceive('isOk')->once()->andReturn(true); | ||
|
||
$this->assertResponseOk(); | ||
} | ||
|
||
public function testAssertResponseStatusMethod() | ||
{ | ||
$this->client = $client = m::mock('\Illuminate\Foundation\Testing\Client'); | ||
|
||
$client->shouldReceive('getResponse')->once()->andReturnSelf() | ||
->shouldReceive('getStatusCode')->once()->andReturn(400); | ||
|
||
$this->assertResponseStatus(400); | ||
} | ||
|
||
public function testAssertViewHasMethod() | ||
{ | ||
$this->client = $client = m::mock('\Illuminate\Foundation\Testing\Client'); | ||
$view = new View(m::mock('\Illuminate\View\Factory'), m::mock('\Illuminate\View\Engines\EngineInterface'), 'hello', '/var/laravel/views', [ | ||
'foo' => 'bar', | ||
'hello' => 'world', | ||
]); | ||
|
||
$response = new Fluent([ | ||
'original' => $view, | ||
]); | ||
|
||
$client->shouldReceive('getResponse')->once()->andReturn($response); | ||
|
||
$this->assertViewHas('foo'); | ||
$this->assertViewHas('hello', 'world'); | ||
} | ||
|
||
public function testAssertViewHasAllMethod() | ||
{ | ||
$this->client = $client = m::mock('\Illuminate\Foundation\Testing\Client'); | ||
$view = new View(m::mock('\Illuminate\View\Factory'), m::mock('\Illuminate\View\Engines\EngineInterface'), 'hello', '/var/laravel/views', [ | ||
'foo' => 'bar', | ||
'bar' => 'foo', | ||
]); | ||
$response = new Fluent([ | ||
'original' => $view, | ||
]); | ||
|
||
$client->shouldReceive('getResponse')->once()->andReturn($response); | ||
|
||
$this->assertViewHas(['foo', 'bar', 'foo' => 'bar']); | ||
} | ||
|
||
public function testAssertViewMissingMethod() | ||
{ | ||
$this->client = $client = m::mock('\Illuminate\Foundation\Testing\Client'); | ||
$view = new View(m::mock('\Illuminate\View\Factory'), m::mock('\Illuminate\View\Engines\EngineInterface'), 'hello', '/var/laravel/views', []); | ||
$response = new Fluent([ | ||
'original' => $view, | ||
]); | ||
|
||
$client->shouldReceive('getResponse')->once()->andReturn($response); | ||
|
||
$this->assertViewMissing('foo'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php namespace Orchestra\Testbench\TestCase\Traits; | ||
|
||
use Mockery as m; | ||
use Orchestra\Testbench\Testing\UnitAssertionTrait; | ||
use Orchestra\Testbench\Traits\BehatPHPUnitAssertionsTrait; | ||
|
||
class BehatPHPAssertionsTraitTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
use BehatPHPUnitAssertionsTrait, UnitAssertionTrait; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php namespace Orchestra\Testbench\TestCase\Traits; | ||
|
||
use Mockery as m; | ||
use Orchestra\Testbench\Testing\UnitAssertionTrait; | ||
use Orchestra\Testbench\Traits\PHPUnitAssertionsTrait; | ||
|
||
class PHPUnitAssertionsTraitTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
use PHPUnitAssertionsTrait, UnitAssertionTrait; | ||
} |