@@ -54,6 +54,63 @@ public function it_can_store_scoped_computed_callbacks_for_multiple_scopes()
54
54
'some_field ' => $ closure ,
55
55
], $ repository ->getComputedCallbacks ('articles ' )->all ());
56
56
}
57
+
58
+ #[Test]
59
+ public function it_can_store_multiple_scoped_computed_callbacks ()
60
+ {
61
+ $ repository = new FakeRepositoryWithScopedCallbacks ;
62
+
63
+ $ repository ->computed ('events ' , [
64
+ 'some_field ' => $ closureA = function ($ item , $ value ) {
65
+ //
66
+ },
67
+ ]);
68
+
69
+ $ repository ->computed ('articles ' , [
70
+ 'some_field ' => $ closureB = function ($ item , $ value ) {
71
+ //
72
+ },
73
+ 'another_field ' => $ closureC = function ($ item , $ value ) {
74
+ //
75
+ },
76
+ ]);
77
+
78
+ $ this ->assertEquals ([
79
+ 'some_field ' => $ closureA ,
80
+ ], $ repository ->getComputedCallbacks ('events ' )->all ());
81
+
82
+ $ this ->assertEquals ([
83
+ 'some_field ' => $ closureB ,
84
+ 'another_field ' => $ closureC ,
85
+ ], $ repository ->getComputedCallbacks ('articles ' )->all ());
86
+
87
+ $ this ->assertEquals ([], $ repository ->getComputedCallbacks ('products ' )->all ());
88
+ }
89
+
90
+ #[Test]
91
+ public function it_can_store_multiple_scoped_computed_callbacks_for_multiple_scopes ()
92
+ {
93
+ $ repository = new FakeRepositoryWithScopedCallbacks ;
94
+
95
+ $ repository ->computed (['events ' , 'articles ' ], [
96
+ 'some_field ' => $ closureA = function ($ item , $ value ) {
97
+ //
98
+ },
99
+ 'another_field ' => $ closureB = function ($ item , $ value ) {
100
+ //
101
+ },
102
+ ]);
103
+
104
+ $ this ->assertEquals ([
105
+ 'some_field ' => $ closureA ,
106
+ 'another_field ' => $ closureB ,
107
+ ], $ repository ->getComputedCallbacks ('events ' )->all ());
108
+
109
+ $ this ->assertEquals ([
110
+ 'some_field ' => $ closureA ,
111
+ 'another_field ' => $ closureB ,
112
+ ], $ repository ->getComputedCallbacks ('articles ' )->all ());
113
+ }
57
114
}
58
115
59
116
class FakeRepositoryWithScopedCallbacks
0 commit comments