Files
archived-web-pecl/tests/ConfigTest.php
2019-01-25 00:22:14 +01:00

55 lines
2.2 KiB
PHP

<?php
/*
+----------------------------------------------------------------------+
| The PECL website |
+----------------------------------------------------------------------+
| Copyright (c) 1999-2019 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Peter Kokot <petk@php.net> |
+----------------------------------------------------------------------+
*/
namespace App\Tests;
use PHPUnit\Framework\TestCase;
use App\Config;
class ConfigTest extends TestCase
{
/**
* @dataProvider configurationProvider
*/
public function testGet($file, $key, $expected)
{
$values = require $file;
$config = new Config($values);
$this->assertEquals($expected, $config->get($key));
}
public function configurationProvider()
{
return [
[__DIR__.'/fixtures/config.php', 'some_string', 'foo'],
[__DIR__.'/fixtures/config.php', 'array', ['value_1' => 1]],
[__DIR__.'/fixtures/config_2.php', 'db_username', 'nobody'],
[__DIR__.'/fixtures/config_2.php', 'db_password', 'password'],
[__DIR__.'/fixtures/config_2.php', 'db_host', 'localhost'],
[__DIR__.'/fixtures/config_2.php', 'db_name', 'pecl'],
[__DIR__.'/fixtures/config_3.php', 'db_username', 'root'],
[__DIR__.'/fixtures/config_3.php', 'db_password', 'secret'],
[__DIR__.'/fixtures/config_3.php', 'db_host', 'localhost'],
[__DIR__.'/fixtures/config_3.php', 'db_name', 'app'],
];
}
}