PK 2^GMۻy 3 integration/PhpSpec/Loader/examples/ExampleSpec.phpnu W+A addTransformer(new TypeHintRewriter(new TokenizedTypeHintRewriter(new InMemoryTypeHintIndex(), new TokenizedNamespaceResolver())));
StreamWrapper::register();
}
/**
* @test
* @requires PHP 7.0
*/
function it_loads_a_spec_with_no_typehints()
{
require StreamWrapper::wrapPath(__DIR__.'/examples/ExampleSpec.php');
$reflection = new \ReflectionClass('integration\PhpSpec\Loader\examples\ExampleSpec');
$method = $reflection->getMethod('it_requires_a_stdclass');
$parameters = $method->getParameters();
$this->assertNull($parameters[0]->getClass());
}
}
PK 2^GM9?v-
-
4 integration/PhpSpec/Console/Prompter/FactoryTest.phpnu W+A reportingLevel = error_reporting();
error_reporting($this->reportingLevel & ~E_USER_DEPRECATED);
$this->input = $this->getMock('Symfony\Component\Console\Input\InputInterface');
$this->output = $this->getMock('Symfony\Component\Console\Output\OutputInterface');
}
/**
* Symfony <2.5 case
*
* @requires function \Symfony\Component\Console\Helper\DialogHelper::askConfirmation
* @test
*/
function it_provides_a_dialog_prompter_when_only_dialoghelper_is_registered()
{
$dialogHelper = $this->getMock('Symfony\Component\Console\Helper\DialogHelper');
$helperSet = new HelperSet(array(
'dialog' => $dialogHelper
));
$factory = new Factory($this->input, $this->output, $helperSet);
$prompter = $factory->getPrompter();
$this->assertInstanceOf('PhpSpec\Console\Prompter\Dialog', $prompter);
$dialogHelper->expects($this->once())->method('askConfirmation');;
$prompter->askConfirmation('Are you sure?');
}
/**
* Symfony >=3.0 case
*
* @requires function \Symfony\Component\Console\Helper\QuestionHelper::ask
* @test
*/
function it_provides_a_question_prompter_when_only_questionhelper_is_registered()
{
$questionHelper = $this->getMock('Symfony\Component\Console\Helper\QuestionHelper');
$helperSet = new HelperSet(array(
'question' => $questionHelper
));
$factory = new Factory($this->input, $this->output, $helperSet);
$prompter = $factory->getPrompter();
$this->assertInstanceOf('PhpSpec\Console\Prompter\Question', $prompter);
$questionHelper->expects($this->once())->method('ask');
$prompter->askConfirmation('Are you sure?');
}
/**
* Symfony >=2.5 <3.0 case
*
* @requires function \Symfony\Component\Console\Helper\QuestionHelper::ask
* @requires function \Symfony\Component\Console\Helper\DialogHelper::askConfirmation
* @test
*/
function it_provides_a_question_prompter_when_both_prompters_are_registered()
{
$dialogHelper = $this->getMock('Symfony\Component\Console\Helper\DialogHelper');
$questionHelper = $this->getMock('Symfony\Component\Console\Helper\QuestionHelper');
$helperSet = new HelperSet(array(
'dialog' => $dialogHelper,
'question' => $questionHelper
));
$factory = new Factory($this->input, $this->output, $helperSet);
$prompter = $factory->getPrompter();
$this->assertInstanceOf('PhpSpec\Console\Prompter\Question', $prompter);
$questionHelper->expects($this->once())->method('ask');
$prompter->askConfirmation('Are you sure?');
}
protected function tearDown()
{
error_reporting($this->reportingLevel);
}
}
PK 2^GMJm m 5 integration/PhpSpec/Console/Prompter/QuestionTest.phpnu W+A input = $this->getMock('Symfony\Component\Console\Input\InputInterface');
$this->output = $this->getMock('Symfony\Component\Console\Output\OutputInterface');
$this->questionHelper = $this->getMock('Symfony\Component\Console\Helper\QuestionHelper');
$this->prompter = new Question($this->input, $this->output, $this->questionHelper);
}
/**
* @test
*/
function it_is_a_prompter()
{
$this->assertInstanceOf('PhpSpec\Console\Prompter', $this->prompter);
}
/**
* @test
*/
function it_can_ask_a_question_and_return_the_result()
{
$this->questionHelper->expects($this->once())
->method('ask')
->with(
$this->identicalTo($this->input),
$this->identicalTo($this->output),
$this->equalTo(new ConfirmationQuestion('Are you sure?', true))
)
->willReturn(true);
$result = $this->prompter->askConfirmation('Are you sure?');
$this->assertEquals(true, $result);
}
}
PK 2^GM# 3 integration/PhpSpec/Console/Prompter/DialogTest.phpnu W+A output = $this->getMock('Symfony\Component\Console\Output\OutputInterface');
$this->dialogHelper = $this->getMockBuilder('Symfony\Component\Console\Helper\DialogHelper')
->disableOriginalConstructor()->getMock();
$this->prompter = new Dialog($this->output, $this->dialogHelper);
}
/**
* @test
*/
function it_is_a_prompter()
{
$this->assertInstanceOf('PhpSpec\Console\Prompter', $this->prompter);
}
/**
* @test
*/
function it_can_ask_a_question_and_return_the_result()
{
$this->dialogHelper->expects($this->once())
->method('askConfirmation')
->with($this->identicalTo($this->output), 'Are you sure?', true)
->willReturn(true);
$result = $this->prompter->askConfirmation('Are you sure?');
$this->assertEquals(true, $result);
}
}
PK 2^GM~ ~ .travis.ymlnu W+A language: php
sudo: false
cache:
directories:
- $HOME/.composer/cache
matrix:
include:
- php: 5.3
- php: 5.3.3
env: DEPENDENCIES='low'
- php: 5.4
- php: 5.5
- php: 5.6
env: DEPENDENCIES='dev'
- php: 5.6
- php: hhvm
- php: 7.0
allow_failures:
- env: DEPENDENCIES='dev'
fast_finish: true
before_install:
- composer selfupdate
- if [ "$DEPENDENCIES" == "low" ]; then composer config disable-tls true; fi;
install:
- export COMPOSER_ROOT_VERSION=dev-master
- if [ "$DEPENDENCIES" == "dev" ]; then perl -pi -e 's/^}$/,"minimum-stability":"dev"}/' composer.json; fi;
- if [ "$DEPENDENCIES" != "low" ]; then composer update; fi;
- if [ "$DEPENDENCIES" == "low" ]; then composer update --prefer-lowest; fi;
before_script:
- echo "= 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`
PK 2^GM9Ҹ behat.yml.distnu W+A default:
suites:
application:
contexts: [ ApplicationContext, FilesystemContext ]
filters: { tags: "~@isolated" }
isolated:
contexts: [ IsolatedProcessContext, FilesystemContext ]
filters: { tags: "@isolated" }
smoke:
contexts: [ IsolatedProcessContext, FilesystemContext ]
filters: { tags: "@smoke && ~@isolated" }
no-smoke:
suites:
smoke: ~
PK 2^GMw)
CHANGES.mdnu W+A 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
* No longer attempts to generate methods with reserved names
* Fixed bug where bootstrapped classes could not be loaded after class generation
* Fixed bug where line numbers were incorrectly reported on PHP 7
* Fixed new methods being inserted incorrectly when strings included closing brace
* Dot formatter now shows spec count on last line
2.4.1 / 2016-01-01
==================
* Correctly handle nested class definitions
* Correctly handle anonymous functions in code generation
* Fixed rerunning on Windows platform
* Fixed code generation on Windows platform
* Fixed issue with fatal errors being suppressed
* Handle underscores correctly when using PSR-4
* Fixed HTML formatter
2.4.0 / 2015-11-28
==================
* 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
* Warning added when trying to typehint scalars or callable in spec
* No longer truncates strings when diffing arrays in verbose mode
* New %resource_name% placeholder for generated specs
* Fixed case error in class name that triggered strictness warnings on some platforms
* Fixed undefined index error in some versions of Windows
* Clarified in composer that ext-tokenizer is required
* Supported installation with Symfony 3.0
* Fixed error when spec and src paths are the same
* New event is fired when phpspec creates a file
* Internal refactoring of Presenter objects
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
* Offers to make constructors private after generating a named constructor
* Shows a warning when a class is generated in a location that is not autoloadable
* Adds `%paths.config%` placeholder to allow config paths to be relative to config file
* Fixed invalid JUnit output in some non-EN locales
2.2.1 / 2015-05-30
==================
* Fix false positives in `shouldHaveKeyWithValue` matcher
* Fix fatal error in edge case when method call parameters don't match expectations
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
2.1.1 / 2015-01-09
==================
* Smoother rendering for progress bar
* Fixed progress bar for case where no examples are found
* Tidier output alignment + block width
* Removed deprecated calls to Yaml::parse
* More accurate lower bounds for composer installation
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
* Allow examples to mark themselves as skipped
* PSR-4 support
* PSR-0 locator now supports underscores correctly
* Ability to specify a custom bootstrap file using '--bootstrap' (for autoloader registration etc)
* Ability to have a personal .phpspec.yml in home folder
* Progress bar grows from left to right and flickers less
* Improved diffs for object comparison
* Throw an exception when construction method is redefined
* Non-zero exit code when dependencies are missing
* Respect exit code of commands other than 'run'
* Higher CLI verbosity levels are handled properly
* Code Generation and Stop on Failure are configurable through phpspec.yml
* Fixes for object instantiation changes in newer versions of PHP
* PHP 5.6 support
* Fixes for progress bar sometimes rounding up to 100% when not all specs passed
* Support for non-standard Composer autoloader location
* Improved hhvm support
* Extensions can now register new command
* Resource locator de-duplicates resources (supports custom locators in extensions)
2.0.1 / 2014-07-01
==================
* Fixed the loading of the autoloader for projects using a custom composer vendor folder
2.0.0 / 2014-03-19
==================
* 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
* Add psr0 validator
* Remove Nyan from core
* Added an exception if the specified config file does not exist
* 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
* Fixed the support of the ``--no-interaction`` option
* Added more events to add extension points
* Added the number of specs in the console output
* Fixed the handling of Windows line endings in the StringEngine and in reading doc comments
* Added extension points in the template loading
* 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
* Fix stack trace and matchers failure printing
2.0.0beta1 / 2013-04-29
=======================
* Initial release
PK 2^GM* Makefilenu W+A all:
@echo "Only build-phar target is currently supported."
build-phar:
@echo "--> Checking for composer command line tool"
command -v composer >/dev/null && continue || { echo "composer command not found."; exit 1; }
@echo "--> Cleaning vendor directory"
rm -Rfv vendor
@echo "--> Installing dependencies without dev"
composer install --no-dev
@echo "--> Building Phar"
box build
@echo "--> Success"
PK 2^GM- > spec/PhpSpec/Exception/Fracture/ClassNotFoundExceptionSpec.phpnu W+A beConstructedWith('Not equal', 'stdClass');
}
function it_is_fracture()
{
$this->shouldBeAnInstanceOf('PhpSpec\Exception\Fracture\FractureException');
}
function it_provides_a_link_to_classname()
{
$this->getClassname()->shouldReturn('stdClass');
}
}
PK 2^GM4 A spec/PhpSpec/Exception/Fracture/MethodNotVisibleExceptionSpec.phpnu W+A beConstructedWith('No method', $subject, 'setName', array('everzet'));
}
function it_is_fracture()
{
$this->shouldBeAnInstanceOf('PhpSpec\Exception\Fracture\FractureException');
}
function it_provides_a_link_to_subject($subject)
{
$this->getSubject()->shouldReturn($subject);
}
function it_provides_a_link_to_methodName()
{
$this->getMethodName()->shouldReturn('setName');
}
function it_provides_a_link_to_arguments()
{
$this->getArguments()->shouldReturn(array('everzet'));
}
}
PK 2^GMUC] I spec/PhpSpec/Exception/Fracture/NamedConstructorNotFoundExceptionSpec.phpnu W+A beConstructedWith('No named constructor', $subject, 'setName', array('jmurphy'));
}
function it_is_fracture()
{
$this->shouldBeAnInstanceOf('PhpSpec\Exception\Fracture\FractureException');
}
function it_provides_a_link_to_subject($subject)
{
$this->getSubject()->shouldReturn($subject);
}
function it_provides_a_link_to_methodName()
{
$this->getMethodName()->shouldReturn('setName');
}
function it_provides_a_link_to_arguments()
{
$this->getArguments()->shouldReturn(array('jmurphy'));
}
}
PK 2^GMLTt t H spec/PhpSpec/Exception/Fracture/InterfaceNotImplementedExceptionSpec.phpnu W+A beConstructedWith('Not equal', $subject, 'ArrayAccess');
}
function it_is_fracture()
{
$this->shouldBeAnInstanceOf('PhpSpec\Exception\Fracture\FractureException');
}
function it_provides_a_link_to_subject($subject)
{
$this->getSubject()->shouldReturn($subject);
}
function it_provides_a_link_to_interface()
{
$this->getInterface()->shouldReturn('ArrayAccess');
}
}
PK 2^GMQi i A spec/PhpSpec/Exception/Fracture/PropertyNotFoundExceptionSpec.phpnu W+A beConstructedWith('No method', $subject, 'attributes');
}
function it_is_fracture()
{
$this->shouldBeAnInstanceOf('PhpSpec\Exception\Fracture\FractureException');
}
function it_provides_a_link_to_subject($subject)
{
$this->getSubject()->shouldReturn($subject);
}
function it_provides_a_link_to_property()
{
$this->getProperty()->shouldReturn('attributes');
}
}
PK 2^GMU= ? spec/PhpSpec/Exception/Fracture/MethodNotFoundExceptionSpec.phpnu W+A beConstructedWith('No method', $subject, 'setName', array('everzet'));
}
function it_is_fracture()
{
$this->shouldBeAnInstanceOf('PhpSpec\Exception\Fracture\FractureException');
}
function it_provides_a_link_to_subject($subject)
{
$this->getSubject()->shouldReturn($subject);
}
function it_provides_a_link_to_methodName()
{
$this->getMethodName()->shouldReturn('setName');
}
function it_provides_a_link_to_arguments()
{
$this->getArguments()->shouldReturn(array('everzet'));
}
}
PK 2^GMG G spec/PhpSpec/Exception/Wrapper/InvalidCollaboratorTypeExceptionSpec.phpnu W+A beConstructedWith($parameter, $function);
}
function it_is_initializable()
{
$this->shouldHaveType('PhpSpec\Exception\Wrapper\InvalidCollaboratorTypeException');
$this->shouldHaveType('PhpSpec\Exception\Wrapper\CollaboratorException');
}
function it_generates_correct_message_based_on_function_and_parameter(
\ReflectionParameter $parameter,
\ReflectionMethod $function,
\ReflectionClass $class
) {
$parameter->getPosition()->willReturn(2);
$function->getDeclaringClass()->willReturn($class);
$class->getName()->willReturn('Acme\Foo');
$function->getName()->willReturn('bar');
$this->getMessage()->shouldStartWith('Collaborator must be an object: argument 2 defined in Acme\Foo::bar.');
}
function it_sets_cause(\ReflectionFunction $function)
{
$this->getCause()->shouldReturn($function);
}
}
PK 2^GMK`+| ( spec/PhpSpec/Exception/ExceptionSpec.phpnu W+A shouldBeAnInstanceOf('Exception');
}
function it_could_have_a_cause(ReflectionMethod $cause)
{
$this->setCause($cause);
$this->getCause()->shouldReturn($cause);
}
}
PK 2^GMӛe / spec/PhpSpec/Exception/ExceptionFactorySpec.phpnu W+A beConstructedWith($presenter);
$this->fixture = new \stdClass();
$this->fixture->subject = new \stdClass();
$this->fixture->method = 'foo';
$this->fixture->arguments = array('bar');
$this->fixture->classname = '\stdClass';
$this->fixture->property = 'zoo';
}
function it_creates_a_named_constructor_not_found_exception(PresenterInterface $presenter)
{
$presenter->presentString("{$this->fixture->classname}::{$this->fixture->method}")
->shouldBeCalled()
->willReturn("\"{$this->fixture->classname}::{$this->fixture->method}\"");
$this->fixture->message = 'Named constructor "\stdClass::foo" not found.';
$this->createdException = $this->namedConstructorNotFound(
$this->fixture->classname,
$this->fixture->method,
$this->fixture->arguments
);
$this->shouldCreateNamedConstructorNotFoundException();
}
function it_creates_a_method_not_found_exception(PresenterInterface $presenter)
{
$presenter->presentString("{$this->fixture->classname}::{$this->fixture->method}")
->shouldBeCalled()
->willReturn("\"{$this->fixture->classname}::{$this->fixture->method}\"");
$this->fixture->message = 'Method "\stdClass::foo" not found.';
$this->createdException = $this->methodNotFound(
$this->fixture->classname,
$this->fixture->method,
$this->fixture->arguments
);
$this->shouldCreateMethodNotFoundException();
}
function it_creates_a_method_not_visible_exception(PresenterInterface $presenter)
{
$presenter->presentString("{$this->fixture->classname}::{$this->fixture->method}")
->shouldBeCalled()
->willReturn("\"{$this->fixture->classname}::{$this->fixture->method}\"");
$this->fixture->message = 'Method "\stdClass::foo" not visible.';
$this->createdException = $this->methodNotVisible(
$this->fixture->classname,
$this->fixture->method,
$this->fixture->arguments
);
$this->shouldCreateMethodNotVisibleException();
}
function it_creates_a_class_not_found_exception(PresenterInterface $presenter)
{
$presenter->presentString("{$this->fixture->classname}")
->shouldBeCalled()
->willReturn("\"{$this->fixture->classname}\"");
$this->fixture->message = 'Class "\stdClass" does not exist.';
$this->createdException = $this->classNotFound(
$this->fixture->classname
);
$this->shouldCreateClassNotFoundException();
}
function it_creates_a_property_not_found_exception(PresenterInterface $presenter)
{
$presenter->presentString("{$this->fixture->property}")
->shouldBeCalled()
->willReturn("\"{$this->fixture->property}\"");
$this->fixture->message = 'Property "zoo" not found.';
$this->createdException = $this->propertyNotFound(
$this->fixture->subject,
$this->fixture->property
);
$this->shouldCreatePropertyNotFoundException();
}
function it_creates_a_calling_method_on_non_object_exception(PresenterInterface $presenter)
{
$presenter->presentString("{$this->fixture->method}()")
->shouldBeCalled()
->willReturn("\"{$this->fixture->method}()\"");
$fixtureMessage = "Call to a member function \"{$this->fixture->method}()\" on a non-object.";
$exception = $this->callingMethodOnNonObject($this->fixture->method);
$exception->shouldHaveType('PhpSpec\Exception\Wrapper\SubjectException');
$exception->getMessage()->shouldBe($fixtureMessage);
}
function it_creates_a_setting_property_on_non_object_exception(PresenterInterface $presenter)
{
$presenter->presentString("{$this->fixture->property}")
->shouldBeCalled()
->willReturn("\"{$this->fixture->property}\"");
$fixtureMessage = "Setting property \"{$this->fixture->property}\" on a non-object.";
$exception = $this->settingPropertyOnNonObject($this->fixture->property);
$exception->shouldHaveType('PhpSpec\Exception\Wrapper\SubjectException');
$exception->getMessage()->shouldBe($fixtureMessage);
}
function it_creates_an_accessing_property_on_non_object_exception(PresenterInterface $presenter)
{
$presenter->presentString("{$this->fixture->property}")
->shouldBeCalled()
->willReturn("\"{$this->fixture->property}\"");
$fixtureMessage = "Getting property \"{$this->fixture->property}\" on a non-object.";
$exception = $this->gettingPropertyOnNonObject($this->fixture->property);
$exception->shouldHaveType('PhpSpec\Exception\Wrapper\SubjectException');
$exception->getMessage()->shouldBe($fixtureMessage);
}
function shouldCreateNamedConstructorNotFoundException()
{
$this->createdException->shouldHaveType('PhpSpec\Exception\Fracture\NamedConstructorNotFoundException');
$this->createdException->getMessage()->shouldReturn($this->fixture->message);
$this->createdException->getSubject()->shouldBeLike($this->fixture->subject);
$this->createdException->getMethodName()->shouldReturn($this->fixture->method);
$this->createdException->getArguments()->shouldReturn($this->fixture->arguments);
}
function shouldCreateMethodNotFoundException()
{
$this->createdException->shouldHaveType('PhpSpec\Exception\Fracture\MethodNotFoundException');
$this->createdException->getMessage()->shouldReturn($this->fixture->message);
$this->createdException->getSubject()->shouldBeLike($this->fixture->subject);
$this->createdException->getMethodName()->shouldReturn($this->fixture->method);
$this->createdException->getArguments()->shouldReturn($this->fixture->arguments);
}
function shouldCreateMethodNotVisibleException()
{
$this->createdException->shouldHaveType('PhpSpec\Exception\Fracture\MethodNotVisibleException');
$this->createdException->getMessage()->shouldReturn($this->fixture->message);
$this->createdException->getSubject()->shouldBeLike($this->fixture->subject);
$this->createdException->getMethodName()->shouldReturn($this->fixture->method);
$this->createdException->getArguments()->shouldReturn($this->fixture->arguments);
}
function shouldCreateClassNotFoundException()
{
$this->createdException->shouldHaveType('PhpSpec\Exception\Fracture\ClassNotFoundException');
$this->createdException->getMessage()->shouldReturn($this->fixture->message);
$this->createdException->getClassname()->shouldReturn($this->fixture->classname);
}
function shouldCreatePropertyNotFoundException()
{
$this->createdException->shouldHaveType('PhpSpec\Exception\Fracture\PropertyNotFoundException');
$this->createdException->getMessage()->shouldReturn($this->fixture->message);
$this->createdException->getSubject()->shouldReturn($this->fixture->subject);
$this->createdException->getProperty()->shouldReturn($this->fixture->property);
}
}
PK 2^GM' ' 8 spec/PhpSpec/Exception/Example/NotEqualExceptionSpec.phpnu W+A beConstructedWith('Not equal', 2, 5);
}
function it_is_failure()
{
$this->shouldBeAnInstanceOf('PhpSpec\Exception\Example\FailureException');
}
function it_provides_a_link_to_expected()
{
$this->getExpected()->shouldReturn(2);
}
function it_provides_a_link_to_actual()
{
$this->getActual()->shouldReturn(5);
}
}
PK 2^GM+ = spec/PhpSpec/Exception/Example/StopOnFailureExceptionSpec.phpnu W+A beConstructedWith('Message', 0, null, 1);
}
function it_is_an_example_exception()
{
$this->shouldBeAnInstanceOf('PhpSpec\Exception\Example\ExampleException');
}
function it_has_a_the_result_of_the_last_spec()
{
$this->getResult()->shouldReturn(1);
}
}
PK 2^GMo
0 spec/PhpSpec/Formatter/ProgressFormatterSpec.phpnu W+A beConstructedWith($presenter, $io, $stats);
}
function it_is_an_event_subscriber()
{
$this->shouldHaveType('Symfony\Component\EventDispatcher\EventSubscriberInterface');
}
function it_outputs_progress_as_0_when_0_examples_have_run(ExampleEvent $event, IO $io, StatisticsCollector $stats)
{
$stats->getEventsCount()->willReturn(0);
$stats->getCountsHash()->willReturn(array(
'passed' => 0,
'pending' => 0,
'skipped' => 0,
'failed' => 0,
'broken' => 0,
));
$stats->getTotalSpecs()->willReturn(0);
$stats->getTotalSpecsCount()->willReturn(0);
$this->afterExample($event);
$expected = '/ skipped: 0% / pending: 0% / passed: 0% / failed: 0% / broken: 0% / 0 examples';
$io->writeTemp($expected)->shouldHaveBeenCalled();
}
function it_outputs_progress_as_0_when_0_examples_have_passed(ExampleEvent $event, IO $io, StatisticsCollector $stats)
{
$stats->getEventsCount()->willReturn(1);
$stats->getCountsHash()->willReturn(array(
'passed' => 1,
'pending' => 0,
'skipped' => 0,
'failed' => 0,
'broken' => 0,
));
$stats->getTotalSpecs()->willReturn(1);
$stats->getTotalSpecsCount()->willReturn(1);
$this->afterExample($event);
$expected = '/ skipped: 0% / pending: 0% / passed: 100% / failed: 0% / broken: 0% / 1 examples';
$io->writeTemp($expected)->shouldHaveBeenCalled();
}
function it_outputs_progress_as_100_when_1_of_3_examples_have_passed(ExampleEvent $event, IO $io, StatisticsCollector $stats)
{
$stats->getEventsCount()->willReturn(1);
$stats->getCountsHash()->willReturn(array(
'passed' => 1,
'pending' => 0,
'skipped' => 0,
'failed' => 0,
'broken' => 0,
));
$stats->getTotalSpecs()->willReturn(1);
$stats->getTotalSpecsCount()->willReturn(3);
$this->afterExample($event);
$expected = '/ skipped: 0% / pending: 0% / passed: 100% / failed: 0% / broken: 0% / 1 examples';
$io->writeTemp($expected)->shouldHaveBeenCalled();
}
function it_outputs_progress_as_33_when_3_of_3_examples_have_run_and_one_passed(ExampleEvent $event, IO $io, StatisticsCollector $stats)
{
$stats->getEventsCount()->willReturn(3);
$stats->getCountsHash()->willReturn(array(
'passed' => 1,
'pending' => 0,
'skipped' => 0,
'failed' => 2,
'broken' => 0,
));
$stats->getTotalSpecs()->willReturn(3);
$stats->getTotalSpecsCount()->willReturn(3);
$this->afterExample($event);
$expected = '/ skipped: 0% / pending: 0% / passed: 33% / failed: 66% / broken: 0% / 3 examples';
$io->writeTemp($expected)->shouldHaveBeenCalled();
}
}
PK 2^GMl + spec/PhpSpec/Formatter/DotFormatterSpec.phpnu W+A beConstructedWith($presenter, $io, $stats);
}
function it_is_a_console_formatter()
{
$this->shouldHaveType('PhpSpec\Formatter\ConsoleFormatter');
}
function it_outputs_a_dot_for_a_passed_example(
ExampleEvent $event,
IO $io,
StatisticsCollector $stats
) {
$event->getResult()->willReturn(ExampleEvent::PASSED);
$this->afterExample($event);
$io->write(".")->shouldHaveBeenCalled();
}
function it_outputs_a_p_for_a_pending_example(
ExampleEvent $event,
IO $io,
StatisticsCollector $stats
) {
$event->getResult()->willReturn(ExampleEvent::PENDING);
$this->afterExample($event);
$io->write('P')->shouldHaveBeenCalled();
}
function it_outputs_an_s_for_a_skipped_example(
ExampleEvent $event,
IO $io,
StatisticsCollector $stats
) {
$event->getResult()->willReturn(ExampleEvent::SKIPPED);
$this->afterExample($event);
$io->write('S')->shouldHaveBeenCalled();
}
function it_outputs_an_f_for_a_failed_example(
ExampleEvent $event,
IO $io,
StatisticsCollector $stats
) {
$event->getResult()->willReturn(ExampleEvent::FAILED);
$this->afterExample($event);
$io->write('F')->shouldHaveBeenCalled();
}
function it_outputs_a_b_for_a_broken_example(
ExampleEvent $event,
IO $io,
StatisticsCollector $stats
) {
$event->getResult()->willReturn(ExampleEvent::BROKEN);
$this->afterExample($event);
$io->write('B')->shouldHaveBeenCalled();
}
function it_outputs_the_progress_every_50_examples(
ExampleEvent $exampleEvent,
SuiteEvent $suiteEvent,
IO $io,
StatisticsCollector $stats
) {
$exampleEvent->getResult()->willReturn(ExampleEvent::PASSED);
$suiteEvent->getSuite()->willReturn(range(1, 100));
$stats->getEventsCount()->willReturn(50);
$this->beforeSuite($suiteEvent);
$this->afterExample($exampleEvent);
$io->write(' 50 / 100')->shouldHaveBeenCalled();
}
function it_outputs_exceptions_for_failed_examples(
SuiteEvent $event,
ExampleEvent $pendingEvent,
IO $io,
StatisticsCollector $stats,
SpecificationNode $specification,
ExampleNode $example,
ReflectionFunctionAbstract $reflectionFunction
) {
$reflectionFunction->getStartLine()->willReturn(37);
$example->getFunctionReflection()->willReturn($reflectionFunction);
$example->getTitle()->willReturn('it tests something');
$pendingEvent->getException()->willReturn(new PendingException());
$pendingEvent->getSpecification()->willReturn($specification);
$pendingEvent->getExample()->willReturn($example);
$stats->getEventsCount()->willReturn(1);
$stats->getFailedEvents()->willReturn(array());
$stats->getBrokenEvents()->willReturn(array());
$stats->getPendingEvents()->willReturn(array($pendingEvent));
$stats->getSkippedEvents()->willReturn(array());
$stats->getTotalSpecs()->willReturn(1);
$stats->getCountsHash()->willReturn(array(
'passed' => 0,
'pending' => 1,
'skipped' => 0,
'failed' => 0,
'broken' => 0,
));
$this->afterSuite($event);
$expected = ' 37 - it tests something';
$io->writeln($expected)->shouldHaveBeenCalled();
}
function it_outputs_a_suite_summary(
SuiteEvent $event,
IO $io,
StatisticsCollector $stats
) {
$stats->getEventsCount()->willReturn(1);
$stats->getFailedEvents()->willReturn(array());
$stats->getBrokenEvents()->willReturn(array());
$stats->getPendingEvents()->willReturn(array());
$stats->getSkippedEvents()->willReturn(array());
$stats->getTotalSpecs()->willReturn(15);
$event->getTime()->willReturn(12.345);
$stats->getCountsHash()->willReturn(array(
'passed' => 1,
'pending' => 0,
'skipped' => 0,
'failed' => 2,
'broken' => 0,
));
$this->afterSuite($event);
$io->writeln('15 specs')->shouldHaveBeenCalled();
$io->writeln("\n12345ms")->shouldHaveBeenCalled();
$io->write('1 example ')->shouldHaveBeenCalled();
$expected = '(1 passed, 2 failed)';
$io->write($expected)->shouldHaveBeenCalled();
}
}
PK 2^GMtX{ - spec/PhpSpec/Formatter/BasicFormatterSpec.phpnu W+A beAnInstanceOf('spec\PhpSpec\Formatter\TestableBasicFormatter');
$this->beConstructedWith($presenter, $io, $stats);
}
function it_is_an_event_subscriber()
{
$this->shouldHaveType('Symfony\Component\EventDispatcher\EventSubscriberInterface');
}
function it_returns_a_list_of_subscribed_events()
{
$this::getSubscribedEvents()->shouldBe(
array(
'beforeSuite' => 'beforeSuite',
'afterSuite' => 'afterSuite',
'beforeExample' => 'beforeExample',
'afterExample' => 'afterExample',
'beforeSpecification' => 'beforeSpecification',
'afterSpecification' => 'afterSpecification'
)
);
}
}
class TestableBasicFormatter extends BasicFormatter
{
}
PK 2^GMp 4 spec/PhpSpec/Formatter/Html/ReportPassedItemSpec.phpnu W+A beConstructedWith($template, $event);
}
function it_writes_a_pass_message_for_a_passing_example(Template $template, ExampleEvent $event)
{
$event->getTitle()->willReturn(self::EVENT_TITLE);
$template->render(Template::DIR.'/Template/ReportPass.html', array(
'title' => self::EVENT_TITLE
))->shouldBeCalled();
$this->write();
}
}
PK 2^GM 5 spec/PhpSpec/Formatter/Html/ReportPendingItemSpec.phpnu W+A beConstructedWith($template, $event);
}
function it_writes_a_pass_message_for_a_passing_example(Template $template, ExampleEvent $event)
{
$event->getTitle()->willReturn(self::EVENT_TITLE);
$template->render(Template::DIR.'/Template/ReportPending.html', array(
'title' => self::EVENT_TITLE,
'pendingExamplesCount' => 1
))->shouldBeCalled();
$this->write();
}
}
PK 2^GM1ӝ 5 spec/PhpSpec/Formatter/Html/ReportItemFactorySpec.phpnu W+A beConstructedWith($template);
}
function it_creates_a_ReportPassedItem(ExampleEvent $event, Presenter $presenter)
{
$event->getResult()->willReturn(ExampleEvent::PASSED);
$this->create($event, $presenter)->shouldHaveType('PhpSpec\Formatter\Html\ReportPassedItem');
}
function it_creates_a_ReportPendingItem(ExampleEvent $event, Presenter $presenter)
{
$event->getResult()->willReturn(ExampleEvent::PENDING);
$this->create($event, $presenter)->shouldHaveType('PhpSpec\Formatter\Html\ReportPendingItem');
}
function it_creates_a_ReportFailedItem(ExampleEvent $event, Presenter $presenter)
{
$event->getResult()->willReturn(ExampleEvent::FAILED);
$this->create($event, $presenter)->shouldHaveType('PhpSpec\Formatter\Html\ReportFailedItem');
}
function it_creates_a_ReportBrokenItem(ExampleEvent $event, Presenter $presenter)
{
$event->getResult()->willReturn(ExampleEvent::BROKEN);
$this->create($event, $presenter)->shouldHaveType('PhpSpec\Formatter\Html\ReportFailedItem');
}
}
PK 2^GM!+u 4 spec/PhpSpec/Formatter/Html/ReportFailedItemSpec.phpnu W+A 42, 'file' => '/some/path/to/SomeException.php')
);
const BACKTRACE = "#42 /some/path/to/SomeException.php";
const CODE = 'code';
function let(Template $template, ExampleEvent $event, Presenter $presenter)
{
$this->beConstructedWith($template, $event, $presenter);
}
function it_writes_a_fail_message_for_a_failing_example(Template $template, ExampleEvent $event, Presenter $presenter)
{
$event->getTitle()->willReturn(self::EVENT_TITLE);
$event->getMessage()->willReturn(self::EVENT_MESSAGE);
$event->getBacktrace()->willReturn(self::$BACKTRACE);
$event->getException()->willReturn(new \Exception());
$template->render(Template::DIR.'/Template/ReportFailed.html', array(
'title' => self::EVENT_TITLE,
'message' => self::EVENT_MESSAGE,
'backtrace' => self::BACKTRACE,
'code' => self::CODE,
'index' => 1,
'specification' => 1
))->shouldBeCalled();
$presenter->presentException(Argument::cetera())->willReturn(self::CODE);
$this->write(1);
}
}
PK 2^GM