update 1.0.8.0

Commits for version update
This commit is contained in:
Manish Verma
2016-10-17 12:02:27 +05:30
parent dec927987b
commit 76e85db070
9674 changed files with 495757 additions and 58922 deletions

View File

@@ -9,7 +9,7 @@ cache:
matrix:
include:
- php: 5.3
- php: 5.3.3
- php: 5.3
env: DEPENDENCIES='low'
- php: 5.4
- php: 5.5
@@ -23,8 +23,7 @@ matrix:
fast_finish: true
before_install:
- composer selfupdate
- if [ "$DEPENDENCIES" == "low" ]; then composer config disable-tls true; fi;
- if [[ ${TRAVIS_PHP_VERSION:0:4} != "hhvm" ]]; then phpenv config-rm xdebug.ini; fi
install:
- export COMPOSER_ROOT_VERSION=dev-master
@@ -32,10 +31,7 @@ install:
- if [ "$DEPENDENCIES" != "low" ]; then composer update; fi;
- if [ "$DEPENDENCIES" == "low" ]; then composer update --prefer-lowest; fi;
before_script:
- echo "<?php if (defined('HHVM_VERSION')) { echo ',@hhvm'; } else { if (PHP_VERSION_ID >= 50400) echo ',@php5.4'; if (PHP_VERSION_ID >= 70000) echo ',@php7'; }" > php_version_tags.php
script:
- bin/phpspec run --format=pretty
- ./vendor/bin/phpunit --testdox
- ./vendor/bin/behat --format=pretty --tags '~@php-version'`php php_version_tags.php`
- ./vendor/bin/behat --format=pretty

View File

@@ -1,17 +1,19 @@
2.5.2 / 2017-09-04
==================
* [fixed] Exceptions are properly highlighted in error messages (@ciaranmcnulty)
2.5.1 / 2016-07-16
==================
* [fixed] Describing a class providing a namespace with leading backslash (@mheki)
* [fixed] bug where rerun test suite was uncoloured (@ciaranmcnulty)
* [fixed] Bug in DotFormatter when number of rows is multiple of column width (@bendavies)
2.5.0 / 2016-03-20
==================
* No changes from RC1
2.5.0-rc1 / 2016-03-12
======================
* Fixed bug with typehints in classes defined in spec file
2.5.0-beta / 2016-02-16
=======================
* Supports grouped Use statements
* Now shows path in error message when spec file doesn't contain a class
* Supports catching PHP 7 Errors in shouldThrow
@@ -36,25 +38,8 @@
==================
* Improved docblock for beConstructedThrough()
2.4.0-rc1 / 2015-11-20
======================
* No changes from RC1
2.4.0-beta / 2015-11-13
=======================
* Handle and present fatal errors
2.4.0-alpha2 / 2015-11-03
=========================
* Fixed edge case with partial use statements
2.4.0-alpha1 / 2015-11-01
=========================
* Initial support for typehinted doubles in PHP7
* Specs can now be run by specifying a fully qualified class name
* New shouldContain matcher for strings
@@ -72,26 +57,7 @@
2.3.0 / 2015-09-07
==================
* No changes from rc1
2.3.0-rc1 / 2015-08-28
======================
* No changes from beta3
2.3.0-beta3 / 2015-08-08
========================
* Fixed broken dependency in beta2
2.3.0-beta2 / 2015-08-08
========================
* Fixed bugs when generating methods in class with unusual whitespace
2.3.0-beta / 2015-07-04
========================
* Adds `duringInstantiation()` to more easily test constructor exceptions
* Adds `beConstructedThrough*()` and `beConstructed*()` shortcuts for named constructors
* Generated constructors are now placed at the start of the class
@@ -109,33 +75,15 @@
2.2.0 / 2015-04-18
==================
* No changes from rc1
2.2.0-rc1 / 2015-04-13
======================
* No changes from beta2
2.2.0-beta2 / 2015-04-03
========================
* Better diffs when presenting unexpected method arguments
* Better handling of methods delclared inside Traits when faking
2.2.0-beta / 2015-03-28
=======================
* Offer to generate interfaces for missing typehinted collaborators
* Support for TAP format output
* Remove deprecated usage of Symfony DialogHelper
* New array `shouldHaveKeyWithValue` matcher
* Clearer error message when specs have incorrect namespace prefix
* Fix suite rerunning for HHVM
Backward Compatibility
----------------------
* The unused `ask` and `askAndValidate` methods on `Console\IO` have been removed
* [BC break] The unused `ask` and `askAndValidate` methods on `Console\IO` have been removed
2.1.1 / 2015-01-09
==================
@@ -149,25 +97,11 @@ Backward Compatibility
2.1.0 / 2014-12-14
==================
* No changes from RC3
2.1.0-RC3 / 2014-12-04
======================
* Removed minor BC break introduced in RC2
2.1.0-RC2 / 2014-11-14
======================
* Specify bootstrap file via configuration
* Correct error codes while using --stop-on-failure
* Better detection of empty specs
* Fixed issue where non-spec files in spec folder caused errors
* Better PSR-4 support
2.1.0-RC1 / 2014-09-14
======================
* Allow objects to be instantiated via static factory methods
* Automatic generation of return statements using '--fake'
* Test suite is automatically rerun when classes or methods have been generated
@@ -202,10 +136,6 @@ Backward Compatibility
* Improve support to windows
* Improve support to hhvm
* Improve acceptance tests coverage with Behat
2.0.0-RC4 / 2014-02-21
======================
* Revamped junit formatter
* Fixed #269 Problem with exception masking and generation for not found class
* HHVM is officially supported
@@ -215,22 +145,10 @@ Backward Compatibility
* Fixed a problem with generating a constructor when it is first time added
* Improved help
* Fixed the suite runner in fast machines
2.0.0-RC3 / 2014-01-01
======================
* Fixed the Prophecy constraint as the new release is 1.1
* Refactored formatters to be defined as services
2.0.0-RC2 / 2013-12-30
======================
* Fixed the invocation of methods expecting an argument passed by reference
* Fixed the instantiation of the wrapped object in shouldThrow
2.0.0-RC1 / 2013-12-26
======================
* Bump the Prophecy requirement to ``~1.0.5@dev``
* Added a JUnit formatter
* Added the ``--stop-on-failure`` option
@@ -242,23 +160,11 @@ Backward Compatibility
* Added a constructor generator
* Added a HTML formatter
* Added a nyan cat formatter
2.0.0beta4 / 2013-05-19
=======================
* Add collaborator constructor setter
* Fix couple of bugs in Prophecy integration layer
* New (old) dot formatter
2.0.0beta3 / 2013-05-01
=======================
* Prevent loading of unexisting PHP files
* Fix typos in the error messages
2.0.0beta2 / 2013-04-30
=======================
* Bump required Prophecy version to 1.0.1
* Support non-string values with ArrayContain matcher
* Create `src` folder if does not exist

