Skip to content

Commit

Permalink
adding getEnv unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
shimonewman committed May 12, 2024
1 parent 3eceef0 commit 7d5dd5f
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 1 deletion.
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;
}
}
15 changes: 15 additions & 0 deletions tests/unit/GetEnvTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace Utopia\Unit;

use PHPUnit\Framework\TestCase;
use Utopia\Tests\TestPlatform;

class GetEnvTest extends TestCase
{
public function testGetEnv()
{
$platform = new TestPlatform();
$this->assertEquals(3, $platform->getEnv('argc'));
}
}

0 comments on commit 7d5dd5f

Please sign in to comment.