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

How can I create an array of mocks in PHPSpec?

I've just started using PHPSpec and I'm really enjoying it over PHPUnit, especially the no-effort mocks and stubs. Anyway, the method I'm trying to test expects an array of Cell objects. How can I tell PHPSpec to give me an array of…
Kevin Nagurski
  • 1,889
  • 11
  • 24
2
votes
2 answers

How to create global custom matchers in PHPSpec?

I'm testing with PHPSpec, and I've got custom matchers in my spec files that I don't want to have to repeat in every file in which they're used. I want to be able to extend PHPSpec's behaviour and/or the behaviour of all my tests to use a global set…
Rick Gladwin
  • 4,225
  • 1
  • 17
  • 21
2
votes
1 answer

How to make phpspec evaluate my constructor

public function __construct(RequestSchemaInterface $requestSchema) { $this->schema = $requestSchema->getSchema(); } When I run phpspec for Builder then $this->schema is always null. In normal call it sets schema. I got let implemented function…
nomysz
  • 187
  • 1
  • 9
2
votes
1 answer

phpspec creates files in wrong folders per psr-4 namespace specification

I scrapped the earlier form of my question because it was too convoluted. Here's the new version. I want to use phpspec with my psr-4 formatted projects. Here's the way I tried to set up a test project: Created a new folder for the project: cd…
Chris Schmitz
  • 20,160
  • 30
  • 81
  • 137
2
votes
1 answer

Testing command handler with phpspec

Lately I'm giving a try to phpspec. It works great, but I have got a problem with testing command handlers. For example in PHPUnit I test it that way: /** * @test */ public function it_should_change_an_email() { …
tommy
  • 388
  • 2
  • 14
2
votes
1 answer

Test parent-child bidirectional relations using PHPSpec

How to test with phpspec that parent-child biedirectional relations are created properly? class ParentSpec extends ObjectBehavior { function it_adds_a_reference_to_self_while_(Child $child) { $this->addChild($child); …
LNow
  • 68
  • 5
2
votes
1 answer

How to test this class or rewrite it to be testable? phpspec

This class is fairly simple, it adds a twitter hashtag to a string if there is room for it. Twitter only allows 140 characters (minus 23 for a url). So the hashtags keep getting added if there is space for one. I don't think it's 100% working as…
EvWill
  • 392
  • 1
  • 4
  • 13
2
votes
1 answer

Error "Can not find appropriate suite scope for class" when running 'phpspec describe'

I'm trying to get phpspec running with Laravel, following this video I install it ok with composer, and add an alias, but when I run: phpspec describe Shipping' I get an error: [RuntimeException] Can not find appropriate suite scope for class…
Positonic
  • 9,151
  • 14
  • 57
  • 84
2
votes
1 answer

Phpspec matching fails with stdClass Object

Working with a laravel 5 app and have a problem with phpspec. Why does my Phpspec unit test below fail or more precisely how can I get the stdClass Object keys to match so that it wouldn't fail? My spec file: function…
FellowFinn
  • 25
  • 4
2
votes
3 answers

How do I call Validator from a namespace with an already existing Validator class

I'm trying to test a function in phpspec which calls Laravel's Validator::make function (http://laravel.com/docs/4.2/validation) However, I'm trying to call that same function from a namespace where the Validator class name is already taken. How can…
A F
  • 7,424
  • 8
  • 40
  • 52
2
votes
1 answer

Mocking problems with PhpSpec and Prophecy

I am trying to test a method that I have using PhpSpec and Prophecy. I am having a little trouble getting it to work, though. I don't want to use actual values for the mock, so I have used Argument::any(), but it seems to be wanting to execute the…
will
  • 1,491
  • 1
  • 19
  • 28
2
votes
1 answer

Accepting all parameters in phpsepc2 mocks

How i can accept all parameters in function mock with #phpspec2? for example i have code like this: $em->persist($entity)->willReturn(true); I don't want mock all possible parameters, it should accept every entity.
Paweł Mikołajczuk
  • 3,692
  • 25
  • 32
2
votes
1 answer

Run phpspec via travis-ci

I am trying to run phpspec via travis-ci. The specs run fine on my local machine, but on travis it doesn't find the phpspec file. 0.01s$ bin/phpspec run -v /home/travis/build.sh: line 41: bin/phpspec: No such file or directory The command…
Lukas Oppermann
  • 2,918
  • 6
  • 47
  • 62
2
votes
0 answers

PHPSpec with multiple suites only consider the last one

I'm trying to use PHPSpec with multiple suites. This is needed because my app has several paths that does not necessary mathes a namespace (it's a Code Igniter application). I've set the phpspec.yml like this: suites: multi24_libs: …
paulodiovani
  • 1,208
  • 2
  • 16
  • 34
2
votes
2 answers

PHPSpec always says my spec doesnt exist

I have started a composer project and have included phpspec-st, when I run the command: /var/www/yii-video-site/vendor$ bin/phpspec desc videosite/test I get the message: Specification for videosite\test created in…
Paul Preibisch
  • 4,115
  • 2
  • 27
  • 32
1 2
3
13 14