View File

@@ -9,6 +9,8 @@ default:
smoke:
contexts: [ IsolatedProcessContext, FilesystemContext ]
filters: { tags: "@smoke && ~@isolated" }
extensions:
Cjm\Behat\VersionBasedTestSkipperExtension: ~
no-smoke:
suites:

View File

@@ -1,7 +1,7 @@
#!/usr/bin/env php
<?php
define('PHPSPEC_VERSION', '2.5.0');
define('PHPSPEC_VERSION', '2.5.2');
if (is_file($autoload = getcwd() . '/vendor/autoload.php')) {
require $autoload;

View File

@@ -33,9 +33,9 @@
"require-dev": {
"behat/behat": "^3.0.11",
"bossa/phpspec2-expect": "~1.0",
"symfony/filesystem": "~2.1|~3.0",
"phpunit/phpunit": "~4.4"
"phpunit/phpunit": "~4.4",
"ciaranmcnulty/versionbasedtestskipper": "^0.2.1"
},
"suggest": {
@@ -58,7 +58,7 @@
"extra": {
"branch-alias": {
"dev-master": "2.2.x-dev"
"dev-master": "2.5.x-dev"
}
}
}

View File

@@ -1,23 +1,20 @@
<?php
use Behat\Behat\Tester\Exception\PendingException;
use Behat\Behat\Context\Context;
use Behat\Gherkin\Node\PyStringNode;
use Behat\Gherkin\Node\TableNode;
use Fake\Prompter;
use Fake\ReRunner;
use Matcher\ApplicationOutputMatcher;
use Matcher\ValidJUnitXmlMatcher;
use PhpSpec\Console\Application;
use PhpSpec\Loader\StreamWrapper;
use PhpSpec\Matcher\MatchersProviderInterface;
use Symfony\Component\Console\Tester\ApplicationTester;
/**
* Defines application features from the specific context.
*/
class ApplicationContext implements Context, MatchersProviderInterface
class ApplicationContext implements Context
{
const JUNIT_XSD_PATH = '/src/PhpSpec/Resources/schema/junit.xsd';
/**
* @var Application
*/
@@ -83,7 +80,9 @@ class ApplicationContext implements Context, MatchersProviderInterface
'class' => $class
);
expect($this->tester->run($arguments, array('interactive' => false)))->toBe(0);
if ($this->tester->run($arguments, array('interactive' => false)) !== 0) {
throw new \Exception('Test runner exited with an error');
}
}
/**
@@ -167,7 +166,7 @@ class ApplicationContext implements Context, MatchersProviderInterface
*/
public function iShouldSee($output)
{
expect($this->tester)->toHaveOutput((string)$output);
$this->checkApplicationOutput((string)$output);
}
/**
@@ -175,7 +174,9 @@ class ApplicationContext implements Context, MatchersProviderInterface
*/
public function iShouldBePromptedForCodeGeneration()
{
expect($this->prompter)->toHaveBeenAsked();
if(!$this->prompter->hasBeenAsked()) {
throw new \Exception('There was a missing prompt for code generation');
}
}
/**
@@ -183,7 +184,9 @@ class ApplicationContext implements Context, MatchersProviderInterface
*/
public function iShouldNotBePromptedForCodeGeneration()
{
expect($this->prompter)->toNotHaveBeenAsked();
if($this->prompter->hasBeenAsked()) {
throw new \Exception('There was an unexpected prompt for code generation');
}
}
/**
@@ -191,7 +194,7 @@ class ApplicationContext implements Context, MatchersProviderInterface
*/
public function theSuiteShouldPass()
{
expect($this->lastExitCode)->toBeLike(0);
$this->theExitCodeShouldBe(0);
}
/**
@@ -199,7 +202,9 @@ class ApplicationContext implements Context, MatchersProviderInterface
*/
public function theSuiteShouldNotPass()
{
expect($this->lastExitCode)->notToBeLike(0);
if ($this->lastExitCode === 0) {
throw new \Exception('The application did not exit with an error code');
}
}
/**
@@ -207,7 +212,7 @@ class ApplicationContext implements Context, MatchersProviderInterface
*/
public function exampleShouldHaveBeenSkipped($number)
{
expect($this->tester)->toHaveOutput("($number skipped)");
$this->checkApplicationOutput("($number skipped)");
}
/**
@@ -215,7 +220,7 @@ class ApplicationContext implements Context, MatchersProviderInterface
*/
public function examplesShouldHaveBeenRun($number)
{
expect($this->tester)->toHaveOutput("$number examples");
$this->checkApplicationOutput("$number examples");
}
/**
@@ -223,7 +228,13 @@ class ApplicationContext implements Context, MatchersProviderInterface
*/
public function theExitCodeShouldBe($code)
{
expect($this->lastExitCode)->toBeLike($code);
if ($this->lastExitCode !== (int)$code) {
throw new \Exception(sprintf(
'The application existed with an unexpected code: expected: %s, actual: %s',
$code,
$this->lastExitCode
));
}
}
/**
@@ -231,7 +242,13 @@ class ApplicationContext implements Context, MatchersProviderInterface
*/
public function iShouldSeeValidJunitOutput()
{
expect($this->tester)->toHaveOutputValidJunitXml();
$dom = new \DOMDocument();
$dom->loadXML($this->tester->getDisplay());
if (!$dom->schemaValidate(__DIR__ . '/../..' . self::JUNIT_XSD_PATH)) {
throw new \Exception(sprintf(
"Output was not valid JUnit XML"
));
}
}
/**
@@ -239,7 +256,9 @@ class ApplicationContext implements Context, MatchersProviderInterface
*/
public function theTestsShouldBeRerun()
{
expect($this->reRunner)->toHaveBeenRerun();
if (!$this->reRunner->hasBeenReRun()) {
throw new \Exception('The tests should have been rerun');
}
}
/**
@@ -247,7 +266,9 @@ class ApplicationContext implements Context, MatchersProviderInterface
*/
public function theTestsShouldNotBeRerun()
{
expect($this->reRunner)->toNotHaveBeenRerun();
if ($this->reRunner->hasBeenReRun()) {
throw new \Exception('The tests should not have been rerun');
}
}
/**
@@ -255,7 +276,10 @@ class ApplicationContext implements Context, MatchersProviderInterface
*/
public function iShouldBePromptedWith(PyStringNode $question)
{
expect($this->prompter)->toHaveBeenAsked((string)$question);
$stringQuestion = (string)$question;
if (!$this->prompter->hasBeenAsked($stringQuestion)) {
throw new \Exception("The prompt was not shown: $stringQuestion");
}
}
/**
@@ -270,7 +294,9 @@ class ApplicationContext implements Context, MatchersProviderInterface
'--config' => $config
);
expect($this->tester->run($arguments, array('interactive' => false)))->toBe(0);
if ($this->tester->run($arguments, array('interactive' => false)) !== 0) {
throw new \Exception('Test runner exited with an error');
}
}
/**
@@ -288,19 +314,6 @@ class ApplicationContext implements Context, MatchersProviderInterface
$this->lastExitCode = $this->tester->run($arguments, array('interactive' => true));
}
/**
* Custom matchers
*
* @return array
*/
public function getMatchers()
{
return array(
new ApplicationOutputMatcher(),
new ValidJUnitXmlMatcher()
);
}
/**
* @When I run phpspec with the spec :spec
*/
@@ -327,4 +340,24 @@ class ApplicationContext implements Context, MatchersProviderInterface
$this->lastExitCode = $this->tester->run($arguments, array('interactive' => false));
}
private function checkApplicationOutput($output)
{
$expected = $this->normalize($output);
$actual = $this->normalize($this->tester->getDisplay(true));
if (strpos($actual, $expected) === false) {
throw new \Exception(sprintf(
"Application output did not contain expected '%s'. Actual output:\n'%s'" ,
$expected,
$this->tester->getDisplay()
));
}
}
private function normalize($string)
{
$string = preg_replace('/\([0-9]+ms\)/', '', $string);
return $string;
}
}

