SHARE
TWEET

Untitled

a guest Jun 8th, 2017 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. namespace Tests\Unit;
  4.  
  5. use Tests\TestCase;
  6. use Illuminate\Foundation\Testing\DatabaseMigrations;
  7. use Illuminate\Foundation\Testing\DatabaseTransactions;
  8. use Illuminate\Support\Facades\Queue;
  9. use Illuminate\Foundation\Testing\WithoutMiddleware;
  10.  
  11. use App\User;
  12. use App\SerializableUser;
  13.  
  14. use App\Jobs\SerializableUserJob;
  15. use App\Jobs\UserJob;
  16.  
  17. class UUidUserQueueTest extends TestCase
  18. {
  19.     use DatabaseTransactions;
  20.  
  21.     private $_user;
  22.     private $_serialiableUser;
  23.  
  24.     public function setUp()
  25.     {
  26.         parent::setUp();
  27.         $this->_user = new User();
  28.         $this->_user->name = "JValck";
  29.         $this->_user->password = "DifficultPassword";
  30.         $this->_user->email = "email@example.com";
  31.         $this->_user->save();
  32.  
  33.         $this->_serialiableUser = new SerializableUser();
  34.         $this->_serialiableUser->name = "JValck";
  35.         $this->_serialiableUser->password = "DifficultPassword";
  36.         $this->_serialiableUser->email = "email@example.com";
  37.         $this->_serialiableUser->save();
  38.     }
  39.  
  40.     public function testAddingModelSavesToDb()
  41.     {
  42.         $user = new User();
  43.         $user->name = "JValck";
  44.         $user->password = "DifficultPassword";
  45.         $user->email = "email2@example.com";
  46.         $saved = $user->save();
  47.         $this->assertTrue($saved);
  48.     }
  49.  
  50.     public function testAddingSerizalizableModelSavesToDb()
  51.     {
  52.         $user = new SerializableUser();
  53.         $user->name = "JValck";
  54.         $user->password = "DifficultPassword";
  55.         $user->email = "email2@example.com";
  56.         $saved = $user->save();
  57.         $this->assertTrue($saved);
  58.     }
  59.  
  60.     public function testQueuingModelSucceeds()
  61.     {
  62.         Queue::fake();
  63.         $user = $this->_user;
  64.         $job = Queue::push(new UserJob($user));
  65.         Queue::assertPushed(UserJob::class, function ($job) use ($user) {
  66.             return $job->user->id === $user->id;
  67.         });
  68.     }
  69.  
  70.     public function testQueuingSerializableModelSucceeds()
  71.     {
  72.         Queue::fake();
  73.         $user = $this->_serialiableUser;
  74.         $job = Queue::push(new SerializableUserJob($user));
  75.         Queue::assertPushed(SerializableUserJob::class, function ($job) use ($user) {
  76.             return $job->serializableUser->id === $user->id;
  77.         });
  78.     }
  79. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top