appwrite/tests/unit/Docker/EnvTest.php

44 lines
1.1 KiB
PHP
Raw Normal View History

2020-07-29 15:26:01 +00:00
<?php
2022-08-01 10:22:04 +00:00
namespace Tests\Unit\Docker;
2020-07-29 15:26:01 +00:00
use Appwrite\Docker\Env;
use Exception;
use PHPUnit\Framework\TestCase;
class EnvTest extends TestCase
{
2022-08-01 10:22:04 +00:00
protected ?Env $object = null;
2020-07-29 15:26:01 +00:00
2020-09-30 21:52:02 +00:00
public function setUp(): void
2020-07-29 15:26:01 +00:00
{
2022-05-23 14:54:50 +00:00
$data = @file_get_contents(__DIR__ . '/../../resources/docker/.env');
2020-07-29 15:26:01 +00:00
2020-10-27 19:48:38 +00:00
if ($data === false) {
2020-07-29 15:26:01 +00:00
throw new Exception('Failed to read compose file');
}
$this->object = new Env($data);
}
2022-08-01 10:22:04 +00:00
public function testVars(): void
2020-07-29 15:26:01 +00:00
{
$this->object->setVar('_APP_TEST', 'value4');
$this->assertEquals('value1', $this->object->getVar('_APP_X'));
$this->assertEquals('value2', $this->object->getVar('_APP_Y'));
$this->assertEquals('value3', $this->object->getVar('_APP_Z'));
$this->assertEquals('value5=', $this->object->getVar('_APP_W'));
2020-07-29 15:26:01 +00:00
$this->assertEquals('value4', $this->object->getVar('_APP_TEST'));
}
2022-08-01 10:22:04 +00:00
public function testExport(): void
2020-07-29 15:26:01 +00:00
{
$this->assertEquals("_APP_X=value1
_APP_Y=value2
_APP_Z=value3
2022-12-27 08:09:47 +00:00
_APP_W=value5=
2020-07-29 15:26:01 +00:00
", $this->object->export());
}
2020-09-30 21:52:02 +00:00
}