View File

@@ -1,19 +1,14 @@
<?php
use Behat\Behat\Tester\Exception\PendingException;
use Behat\Behat\Context\Context;
use Behat\Gherkin\Node\PyStringNode;
use Behat\Gherkin\Node\TableNode;
use Matcher\FileExistsMatcher;
use Matcher\FileHasContentsMatcher;
use PhpSpec\Matcher\MatchersProviderInterface;
use Symfony\Component\Filesystem\Exception\IOException;
use Symfony\Component\Filesystem\Filesystem;
/**
* Defines application features from the specific context.
*/
class FilesystemContext implements Context, MatchersProviderInterface
class FilesystemContext implements Context
{
/**
* @var string
@@ -98,8 +93,12 @@ class FilesystemContext implements Context, MatchersProviderInterface
*/
public function thereIsNoFile($file)
{
expect($file)->toNotExist();
expect(file_exists($file))->toBe(false);
if (file_exists($file)) {
throw new \Exception(sprintf(
"File unexpectedly exists at path '%s'",
$file
));
}
}
/**
@@ -108,8 +107,22 @@ class FilesystemContext implements Context, MatchersProviderInterface
*/
public function theFileShouldContain($file, PyStringNode $contents)
{
expect($file)->toExist();
expect($file)->toHaveContents($contents);
if (!file_exists($file)) {
throw new \Exception(sprintf(
"File did not exist at path '%s'",
$file
));
}
$expectedContents = (string)$contents;
if ($expectedContents != file_get_contents($file)) {
throw new \Exception(sprintf(
"File at '%s' did not contain expected contents.\nExpected: '%s'\nActual: '%s'",
$file,
$expectedContents,
file_get_contents($file)
));
}
}
/**
@@ -127,15 +140,4 @@ class FilesystemContext implements Context, MatchersProviderInterface
{
$this->filesystem->remove($this->workingDirectory . '/vendor/autoload.php');
}
/**
* @return array
*/
public function getMatchers()
{
return array(
new FileExistsMatcher(),
new FileHasContentsMatcher()
);
}
}

View File

@@ -3,8 +3,6 @@
use Behat\Behat\Context\Context;
use Behat\Behat\Context\SnippetAcceptingContext;
use Symfony\Component\Process\Process;
use Symfony\Component\Filesystem\Filesystem;
use Behat\Gherkin\Node\PyStringNode;
/**
* Defines application features from the specific context.
@@ -29,7 +27,9 @@ class IsolatedProcessContext implements Context, SnippetAcceptingContext
$process->run();
expect($process->getExitCode())->toBe(0);
if ($process->getExitCode() !== 0) {
throw new \Exception('The describe process ended with an error');
}
}
/**
@@ -70,7 +70,9 @@ class IsolatedProcessContext implements Context, SnippetAcceptingContext
*/
public function theTestsShouldBeRerun()
{
expect(substr_count($this->process->getOutput(), 'specs'))->toBe(2);
if (substr_count($this->process->getOutput(), 'specs') !== 2) {
throw new \Exception('The tests were not rerun');
}
}
/**
@@ -78,7 +80,9 @@ class IsolatedProcessContext implements Context, SnippetAcceptingContext
*/
public function iShouldSeeAnErrorAboutTheMissingAutoloader()
{
expect($this->process->getErrorOutput())->toMatch('/autoload/');
if (!preg_match('/autoload/', $this->process->getErrorOutput().$this->process->getOutput())) {
throw new \Exception('There was no error regarding a missing autoloader:');
}
}
/**
@@ -102,20 +106,7 @@ class IsolatedProcessContext implements Context, SnippetAcceptingContext
$this->buildPhpSpecCmd() . " --format=$formatter run"
);
$process->run();
$this->lastOutput = $process->getErrorOutput();
}
/**
* @When I run phpspec on HHVM with the :formatter formatter
*/
public function iRunPhpspecOnHhvmWithThe($formatter)
{
$process = new Process(
$this->buildPhpSpecCmd() . " --format=$formatter run"
);
$process->run();
$this->lastOutput = $process->getOutput();
$this->lastOutput = $process->getErrorOutput().$process->getOutput();
}
@@ -124,7 +115,9 @@ class IsolatedProcessContext implements Context, SnippetAcceptingContext
*/
public function iShouldSee($message)
{
expect(strpos($this->lastOutput, $message))->toNotBe(false);
if (strpos($this->lastOutput, $message) === false) {
throw new \Exception("Missing message: $message");
}
}
}

