@@ -70,7 +70,7 @@ public function testInitialize()
70
70
$ property ->setAccessible (true );
71
71
$ property ->setValue ($ behavior , $ table );
72
72
73
- $ behavior ->expects ($ this ->exactly (2 ))
73
+ $ behavior ->expects ($ this ->exactly (3 ))
74
74
->method ('config ' )
75
75
->will ($ this ->returnValue ($ this ->settings ));
76
76
@@ -113,6 +113,35 @@ public function testInitializeIndexedConfig()
113
113
$ this ->assertEquals (['field ' => []], $ behavior ->config ());
114
114
}
115
115
116
+ public function testInitializeAddBehaviorOptionsInterfaceConfig ()
117
+ {
118
+ $ settings = [
119
+ 'className ' => 'Josegonzalez\Upload\Model\Behavior\UploadBehavior ' ,
120
+ 'field ' => []
121
+ ];
122
+ $ table = $ this ->getMock ('Cake\ORM\Table ' );
123
+ $ schema = $ this ->getMock ('Cake\Database\Schema\Table ' , [], [$ table , []]);
124
+ $ schema ->expects ($ this ->once ())
125
+ ->method ('columnType ' )
126
+ ->with ('field ' , 'upload.file ' );
127
+ $ table ->expects ($ this ->at (0 ))
128
+ ->method ('schema ' )
129
+ ->will ($ this ->returnValue ($ schema ));
130
+ $ table ->expects ($ this ->at (1 ))
131
+ ->method ('schema ' )
132
+ ->will ($ this ->returnValue ($ schema ));
133
+
134
+ $ methods = array_diff ($ this ->behaviorMethods , ['initialize ' , 'config ' ]);
135
+ $ behavior = $ this ->getMock ('Josegonzalez\Upload\Model\Behavior\UploadBehavior ' , $ methods , [$ table , $ settings ], '' , false );
136
+ $ reflection = new ReflectionClass ($ behavior );
137
+ $ property = $ reflection ->getProperty ('_table ' );
138
+ $ property ->setAccessible (true );
139
+ $ property ->setValue ($ behavior , $ table );
140
+ $ behavior ->initialize ($ settings );
141
+
142
+ $ this ->assertEquals (['field ' => []], $ behavior ->config ());
143
+ }
144
+
116
145
public function testBeforeMarshalOk ()
117
146
{
118
147
$ validator = $ this ->getMock ('Cake\Validation\Validator ' );
0 commit comments