Skip to content

Commit

Permalink
Fixing lots of tests that enforcing base_url broke.
Browse files Browse the repository at this point in the history
  • Loading branch information
lonnieezell committed Dec 19, 2017
1 parent fc8cdc8 commit 6996f76
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 38 deletions.
2 changes: 1 addition & 1 deletion system/HTTP/URI.php
Original file line number Diff line number Diff line change
Expand Up @@ -1056,7 +1056,7 @@ protected function mergePaths(URI $base, URI $reference)
{
if ( ! empty($base->getAuthority()) && empty($base->getPath()))
{
return '/' . ltrim($base->getPath(), '/ ');
return '/' . ltrim($reference->getPath(), '/ ');
}

$path = explode('/', $base->getPath());
Expand Down
2 changes: 1 addition & 1 deletion tests/_support/Config/MockAppConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

class MockAppConfig
{
public $baseURL = '';
public $baseURL = 'http://example.com';

public $uriProtocol = 'REQUEST_URI';

Expand Down
12 changes: 10 additions & 2 deletions tests/system/HTTP/IncomingRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,7 @@ public function testNegotiatesLocale()
$config = new App();
$config->negotiateLocale = true;
$config->supportedLocales = ['en', 'es'];
$config->baseURL = 'http://example.com';

$request = new IncomingRequest($config, new URI());

Expand All @@ -387,7 +388,10 @@ public function testCanGrabGetRawJSON()
'message' => 'ok'
];

$request = new IncomingRequest(new App(), new URI(), $json);
$config = new App();
$config->baseURL = 'http://example.com';

$request = new IncomingRequest($config, new URI(), $json);

$this->assertEquals($expected, $request->getJSON(true));
}
Expand All @@ -403,7 +407,11 @@ public function testCanGrabGetRawInput()
'role' => 'administrator',
'usepass' => 0
];
$request = new IncomingRequest(new App(), new URI(), $rawstring);

$config = new App();
$config->baseURL = 'http://example.com';

$request = new IncomingRequest($config, new URI(), $rawstring);

