15
15
use CodeIgniter \Config \Services ;
16
16
use CodeIgniter \controller ;
17
17
use CodeIgniter \Exceptions \PageNotFoundException ;
18
+ use CodeIgniter \HTTP \Method ;
18
19
use CodeIgniter \Test \CIUnitTestCase ;
19
20
use Config \Modules ;
20
21
use Config \Routing ;
@@ -144,7 +145,7 @@ public function testAddIgnoresDefaultNamespaceWhenExists(): void
144
145
145
146
public function testAddWorksWithCurrentHTTPMethods (): void
146
147
{
147
- Services::request ()->setMethod (' GET ' );
148
+ Services::request ()->setMethod (Method:: GET );
148
149
149
150
$ routes = $ this ->getCollector ();
150
151
@@ -176,7 +177,7 @@ public function testAddWithLeadingSlash(): void
176
177
177
178
public function testMatchIgnoresInvalidHTTPMethods (): void
178
179
{
179
- Services::request ()->setMethod (' GET ' );
180
+ Services::request ()->setMethod (Method:: GET );
180
181
181
182
$ routes = $ this ->getCollector ();
182
183
@@ -189,7 +190,7 @@ public function testMatchIgnoresInvalidHTTPMethods(): void
189
190
190
191
public function testAddWorksWithArrayOFHTTPMethods (): void
191
192
{
192
- Services::request ()->setMethod (' POST ' );
193
+ Services::request ()->setMethod (Method:: POST );
193
194
194
195
$ routes = $ this ->getCollector ();
195
196
@@ -696,7 +697,7 @@ public function testPresenterScaffoldsCorrectly(): void
696
697
697
698
public function testResourcesWithCustomController (): void
698
699
{
699
- Services::request ()->setMethod (' GET ' );
700
+ Services::request ()->setMethod (Method:: GET );
700
701
$ routes = $ this ->getCollector ();
701
702
702
703
$ routes ->resource ('photos ' , ['controller ' => '<script>gallery ' ]);
@@ -713,7 +714,7 @@ public function testResourcesWithCustomController(): void
713
714
714
715
public function testResourcesWithCustomPlaceholder (): void
715
716
{
716
- Services::request ()->setMethod (' GET ' );
717
+ Services::request ()->setMethod (Method:: GET );
717
718
$ routes = $ this ->getCollector ();
718
719
719
720
$ routes ->resource ('photos ' , ['placeholder ' => ':num ' ]);
@@ -730,7 +731,7 @@ public function testResourcesWithCustomPlaceholder(): void
730
731
731
732
public function testResourcesWithDefaultPlaceholder (): void
732
733
{
733
- Services::request ()->setMethod (' GET ' );
734
+ Services::request ()->setMethod (Method:: GET );
734
735
$ routes = $ this ->getCollector ();
735
736
736
737
$ routes ->setDefaultConstraint ('num ' );
@@ -748,7 +749,7 @@ public function testResourcesWithDefaultPlaceholder(): void
748
749
749
750
public function testResourcesWithBogusDefaultPlaceholder (): void
750
751
{
751
- Services::request ()->setMethod (' GET ' );
752
+ Services::request ()->setMethod (Method:: GET );
752
753
$ routes = $ this ->getCollector ();
753
754
754
755
$ routes ->setDefaultConstraint (':num ' );
@@ -766,7 +767,7 @@ public function testResourcesWithBogusDefaultPlaceholder(): void
766
767
767
768
public function testResourcesWithOnly (): void
768
769
{
769
- Services::request ()->setMethod (' GET ' );
770
+ Services::request ()->setMethod (Method:: GET );
770
771
$ routes = $ this ->getCollector ();
771
772
772
773
$ routes ->resource ('photos ' , ['only ' => 'index ' ]);
@@ -780,7 +781,7 @@ public function testResourcesWithOnly(): void
780
781
781
782
public function testResourcesWithExcept (): void
782
783
{
783
- Services::request ()->setMethod (' GET ' );
784
+ Services::request ()->setMethod (Method:: GET );
784
785
$ routes = $ this ->getCollector ();
785
786
786
787
$ routes ->resource ('photos ' , ['except ' => 'edit,new ' ]);
@@ -811,23 +812,23 @@ public function testResourcesWithWebsafe(): void
811
812
812
813
public function testMatchSupportsMultipleMethods (): void
813
814
{
814
- Services::request ()->setMethod (' GET ' );
815
+ Services::request ()->setMethod (Method:: GET );
815
816
$ routes = $ this ->getCollector ();
816
817
817
818
$ expected = ['here ' => '\there ' ];
818
819
819
820
$ routes ->match (['GET ' , 'POST ' ], 'here ' , 'there ' );
820
821
$ this ->assertSame ($ expected , $ routes ->getRoutes ());
821
822
822
- Services::request ()->setMethod (' POST ' );
823
+ Services::request ()->setMethod (Method:: POST );
823
824
$ routes = $ this ->getCollector ();
824
825
$ routes ->match (['GET ' , 'POST ' ], 'here ' , 'there ' );
825
826
$ this ->assertSame ($ expected , $ routes ->getRoutes ());
826
827
}
827
828
828
829
public function testGet (): void
829
830
{
830
- Services::request ()->setMethod (' GET ' );
831
+ Services::request ()->setMethod (Method:: GET );
831
832
$ routes = $ this ->getCollector ();
832
833
833
834
$ expected = ['here ' => '\there ' ];
@@ -949,7 +950,7 @@ public function testEnvironmentRestricts(): void
949
950
{
950
951
// ENVIRONMENT should be 'testing'
951
952
952
- Services::request ()->setMethod (' GET ' );
953
+ Services::request ()->setMethod (Method:: GET );
953
954
$ routes = $ this ->getCollector ();
954
955
955
956
$ expected = ['here ' => '\there ' ];
@@ -1434,7 +1435,7 @@ static function (): void {},
1434
1435
1435
1436
public function testRouteGroupWithFilterSimple (): void
1436
1437
{
1437
- Services::request ()->setMethod (' GET ' );
1438
+ Services::request ()->setMethod (Method:: GET );
1438
1439
$ routes = $ this ->getCollector ();
1439
1440
1440
1441
$ routes ->group (
@@ -1453,7 +1454,7 @@ static function ($routes): void {
1453
1454
1454
1455
public function testRouteGroupWithFilterWithParams (): void
1455
1456
{
1456
- Services::request ()->setMethod (' GET ' );
1457
+ Services::request ()->setMethod (Method:: GET );
1457
1458
$ routes = $ this ->getCollector ();
1458
1459
1459
1460
$ routes ->group (
@@ -1471,15 +1472,15 @@ static function ($routes): void {
1471
1472
1472
1473
public function test404OverrideNot (): void
1473
1474
{
1474
- Services::request ()->setMethod (' GET ' );
1475
+ Services::request ()->setMethod (Method:: GET );
1475
1476
$ routes = $ this ->getCollector ();
1476
1477
1477
1478
$ this ->assertNull ($ routes ->get404Override ());
1478
1479
}
1479
1480
1480
1481
public function test404OverrideString (): void
1481
1482
{
1482
- Services::request ()->setMethod (' GET ' );
1483
+ Services::request ()->setMethod (Method:: GET );
1483
1484
$ routes = $ this ->getCollector ();
1484
1485
1485
1486
$ routes ->set404Override ('Explode ' );
@@ -1488,7 +1489,7 @@ public function test404OverrideString(): void
1488
1489
1489
1490
public function test404OverrideCallable (): void
1490
1491
{
1491
- Services::request ()->setMethod (' GET ' );
1492
+ Services::request ()->setMethod (Method:: GET );
1492
1493
$ routes = $ this ->getCollector ();
1493
1494
1494
1495
$ routes ->set404Override (static function (): void {
@@ -1499,7 +1500,7 @@ public function test404OverrideCallable(): void
1499
1500
1500
1501
public function testOffsetParameters (): void
1501
1502
{
1502
- Services::request ()->setMethod (' GET ' );
1503
+ Services::request ()->setMethod (Method:: GET );
1503
1504
$ routes = $ this ->getCollector ();
1504
1505
1505
1506
$ routes ->get ('users/(:num) ' , 'users/show/$1 ' , ['offset ' => 1 ]);
@@ -1515,7 +1516,7 @@ public function testOffsetParameters(): void
1515
1516
public function testRouteToWithSubdomainMatch (): void
1516
1517
{
1517
1518
$ _SERVER ['HTTP_HOST ' ] = 'doc.example.com ' ;
1518
- Services::request ()->setMethod (' GET ' );
1519
+ Services::request ()->setMethod (Method:: GET );
1519
1520
1520
1521
$ routes = $ this ->getCollector ();
1521
1522
@@ -1527,7 +1528,7 @@ public function testRouteToWithSubdomainMatch(): void
1527
1528
public function testRouteToWithSubdomainMismatch (): void
1528
1529
{
1529
1530
$ _SERVER ['HTTP_HOST ' ] = 'dev.example.com ' ;
1530
- Services::request ()->setMethod (' GET ' );
1531
+ Services::request ()->setMethod (Method:: GET );
1531
1532
1532
1533
$ routes = $ this ->getCollector ();
1533
1534
@@ -1539,7 +1540,7 @@ public function testRouteToWithSubdomainMismatch(): void
1539
1540
public function testRouteToWithSubdomainNot (): void
1540
1541
{
1541
1542
$ _SERVER ['HTTP_HOST ' ] = 'example.com ' ;
1542
- Services::request ()->setMethod (' GET ' );
1543
+ Services::request ()->setMethod (Method:: GET );
1543
1544
1544
1545
$ routes = $ this ->getCollector ();
1545
1546
@@ -1551,7 +1552,7 @@ public function testRouteToWithSubdomainNot(): void
1551
1552
public function testRouteToWithGenericSubdomainMatch (): void
1552
1553
{
1553
1554
$ _SERVER ['HTTP_HOST ' ] = 'doc.example.com ' ;
1554
- Services::request ()->setMethod (' GET ' );
1555
+ Services::request ()->setMethod (Method:: GET );
1555
1556
1556
1557
$ routes = $ this ->getCollector ();
1557
1558
@@ -1563,7 +1564,7 @@ public function testRouteToWithGenericSubdomainMatch(): void
1563
1564
public function testRouteToWithGenericSubdomainMismatch (): void
1564
1565
{
1565
1566
$ _SERVER ['HTTP_HOST ' ] = 'dev.example.com ' ;
1566
- Services::request ()->setMethod (' GET ' );
1567
+ Services::request ()->setMethod (Method:: GET );
1567
1568
1568
1569
$ routes = $ this ->getCollector ();
1569
1570
@@ -1575,7 +1576,7 @@ public function testRouteToWithGenericSubdomainMismatch(): void
1575
1576
public function testRouteToWithGenericSubdomainNot (): void
1576
1577
{
1577
1578
$ _SERVER ['HTTP_HOST ' ] = 'example.com ' ;
1578
- Services::request ()->setMethod (' GET ' );
1579
+ Services::request ()->setMethod (Method:: GET );
1579
1580
1580
1581
$ routes = $ this ->getCollector ();
1581
1582
@@ -1587,7 +1588,7 @@ public function testRouteToWithGenericSubdomainNot(): void
1587
1588
public function testRouteToWithoutSubdomainMatch (): void
1588
1589
{
1589
1590
$ _SERVER ['HTTP_HOST ' ] = 'doc.example.com ' ;
1590
- Services::request ()->setMethod (' GET ' );
1591
+ Services::request ()->setMethod (Method:: GET );
1591
1592
1592
1593
$ routes = $ this ->getCollector ();
1593
1594
@@ -1599,7 +1600,7 @@ public function testRouteToWithoutSubdomainMatch(): void
1599
1600
public function testRouteToWithoutSubdomainMismatch (): void
1600
1601
{
1601
1602
$ _SERVER ['HTTP_HOST ' ] = 'dev.example.com ' ;
1602
- Services::request ()->setMethod (' GET ' );
1603
+ Services::request ()->setMethod (Method:: GET );
1603
1604
1604
1605
$ routes = $ this ->getCollector ();
1605
1606
@@ -1611,7 +1612,7 @@ public function testRouteToWithoutSubdomainMismatch(): void
1611
1612
public function testRouteToWithoutSubdomainNot (): void
1612
1613
{
1613
1614
$ _SERVER ['HTTP_HOST ' ] = 'example.com ' ;
1614
- Services::request ()->setMethod (' GET ' );
1615
+ Services::request ()->setMethod (Method:: GET );
1615
1616
1616
1617
$ routes = $ this ->getCollector ();
1617
1618
@@ -1628,7 +1629,7 @@ public function testRouteToWithoutSubdomainNot(): void
1628
1629
public function testRouteOverwritingDifferentSubdomains (): void
1629
1630
{
1630
1631
$ _SERVER ['HTTP_HOST ' ] = 'doc.domain.com ' ;
1631
- Services::request ()->setMethod (' GET ' );
1632
+ Services::request ()->setMethod (Method:: GET );
1632
1633
1633
1634
$ routes = $ this ->getCollector ();
1634
1635
$ router = new Router ($ routes , Services::request ());
@@ -1649,7 +1650,7 @@ public function testRouteOverwritingDifferentSubdomains(): void
1649
1650
public function testRouteOverwritingTwoRules (): void
1650
1651
{
1651
1652
$ _SERVER ['HTTP_HOST ' ] = 'doc.domain.com ' ;
1652
- Services::request ()->setMethod (' GET ' );
1653
+ Services::request ()->setMethod (Method:: GET );
1653
1654
1654
1655
$ routes = $ this ->getCollector ();
1655
1656
$ router = new Router ($ routes , Services::request ());
@@ -1670,7 +1671,7 @@ public function testRouteOverwritingTwoRules(): void
1670
1671
public function testRouteOverwritingTwoRulesLastApplies (): void
1671
1672
{
1672
1673
$ _SERVER ['HTTP_HOST ' ] = 'doc.domain.com ' ;
1673
- Services::request ()->setMethod (' GET ' );
1674
+ Services::request ()->setMethod (Method:: GET );
1674
1675
1675
1676
$ routes = $ this ->getCollector ();
1676
1677
$ router = new Router ($ routes , Services::request ());
@@ -1690,7 +1691,7 @@ public function testRouteOverwritingTwoRulesLastApplies(): void
1690
1691
public function testRouteOverwritingMatchingSubdomain (): void
1691
1692
{
1692
1693
$ _SERVER ['HTTP_HOST ' ] = 'doc.domain.com ' ;
1693
- Services::request ()->setMethod (' GET ' );
1694
+ Services::request ()->setMethod (Method:: GET );
1694
1695
1695
1696
$ routes = $ this ->getCollector ();
1696
1697
$ router = new Router ($ routes , Services::request ());
@@ -1710,7 +1711,7 @@ public function testRouteOverwritingMatchingSubdomain(): void
1710
1711
public function testRouteOverwritingMatchingHost (): void
1711
1712
{
1712
1713
$ _SERVER ['HTTP_HOST ' ] = 'doc.domain.com ' ;
1713
- Services::request ()->setMethod (' GET ' );
1714
+ Services::request ()->setMethod (Method:: GET );
1714
1715
1715
1716
$ routes = $ this ->getCollector ();
1716
1717
$ router = new Router ($ routes , Services::request ());
@@ -1734,7 +1735,7 @@ public function testRouteOverwritingMatchingHost(): void
1734
1735
*/
1735
1736
public function testRouteDefaultNameSpace (): void
1736
1737
{
1737
- Services::request ()->setMethod (' GET ' );
1738
+ Services::request ()->setMethod (Method:: GET );
1738
1739
$ routes = $ this ->getCollector ();
1739
1740
$ router = new Router ($ routes , Services::request ());
1740
1741
@@ -1748,7 +1749,7 @@ public function testRouteDefaultNameSpace(): void
1748
1749
1749
1750
public function testZeroAsURIPath (): void
1750
1751
{
1751
- Services::request ()->setMethod (' GET ' );
1752
+ Services::request ()->setMethod (Method:: GET );
1752
1753
$ routes = $ this ->getCollector ();
1753
1754
$ router = new Router ($ routes , Services::request ());
1754
1755
@@ -1796,7 +1797,7 @@ public function testAutoRoutesControllerNameReturnsFQCN($namespace): void
1796
1797
*/
1797
1798
public function testRoutesControllerNameReturnsFQCN ($ namespace ): void
1798
1799
{
1799
- Services::request ()->setMethod (' GET ' );
1800
+ Services::request ()->setMethod (Method:: GET );
1800
1801
$ routes = $ this ->getCollector ();
1801
1802
$ routes ->setAutoRoute (false );
1802
1803
$ routes ->setDefaultNamespace ($ namespace );
0 commit comments