View File

@@ -1,74 +0,0 @@
<?php
namespace Matcher;
use PhpSpec\Exception\Example\FailureException;
use PhpSpec\Matcher\MatcherInterface;
use Symfony\Component\Console\Tester\ApplicationTester;
class ApplicationOutputMatcher implements MatcherInterface
{
/**
* Checks if matcher supports provided subject and matcher name.
*
* @param string $name
* @param mixed $subject
* @param array $arguments
*
* @return Boolean
*/
public function supports($name, $subject, array $arguments)
{
return ($name == 'haveOutput' && $subject instanceof ApplicationTester);
}
/**
* Evaluates positive match.
*
* @param string $name
* @param mixed $subject
* @param array $arguments
*/
public function positiveMatch($name, $subject, array $arguments)
{
$expected = $this->normalize($arguments[0]);
$actual = $this->normalize($subject->getDisplay(true));
if (strpos($actual, $expected) === false) {
throw new FailureException(sprintf(
"Application output did not contain expected '%s'. Actual output:\n'%s'" ,
$expected,
$subject->getDisplay()
));
}
}
private function normalize($string)
{
$string = preg_replace('/\([0-9]+ms\)/', '', $string);
return $string;
}
/**
* Evaluates negative match.
*
* @param string $name
* @param mixed $subject
* @param array $arguments
*/
public function negativeMatch($name, $subject, array $arguments)
{
throw new FailureException('Negative application output matcher not implemented');
}
/**
* Returns matcher priority.
*
* @return integer
*/
public function getPriority()
{
return 51;
}
}

View File

@@ -1,67 +0,0 @@
<?php
namespace Matcher;
use PhpSpec\Exception\Example\FailureException;
use PhpSpec\Matcher\MatcherInterface;
class FileExistsMatcher implements MatcherInterface
{
/**
* Checks if matcher supports provided subject and matcher name.
*
* @param string $name
* @param mixed $subject
* @param array $arguments
*
* @return Boolean
*/
public function supports($name, $subject, array $arguments)
{
return ('exist' == $name && is_string($subject));
}
/**
* Evaluates positive match.
*
* @param string $name
* @param mixed $subject
* @param array $arguments
*/
public function positiveMatch($name, $subject, array $arguments)
{
if (!file_exists($subject)) {
throw new FailureException(sprintf(
"File did not exist at path '%s'",
$subject
));
}
}
/**
* Evaluates negative match.
*
* @param string $name
* @param mixed $subject
* @param array $arguments
*/
public function negativeMatch($name, $subject, array $arguments)
{
if (file_exists($subject)) {
throw new FailureException(sprintf(
"File unexpectedly exists at path '%s'",
$subject
));
}
}
/**
* Returns matcher priority.
*
* @return integer
*/
public function getPriority()
{
return 0;
}
}

View File

