public function testGetPersistedIsEmptyIfStaticMappingIsNull()
 {
     $attributes = Car::withAllPersisted([], function () {
         return (new Car())->getPersistedAttributes();
     });
     $this->assertEquals([], $attributes);
 }
 public function testAllAttributesAreSavedIfPersistedIsEmpty()
 {
     $car = new Car();
     $car->color = 'red';
     $car->fuel = 'unleaded';
     $car->cruft = 'red is my favorite';
     Car::withAllPersisted([], function () use($car) {
         $car->save();
     });
     $dbCar = DB::table('vehicles')->first();
     $this->assertEquals($car->id, $dbCar->id);
     $this->assertEquals('red is my favorite', $dbCar->cruft);
     $this->assertEquals('red', $dbCar->color);
     $this->assertEquals('unleaded', $dbCar->fuel);
 }
 public function testEmptyPersistedAttributesReturnsEverythingInQuery()
 {
     $now = Carbon::now();
     DB::table('vehicles')->insert([['type' => 'car', 'color' => 'red', 'cruft' => 'red is my favorite', 'owner_id' => null, 'created_at' => $now, 'updated_at' => $now]]);
     $car = Car::withAllPersisted([], function () {
         return Car::all()->first();
     });
     $this->assertEquals('red is my favorite', $car->cruft);
 }