Questions tagged [phpspec]

A php toolset to drive emergent design by specification.

phpspec is a development tool, designed to help you achieve clean and working PHP code by using a technique derived from test-first development called (spec) behaviour driven development, or SpecBDD.

The technique consists of describing the next object behaviour (spec) you are about to implement, using a tool like phpspec, then writing just enough code to quickly satisfy that specification and finally stopping to refactor the last increment, allowing the emergent design to guide the direction. This is done in small iterative steps.

www.phpspec.net

200 questions
2
votes
1 answer

phpspec spec_path location configuration

Can't figure this out and the docs are not especially helpful in this case. I have a package structure like this: -src/ - Acme/ - Foo/ - Component1/ - Component2/ … What I try to achieve is that every testsuite should be…
iwyg
  • 210
  • 3
  • 11
2
votes
1 answer

Stub for formal parameter passed by reference in PHPSpec/Prophecy

I have a method in PHP which looks like this:
Janusz Slota
  • 383
  • 1
  • 3
  • 17
2
votes
3 answers

Should I use positive and negative assertions in BDD?

Which of these is better: function it_should_return_number_of_string_provided() { $this->add(1)->shouldReturn(1); $this->add(1)->shouldNotReturn(2); } function it_should_return_number_of_string_provided() { …
Marty Wallace
  • 34,046
  • 53
  • 137
  • 200
2
votes
1 answer

Testing for PUT/POST/DELETE Methods

I am having some trouble running tests for PUT, POST and DELETE using the unit testing framework phpspec2. This is the code that I have in my unit test: $this->beConstructedWith(new \Tonic\Application(), new \Tonic\Request(array( 'uri' => '/', …
Nalum
  • 4,143
  • 5
  • 38
  • 55
1
vote
0 answers

Can't run a suite of test for PhpSpec code coverage on jenkins file

I'm running a jenkins job to report the code coverage for my php spec tests. My problem is that I have two separate path for those tests and I want to report the code coverage for both of them. Since php spec doesn't let you specify a suite of tests…
1
vote
0 answers

Phpspec global composer install not working

I have installed phpspec through composer within codebase root by doing composer require phpspec/phpspec. I wanted to run it without prefixing it each time with vendor/bin, but I also didn't want to add that to PATH, so I installed it globally first…
Norgul
  • 4,613
  • 13
  • 61
  • 144
1
vote
1 answer

Custom PhpSpec matcher and/or extension not working

I'm trying to test if a class is final. Since I've not found a default matcher for this (or any other clean way of testing it), I decided to create a custom extension which adds a new matcher to do just that, but I can't get it to work. I've tried…
Nico V
  • 107
  • 1
  • 9
1
vote
4 answers

How to quickly write debug output from within a PHP Spec test method

I have inherited some phpspec tests. The test is testing the value of a method called "getFatalErrors" and reporting failure with: expected [array:1], but got [array:1]. I would like to see the actual contents of the array. I have tried to hack…
1
vote
0 answers

Use testing environment variables in PHPSpec

I have a service that use getenv function to set some properties. The environment variables are set with a symfony/dotenv component. class BrowshotConfiguration { private $apiKey; public function __construct() { …
pepper
  • 1,732
  • 2
  • 17
  • 33
1
vote
2 answers

How to create class variables in a PHPSpec spec file that can be used for all examples in the spec

I have a PHPSpec class with many examples. I want to be able to create class variables in the spec class that can be used by any example function in the class. Below is a very simplified version: class ThingImTestingSpec extends ObjectBehavior { …
Rick Gladwin
  • 4,225
  • 1
  • 17
  • 21
1
vote
1 answer

Why phpspec can not find classes?

I use PHPSPEC 3.4.0.When I run phpsec with vendor/bin/phpspec run I get this error: class Eastsea\Service\FileStorage\DuplicateFileStorage does not exist. Here is my composer.json file about autoload section: "autoload": { "psr-4": { …
macc
  • 105
  • 9
1
vote
1 answer

PHPSpec - testing with AbstractSpec

Don't find this solution, as more people try testing abstract classes. This is not what i want. I have patter strategy, and all classes should implements interface. Wanted to add base spec, that rest should extends and add own things. I should…
timiTao
  • 1,417
  • 3
  • 20
  • 34
1
vote
1 answer

How, if possible, to configure PHPSpec with no namespace and psr-4

I'm adding composer and PHPSpec to an established proprietary framework but I am unable to get PHPSpec to work with the global namespace when the classes to be tested reside in a non-standard directory which must be defined using psr-4. The file…
ThisLeeNoble
  • 150
  • 9
1
vote
0 answers

Phpspec shouldBeCalled in loop

I have a some collaborator and I want a method to be called on this collaborator. Since in implemented method, collaborator is in for loop, phpspec gives me a No calls have been made that match error. If I place the code outside of the loop, the…
Lord Zed
  • 750
  • 7
  • 28
1
vote
2 answers

Getting clone method called on non-object when specing Symfony command that uses SymfonyStyle for styled output

I'm trying to spec Symfony command and I want to have formated output with SymfonyStyle
Lord Zed
  • 750
  • 7
  • 28