11<?php
22require_once ('src/ReadOnlyTrait.php ' );
3- use MichaelAChrisco \ReadOnly \ReadOnlyException ,
4- MichaelAChrisco \ReadOnly \ReadOnlyTrait ,
5- Illuminate \Database \Eloquent \Model ;
6- // use Illuminate\Database\Eloquent\Builder;
3+
4+ use MichaelAChrisco \ReadOnly \ReadOnlyException ;
5+ use MichaelAChrisco \ReadOnly \ReadOnlyTrait ;
76
87class User extends Illuminate \Database \Eloquent \Model {
98 use ReadOnlyTrait;
@@ -16,7 +15,7 @@ class User extends Illuminate\Database\Eloquent\Model {
1615 function (){
1716 $ user = new User ;
1817 $ user ->create ([]);
19- })->toThrow (new ReadOnlyException (" Not allowed to persist changes in read-only model User" ));
18+ })->toThrow (new ReadOnlyException (' create ' , ' User ' ));
2019 });
2120 });
2221 describe ("::forceCreate() " , function (){
@@ -25,7 +24,7 @@ function(){
2524 $ user = new User ;
2625 $ user ->forceCreate ([]);
2726 };
28- expect ($ closure )->toThrow (new ReadOnlyException (" Not allowed to persist changes in read-only model User" ));
27+ expect ($ closure )->toThrow (new ReadOnlyException (' forceCreate ' , ' User ' ));
2928 });
3029});
3130 describe ("::save() " , function (){
@@ -34,7 +33,7 @@ function(){
3433 function (){
3534 $ user = new User ;
3635 $ user ->save ([]);
37- })->toThrow (new ReadOnlyException (" Not allowed to persist changes in read-only model User" ));
36+ })->toThrow (new ReadOnlyException (' save ' , ' User ' ));
3837 });
3938 });
4039 describe ("::update() " , function (){
@@ -43,7 +42,7 @@ function(){
4342 function (){
4443 $ user = new User ;
4544 $ user ->update ([]);
46- })->toThrow (new ReadOnlyException (" Not allowed to persist changes in read-only model User" ));
45+ })->toThrow (new ReadOnlyException (' update ' , ' User ' ));
4746 });
4847 });
4948 describe ("::firstOrCreate() " , function (){
@@ -52,7 +51,7 @@ function(){
5251 function (){
5352 $ user = new User ;
5453 $ user ->firstOrCreate ([]);
55- })->toThrow (new ReadOnlyException (" Not allowed to persist changes in read-only model User" ));
54+ })->toThrow (new ReadOnlyException (' firstOrCreate ' , ' User ' ));
5655 });
5756 });
5857 describe ("::firstOrNew() " , function (){
@@ -61,7 +60,7 @@ function(){
6160 function (){
6261 $ user = new User ;
6362 $ user ->firstOrNew ([]);
64- })->toThrow (new ReadOnlyException (" Not allowed to persist changes in read-only model User" ));
63+ })->toThrow (new ReadOnlyException (' firstOrNew ' , ' User ' ));
6564 });
6665 });
6766 describe ("::delete() " , function (){
@@ -70,7 +69,7 @@ function(){
7069 function (){
7170 $ user = new User ;
7271 $ user ->delete ();
73- })->toThrow (new ReadOnlyException (" Not allowed to persist changes in read-only model User" ));
72+ })->toThrow (new ReadOnlyException (' delete ' , ' User ' ));
7473 });
7574 });
7675 describe ("::destroy() " , function (){
@@ -79,7 +78,7 @@ function(){
7978 function (){
8079 $ user = new User ;
8180 $ user ->destroy (1 );
82- })->toThrow (new ReadOnlyException (" Not allowed to persist changes in read-only model User" ));
81+ })->toThrow (new ReadOnlyException (' destroy ' , ' User ' ));
8382 });
8483 });
8584 describe ("::restore() " , function (){
@@ -88,7 +87,7 @@ function(){
8887 function (){
8988 $ user = new User ;
9089 $ user ->restore ();
91- })->toThrow (new ReadOnlyException (" Not allowed to persist changes in read-only model User" ));
90+ })->toThrow (new ReadOnlyException (' restore ' , ' User ' ));
9291 });
9392 });
9493 describe ("::forceDelete() " , function (){
@@ -97,7 +96,7 @@ function(){
9796 function (){
9897 $ user = new User ;
9998 $ user ->forceDelete ();
100- })->toThrow (new ReadOnlyException (" Not allowed to persist changes in read-only model User" ));
99+ })->toThrow (new ReadOnlyException (' forceDelete ' , ' User ' ));
101100 });
102101 });
103102 describe ("::performDeleteOnModel() " , function (){
@@ -106,7 +105,7 @@ function(){
106105 function (){
107106 $ user = new User ;
108107 $ user ->performDeleteOnModel ();
109- })->toThrow (new ReadOnlyException (" Not allowed to persist changes in read-only model User" ));
108+ })->toThrow (new ReadOnlyException (' performDeleteOnModel ' , ' User ' ));
110109 });
111110 });
112111 describe ("::push() " , function (){
@@ -115,7 +114,7 @@ function(){
115114 function (){
116115 $ user = new User ;
117116 $ user ->push ();
118- })->toThrow (new ReadOnlyException (" Not allowed to persist changes in read-only model User" ));
117+ })->toThrow (new ReadOnlyException (' push ' , ' User ' ));
119118 });
120119 });
121120 describe ("::finishSave() " , function (){
@@ -124,7 +123,7 @@ function(){
124123 function (){
125124 $ user = new User ;
126125 $ user ->finishSave ([]);
127- })->toThrow (new ReadOnlyException (" Not allowed to persist changes in read-only model User" ));
126+ })->toThrow (new ReadOnlyException (' finishSave ' , ' User ' ));
128127 });
129128 });
130129 describe ("::performUpdate() " , function (){
@@ -142,7 +141,7 @@ function(){
142141 function (){
143142 $ user = new User ;
144143 $ user ->touch ();
145- })->toThrow (new ReadOnlyException (" Not allowed to persist changes in read-only model User" ));
144+ })->toThrow (new ReadOnlyException (' touch ' , ' User ' ));
146145 });
147146 });
148147 describe ("::truncate() " , function (){
@@ -151,7 +150,7 @@ function(){
151150 function (){
152151 $ user = new User ;
153152 $ user ->truncate ();
154- })->toThrow (new ReadOnlyException (" Not allowed to persist changes in read-only model User" ));
153+ })->toThrow (new ReadOnlyException (' truncate ' , ' User ' ));
155154 });
156155 });
157156 describe ("::insert() " , function (){
@@ -160,10 +159,7 @@ function(){
160159 function (){
161160 $ user = new User ;
162161 $ user ->insert ();
163- })->toThrow (new ReadOnlyException (" Not allowed to persist changes in read-only model User" ));
162+ })->toThrow (new ReadOnlyException (' insert ' , ' User ' ));
164163 });
165164 });
166165});
167-
168-
169- ?>
0 commit comments