mirror of
https://github.com/michaelachrisco/ReadOnlyTraitLaravel.git
synced 2024-10-31 21:33:23 -07:00
init
This commit is contained in:
commit
ed1c6694c2
5 changed files with 167 additions and 0 deletions
5
.gitignore
vendored
Normal file
5
.gitignore
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
/vendor
|
||||
composer.phar
|
||||
composer.lock
|
||||
.DS_Store
|
||||
/.idea
|
29
.travis.yml
Normal file
29
.travis.yml
Normal file
|
@ -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
|
17
composer.json
Normal file
17
composer.json
Normal file
|
@ -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"
|
||||
}
|
||||
}
|
77
spec/ReadOnlyTraitSpec.php
Normal file
77
spec/ReadOnlyTraitSpec.php
Normal file
|
@ -0,0 +1,77 @@
|
|||
<?php
|
||||
require_once('src/ReadOnlyTrait.php');
|
||||
// use Michael\ReadOnlyTrait;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
class User extends Illuminate\Database\Eloquent\Model {
|
||||
use Michael\ReadOnly\ReadOnlyTrait;
|
||||
}
|
||||
|
||||
describe("User", function() {
|
||||
describe("::save()", function(){
|
||||
|
||||
it("is expected to return false", function() {
|
||||
$user = new User;
|
||||
expect($user->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);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
?>
|
39
src/ReadOnlyTrait.php
Normal file
39
src/ReadOnlyTrait.php
Normal file
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
namespace Michael\ReadOnly;
|
||||
trait ReadOnlyTrait {
|
||||
public function save(array $options = []){
|
||||
return false;
|
||||
}
|
||||
|
||||
public function update(array $attributes = [], array $options = []){
|
||||
return false;
|
||||
}
|
||||
|
||||
static function firstOrCreate(array $arr){
|
||||
return false;
|
||||
}
|
||||
|
||||
static function firstOrNew(array $arr){
|
||||
return false;
|
||||
}
|
||||
|
||||
public function delete(){
|
||||
return false;
|
||||
}
|
||||
|
||||
static function destroy($ids){
|
||||
return false;
|
||||
}
|
||||
|
||||
public function restore(){
|
||||
return false;
|
||||
}
|
||||
|
||||
public function forceDelete(){
|
||||
return false;
|
||||
}
|
||||
|
||||
public function test(){
|
||||
return false;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue