Skip to content

Commit

Permalink
Merge pull request #6442 from kenjis/fix-CLIRequest-getLocale-error
Browse files Browse the repository at this point in the history
fix: Call to undefined method CodeIgniter\HTTP\CLIRequest::getLocale()
  • Loading branch information
MGatner authored Aug 29, 2022
2 parents 6a31be4 + 6aafff0 commit 31aab61
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
10 changes: 10 additions & 0 deletions system/HTTP/CLIRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace CodeIgniter\HTTP;

use Config\App;
use Locale;
use RuntimeException;

/**
Expand Down Expand Up @@ -280,4 +281,13 @@ private function returnNullOrEmptyArray($index)
{
return ($index === null || is_array($index)) ? [] : null;
}

/**
* Gets the current locale, with a fallback to the default
* locale if none is set.
*/
public function getLocale(): string
{
return Locale::getDefault();
}
}
11 changes: 8 additions & 3 deletions tests/system/HTTP/CLIRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -599,16 +599,21 @@ public function testGetGet()

public function testGetPost()
{
$this->assertSame([], $this->request->getGet());
$this->assertSame([], $this->request->getPost());
}

public function testGetPostGet()
{
$this->assertSame([], $this->request->getGet());
$this->assertSame([], $this->request->getPostGet());
}

public function testGetGetPost()
{
$this->assertSame([], $this->request->getGet());
$this->assertSame([], $this->request->getGetPost());
}

public function testGetLocale()
{
$this->assertSame('en', $this->request->getLocale());
}
}

0 comments on commit 31aab61

Please sign in to comment.