subject = new EnvironmentVariable(self::VAR_NAME); } public function testConstructor() { $this->assertInstanceOf(EnvironmentVariable::class, $this->subject); $property = new \ReflectionProperty(EnvironmentVariable::class, 'name'); $property->setAccessible(true); $this->assertSame(self::VAR_NAME, $property->getValue($this->subject)); } public function testConstructorWithNonStringKeyThrowsException() { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('Environment variable name must be a string.'); new EnvironmentVariable([]); } public function testToPhpCode() { $this->assertSame('new ' . EnvironmentVariable::class . '(' . Utils::toPHPVariableString(self::VAR_NAME) . ')', $this->subject->__toPhpCode()); } public function testToString() { $_ENV[self::VAR_NAME] = 1012; $this->assertSame('1012', (string)$this->subject); } }