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
0
votes
1 answer

phpspec force method-returned value

I am trying to test a class method that gets its data from another method. So I did this : function it_should_return_json_file_as_array() { $this->exist()->willReturn(true); $this->read()->willReturn("{\"key\":\"value\"}"); …
0
votes
1 answer

Stubbing a stateful object in PHPSpec (or any unit testing framework)

How would you go about stubbing a DTO that also contains some logic (which kind of makes it more than a DTO anyway)? Would you even stub it? Consider this simple example: class Context { /** * @var string */ private $value; …
rdiz
  • 6,136
  • 1
  • 29
  • 41
0
votes
1 answer

PHPSpec with Mock example test always returns null but implementation works as expected

I want to start with PHPSpec, so I'm working with two simple classes. The first one is responsible for applying a percentage reduce or enlarge to number, and the second one is responsible for calculate a product price with use of percentage applyer…
Karol F
  • 1,556
  • 2
  • 18
  • 33
0
votes
1 answer

Laravel Controller testing

I am trying to test some laravel controllers but am not doing so well so far. I am meant to be using PHPSpec to do this. I have no idea where to start and I am meant to be testing the crud functionality of the controller. I understand how I might be…
csc
  • 59
  • 2
  • 7
0
votes
2 answers

'phpspec' is not recognized as an internal or external command, operable program or batch file

I'm using Windows. I installed phpspec package with composer, I added the folder phpspec/bin/ to my system's path variable. But when I try to run phpspec command I get the following error: 'phpspec' is not recognized as an internal or external…
Amaynut
  • 4,091
  • 6
  • 39
  • 44
0
votes
1 answer

application testing with PHPSpec and PHPUnit

Is it possible to with two different testing methodologies? For example PHPUnit and PHPSpec in the one applicationor package? Does anyone have any guidance?
AndrewMcLagan
  • 13,459
  • 23
  • 91
  • 158
0
votes
1 answer

PHPSpec and Laravel

What is the point in using PHPSpec if I cant access or use any Eloquent methods? For example: ($this reffers to an Eloquent Product model) function it_removes_property(PropertyValueInterface $property) { $this->addProperty($property); …
AndrewMcLagan
  • 13,459
  • 23
  • 91
  • 158
0
votes
2 answers

running phpspec from windows CMD creates the spec and src folders in vendor/bin instead of the project root

Lately I've been learning about phpspec and gulp and decided to integrate them in my workflow. When I installed phpspec via composer, I get the file structure of: vendor bin phpspec there are more files but and folders but these are the…
kfirba
  • 5,231
  • 14
  • 41
  • 70
0
votes
1 answer

Phpspec testing class constructor

I've just started using Phpspec on my Laravel project. The class I'm testing has the following schema: class Card { /** * @var int */ private $rank; /** * @var int */ private $suit; /** * @param int…
0
votes
1 answer

Testing API wrapper with phpspec

I'm trying to create a wrapper for an API class using TDD with phpspec. I've written a Client class which deals with requesting/retrieving data from a REST API which is then mapped to of one several Entity classes, so it behaves like an ORM. I'm a…
Mike F
  • 358
  • 1
  • 5
  • 14
0
votes
1 answer

PhpSpec expected call exact

I have a method for my Laravel5 application I'm trying to test in PhpSpec but it keeps throwing the following error: App/Helpers/RecurrRule 37 ! it should return a recurrence collection method call: …
alexleonard
  • 1,314
  • 3
  • 21
  • 37
0
votes
1 answer

mocking database in derived class

I've got Repository classes which implement a specific interface and also extend a base class for the specific database. base class: abstract class CouchDB { protected $db; public function __construct(Sag $db) { $this->db = $db; } …
soupdiver
  • 3,504
  • 9
  • 40
  • 68
0
votes
1 answer

PhpSpec return always null on mocks

I'm working with PhpSpec and for some reason when I mock my dependencies and call them the willReturn method of PhpSpec give me a null value instead of the value passed. This is the method that I'm trying to describe /** * Register an User …
Fabrizio Fenoglio
  • 5,767
  • 14
  • 38
  • 75
0
votes
1 answer

How can a laravel session be used within a phpspec test

I'm trying to test a very simple class with phpspec. Some methods of the class that should be tested /** * @param Store $session */ function __construct(Store $session) { $this->session = $session; } /** * @param Store $session */ function…
murze
  • 4,015
  • 8
  • 43
  • 70
0
votes
1 answer

phpspec - method returns object instead of string

I'm still fresh in phpspec but usually I'm finding a solution when I struggle with something but this one is tough. I've tried many different approaches and I haven't found a solution. I'm using Symfony2. I have a class that I want to test: class…
wielo
  • 67
  • 5