@@ -1,66 +0,0 @@
<?php
namespace Matcher;
use PhpSpec\Exception\Example\FailureException;
use PhpSpec\Matcher\MatcherInterface;
class FileHasContentsMatcher implements MatcherInterface
{
/**
* Checks if matcher supports provided subject and matcher name.
*
* @param string $name
* @param mixed $subject
* @param array $arguments
*
* @return Boolean
*/
public function supports($name, $subject, array $arguments)
{
return ('haveContents' == $name && is_string($subject));
}
/**
* Evaluates positive match.
*
* @param string $name
* @param mixed $subject
* @param array $arguments
*/
public function positiveMatch($name, $subject, array $arguments)
{
$path = $subject;
$expectedContents = $arguments[0];
if ($expectedContents != file_get_contents($path)) {
throw new FailureException(sprintf(
"File at '%s' did not contain expected contents.\nExpected: '%s'\nActual: '%s'",
$path,
$expectedContents,
file_get_contents($path)
));
}
}
/**
* Evaluates negative match.
*
* @param string $name
* @param mixed $subject
* @param array $arguments
*/
public function negativeMatch($name, $subject, array $arguments)
{
throw new FailureException('Negative file contents matcher not implemented');
}
/**
* Returns matcher priority.
*
* @return integer
*/
public function getPriority()
{
return 51;
}
}

View File

@@ -1,66 +0,0 @@
<?php
namespace Matcher;
use PhpSpec\Exception\Example\FailureException;
use PhpSpec\Matcher\MatcherInterface;
use Symfony\Component\Console\Tester\ApplicationTester;
const JUNIT_XSD_PATH = '/src/PhpSpec/Resources/schema/junit.xsd';
class ValidJUnitXmlMatcher implements MatcherInterface
{
/**
* Checks if matcher supports provided subject and matcher name.
*
* @param string $name
* @param mixed $subject
* @param array $arguments
*
* @return Boolean
*/
public function supports($name, $subject, array $arguments)
{
return ($name == 'haveOutputValidJunitXml' && $subject instanceof ApplicationTester);
}
/**
* Evaluates positive match.
*
* @param string $name
* @param mixed $subject
* @param array $arguments
*/
public function positiveMatch($name, $subject, array $arguments)
{
$dom = new \DOMDocument();
$dom->loadXML($subject->getDisplay());
if (!$dom->schemaValidate(__DIR__ . '/../../..' . JUNIT_XSD_PATH)) {
throw new FailureException(sprintf(
"Output was not valid JUnit XML"
));
}
}
/**
* Evaluates negative match.
*
* @param string $name
* @param mixed $subject
* @param array $arguments
*/
public function negativeMatch($name, $subject, array $arguments)
{
throw new FailureException('Negative JUnit matcher not implemented');
}
/**
* Returns matcher priority.
*
* @return integer
*/
public function getPriority()
{
return 51;
}
}

View File

@@ -3,7 +3,7 @@ Feature: Developer generates a class
I want to automate creating classes
In order to avoid repetitive tasks and interruptions in development flow
@smoke @php-version @php5.4
@smoke @php:~5.4||~7.0
Scenario: Generating a class
Given I have started describing the "CodeGeneration/ClassExample1/Markdown" class
When I run phpspec and answer "y" when asked if I want to generate the code
@@ -132,7 +132,7 @@ Feature: Developer generates a class
"""
@isolated @php-version @php5.4
@isolated @php:~5.4||~7.0
Scenario: Generating a class outside of autoloadable paths gives a warning
Given I have started describing the "CodeGeneration/ClassExample2/Markdown" class
But I have not configured an autoloader

View File

@@ -1,4 +1,4 @@
@php-version @php7
@php:~7.0
Feature: Developer generates a collaborator
As a Developer
I want to automate creating collaborators

View File

@@ -260,7 +260,7 @@ Feature: Developer generates a method returning a constant
When I run phpspec interactively
Then I should be prompted for code generation
@php-version @php5.4
@php:~5.4||~7.0
Scenario: Generating a scalar return type when method is in trait
Given the spec file "spec/CodeGeneration/ConstantExample7/MarkdownSpec.php" contains:
"""

View File

@@ -3,7 +3,7 @@ Feature: Developer generates a class
I want the tests to automatically rerun after code generation events
In order to avoid repetitive tasks and interruptions in development flow
@smoke @php-version @php5.4
@smoke @php:~5.4||~7.0
Scenario: Rerun after class generation
Given I have started describing the "CodeGeneration/RerunExample1/Markdown" class
When I run phpspec and answer "y" when asked if I want to generate the code

View File

