Code Duplication    Length = 39-40 lines in 3 locations

tests/phpunit/tests/media.php 3 locations

@@ 1357-1396 (lines=40) @@
1354
     * @ticket 34955
1355
     * @ticket 33641
1356
     */
1357
    function test_wp_calculate_image_srcset_ratio_variance() 
1358
    {
1359
        // Mock data for this test.
1360
        $size_array = array( 218, 300 );
1361
        $image_src = 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/2015/12/test-768x1055-218x300.png';
1362
        $image_meta = array(
1363
         'width' => 768,
1364
         'height' => 1055,
1365
         'file' => '2015/12/test-768x1055.png',
1366
         'sizes' => array(
1367
          'thumbnail' => array(
1368
        'file' => 'test-768x1055-150x150.png',
1369
        'width' => 150,
1370
        'height' => 150,
1371
        'mime-type' => 'image/png',
1372
          ),
1373
          'medium' => array(
1374
           'file' => 'test-768x1055-218x300.png',
1375
           'width' => 218,
1376
           'height' => 300,
1377
           'mime-type' => 'image/png',
1378
          ),
1379
          'custom-600' => array(
1380
           'file' => 'test-768x1055-600x824.png',
1381
           'width' => 600,
1382
           'height' => 824,
1383
           'mime-type' => 'image/png',
1384
          ),
1385
          'post-thumbnail' => array(
1386
           'file' => 'test-768x1055-768x510.png',
1387
           'width' => 768,
1388
           'height' => 510,
1389
           'mime-type' => 'image/png',
1390
          ),
1391
         ),
1392
        );
1393
1394
        $expected_srcset = 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/2015/12/test-768x1055-218x300.png 218w, http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/2015/12/test-768x1055-600x824.png 600w, http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/2015/12/test-768x1055.png 768w';
1395
1396
        $this->assertSame($expected_srcset, wp_calculate_image_srcset($size_array, $image_src, $image_meta));
1397
    }
1398
1399
    /**
@@ 1403-1442 (lines=40) @@
1400
     * @ticket 35108
1401
     * @ticket 33641
1402
     */
1403
    function test_wp_calculate_image_srcset_include_src() 
1404
    {
1405
        // Mock data for this test.
1406
        $size_array = array( 2000, 1000 );
1407
        $image_src = 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/2015/12/test.png';
1408
        $image_meta = array(
1409
         'width' => 2000,
1410
         'height' => 1000,
1411
         'file' => '2015/12/test.png',
1412
         'sizes' => array(
1413
          'thumbnail' => array(
1414
        'file' => 'test-150x150.png',
1415
        'width' => 150,
1416
        'height' => 150,
1417
        'mime-type' => 'image/png',
1418
          ),
1419
          'medium' => array(
1420
           'file' => 'test-300x150.png',
1421
           'width' => 300,
1422
           'height' => 150,
1423
           'mime-type' => 'image/png',
1424
          ),
1425
          'medium_large' => array(
1426
           'file' => 'test-768x384.png',
1427
           'width' => 768,
1428
           'height' => 384,
1429
           'mime-type' => 'image/png',
1430
          ),
1431
          'large' => array(
1432
           'file' => 'test-1024x512.png',
1433
           'width' => 1024,
1434
           'height' => 512,
1435
           'mime-type' => 'image/png',
1436
          ),
1437
         ),
1438
        );
1439
1440
        $expected_srcset = 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/2015/12/test.png 2000w, http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/2015/12/test-300x150.png 300w, http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/2015/12/test-768x384.png 768w, http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/2015/12/test-1024x512.png 1024w';
1441
1442
        $this->assertSame($expected_srcset, wp_calculate_image_srcset($size_array, $image_src, $image_meta));
1443
    }
1444
1445
    /**
@@ 1523-1561 (lines=39) @@
1520
     * @ticket 36549
1521
     * @ticket 33641
1522
     */
1523
    function test_wp_calculate_image_srcset_with_spaces_in_filenames() 
1524
    {
1525
        // Mock data for this test.
1526
        $image_src = 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/2015/12/test image-300x150.png';
1527
        $image_meta = array(
1528
         'width' => 2000,
1529
         'height' => 1000,
1530
         'file' => '2015/12/test image.png',
1531
         'sizes' => array(
1532
          'thumbnail' => array(
1533
        'file' => 'test image-150x150.png',
1534
        'width' => 150,
1535
        'height' => 150,
1536
        'mime-type' => 'image/png',
1537
          ),
1538
          'medium' => array(
1539
           'file' => 'test image-300x150.png',
1540
           'width' => 300,
1541
           'height' => 150,
1542
           'mime-type' => 'image/png',
1543
          ),
1544
          'medium_large' => array(
1545
           'file' => 'test image-768x384.png',
1546
           'width' => 768,
1547
           'height' => 384,
1548
           'mime-type' => 'image/png',
1549
          ),
1550
          'large' => array(
1551
           'file' => 'test image-1024x512.png',
1552
           'width' => 1024,
1553
           'height' => 512,
1554
           'mime-type' => 'image/png',
1555
          ),
1556
         ),
1557
        );
1558
1559
        $expected_srcset = 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/2015/12/test%20image-300x150.png 300w, http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/2015/12/test%20image-768x384.png 768w, http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/2015/12/test%20image-1024x512.png 1024w';
1560
1561
        $this->assertSame($expected_srcset, wp_calculate_image_srcset(array( 300, 150 ), $image_src, $image_meta));
1562
    }
1563
1564
    /**