$this->assertEquals($expected, $request->getRawInput());
}
Expand Down
20 changes: 10 additions & 10 deletions tests/system/Helpers/HTMLHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ public function testDocType()
public function testVideo()
{
$expected = <<<EOH
<video src="test.mp4" controls>
<video src="http://example.com/test.mp4" controls>
Your browser does not support the video tag.
</video>
Expand Down Expand Up @@ -215,10 +215,10 @@ public function testVideo()

$expected = <<<EOH
<video class="test" controls>
<source src="movie.mp4" type="video/mp4" class="test" />
<source src="movie.ogg" type="video/ogg" />
<source src="movie.mov" type="video/quicktime" />
<source src="movie.ogv" type="video/ogv; codecs=dirac, speex" />
<source src="http://example.com/movie.mp4" type="video/mp4" class="test" />
<source src="http://example.com/movie.ogg" type="video/ogg" />
<source src="http://example.com/movie.mov" type="video/quicktime" />
<source src="http://example.com/movie.ogv" type="video/ogv; codecs=dirac, speex" />
<track src="subtitles_no.vtt" kind="subtitles" srclang="no" label="Norwegian No" />
<track src="subtitles_yes.vtt" kind="subtitles" srclang="yes" label="Norwegian Yes" />
Your browser does not support the video tag.
Expand Down Expand Up @@ -248,8 +248,8 @@ public function testAudio()
{
$expected = <<<EOH
<audio id="test" controls>
<source src="sound.ogg" type="audio/ogg" />
<source src="sound.mpeg" type="audio/mpeg" />
<source src="http://example.com/sound.ogg" type="audio/ogg" />
<source src="http://example.com/sound.mpeg" type="audio/mpeg" />
<track src="subtitles_no.vtt" kind="subtitles" srclang="no" label="Norwegian No" />
<track src="subtitles_yes.vtt" kind="subtitles" srclang="yes" label="Norwegian Yes" />
Your browser does not support the audio tag.
Expand All @@ -276,7 +276,7 @@ public function testAudio()
public function testEmbed()
{
$expected = <<<EOH
<embed src="movie.mov" type="video/quicktime" class="test" />
<embed src="http://example.com/movie.mov" type="video/quicktime" class="test" />
EOH;

Expand All @@ -287,7 +287,7 @@ public function testEmbed()
public function testObject()
{
$expected = <<<EOH
<object data="movie.swf" class="test"></object>
<object data="http://example.com/movie.swf" class="test"></object>
EOH;

Expand All @@ -301,7 +301,7 @@ public function testObject()
$this->assertEquals($expected, $object);

$expected = <<<EOH
<object data="movie.swf" class="test">
<object data="http://example.com/movie.swf" class="test">
<param name="foo" type="ref" value="bar" class="test" />
<param name="hello" type="ref" value="world" class="test" />
</object>
Expand Down
48 changes: 24 additions & 24 deletions tests/system/Helpers/URLHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function testSiteURLBasics()
$_SERVER['REQUEST_URI'] = '/';

$config = new App();
$config->baseURL = '';
$config->baseURL = 'http://example.com';
$config->indexPage = 'index.php';
$request = Services::request($config);
$request->uri = new URI('http://example.com/');
Expand All @@ -45,7 +45,7 @@ public function testSiteURLHTTPS()
$_SERVER['HTTPS'] = 'on';

$config = new App();
$config->baseURL = '';
$config->baseURL = 'http://example.com';
$config->indexPage = 'index.php';
$request = Services::request($config);
$request->uri = new URI('http://example.com/');
Expand All @@ -61,7 +61,7 @@ public function testSiteURLNoIndex()
$_SERVER['REQUEST_URI'] = '/';

$config = new App();
$config->baseURL = '';
$config->baseURL = 'http://example.com';
$config->indexPage = '';
$request = Services::request($config);
$request->uri = new URI('http://example.com/');
Expand All @@ -77,7 +77,7 @@ public function testSiteURLDifferentIndex()
$_SERVER['REQUEST_URI'] = '/';

$config = new App();
$config->baseURL = '';
$config->baseURL = 'http://example.com';
$config->indexPage = 'banana.php';
$request = Services::request($config);
$request->uri = new URI('http://example.com/');
Expand All @@ -93,7 +93,7 @@ public function testSiteURLNoIndexButPath()
$_SERVER['REQUEST_URI'] = '/';

$config = new App();
$config->baseURL = '';
$config->baseURL = 'http://example.com';
$config->indexPage = '';
$request = Services::request($config);
$request->uri = new URI('http://example.com/');
Expand All @@ -109,7 +109,7 @@ public function testSiteURLAttachesPath()
$_SERVER['REQUEST_URI'] = '/';

$config = new App();
$config->baseURL = '';
$config->baseURL = 'http://example.com';
$config->indexPage = 'index.php';
$request = Services::request($config);
$request->uri = new URI('http://example.com/');
Expand All @@ -125,7 +125,7 @@ public function testSiteURLAttachesScheme()
$_SERVER['REQUEST_URI'] = '/';

$config = new App();
$config->baseURL = '';
$config->baseURL = 'http://example.com';
$config->indexPage = 'index.php';
$request = Services::request($config);
$request->uri = new URI('http://example.com/');
Expand All @@ -141,7 +141,7 @@ public function testSiteURLExample()
$_SERVER['REQUEST_URI'] = '/';

$config = new App();
$config->baseURL = '';
$config->baseURL = 'http://example.com';
$config->indexPage = 'index.php';
$request = Services::request($config);
$request->uri = new URI('http://example.com/');
Expand All @@ -157,7 +157,7 @@ public function testSiteURLSegments()
$_SERVER['REQUEST_URI'] = '/';

$config = new App();
$config->baseURL = '';
$config->baseURL = 'http://example.com';
$config->indexPage = 'index.php';
$request = Services::request($config);
$request->uri = new URI('http://example.com/');
Expand Down Expand Up @@ -198,7 +198,7 @@ public function testSiteURLWithSegmentsAgain()

// Since we're on a CLI, we must provide our own URI
$config = new App();
$config->baseURL = '';
$config->baseURL = 'http://example.com';
$request = Services::request($config, false);
$request->uri = new URI('http://example.com/test/page');

Expand All @@ -218,7 +218,7 @@ public function testBaseURLBasics()
$_SERVER['HTTP_HOST'] = 'example.com';
$_SERVER['REQUEST_URI'] = '/';

$this->assertEquals('http://example.com/', base_url());
$this->assertEquals('http://example.com', base_url());
}

public function testBaseURLAttachesPath()
Expand Down Expand Up @@ -312,13 +312,13 @@ public function testBaseURLWithSegmentsAgain()

// Since we're on a CLI, we must provide our own URI
$config = new App();
$config->baseURL = '';
$config->baseURL = 'http://example.com';
$request = Services::request($config, false);
$request->uri = new URI('http://example.com/test/page');

Services::injectMock('request', $request);

$this->assertEquals('http://example.com/', base_url());
$this->assertEquals('http://example.com', base_url());
$this->assertEquals('http://example.com/profile', base_url('profile'));
}

Expand Down Expand Up @@ -433,7 +433,7 @@ public function testUriString()
$_SERVER['REQUEST_URI'] = '/';

$config = new App();
$config->baseURL = '';
$config->baseURL = 'http://example.com';
$config->indexPage = 'index.php';
$request = Services::request($config);
$request->uri = new URI('http://example.com/');
Expand All @@ -451,7 +451,7 @@ public function testUriStringExample()
$_SERVER['REQUEST_URI'] = '/assets/image.jpg';

$config = new App();
$config->baseURL = '';
$config->baseURL = 'http://example.com';
$config->indexPage = 'index.php';
$request = Services::request($config);
$request->uri = new URI('http://example.com/assets/image.jpg');
Expand All @@ -468,7 +468,7 @@ public function testUriStringExample()
public function testIndexPage()
{
$config = new App();
$config->baseURL = '';
$config->baseURL = 'http://example.com';
$config->indexPage = 'index.php';
$request = Services::request($config);
$request->uri = new URI('http://example.com/');
Expand All @@ -481,7 +481,7 @@ public function testIndexPage()
public function testIndexPageAlt()
{
$config = new App();
$config->baseURL = '';
$config->baseURL = 'http://example.com';
$config->indexPage = 'banana.php';
$request = Services::request($config);
$request->uri = new URI('http://example.com/');
Expand Down Expand Up @@ -516,7 +516,7 @@ public function testAnchor($expected = '', $uri = '', $title = '', $attributes =
$_SERVER['REQUEST_URI'] = '/';

$config = new App();
$config->baseURL = '';
$config->baseURL = 'http://example.com';
$config->indexPage = 'index.php';
$request = Services::request($config);
$request->uri = new URI('http://example.com/');
Expand Down Expand Up @@ -547,7 +547,7 @@ public function testAnchorNoindex($expected = '', $uri = '', $title = '', $attri
$_SERVER['REQUEST_URI'] = '/';

$config = new App();
$config->baseURL = '';
$config->baseURL = 'http://example.com';
$config->indexPage = '';
$request = Services::request($config);
$request->uri = new URI('http://example.com/');
Expand Down Expand Up @@ -577,7 +577,7 @@ public function testAnchorTargetted($expected = '', $uri = '', $title = '', $att
$_SERVER['REQUEST_URI'] = '/';

$config = new App();
$config->baseURL = '';
$config->baseURL = 'http://example.com';
$config->indexPage = '';
$request = Services::request($config);
$request->uri = new URI('http://example.com/');
Expand Down Expand Up @@ -605,7 +605,7 @@ public function testAnchorExamples($expected = '', $uri = '', $title = '', $attr
$_SERVER['REQUEST_URI'] = '/';

$config = new App();
$config->baseURL = '';
$config->baseURL = 'http://example.com';
$config->indexPage = 'index.php';
$request = Services::request($config);
$request->uri = new URI('http://example.com/');
Expand Down Expand Up @@ -651,7 +651,7 @@ public function testAnchorPopup($expected = '', $uri = '', $title = '', $attribu
$_SERVER['REQUEST_URI'] = '/';

$config = new App();
$config->baseURL = '';
$config->baseURL = 'http://example.com';
$config->indexPage = 'index.php';
$request = Services::request($config);
$request->uri = new URI('http://example.com/');
Expand Down Expand Up @@ -681,7 +681,7 @@ public function testMailto($expected = '', $email, $title = '', $attributes = ''
$_SERVER['REQUEST_URI'] = '/';

$config = new App();
$config->baseURL = '';
$config->baseURL = 'http://example.com';
$config->indexPage = 'index.php';
$request = Services::request($config);
$request->uri = new URI('http://example.com/');
Expand Down Expand Up @@ -715,7 +715,7 @@ public function testSafeMailto($expected = '', $email, $title = '', $attributes
$_SERVER['REQUEST_URI'] = '/';

$config = new App();
$config->baseURL = '';
$config->baseURL = 'http://example.com';
$config->indexPage = 'index.php';
$request = Services::request($config);
$request->uri = new URI('http://example.com/');
Expand Down

0 comments on commit 6996f76

Please sign in to comment.