setParameter('env(foo)', $value); $container->compile(); $processor = new EnvVarProcessor($container); $result = $processor->getEnv('string', 'foo', function () { $this->fail('Should not be called'); }); $this->assertSame($processed, $result); } public function validStrings() { return array( array('hello', 'hello'), array('true', 'true'), array('false', 'false'), array('null', 'null'), array('1', '1'), array('0', '0'), array('1.1', '1.1'), array('1e1', '1e1'), ); } /** * @dataProvider validBools */ public function testGetEnvBool($value, $processed) { $processor = new EnvVarProcessor(new Container()); $result = $processor->getEnv('bool', 'foo', function ($name) use ($value) { $this->assertSame('foo', $name); return $value; }); $this->assertSame($processed, $result); } public function validBools() { return array( array('true', true), array('false', false), array('null', false), array('1', true), array('0', false), array('1.1', true), array('1e1', true), ); } /** * @dataProvider validInts */ public function testGetEnvInt($value, $processed) { $processor = new EnvVarProcessor(new Container()); $result = $processor->getEnv('int', 'foo', function ($name) use ($value) { $this->assertSame('foo', $name); return $value; }); $this->assertSame($processed, $result); } public function validInts() { return array( array('1', 1), array('1.1', 1), array('1e1', 10), ); } /** * @expectedException \Symfony\Component\DependencyInjection\Exception\RuntimeException * @expectedExceptionMessage Non-numeric env var * @dataProvider invalidInts */ public function testGetEnvIntInvalid($value) { $processor = new EnvVarProcessor(new Container()); $processor->getEnv('int', 'foo', function ($name) use ($value) { $this->assertSame('foo', $name); return $value; }); } public function invalidInts() { return array( array('foo'), array('true'), array('null'), ); } /** * @dataProvider validFloats */ public function testGetEnvFloat($value, $processed) { $processor = new EnvVarProcessor(new Container()); $result = $processor->getEnv('float', 'foo', function ($name) use ($value) { $this->assertSame('foo', $name); return $value; }); $this->assertSame($processed, $result); } public function validFloats() { return array( array('1', 1.0), array('1.1', 1.1), array('1e1', 10.0), ); } /** * @expectedException \Symfony\Component\DependencyInjection\Exception\RuntimeException * @expectedExceptionMessage Non-numeric env var * @dataProvider invalidFloats */ public function testGetEnvFloatInvalid($value) { $processor = new EnvVarProcessor(new Container()); $processor->getEnv('float', 'foo', function ($name) use ($value) { $this->assertSame('foo', $name); return $value; }); } public function invalidFloats() { return array( array('foo'), array('true'), array('null'), ); } /** * @dataProvider validConsts */ public function testGetEnvConst($value, $processed) { $processor = new EnvVarProcessor(new Container()); $result = $processor->getEnv('const', 'foo', function ($name) use ($value) { $this->assertSame('foo', $name); return $value; }); $this->assertSame($processed, $result); } public function validConsts() { return array( array('Symfony\Component\DependencyInjection\Tests\EnvVarProcessorTest::TEST_CONST', self::TEST_CONST), array('E_ERROR', E_ERROR), ); } /** * @expectedException \Symfony\Component\DependencyInjection\Exception\RuntimeException * @expectedExceptionMessage undefined constant * @dataProvider invalidConsts */ public function testGetEnvConstInvalid($value) { $processor = new EnvVarProcessor(new Container()); $processor->getEnv('const', 'foo', function ($name) use ($value) { $this->assertSame('foo', $name); return $value; }); } public function invalidConsts() { return array( array('Symfony\Component\DependencyInjection\Tests\EnvVarProcessorTest::UNDEFINED_CONST'), array('UNDEFINED_CONST'), ); } public function testGetEnvBase64() { $processor = new EnvVarProcessor(new Container()); $result = $processor->getEnv('base64', 'foo', function ($name) { $this->assertSame('foo', $name); return base64_encode('hello'); }); $this->assertSame('hello', $result); } public function testGetEnvJson() { $processor = new EnvVarProcessor(new Container()); $result = $processor->getEnv('json', 'foo', function ($name) { $this->assertSame('foo', $name); return json_encode(array(1)); }); $this->assertSame(array(1), $result); } /** * @expectedException \Symfony\Component\DependencyInjection\Exception\RuntimeException * @expectedExceptionMessage Syntax error */ public function testGetEnvInvalidJson() { $processor = new EnvVarProcessor(new Container()); $processor->getEnv('json', 'foo', function ($name) { $this->assertSame('foo', $name); return 'invalid_json'; }); } /** * @expectedException \Symfony\Component\DependencyInjection\Exception\RuntimeException * @expectedExceptionMessage Invalid JSON env var * @dataProvider otherJsonValues */ public function testGetEnvJsonOther($value) { $processor = new EnvVarProcessor(new Container()); $processor->getEnv('json', 'foo', function ($name) use ($value) { $this->assertSame('foo', $name); return json_encode($value); }); } public function otherJsonValues() { return array( array(1), array(1.1), array(true), array(false), ); } /** * @expectedException \Symfony\Component\DependencyInjection\Exception\RuntimeException * @expectedExceptionMessage Unsupported env var prefix */ public function testGetEnvUnknown() { $processor = new EnvVarProcessor(new Container()); $processor->getEnv('unknown', 'foo', function ($name) { $this->assertSame('foo', $name); return 'foo'; }); } } __halt_compiler();----SIGNATURE:----A9YeqpA/ywweI6PnSu+QqjqgbJR8P8TWXPI9KIRzT4mEgUwjxfN2Y0YZFxMjqHl9qZzcfa46P1Qfpl2H05nusGYLWhX4sw9fo6S+AkrsIah5fyMWdm9VbfNBh4NIGD7k4kR2DMYQD3o5sw0tKIsRxWUdQvPnwfnZVbe28pNhNusUEOPg7Fub3cwhblWH/3Bhg9jVYKWVJSgZoJyws3mgvao+mpaiLgpO3JW53Mdx16feI4DAqvYpfE2E+4tQWHV6JIgB6AMGIuSAqXQ6gpjq4n4aRCQSnhF6YD+ow4GzT0R8GNSOJU31YOvS3qb2AbEOs93qfWH8W3rAiHjzqPXrgBibG/93AwCHmHat61j+p2M//mPKQQwedVge9bN00AOgwEe0SlYXf03GbT8imvnWpPpXk7T48i1xZ96bvYZmG6u8WmhHFX/m+56GYXmRjhsen1EQpoWGk25ZtVe5U/PPN2ZCJKLZFYEMXulzv4nfVotFyqIUOP53Kn9vGByZWEVIpLYNOoQm5PAG+Jp2hYur0inL9zejLkOdlyoBpsHWZHXLiVGIBqZLJzS7X5serbBHcHUg82XQpyULBw3tKkf5LnKbl8K1im0hG6TFl4WU7vohsbjf4EjcApd+hEbJD2urxxClMJqgN43EwrmOKrZR94GPP+1IrJKdOk00gILLa9k=----ATTACHMENT:----NDcyNjkxNDYxNzIzMzUyNyA2NDQxMDMyOTQ5MjM2NTggOTczMTYyMTQ2MzQ5MTU5Mg==