Skip to content

Commit

Permalink
Finish Release-1
Browse files Browse the repository at this point in the history
  • Loading branch information
dohzoh committed Nov 22, 2014
2 parents f41e038 + f8b62ed commit d0caf41
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 13 deletions.
30 changes: 20 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,37 +5,47 @@ Extension for using PhpSpec with FuelPHP framework

**Installation**

Download fuelphp framework from http://fuelphp.com/downloads

```bash
wget -O fuelphp.zip http://fuelphp.com/files/download/28
unzip fuelphp.zip
cd fuelphp-1.7.2
```

And install to use composer

```bash
php composer.phar selfupdate
php composer.phar run-script post-install-cmd
php composer.phar config bin-dir "bin/"
php composer.phar require dohzoh/phpspec-fuel dev-master
php composer.phar require monolog/monolog 1.5.* # I don't know why remove on original composer.json
```

**Configuration**
**Setting**

```yml
#phpspec.yml
extensions:
- PhpSpec\Fuelphp\Extension
cp fuel/vendor/dohzoh/phpspec-fuel/phpspec.yml.dist phpspec.yml
```

**Usage**

```
bin/phpspec describe Controller_Index
bin/phpspec describe Model_Blog
```

```
bin/phpspec run
```
OR
```
bin/phpspec run -b public/index.php
```

**Configuration**

You specify the applicaiton root in phpspec.yml, for example:
```
src_path: fuel/app
spec_path: fuel/app/tests
phpunit.xml: fuel/core/phpunit.xml
```
This will usually match the path you set for your composer autoload to search for classes.

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
"license": "MIT",
"require": {
"php": ">=5.3.3",
"phpunit/phpunit": "3.7.*",
"phpspec/phpspec": "~2.0"
},
"require-dev": {
"phpunit/phpunit": "4.*",
"behat/behat": "*",
"squizlabs/php_codesniffer": "2.*",
"bossa/phpspec2-expect": "dev-master"
Expand Down
1 change: 1 addition & 0 deletions phpspec.yml.dist
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
src_path: fuel/app
spec_path: fuel/app/tests
phpunit.xml: fuel/core/phpunit.xml

modules:
mymod:
Expand Down
30 changes: 28 additions & 2 deletions src/PhpSpec/Fuelphp/Extension.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,21 @@
use PhpSpec\Fuelphp\Generator\FuelphpSpecificationGenerator;
use PhpSpec\Fuelphp\Locator\PSR0Locator;
use PhpSpec\ServiceContainer;
use PHPUnit_Util_Configuration;

class Extension implements ExtensionInterface
{
const DEFAULTPATH_SRC = "fuel/app";
const DEFAULTPATH_SPEC = "fuel/app/tests";
const DEFAULTPATH_SRC = "fuel/app";
const DEFAULTPATH_SPEC = "fuel/app/tests";
const DEFAULTPATH_PHPUNITXML = "fuel/core/phpunit.xml";
/**
*
* @param \PhpSpec\ServiceContainer $container
* @return type
*/
public function load(ServiceContainer $container)
{
self::loadPhpunitConfiguration($container);

$container->addConfigurator(function($c) {
$c->setShared(
Expand All @@ -46,4 +49,27 @@ function($c) {
);
});
}

/**
* set global fuel setting
* $_SERVER[
* [doc_root] => ../../
* [app_path] => fuel/app
* [core_path] => fuel/core
* [package_path] => fuel/packages
* [vendor_path] => fuel/vendor
* [FUEL_ENV] => test
* ]
* and
* load bootstrap;
* @param ServiceContainer $container
*/
protected function loadPhpunitConfiguration(ServiceContainer $container)
{
$file = $container->getParam('phpunit.xml', self::DEFAULTPATH_PHPUNITXML);
$config = PHPUnit_Util_Configuration::getInstance($file);
$config->handlePHPConfiguration();
$configures = $config->getPHPUnitConfiguration();
@include_once($configures['bootstrap']);
}
}

0 comments on commit d0caf41

Please sign in to comment.