commit ed1c6694c26621f2ed7b5fe3551932536e88bdca Author: Michael Chrisco Date: Mon Mar 28 11:15:08 2016 -0700 init diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0b27101 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +/vendor +composer.phar +composer.lock +.DS_Store +/.idea diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..596fed6 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,29 @@ +language: php + +php: + - 5.5.9 + - 5.5 + - 5.6 + - 7.0 + - hhvm + +env: + global: + - setup=basic + +matrix: + include: + - php: 5.5.9 + +sudo: false + +install: + - if [[ $setup = 'basic' ]]; then travis_retry composer install --no-interaction --prefer-source; fi + - if [[ $setup = 'stable' ]]; then travis_retry composer update --prefer-source --no-interaction --prefer-stable; fi + - if [[ $setup = 'lowest' ]]; then travis_retry composer update --prefer-source --no-interaction --prefer-lowest --prefer-stable; fi + +before_script: + - cp .env.example .env + - php artisan key:generate + +script: ./vendor/bin/kahlan -reporter=verbose diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..6fa6181 --- /dev/null +++ b/composer.json @@ -0,0 +1,17 @@ +{ + "name": "michael/readonly", + "description": "Readonly Models for Laravel 5", + "authors": [ + { + "name": "Michael Chrisco", + "email": "michaelachrisco@gmail.com" + } + ], + "require": { + "php": ">=5.5.9", + "illuminate/database": ">=5.2.0" + }, + "require-dev": { + "crysalead/kahlan": "^2.4" + } +} diff --git a/spec/ReadOnlyTraitSpec.php b/spec/ReadOnlyTraitSpec.php new file mode 100644 index 0000000..8e3843b --- /dev/null +++ b/spec/ReadOnlyTraitSpec.php @@ -0,0 +1,77 @@ +save([]))->toBe(false); + unset($user); + }); + }); + describe("::update()", function(){ + it("is expected to return false", function() { + $user = new User; + expect($user->update([]))->toBe(false); + unset($user); + }); + }); + describe("::firstOrCreate()", function(){ + it("is expected to return false", function() { + $user = new User; + expect($user->firstOrCreate([]))->toBe(false); + unset($user); + }); + }); + describe("::firstOrNew()", function(){ + it("is expected to return false", function() { + $user = new User; + expect($user->firstOrNew([]))->toBe(false); + unset($user); + }); + }); + describe("::delete()", function(){ + it("is expected to return false", function() { + $user = new User; + expect($user->delete())->toBe(false); + unset($user); + }); + }); + describe("::destroy()", function(){ + it("is expected to return false", function() { + $user = new User; + expect($user->destroy(1))->toBe(false); + unset($user); + }); + }); + describe("::restore()", function(){ + it("is expected to return false", function() { + $user = new User; + expect($user->restore())->toBe(false); + unset($user); + }); + }); + describe("::forceDelete()", function(){ + it("is expected to return false", function() { + $user = new User; + expect($user->forceDelete())->toBe(false); + unset($user); + }); + }); + describe("::test()", function(){ + it("is expected to return false", function() { + $user = new User; + expect($user->test())->toBe(false); + unset($user); + }); + }); +}); + + + ?> diff --git a/src/ReadOnlyTrait.php b/src/ReadOnlyTrait.php new file mode 100644 index 0000000..cc317be --- /dev/null +++ b/src/ReadOnlyTrait.php @@ -0,0 +1,39 @@ +