@@ -1293,6 +1293,110 @@ public function testFieldValueNotEquals()
1293
1293
$ this ->assertCorrectAssertion ('fieldValueNotEquals ' , array ('username ' , '' ));
1294
1294
}
1295
1295
1296
+ public function testFieldValueMatches ()
1297
+ {
1298
+ $ page = $ this ->getMockBuilder ('Behat \\Mink \\Element \\DocumentElement ' )
1299
+ ->disableOriginalConstructor ()
1300
+ ->getMock ()
1301
+ ;
1302
+
1303
+ $ element = $ this ->getMockBuilder ('Behat \\Mink \\Element \\NodeElement ' )
1304
+ ->disableOriginalConstructor ()
1305
+ ->getMock ()
1306
+ ;
1307
+
1308
+ $ this ->session
1309
+ ->expects ($ this ->exactly (4 ))
1310
+ ->method ('getPage ' )
1311
+ ->will ($ this ->returnValue ($ page ))
1312
+ ;
1313
+
1314
+ $ page
1315
+ ->expects ($ this ->exactly (4 ))
1316
+ ->method ('findField ' )
1317
+ ->with ('username ' )
1318
+ ->will ($ this ->returnValue ($ element ))
1319
+ ;
1320
+
1321
+ $ element
1322
+ ->expects ($ this ->exactly (4 ))
1323
+ ->method ('getValue ' )
1324
+ ->will ($ this ->returnValue (234 ))
1325
+ ;
1326
+
1327
+ $ this ->assertCorrectAssertion ('fieldValueMatches ' , array ('username ' , '/234/ ' ));
1328
+ $ this ->assertWrongAssertion (
1329
+ 'fieldValueMatches ' ,
1330
+ array ('username ' , '/235/ ' ),
1331
+ 'Behat \\Mink \\Exception \\ExpectationException ' ,
1332
+ 'The pattern "/235/" was not found in the value "234" of field "username". '
1333
+ );
1334
+ $ this ->assertWrongAssertion (
1335
+ 'fieldValueMatches ' ,
1336
+ array ('username ' , '/22/ ' ),
1337
+ 'Behat \\Mink \\Exception \\ExpectationException ' ,
1338
+ 'The pattern "/22/" was not found in the value "234" of field "username". '
1339
+ );
1340
+ $ this ->assertWrongAssertion (
1341
+ 'fieldValueMatches ' ,
1342
+ array ('username ' , '/\D+/ ' ),
1343
+ 'Behat \\Mink \\Exception \\ExpectationException ' ,
1344
+ 'The pattern "/\D+/" was not found in the value "234" of field "username". '
1345
+ );
1346
+ }
1347
+
1348
+ public function testFieldValueNotMatches ()
1349
+ {
1350
+ $ page = $ this ->getMockBuilder ('Behat \\Mink \\Element \\DocumentElement ' )
1351
+ ->disableOriginalConstructor ()
1352
+ ->getMock ()
1353
+ ;
1354
+
1355
+ $ element = $ this ->getMockBuilder ('Behat \\Mink \\Element \\NodeElement ' )
1356
+ ->disableOriginalConstructor ()
1357
+ ->getMock ()
1358
+ ;
1359
+
1360
+ $ this ->session
1361
+ ->expects ($ this ->exactly (4 ))
1362
+ ->method ('getPage ' )
1363
+ ->will ($ this ->returnValue ($ page ))
1364
+ ;
1365
+
1366
+ $ page
1367
+ ->expects ($ this ->exactly (4 ))
1368
+ ->method ('findField ' )
1369
+ ->with ('username ' )
1370
+ ->will ($ this ->returnValue ($ element ))
1371
+ ;
1372
+
1373
+ $ element
1374
+ ->expects ($ this ->exactly (4 ))
1375
+ ->method ('getValue ' )
1376
+ ->will ($ this ->returnValue (235 ))
1377
+ ;
1378
+
1379
+ $ this ->assertCorrectAssertion ('fieldValueNotMatches ' , array ('username ' , '/234/ ' ));
1380
+ $ this ->assertWrongAssertion (
1381
+ 'fieldValueNotMatches ' ,
1382
+ array ('username ' , '/235/ ' ),
1383
+ 'Behat \\Mink \\Exception \\ExpectationException ' ,
1384
+ 'The pattern "/235/" was found in the value "235" of field "username", but it should not. '
1385
+ );
1386
+ $ this ->assertWrongAssertion (
1387
+ 'fieldValueNotMatches ' ,
1388
+ array ('username ' , '/23/ ' ),
1389
+ 'Behat \\Mink \\Exception \\ExpectationException ' ,
1390
+ 'The pattern "/23/" was found in the value "235" of field "username", but it should not. '
1391
+ );
1392
+ $ this ->assertWrongAssertion (
1393
+ 'fieldValueNotMatches ' ,
1394
+ array ('username ' , '/\d+/ ' ),
1395
+ 'Behat \\Mink \\Exception \\ExpectationException ' ,
1396
+ 'The pattern "/\d+/" was found in the value "235" of field "username", but it should not. '
1397
+ );
1398
+ }
1399
+
1296
1400
public function testCheckboxChecked ()
1297
1401
{
1298
1402
$ page = $ this ->getMockBuilder ('Behat \\Mink \\Element \\DocumentElement ' )
0 commit comments