Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add get server #23

Closed
wants to merge 11 commits into from
Closed
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
},
"autoload-dev": {
"psr-4": {
"Utopia\\Tests\\": "tests/Platform"
"Utopia\\Tests\\": "tests/Platform",
"Utopia\\Unit\\": "tests/unit"
}
},
"require": {
Expand Down
3 changes: 3 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
stopOnFailure="false"
>
<testsuites>
<testsuite name="unit">
<directory>./tests/unit</directory>
</testsuite>
<testsuite name="Application Test Suite">
<file>./tests/e2e/Client.php</file>
<directory>./tests/</directory>
Expand Down
14 changes: 14 additions & 0 deletions src/Platform/Platform.php
Original file line number Diff line number Diff line change
Expand Up @@ -319,4 +319,18 @@ public function setWorker(Server $worker): self

return $this;
}

/**
* Get env
*
* Method for querying env parameters. If $key is not found $default value will be returned.
*
* @param string $key
* @param string|null $default
* @return mixed
*/
public function getEnv(string $key, string $default = null): mixed
{
return $_SERVER[$key] ?? $default;
}
}
14 changes: 14 additions & 0 deletions tests/unit/GetEnvTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

namespace Utopia\Unit;

use PHPUnit\Framework\TestCase;

class GetEnvTest extends TestCase
{
public function testGetEnv()
{
$platform = new Mock();
$this->assertEquals(3, $platform->getEnv('argc'));
}
}
15 changes: 15 additions & 0 deletions tests/unit/Mock.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace Utopia\Unit;

use Utopia\Platform\Platform;
use Utopia\Tests\TestModule;

class Mock extends Platform
{
public function __construct()
{
$module = new TestModule();
parent::__construct($module);
}
}
Loading