-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from robbieaverill/feature/extension-in-get-se…
…rver-name Feature/extension in get server name
- Loading branch information
Showing
3 changed files
with
100 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# For more information about the properties used in | ||
# this file, please see the EditorConfig documentation: | ||
# http://editorconfig.org/ | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
indent_size = 4 | ||
indent_style = space | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false | ||
|
||
[*.yml] | ||
indent_size = 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,62 @@ | ||
<?php | ||
|
||
/** | ||
* @todo | ||
* Class CloudFlareTest | ||
* | ||
* @todo | ||
* @coversDefaultClass CloudFlare | ||
*/ | ||
class CloudFlareTest extends SapphireTest { | ||
|
||
class CloudFlareTest extends SapphireTest | ||
{ | ||
/** | ||
* Tests CloudFlare::inst()->getUrlVariants() | ||
* @covers ::getUrlVariants | ||
*/ | ||
public function testGetUrlVariants() { | ||
public function testGetUrlVariants() | ||
{ | ||
$urls = array( | ||
"http://www.example.com", | ||
'http://www.example.com', | ||
); | ||
|
||
$this->assertEquals( | ||
CloudFlare::inst()->getUrlVariants($urls), | ||
array( | ||
"http://www.example.com", | ||
"https://www.example.com", | ||
"http://www.example.com?stage=Stage", | ||
"https://www.example.com?stage=Stage" | ||
'http://www.example.com', | ||
'https://www.example.com', | ||
'http://www.example.com?stage=Stage', | ||
'https://www.example.com?stage=Stage' | ||
) | ||
); | ||
} | ||
|
||
|
||
} | ||
/** | ||
* Ensures that the server name can be retrieved as expected from environment variables or an extension attached | ||
* @covers ::getServerName | ||
*/ | ||
public function testGetServerName() | ||
{ | ||
// Ensures the CI environment can be factored in | ||
putenv('TRAVIS=1'); | ||
putenv('CLOUDFLARE_DUMMY_SITE=https://www.sometest.dev'); | ||
$this->assertSame('sometest.dev', CloudFlare::inst()->getServerName()); | ||
|
||
// Apply a test extension, get a new instance of the CF class and test again to ensure the hook works | ||
CloudFlare::add_extension('CloudFlareTest_Extension'); | ||
$this->assertSame('extended.dev', CloudFlare::create()->getServerName()); | ||
} | ||
} | ||
|
||
/** | ||
* A stub extension applied to CloudFlare as needed to test extension hooks | ||
*/ | ||
class CloudFlareTest_Extension extends Extension implements TestOnly | ||
{ | ||
/** | ||
* Set a dummy server name | ||
* | ||
* @see CloudFlare::getServerName | ||
* @var string $serverName | ||
*/ | ||
public function updateCloudFlareServerName(&$serverName) | ||
{ | ||
$serverName = 'extended.dev'; | ||
} | ||
} |