mirror of
https://github.com/michaelachrisco/ReadOnlyTraitLaravel.git
synced 2024-10-31 21:33:23 -07:00
Add PHPDocs and create/forceCreate methods
This commit is contained in:
parent
90f53b52a3
commit
1c6b5e2cc5
3 changed files with 83 additions and 12 deletions
|
@ -11,7 +11,7 @@
|
|||
"php": ">=5.5.9"
|
||||
},
|
||||
"require-dev": {
|
||||
"crysalead/kahlan": "^2.4",
|
||||
"kahlan/kahlan": "^2.4",
|
||||
"illuminate/database": ">=5.2.0"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,22 @@ 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);
|
||||
unset($user);
|
||||
});
|
||||
});
|
||||
describe("::forceCreate()", function(){
|
||||
|
||||
it("is expected to return false", function() {
|
||||
$user = new User;
|
||||
expect($user->forceCreate([]))->toBe(false);
|
||||
unset($user);
|
||||
});
|
||||
});
|
||||
describe("::save()", function(){
|
||||
|
||||
it("is expected to return false", function() {
|
||||
|
@ -64,13 +80,6 @@ describe("User", function() {
|
|||
unset($user);
|
||||
});
|
||||
});
|
||||
describe("::test()", function(){
|
||||
it("is expected to return false", function() {
|
||||
$user = new User;
|
||||
expect($user->test())->toBe(false);
|
||||
unset($user);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
|
|
@ -1,39 +1,101 @@
|
|||
<?php
|
||||
namespace MichaelAChrisco\ReadOnly;
|
||||
trait ReadOnlyTrait {
|
||||
/**
|
||||
* returns false on create
|
||||
* @method create
|
||||
* @param array $attributes
|
||||
* @return false
|
||||
*/
|
||||
static function create(array $attributes = []){
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns false on forceCreate
|
||||
* @method forceCreate
|
||||
* @param array $attributes
|
||||
* @return false
|
||||
*/
|
||||
static function forceCreate(array $attributes){
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns false on save
|
||||
* @method save
|
||||
* @param array $options
|
||||
* @return false
|
||||
*/
|
||||
public function save(array $options = []){
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns false on update
|
||||
* @method update
|
||||
* @param [type] $attributes
|
||||
* @param [type] $options
|
||||
* @return false
|
||||
*/
|
||||
public function update(array $attributes = [], array $options = []){
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns false on firstOrCreate
|
||||
* @method firstOrCreate
|
||||
* @param array $arr
|
||||
* @return false
|
||||
*/
|
||||
static function firstOrCreate(array $arr){
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns false on firstOrNew
|
||||
* @method firstOrNew
|
||||
* @param array $arr
|
||||
* @return false
|
||||
*/
|
||||
static function firstOrNew(array $arr){
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns false on delete
|
||||
* @method delete
|
||||
* @return false
|
||||
*/
|
||||
public function delete(){
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns false on destroy
|
||||
* @method destroy
|
||||
* @param mixed $ids
|
||||
* @return false
|
||||
*/
|
||||
static function destroy($ids){
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns false on restore
|
||||
* @method restore
|
||||
* @return false
|
||||
*/
|
||||
public function restore(){
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns false on forceDelete
|
||||
* @method forceDelete
|
||||
* @return false
|
||||
*/
|
||||
public function forceDelete(){
|
||||
return false;
|
||||
}
|
||||
|
||||
public function test(){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue