@@ -88,6 +88,25 @@ public static function phone($check) {
88
88
89
89
}
90
90
91
+ /**
92
+ * ValidationStub
93
+ *
94
+ * @package Cake.Test.Case.Utility
95
+ */
96
+ class ValidationStub extends Validation {
97
+
98
+ /**
99
+ * Stub out is_uploaded_file check
100
+ *
101
+ * @param string $path
102
+ * @return void
103
+ */
104
+ protected static function _isUploadedFile ($ path ) {
105
+ return file_exists ($ path );
106
+ }
107
+
108
+ }
109
+
91
110
/**
92
111
* Test Case for Validation Class
93
112
*
@@ -2405,21 +2424,21 @@ public function testFileSize() {
2405
2424
* @return void
2406
2425
*/
2407
2426
public function testUploadedFileErrorCode () {
2408
- $ this ->assertFalse (Validation ::uploadedFile ('derp ' ));
2427
+ $ this ->assertFalse (ValidationStub ::uploadedFile ('derp ' ));
2409
2428
$ invalid = array (
2410
2429
'name ' => 'testing '
2411
2430
);
2412
- $ this ->assertFalse (Validation ::uploadedFile ($ invalid ));
2431
+ $ this ->assertFalse (ValidationStub ::uploadedFile ($ invalid ));
2413
2432
$ file = array (
2414
2433
'name ' => 'cake.power.gif ' ,
2415
2434
'tmp_name ' => CORE_PATH . 'Cake ' . DS . 'Test ' . DS . 'test_app ' . DS . 'webroot/img/cake.power.gif ' ,
2416
2435
'error ' => UPLOAD_ERR_OK ,
2417
2436
'type ' => 'image/gif ' ,
2418
2437
'size ' => 201
2419
2438
);
2420
- $ this ->assertTrue (Validation ::uploadedFile ($ file ));
2439
+ $ this ->assertTrue (ValidationStub ::uploadedFile ($ file ));
2421
2440
$ file ['error ' ] = UPLOAD_ERR_NO_FILE ;
2422
- $ this ->assertFalse (Validation ::uploadedFile ($ file ), 'Error upload should fail. ' );
2441
+ $ this ->assertFalse (ValidationStub ::uploadedFile ($ file ), 'Error upload should fail. ' );
2423
2442
}
2424
2443
2425
2444
/**
@@ -2438,11 +2457,11 @@ public function testUploadedFileMimeType() {
2438
2457
$ options = array (
2439
2458
'types ' => array ('text/plain ' )
2440
2459
);
2441
- $ this ->assertFalse (Validation ::uploadedFile ($ file , $ options ), 'Incorrect mimetype. ' );
2460
+ $ this ->assertFalse (ValidationStub ::uploadedFile ($ file , $ options ), 'Incorrect mimetype. ' );
2442
2461
$ options = array (
2443
2462
'types ' => array ('image/gif ' , 'image/png ' )
2444
2463
);
2445
- $ this ->assertTrue (Validation ::uploadedFile ($ file , $ options ));
2464
+ $ this ->assertTrue (ValidationStub ::uploadedFile ($ file , $ options ));
2446
2465
}
2447
2466
2448
2467
/**
@@ -2461,24 +2480,24 @@ public function testUploadedFileSize() {
2461
2480
$ options = array (
2462
2481
'minSize ' => 500
2463
2482
);
2464
- $ this ->assertFalse (Validation ::uploadedFile ($ file , $ options ), 'Too small ' );
2483
+ $ this ->assertFalse (ValidationStub ::uploadedFile ($ file , $ options ), 'Too small ' );
2465
2484
$ options = array (
2466
2485
'maxSize ' => 100
2467
2486
);
2468
- $ this ->assertFalse (Validation ::uploadedFile ($ file , $ options ), 'Too big ' );
2487
+ $ this ->assertFalse (ValidationStub ::uploadedFile ($ file , $ options ), 'Too big ' );
2469
2488
$ options = array (
2470
2489
'minSize ' => 100 ,
2471
2490
);
2472
- $ this ->assertTrue (Validation ::uploadedFile ($ file , $ options ));
2491
+ $ this ->assertTrue (ValidationStub ::uploadedFile ($ file , $ options ));
2473
2492
$ options = array (
2474
2493
'maxSize ' => 500 ,
2475
2494
);
2476
- $ this ->assertTrue (Validation ::uploadedFile ($ file , $ options ));
2495
+ $ this ->assertTrue (ValidationStub ::uploadedFile ($ file , $ options ));
2477
2496
$ options = array (
2478
2497
'minSize ' => 100 ,
2479
2498
'maxSize ' => 500
2480
2499
);
2481
- $ this ->assertTrue (Validation ::uploadedFile ($ file , $ options ));
2500
+ $ this ->assertTrue (ValidationStub ::uploadedFile ($ file , $ options ));
2482
2501
}
2483
2502
2484
2503
/**
@@ -2519,6 +2538,6 @@ public function testUploadedFileWithDifferentFileParametersOrder() {
2519
2538
'size ' => 201
2520
2539
);
2521
2540
$ options = array ();
2522
- $ this ->assertTrue (Validation ::uploadedFile ($ file , $ options ), 'Wrong order ' );
2541
+ $ this ->assertTrue (ValidationStub ::uploadedFile ($ file , $ options ), 'Wrong order ' );
2523
2542
}
2524
2543
}
0 commit comments