Skip to content

Commit e639f60

Browse files
xujiajunxujiajun
authored and
xujiajun
committedJul 12, 2017
supprot psr11&& fix phpunit configure
1 parent 06b14f2 commit e639f60

10 files changed

+135
-15
lines changed
 

‎.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
composer.json.bak
33
vendor/
44
config/*
5-
web/*
5+
web/*
6+
build/

‎composer.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@
4242
"mtdowling/cron-expression": "~1.0",
4343
"pda/pheanstalk": "^3.1",
4444
"symfony/polyfill-iconv": "^1.2",
45-
"filp/whoops": "^2.1"
45+
"filp/whoops": "^2.1",
46+
"psr/container": "~1.0"
4647
},
4748
"require-dev": {
4849
"phpunit/phpunit": "5.5.*"

‎composer.lock

+50-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎phpunit.xml.dist

+5-9
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
1-
<phpunit bootstrap="tests/bootstrap.php" colors="true" syntaxCheck="true">
1+
<phpunit bootstrap="tests/bootstrap.php" colors="true" syntaxCheck="true" >
22
<testsuites>
33
<testsuite name="Tastphp framework Test Suite">
4-
<directory>./tests/</directory>
4+
<directory suffix="Test.php">./tests/</directory>
55
</testsuite>
66
</testsuites>
77
<filter>
8-
<blacklist>
9-
<directory>./vendor/</directory>
10-
</blacklist>
8+
<whitelist processUncoveredFilesFromWhitelist="true">
9+
<directory suffix=".php">./src/</directory>
10+
</whitelist>
1111
</filter>
12-
<logging>
13-
<log type="coverage-clover" target="build/logs/clover.xml"/>
14-
</logging>
15-
1612
</phpunit>

‎src/Framework/Container/Container.php

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<?php
22

33
namespace TastPHP\Framework\Container;
4-
54
/**
65
* Class Container
76
* @package TastPHP\Framework\Container
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
namespace TastPHP\Framework\Container;
4+
5+
use Psr\Container\NotFoundExceptionInterface;
6+
7+
class NotFoundException extends \InvalidArgumentException implements NotFoundExceptionInterface
8+
{
9+
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
3+
namespace TastPHP\Framework\Container;
4+
5+
use Pimple\Container;
6+
7+
/**
8+
* Class PimpleContainer
9+
* @package TastPHP\Framework\Container
10+
*/
11+
class PimpleContainer implements \Psr\Container\ContainerInterface
12+
{
13+
/**
14+
* @var Container
15+
*/
16+
private $container;
17+
18+
public function __construct(Container $container)
19+
{
20+
$this->container = $container;
21+
}
22+
23+
/**
24+
* @param string $id
25+
* @return mixed
26+
*/
27+
public function get($id)
28+
{
29+
if (!isset($this->container[$id])) {
30+
throw new NotFoundException(sprintf('Identifier "%s" is not defined in container.', $id));
31+
}
32+
return $this->container[$id];
33+
}
34+
35+
/**
36+
* @param string $id
37+
* @return bool
38+
*/
39+
public function has($id)
40+
{
41+
return isset($this->container[$id]);
42+
}
43+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
namespace TastPHP\Framework\Container;
4+
5+
use TastPHP\Framework\Service\ServiceProvider;
6+
7+
/**
8+
* Class PimpleContainerProvider
9+
* @package TastPHP\Framework\Container
10+
*/
11+
class PimpleContainerProvider extends ServiceProvider
12+
{
13+
public function register()
14+
{
15+
$this->app->singleton('container', function () {
16+
return new PimpleContainer($this->app);
17+
});
18+
}
19+
}

‎tests/KernelTest.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<?php
22

3-
class KernelTest extends PHPUnit_Framework_TestCase
3+
use PHPUnit\Framework\TestCase;
4+
5+
class KernelTest extends TestCase
46
{
57
public function testInstance()
68
{

‎tests/config/app.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ version: v1.0.0
22
debug: true
33
secret: tastphp-framework
44
# dev | test | prod
5-
env: dev
5+
env: test
66
timezone: UTC

0 commit comments

Comments
 (0)