Skip to content

Commit 54ebb52

Browse files
committed
test: add test for missing argument
1 parent e62b539 commit 54ebb52

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

tests/system/Helpers/URLHelper/MiscUrlTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use CodeIgniter\Router\Exceptions\RouterException;
1818
use CodeIgniter\Test\CIUnitTestCase;
1919
use Config\App;
20+
use InvalidArgumentException;
2021

2122
/**
2223
* @backupGlobals enabled
@@ -900,4 +901,20 @@ public function testUrlToWithSupportedLocaleInRoute()
900901
url_to('path-to', 'string', 13, 'en')
901902
);
902903
}
904+
905+
/**
906+
* @see https://github.com/codeigniter4/CodeIgniter4/issues/7651
907+
*/
908+
public function testUrlToMissingArgument()
909+
{
910+
$this->expectException(InvalidArgumentException::class);
911+
$this->expectExceptionMessage('Missing argument for "([a-zA-Z]+)" in route "([a-zA-Z]+)/login".');
912+
913+
$routes = Services::routes();
914+
$routes->group('(:alpha)', static function ($routes) {
915+
$routes->match(['get'], 'login', 'Common\LoginController::loginView', ['as' => 'loginURL']);
916+
});
917+
918+
url_to('loginURL');
919+
}
903920
}

0 commit comments

Comments
 (0)