@@ -44,8 +44,8 @@ Feature: Developer is notified of which scenario caused a fatal error
Then I should see "Fatal error happened while executing the following"
And I should see "it fatals when calling an undeclared function"
@isolated @php-version @php5.4 @php7
Scenario: Fatal error writer message not shown, when formatter does not support it, outputs to stderr.
@isolated @php:~5.4||~7.0
Scenario: Fatal error writer message not shown, when formatter does not support it.
Given the spec file "spec/Message/Fatal/Fatal2Spec.php" contains:
"""
<?php
@@ -83,44 +83,3 @@ Feature: Developer is notified of which scenario caused a fatal error
"""
When I run phpspec with the "junit" formatter
Then I should see "Call to undefined function"
@isolated @hhvm
Scenario: Fatal error writer message not shown, when formatter does not support it, outputs to stdout.
Given the spec file "spec/Message/Fatal/FatalHhvmSpec.php" contains:
"""
<?php
namespace spec\Message\Fatal;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
class FatalHhvmSpec extends ObjectBehavior
{
function it_fatals_when_calling_an_undeclared_function()
{
anything();
}
}
"""
And the class file "src/Message/Fatal/FatalHhvm.php" contains:
"""
<?php
namespace Message\Fatal;
class FatalHhvm
{
public function __construct($param)
{
if ($param == 'throw') {
throw new \Exception();
}
}
}
"""
When I run phpspec on HHVM with the "junit" formatter
Then I should see "Call to undefined function"

View File

@@ -3,8 +3,8 @@ Feature: Developer is shown a parse error
I want to know if a parse error was thrown
So that I can know that I can handle pass errors
@isolated @php-version @php5.4 @php7
Scenario: Spec attempts to call an undeclared function and outputs to stderr
@isolated @php:~5.4||~7.0
Scenario: Spec attempts to call an undeclared function
Given the spec file "spec/Message/Fatal/ParseSpec.php" contains:
"""
<?php
@@ -41,42 +41,3 @@ Feature: Developer is shown a parse error
"""
When I run phpspec with the "junit" formatter
Then I should see "syntax error"
@isolated @hhvm
Scenario: Spec attempts to call an undeclared function and outputs to stdout
Given the spec file "spec/Message/Fatal/ParseHhvmSpec.php" contains:
"""
<?php
namespace spec\Message\Fatal;
use Parse;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
class ParseHhvmSpec extends ObjectBehavior
{
function it_thro ws_a_syntax_error()
{
$this->cool();
}
}
"""
And the spec file "src/Message/Fatal/ParseHhvm.php" contains:
"""
<?php
namespace Message\Parse;
class ParseHhvm
{
public function cool()
{
return true;
}
}
"""
When I run phpspec on HHVM with the "junit" formatter
Then I should see "syntax error"

View File

@@ -43,7 +43,7 @@ Feature: Developer uses unsupported collaborator type hinting
spec\InvalidUsage\InvalidUsageExample1\StorageSpec::it_can_store_data.
"""
@php-version @php5.4
@php:~5.4||~7.0
Scenario: Callable collaborator type hinting
Given the spec file "spec/InvalidUsage/InvalidUsageExample2/InvokerSpec.php" contains:
"""
@@ -86,7 +86,7 @@ Feature: Developer uses unsupported collaborator type hinting
"""
@php-version @php7
@php:~7.0
Scenario: Integer collaborator type hinting
Given the spec file "spec/InvalidUsage/InvalidUsageExample3/StorageSpec.php" contains:
"""

View File

@@ -89,7 +89,7 @@ Feature: Developer is told about pending specs
1 examples (1 passed)
"""
@php-version @php5.4
@php:~5.4||~7.0
Scenario: Spec defined in trait does not cause pending
Given the trait file "spec/Runner/PendingExample4/PartialSpecTrait.php" contains:
"""

View File

