@@ -109,6 +109,29 @@ public function test_delete()
109
109
$ this ->assertNull (TestModelStub::find ($ model ->getDn ()));
110
110
}
111
111
112
+ public function test_delete_attribute ()
113
+ {
114
+ $ model = tap (new TestModelStub , function ($ model ) {
115
+ $ model ->cn = 'John Doe ' ;
116
+ $ model ->foo = 'bar ' ;
117
+ $ model ->baz = 'set ' ;
118
+ $ model ->zal = 'ze ' ;
119
+ $ model ->save ();
120
+ });
121
+
122
+ $ model ->deleteAttribute ('foo ' );
123
+ $ model ->deleteAttribute (['baz ' , 'zal ' => 'invalid ' ]);
124
+
125
+ $ this ->assertNull ($ model ->foo );
126
+ $ this ->assertNull ($ model ->baz );
127
+ $ this ->assertEquals (['ze ' ], $ model ->zal );
128
+ $ this ->assertEquals ('John Doe ' , $ model ->cn [0 ]);
129
+
130
+ $ model ->deleteAttribute (['baz ' , 'zal ' => 'ze ' ]);
131
+
132
+ $ this ->assertEquals ([], $ model ->zal );
133
+ }
134
+
112
135
public function test_delete_attributes ()
113
136
{
114
137
$ model = tap (new TestModelStub , function ($ model ) {
@@ -122,7 +145,7 @@ public function test_delete_attributes()
122
145
$ this ->assertEquals (['bar ' ], $ model ->foo );
123
146
$ this ->assertEquals (['set ' ], $ model ->baz );
124
147
125
- $ model ->deleteAttributes ($ model ->getDn (), ['foo ' , 'baz ' ]);
148
+ $ model ->deleteAttributes ($ model ->getDn (), ['foo ' => [] , 'baz ' => [] ]);
126
149
127
150
$ model = TestModelStub::find ($ model ->getDn ());
128
151
$ this ->assertNull ($ model ->foo );
@@ -232,8 +255,7 @@ public function test_get_only_returns_matching_object_classes()
232
255
{
233
256
TestModelStub::create (['cn ' => ['John ' ]]);
234
257
235
- $ model = new class extends Entry
236
- {
258
+ $ model = new class extends Entry {
237
259
public static $ objectClasses = ['three ' , 'four ' ];
238
260
};
239
261
@@ -589,14 +611,12 @@ public function test_domain_scoping()
589
611
DirectoryEmulator::setup ('alpha ' );
590
612
DirectoryEmulator::setup ('bravo ' );
591
613
592
- $ alpha = new class extends Entry
593
- {
614
+ $ alpha = new class extends Entry {
594
615
protected $ connection = 'alpha ' ;
595
616
public static $ objectClasses = ['one ' , 'two ' ];
596
617
};
597
618
598
- $ bravo = new class extends Entry
599
- {
619
+ $ bravo = new class extends Entry {
600
620
protected $ connection = 'bravo ' ;
601
621
public static $ objectClasses = ['one ' , 'two ' ];
602
622
};
0 commit comments