Skip to content

Commit 170bdab

Browse files
committed
change namespace for testing
1 parent 4d47bb1 commit 170bdab

14 files changed

Lines changed: 133 additions & 64 deletions

README.md

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
# PConfig
22

3-
PConfig is a PHP library for parsing configuration (php, json, xml, yaml, ini).
3+
PConfig is a PHP library for parsing configuration.
44
It has simple APIs and is easy to use.
55

6+
## Supported formats
7+
8+
- php
9+
- json
10+
- xml
11+
- yaml
12+
- ini
13+
614
## Installation
715

816
```bash
@@ -52,10 +60,10 @@ The default key separator is a dot-notation `.`.
5260
key1.key2.key3
5361
```
5462

55-
You can use `Config::CONFIG_SEPARATOR` to custom your own separator.
63+
You can use `PConfig::CONFIG_KEY_EXTRACT_SEPARATOR` to custom your own separator.
5664

5765
```
58-
Config::CONFIG_SEPARATOR => '-',
66+
PConfig::CONFIG_KEY_EXTRACT_SEPARATOR => '-',
5967
```
6068

6169
```
@@ -129,9 +137,10 @@ $config->delete('level1.level2');
129137
- `exists($key)`
130138
- `getConfig($key)`
131139
- `setConfig($key, $value)`
140+
- `setFile($path)`
141+
- `reload()`
132142
- `clear()`
133143
- `save()`
134-
- `setFile($path)`
135144

136145
## Licence
137146

composer.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"name": "oopsguy/pconfig",
33
"description": "A PHP library for parsing configuration(json, yaml, ini, xml and php)",
4+
"type": "library",
45
"license": "MIT",
56
"version": "1.1",
67
"authors": [
@@ -26,8 +27,12 @@
2627
},
2728
"autoload": {
2829
"psr-4": {
29-
"pconfig\\": "src/",
30-
"test\\": "test/"
30+
"pconfig\\": "src/"
31+
}
32+
},
33+
"autoload-dev": {
34+
"psr-4": {
35+
"pconfig\\test\\": "test/"
3136
}
3237
}
3338
}

examples/config/arrayConfig.php

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
<?php
2-
return array (
3-
0 => '',
4-
'debug' => false,
5-
'settings' =>
6-
array (
7-
'key' => 'new value',
8-
),
9-
);
1+
<?php
2+
return ['0' => '',
3+
'debug' => false,
4+
'settings' => [
5+
'key' => 'new value',
6+
],
7+
];

examples/config/databasesRootNode.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
12
<database>
23
<type>nosql</type>
34
<vendors>

examples/config/simpleXml.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
12
<root>
23
<database>oracle</database>
34
<database>mysql</database>

test/PConfigTest.php

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,40 @@
11
<?php
22

3-
namespace pconfig;
3+
namespace pconfig\test;
44

55
use Exception;
6+
use pconfig\PConfig;
67
use PHPUnit\Framework\TestCase;
78

9+
/**
10+
* Class PConfigTest
11+
* @package pconfig\test
12+
*/
813
class PConfigTest extends TestCase
914
{
1015
private $basePath = __DIR__ . '/data/';
1116

1217
public function testJSON()
1318
{
14-
$this->testConfig('json');
19+
$this->_testConfig('json');
1520
}
1621

1722
public function testINI()
1823
{
19-
$this->testConfig('ini');
24+
$this->_testConfig('ini');
2025
}
2126

2227
public function testPHP()
2328
{
24-
$this->testConfig('php');
29+
$this->_testConfig('php');
2530
}
2631

2732
public function testYAML()
2833
{
29-
$this->testConfig('yaml');
34+
$this->_testConfig('yaml');
3035
}
3136

32-
private function testConfig($type)
37+
private function _testConfig($type)
3338
{
3439
$config = null;
3540
try {

test/data/config_new.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?php
1+
<?php
22
return ['language' => [
33
'php' => [
44
'type' => [

test/provider/data/data.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1561712999
1+
1561753033
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
namespace pconfig\test\serializer;
4+
5+
use pconfig\serializer\ISerializer;
6+
use PHPUnit\Framework\TestCase;
7+
8+
/**
9+
* Base serializer test-case class
10+
* Class BaseSerializerTest
11+
* @package pconfig\test\serializer
12+
*/
13+
abstract class BaseSerializerTest extends TestCase
14+
{
15+
16+
/**
17+
* @var ISerializer
18+
*/
19+
protected $serializer;
20+
21+
protected function setUp()
22+
{
23+
$this->serializer = $this->targetSerializer();
24+
}
25+
26+
/**
27+
* @return ISerializer
28+
*/
29+
protected abstract function targetSerializer();
30+
31+
}

test/serializer/INISerializerTest.php

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,24 @@
11
<?php
22

3-
namespace pconfig\serializer\impl;
3+
namespace pconfig\test\serializer\impl;
44

5+
use pconfig\serializer\impl\INISerializer;
56
use pconfig\serializer\ISerializer;
6-
use PHPUnit\Framework\TestCase;
7+
use pconfig\test\serializer\BaseSerializerTest;
78

8-
class INISerializerTest extends TestCase
9+
/**
10+
* Testing for INISerializer
11+
* Class INISerializerTest
12+
* @package pconfig\test\serializer\impl
13+
*/
14+
class INISerializerTest extends BaseSerializerTest
915
{
1016
/**
11-
* @var ISerializer
17+
* @return ISerializer
1218
*/
13-
private $serializer;
14-
15-
protected function setUp()
19+
protected function targetSerializer()
1620
{
17-
$this->serializer = new INISerializer();
21+
return new INISerializer();
1822
}
1923

2024
public function testDeserialize()

0 commit comments

Comments
 (0)