Skip to content

Commit 553ab0f

Browse files
authored
Merge pull request #6682 from kenjis/test-remove-request-uri
test: remove $request->uri and fix incorrect assertions
2 parents 14e9736 + 027e9e6 commit 553ab0f

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

tests/system/HTTP/URITest.php

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -863,56 +863,56 @@ public function testSetBadSegmentSilent()
863863

864864
public function testBasedNoIndex()
865865
{
866-
$this->resetServices();
867-
868866
$_SERVER['HTTP_HOST'] = 'example.com';
869867
$_SERVER['REQUEST_URI'] = '/ci/v4/controller/method';
870868

869+
$this->resetServices();
870+
871871
$config = new App();
872-
$config->baseURL = 'http://example.com/ci/v4';
873-
$config->indexPage = 'index.php';
874-
$request = Services::request($config);
875-
$request->uri = new URI('http://example.com/ci/v4/controller/method');
872+
$config->baseURL = 'http://example.com/ci/v4/';
873+
$config->indexPage = '';
874+
Factories::injectMock('config', 'App', $config);
876875

876+
$request = Services::request($config);
877877
Services::injectMock('request', $request);
878878

879879
// going through request
880880
$this->assertSame('http://example.com/ci/v4/controller/method', (string) $request->getUri());
881-
$this->assertSame('/ci/v4/controller/method', $request->getUri()->getPath());
881+
$this->assertSame('ci/v4/controller/method', $request->getUri()->getPath());
882882

883883
// standalone
884884
$uri = new URI('http://example.com/ci/v4/controller/method');
885885
$this->assertSame('http://example.com/ci/v4/controller/method', (string) $uri);
886886
$this->assertSame('/ci/v4/controller/method', $uri->getPath());
887887

888-
$this->assertSame($uri->getPath(), $request->getUri()->getPath());
888+
$this->assertSame($uri->getPath(), '/' . $request->getUri()->getPath());
889889
}
890890

891891
public function testBasedWithIndex()
892892
{
893-
$this->resetServices();
894-
895893
$_SERVER['HTTP_HOST'] = 'example.com';
896894
$_SERVER['REQUEST_URI'] = '/ci/v4/index.php/controller/method';
897895

896+
$this->resetServices();
897+
898898
$config = new App();
899-
$config->baseURL = 'http://example.com/ci/v4';
899+
$config->baseURL = 'http://example.com/ci/v4/';
900900
$config->indexPage = 'index.php';
901-
$request = Services::request($config);
902-
$request->uri = new URI('http://example.com/ci/v4/index.php/controller/method');
901+
Factories::injectMock('config', 'App', $config);
903902

903+
$request = Services::request($config);
904904
Services::injectMock('request', $request);
905905

906906
// going through request
907907
$this->assertSame('http://example.com/ci/v4/index.php/controller/method', (string) $request->getUri());
908-
$this->assertSame('/ci/v4/index.php/controller/method', $request->getUri()->getPath());
908+
$this->assertSame('ci/v4/index.php/controller/method', $request->getUri()->getPath());
909909

910910
// standalone
911911
$uri = new URI('http://example.com/ci/v4/index.php/controller/method');
912912
$this->assertSame('http://example.com/ci/v4/index.php/controller/method', (string) $uri);
913913
$this->assertSame('/ci/v4/index.php/controller/method', $uri->getPath());
914914

915-
$this->assertSame($uri->getPath(), $request->getUri()->getPath());
915+
$this->assertSame($uri->getPath(), '/' . $request->getUri()->getPath());
916916
}
917917

918918
public function testForceGlobalSecureRequests()

tests/system/Pager/PagerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -467,9 +467,9 @@ public function testBasedURI()
467467
$config = new App();
468468
$config->baseURL = 'http://example.com/ci/v4/';
469469
$config->indexPage = 'fc.php';
470-
$request = Services::request($config);
471-
$request->uri = new URI('http://example.com/ci/v4/x/y');
470+
Factories::injectMock('config', 'App', $config);
472471

472+
$request = Services::request($config);
473473
Services::injectMock('request', $request);
474474

475475
$this->config = new PagerConfig();

0 commit comments

Comments
 (0)