Skip to content

Commit

Permalink
added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
imanghafoori1 committed May 29, 2021
1 parent 17ca8ea commit a3024b6
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
10 changes: 10 additions & 0 deletions tests/Stubs/SomeClass.php
Expand Up @@ -8,4 +8,14 @@ public function someMethod()
{
return false;
}

public function someMethod2($p1, $p2)
{
return response()->json(['Wow' => (string)($p1 + $p2)], 566);
}

public static function someStaticMethod()
{
return response()->json(['Wow' => 'Man'], 201);
}
}
22 changes: 15 additions & 7 deletions tests/reactionsTest.php
Expand Up @@ -95,18 +95,26 @@ public function test_we_respond_from()
{
Route::get('/welcome', 'HomeController@index');

$resp = response()->json(['Wow'=> 'Man'], 566);
\Facades\Imanghafoori\HeyManTests\Stubs\SomeClass::shouldReceive('someMethod')
->once()
->with(20, 30)
->andReturn($resp);
HeyMan::whenYouVisitUrl('welcome')
->thisValueShouldAllow(false)
->otherwise()
->weRespondFrom(SomeClass::class.'@someMethod2', [20, 30]);
app(StartGuarding::class)->start();

$this->get('welcome')->assertStatus(566)->assertJson(['Wow'=> '50']);
}

public function test_we_respond_from_2()
{
Route::get('/welcome', 'HomeController@index');

HeyMan::whenYouVisitUrl('welcome')
->thisValueShouldAllow(false)
->otherwise()
->weRespondFrom(SomeClass::class.'@someMethod', [20, 30]);
->weRespondFrom([SomeClass::class, 'someStaticMethod']);

app(StartGuarding::class)->start();

$this->get('welcome')->assertStatus(566)->assertJson(['Wow'=> 'Man']);
$this->get('welcome')->assertStatus(201)->assertJson(['Wow'=> 'Man']);
}
}

0 comments on commit a3024b6

Please sign in to comment.