@@ -455,6 +455,16 @@ class PSR0LocatorSpec extends ObjectBehavior
$resource->getSpecClassname()->shouldReturn('spec\Console\ApplicationSpec');
}
function it_creates_resource_from_spec_class_with_leading_backslash()
{
$this->beConstructedWith('PhpSpec', 'spec', $this->srcPath, $this->specPath);
$resource = $this->createResource('\PhpSpec\Console\Application');
$resource->getSrcClassname()->shouldReturn('PhpSpec\Console\Application');
$resource->getSpecClassname()->shouldReturn('spec\PhpSpec\Console\ApplicationSpec');
}
function it_throws_an_exception_on_non_PSR0_resource()
{
$this->beConstructedWith('', 'spec', $this->srcPath, $this->specPath);

View File

@@ -18,7 +18,7 @@ use PhpSpec\Process\Context\ExecutionContextInterface;
use Prophecy\Argument;
use Symfony\Component\Process\PhpExecutableFinder;
class PassthruRerunnerSpec extends ObjectBehavior
class ProcOpenReRunnerSpec extends ObjectBehavior
{
function let(PhpExecutableFinder $executableFinder, ExecutionContextInterface $executionContext)
{

View File

@@ -669,7 +669,7 @@ class ContainerAssembler
);
});
$container->setShared('process.rerunner.platformspecific.passthru', function (ServiceContainer $c) {
return ReRunner\PassthruReRunner::withExecutionContext(
return ReRunner\ProcOpenReRunner::withExecutionContext(
$c->get('process.phpexecutablefinder'),
$c->get('process.executioncontext')
);

View File

@@ -49,6 +49,7 @@ class Formatter extends OutputFormatter
$this->setStyle('value', new OutputFormatterStyle('yellow'));
$this->setStyle('lineno', new OutputFormatterStyle(null, 'black'));
$this->setStyle('code', new OutputFormatterStyle('white'));
$this->setStyle('label', new OutputFormatterStyle('white', null, array('bold')));
$this->setStyle('hl', new OutputFormatterStyle('black', 'yellow', array('bold')));
$this->setStyle('question', new OutputFormatterStyle('black', 'yellow', array('bold')));

View File

@@ -62,16 +62,17 @@ class DotFormatter extends ConsoleFormatter
}
$remainder = $eventsCount % 50;
$endOfRow = 0 === $remainder;
$lastRow = $eventsCount === $this->examplesCount;
if ($remainder === 0 || $lastRow) {
if ($lastRow && !$endOfRow) {
$io->write(str_repeat(' ', 50 - $remainder));
}
if ($lastRow || $endOfRow) {
$length = strlen((string) $this->examplesCount);
$format = sprintf(' %%%dd / %%%dd', $length, $length);
if ($lastRow) {
$io->write(str_repeat(' ', 50 - $remainder));
}
$io->write(sprintf($format, $eventsCount, $this->examplesCount));
if ($eventsCount !== $this->examplesCount) {

View File

@@ -230,6 +230,7 @@ class PSR0Locator implements ResourceLocatorInterface
*/
public function createResource($classname)
{
$classname = ltrim($classname, '\\');
$this->validatePsr0Classname($classname);
$classname = str_replace('/', '\\', $classname);

View File

@@ -16,6 +16,9 @@ namespace PhpSpec\Process\ReRunner;
use PhpSpec\Process\Context\ExecutionContextInterface;
use Symfony\Component\Process\PhpExecutableFinder;
/**
* @deprecated
*/
class PassthruReRunner extends PhpExecutableReRunner
{
/**

View File

@@ -0,0 +1,80 @@
<?php
/*
* This file is part of PhpSpec, A php toolset to drive emergent
* design by specification.
*
* (c) Marcello Duarte <marcello.duarte@gmail.com>
* (c) Konstantin Kudryashov <ever.zet@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace PhpSpec\Process\ReRunner;
use PhpSpec\Process\Context\ExecutionContextInterface;
use Symfony\Component\Process\PhpExecutableFinder;
final class ProcOpenReRunner extends PhpExecutableReRunner
{
/**
* @var ExecutionContextInterface
*/
private $executionContext;
/**
* @param PhpExecutableFinder $phpExecutableFinder
* @param ExecutionContextInterface $executionContext
* @return static
*/
public static function withExecutionContext(PhpExecutableFinder $phpExecutableFinder, ExecutionContextInterface $executionContext)
{
$reRunner = new static($phpExecutableFinder);
$reRunner->executionContext = $executionContext;
return $reRunner;
}
/**
* @return boolean
*/
public function isSupported()
{
return (php_sapi_name() == 'cli')
&& $this->getExecutablePath()
&& function_exists('passthru')
&& (stripos(PHP_OS, "win") !== 0);
}
public function reRunSuite()
{
$args = $_SERVER['argv'];
$command = $this->buildArgString() . escapeshellcmd($this->getExecutablePath()).' '.join(' ', array_map('escapeshellarg', $args)) . ' 2>&1';
$desc = array(
0 => array('file', 'php://stdin', 'r'),
1 => array('file', 'php://stdout', 'w'),
2 => array('file', 'php://stderr', 'w'),
);
$proc = proc_open( $command, $desc, $pipes );
do {
sleep(1);
$status = proc_get_status($proc);
} while ($status['running']);
exit($status['exitcode']);
}
private function buildArgString()
{
$argstring = '';
foreach ($this->executionContext->asEnv() as $key => $value) {
$argstring .= $key . '=' . escapeshellarg($value) . ' ';
}
return $argstring;
}
}