<?php
use AppEventsUserRegistered;
class ExampleTest extends TestCase
{
/**
* Test new user registration.
*/
public function testUserRegistration()
{
$this->expectsEvents(UserRegistered::class);
// Test user registration...
}
}
--
<?php
class ExampleTest extends TestCase
{
public function testUserRegistration()
{
$this->withoutEvents();
// Test user registration code...
}
}
--
<?php
use AppEventsOrderShipped;
use AppEventsOrderFailedToShip;
use IlluminateSupportFacadesEvent;
class ExampleTest extends TestCase
{
/**
* Test order shipping.
*/
public function testOrderShipping()
{
Event::fake();
// Perform order shipping...
Event::assertFired(OrderShipped::class, function ($e) use ($order) {
return $e->order->id === $order->id;
});
Event::assertNotFired(OrderFailedToShip::class);
}
}
---
<?php
use AppJobsShipOrder;
class ExampleTest extends TestCase
{
public function testOrderShipping()
{
$this->expectsJobs(ShipOrder::class);
// Test order shipping...
}
}
---
<?php
use AppJobsShipOrder;
class ExampleTest extends TestCase
{
/**
* Test order cancellation.
*/
public function testOrderCancellation()
{
$this->doesntExpectJobs(ShipOrder::class);
// Test order cancellation...
}
}
---
<?php
use AppJobsShipOrder;
class ExampleTest extends TestCase
{
/**
* Test order cancellation.
*/
public function testOrderCancellation()
{
$this->withoutJobs();
// Test order cancellation...
}
}
---
<?php
class FooTest extends TestCase
{
public function testGetIndex()
{
Cache::shouldReceive('get')
->once()
->with('key')
->andReturn('value');
$this->visit('/users')->see('value');
}
}
---
<?php
namespace AppHttpControllers;
use IlluminateSupportFacadesCache;
class UserController extends Controller
{
/**
* Show a list of all users of the application.
*
* @return Response
*/
public function index()
{
$value = Cache::get('key');
//
}
}
From: http://sitestree.com/?p=4682
Categories:Root, Laravel
Tags:
Post Data:2016-12-10 22:08:49
Shop Online: https://www.ShopForSoul.com/
(Big Data, Cloud, Security, Machine Learning): Courses: http://Training.SitesTree.com
In Bengali: http://Bangla.SaLearningSchool.com
http://SitesTree.com
8112223 Canada Inc./JustEtc: http://JustEtc.net (Software/Web/Mobile/Big-Data/Machine Learning)
Shop Online: https://www.ShopForSoul.com/
Medium: https://medium.com/@SayedAhmedCanada