Guest User

Untitled

a guest
Feb 23rd, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. // user class
  2. class User extends Authenticatable
  3. {
  4. use Notifiable;
  5.  
  6. protected $fillable = [
  7. 'name', 'email', 'password',
  8. ];
  9.  
  10. protected $hidden = [
  11. 'password', 'remember_token',
  12. ];
  13.  
  14. protected $casts = [
  15. 'settings' => 'array'
  16. ];
  17. }
  18.  
  19.  
  20. // migration
  21. public function up()
  22. {
  23. Schema::create('users', function (Blueprint $table) {
  24. $table->increments('id');
  25. $table->string('name');
  26. $table->string('email')->unique();
  27. $table->string('password');
  28. $table->json('settings')->nullable();
  29. $table->rememberToken();
  30. $table->timestamps();
  31. });
  32. }
  33.  
  34. // test
  35. public function testCanVerifyJsonColumn()
  36. {
  37. $expectedData = [
  38. 'profile_picture' => 'profile picture',
  39. ];
  40.  
  41. $user = factory(User::class)->create([
  42. 'settings' => $expectedData
  43. ]);
  44.  
  45. $this->assertDatabaseHas('users', [
  46. 'settings' => json_encode($expectedData),
  47. ]);
  48. }
Add Comment
Please, Sign In to add comment