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 testSetFilteredAttributes()
 {
     $car = new Car();
     $car->setFilteredAttributes(['fuel' => 'diesel', 'junk' => 'trunk', 'wingspan' => 30]);
     $this->assertEquals(['fuel' => 'diesel'], $car->getAttributes());
 }
 public function testGetAllPersistedOfLeaf()
 {
     $a = Car::getAllPersistedAttributes();
     sort($a);
     $this->assertEquals(['capacity', 'color', 'fuel', 'owner_id'], $a);
 }
 public function testUpdateRemovesScope()
 {
     $car = new Car();
     $car->color = 'red';
     $car->save();
     $dbCar = Vehicle::where('color', 'red')->first();
     $dbCar->color = 'green';
     $this->assertTrue($dbCar->save());
     // if the scope doesn't remove bindings this save will throw an exception.
 }