Code Duplication    Length = 20-23 lines in 2 locations

tests/ValidatorTest.php 2 locations

@@ 129-148 (lines=20) @@
126
        ], $this->validator->getErrors());
127
    }
128
129
    public function testValidateWithCustomGlobalMessages()
130
    {
131
        $this->validator->validate($this->request, [
132
            'username' => V::length(8),
133
            'password' => V::length(8)
134
        ], [
135
            'length' => 'Too short!'
136
        ]);
137
138
        $this->assertEquals(['username' => 'a_wurth', 'password' => '1234'], $this->validator->getValues());
139
        $this->assertFalse($this->validator->isValid());
140
        $this->assertEquals([
141
            'username' => [
142
                'length' => 'Too short!'
143
            ],
144
            'password' => [
145
                'length' => 'Too short!'
146
            ]
147
        ], $this->validator->getErrors());
148
    }
149
150
    public function testValidateWithCustomDefaultAndGlobalMessages()
151
    {
@@ 190-212 (lines=23) @@
187
        ]);
188
    }
189
190
    public function testValidateWithCustomIndividualMessage()
191
    {
192
        $this->validator->validate($this->request, [
193
            'username' => [
194
                'rules' => V::length(8),
195
                'messages' => [
196
                    'length' => 'Too short!'
197
                ]
198
            ],
199
            'password' => V::length(8)
200
        ]);
201
202
        $this->assertEquals(['username' => 'a_wurth', 'password' => '1234'], $this->validator->getValues());
203
        $this->assertFalse($this->validator->isValid());
204
        $this->assertEquals([
205
            'username' => [
206
                'length' => 'Too short!'
207
            ],
208
            'password' => [
209
                'length' => '"1234" must have a length greater than 8'
210
            ]
211
        ], $this->validator->getErrors());
212
    }
213
214
    /**
215
     * @expectedException InvalidArgumentException