From 663c2b70a0fc93b2dff899382d303c234051fa2b Mon Sep 17 00:00:00 2001 From: michael chrisco Date: Fri, 9 Dec 2016 06:37:13 -0800 Subject: [PATCH] L5.3 methods (#10) --- README.md | 10 ++++----- spec/ReadOnlyTraitSpec.php | 39 ++++++++++++++++++++++++++++++--- src/ReadOnlyTrait.php | 45 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 86 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index b5ff079..f67ecf8 100644 --- a/README.md +++ b/README.md @@ -34,16 +34,16 @@ $result = $legacyUser->save(); * destroy * restore * forceDelete + * performDeleteOnModel + * push + * finishSave + * performUpdate + * touch ## TODO: - * performDeleteOnModel - * push * saveOrFail - * finishSave - * performUpdate * performInsert(??) * insertAndSetId(??) - * touch * Add in a PR for any other methods you can find! diff --git a/spec/ReadOnlyTraitSpec.php b/spec/ReadOnlyTraitSpec.php index 3af4774..5019f46 100644 --- a/spec/ReadOnlyTraitSpec.php +++ b/spec/ReadOnlyTraitSpec.php @@ -8,7 +8,6 @@ class User extends Illuminate\Database\Eloquent\Model { describe("User", function() { describe("::create()", function(){ - it("is expected to return false", function() { $user = new User; expect($user->create([]))->toBe(false); @@ -16,7 +15,6 @@ describe("User", function() { }); }); describe("::forceCreate()", function(){ - it("is expected to return false", function() { $user = new User; expect($user->forceCreate([]))->toBe(false); @@ -30,7 +28,7 @@ describe("User", function() { expect($user->save([]))->toBe(false); unset($user); }); - }); + }); describe("::update()", function(){ it("is expected to return false", function() { $user = new User; @@ -80,6 +78,41 @@ describe("User", function() { unset($user); }); }); + describe("::performDeleteOnModel()", function(){ + it("is expected to return false", function() { + $user = new User; + expect($user->performDeleteOnModel())->toBe(false); + unset($user); + }); + }); + describe("::push()", function(){ + it("is expected to return false", function() { + $user = new User; + expect($user->push())->toBe(false); + unset($user); + }); + }); + describe("::finishSave()", function(){ + it("is expected to return false", function() { + $user = new User; + expect($user->finishSave([]))->toBe(false); + unset($user); + }); + }); + describe("::performUpdate()", function(){ + it("is expected to return false", function() { + $user = new User; + expect($user->performUpdate())->toBe(false); + unset($user); + }); + }); + describe("::touch()", function(){ + it("is expected to return false", function() { + $user = new User; + expect($user->touch())->toBe(false); + unset($user); + }); + }); }); diff --git a/src/ReadOnlyTrait.php b/src/ReadOnlyTrait.php index e215329..e0e7b83 100644 --- a/src/ReadOnlyTrait.php +++ b/src/ReadOnlyTrait.php @@ -98,4 +98,49 @@ trait ReadOnlyTrait { public function forceDelete(){ return false; } + + /** + * returns false on performDeleteOnModel + * @method performDeleteOnModel + * @return false + */ + public function performDeleteOnModel(){ + return false; + } + + /** + * returns false on push + * @method push + * @return false + */ + public function push(){ + return false; + } + + /** + * returns false on finishSave + * @method finishSave + * @return false + */ + public function finishSave(array $options){ + return false; + } + + /** + * returns false on performUpdate + * @method performUpdate + * @return false + */ + public function performUpdate(){ + return false; + } + + /** + * returns false on touch + * @method touch + * @return false + */ + public function touch(){ + return false; + } }