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
1
vote
1 answer

Test contents of return array in PHPSpec

Say I have this method of a RuleFactory: public function makeFromArray($rules) { $array = []; foreach ($rules as $rule) { $array[] = new Rule($rule[0], $rule[1]); } return $array; } I want to test that the return array…
AgmLauncher
  • 7,070
  • 8
  • 41
  • 67
1
vote
1 answer

PHPSpec: Issue stubbing out PDO::execute

I'm having an issue stubbing out PDO::execute using PHPSpec and prophecy, but I keep getting an error that: 29 ! it should perform PDO queries method `Double\PDO\P3::execute()` is not defined. 0…
seagoj
  • 259
  • 1
  • 2
  • 14
1
vote
1 answer

clear example of using PHPSpec with Laravel

I've scoured the net and cannot find a clear example of using PHPSpec with Laravel for specifying the behaviour of Models. I've watched the Jeffrey Way video on Laracasts, which shows how to test other classes within a Laravel project but not…
Adamski
  • 3,585
  • 5
  • 42
  • 78
1
vote
1 answer

Is it possible to use phpspec with functional programming?

Is it possible to use phpspec in functional programming? I would like to use it in Drupal project but can't find any useful example. As far as I see phpspec can be used only with OO programming. Is it true? Thanks.
sobi3ch
  • 2,555
  • 2
  • 31
  • 41
1
vote
1 answer

phpspec testing file contents / file operations

I'm curious about the best way of speccing classes that handle file operations. Assuming I have a fictional class with a method duplicate whose job is to duplicate the contents of a file.
Adam
  • 5,091
  • 5
  • 32
  • 49
1
vote
1 answer

Using phpspec to test two-way relationships that require pass by reference

I'm using phpspec to test my zend 2 module and having issues with testing pass-by-reference. I've read other topics about this that state it's bad design if you are having to do this. I disagree that this a blanket statement. I need to represent a…
Jeremiah
  • 751
  • 9
  • 21
1
vote
1 answer

Testing abstract class with static properties

I'm new to testing and I'm using phpspec to test a service class which validates input. I'm not sure how to test the class because it uses static::$base_rules and static::$create_rules. Those values are determined by the child class extending…
Mark Lewis
  • 157
  • 2
  • 13
1
vote
2 answers

How to test parent call method in a class for phpspec

I have a class with parent call method in it. I want to make sure that parent have been called so that when I edit tested method and remove that line it will fail tests My class: public function myMethod($object) { parent::myMethod($object); …
TroodoN-Mike
  • 15,687
  • 15
  • 55
  • 78
1
vote
1 answer

PHPSpec how to ask if a method returns either this or that

I have a method which queries the database and either returns an array with the results or false if there are no results. All I need PHPSpec to do in this case is test whether it returns an array or false, but I can't work out how to do that. Or do…
alexleonard
  • 1,314
  • 3
  • 21
  • 37
1
vote
1 answer

phpspec issue with testing if a prophecy object exists within a SplObjectStorage

Can anyone explain to me why the follow test isn't passing? Code under test public function doesItExist( $obj, $dataSet ){ if( $dataSet->contains( $obj ) ){ return true; } return false; } phpspec test function…
Alan Quigley
  • 1,642
  • 2
  • 15
  • 19
1
vote
1 answer

PHPSpec - Check if Method Returns a file

I am new to phpspec, and I am trying to test if a method returns a file. The method is essentially: public function getFile(){ return file_get_contents('myFile.pdf'); } So my initial though was to test if getFile() returns a string since…
Bradley Trager
  • 3,570
  • 3
  • 26
  • 33
1
vote
1 answer

phpspec in vagrant vm - permissions error

I am setting up a new Laravel project and wishing to use PHPSpec within the project. I can run PHPSPec from my local OSX machine, but I want to be able to run it from within the VM. I get "command not found" or "Permission denied" errors when…
Adamski
  • 3,585
  • 5
  • 42
  • 78
1
vote
1 answer

phpspec, I would like call shouldBeCalled on a dispatcher

I search the possibility to have a functionnal test with phpspec about dispatcher symfony2 I would like to do this : $dispatcher->dispatch('workflow.post_extract', $event)->shouldBeCalled(); My code is here : function…
1
vote
0 answers

Test Symfony 2 bundle with Guzzle API client with phpspec

Good morning! I have recently created a Symfony 2 bundle that integrates with a third party API. I have used Guzzle with the awesome service description to create the client and call the API. Now I want to improve the quality and add some testing to…
evancauwenberg
  • 233
  • 3
  • 8
1
vote
2 answers

PHP Class not found from a different namespace

I'm currently working on a Symfony2 project with Phpspec and I'm having problems to extend a Spec class described in a different namespace. In my project, for instance, I'm having the following class described in spec/Acme/Model/Foo/FooSpec.php…
Ian Letourneau
  • 415
  • 5
  • 17