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

Testing factory method in command handler with phpspec

How to test static methods which are infact factory methods: public function hireEmployee(HireEmployeeCommand $command) { $username = new EmployeeUsername($command->getUsername()); $firstName = $command->getFirstName(); $lastName =…
tommy
  • 388
  • 2
  • 14
1
vote
1 answer

Why PHPSpec is stepping into mocked/stubed method?

I'm starting with PHPSpec and I've encounter some problems with it. One of them is that I keep getting method call: - find(null) on Double\TaskRepositoryInterface\TaskRepositoryInterface\P95 was not expected, expected calls…
Maciej Szpyra
  • 313
  • 1
  • 12
1
vote
1 answer

PHPSpec missing matchers

When I try using PHPSpec matchers like shouldBeEqualTo, shouldBeString etc I get this error and I don't know why. Call to undefined method Prophecy\Prophecy\MethodProphecy::shouldBeEqualTo() I have imported ObjectBehavior and my spec is extending…
Maciej Szpyra
  • 313
  • 1
  • 12
1
vote
1 answer

phpspec - specify that arguments should be passed to mock object

I'm new to PHPSpec and BDD/TDD in general. Given the following code: interface Checker { public function execute(array $args = array()); } class Check { public $checker; public $params = array(); public function doCheck() { …
cesarv
  • 87
  • 6
1
vote
0 answers

Gulp throws errors after a while, and works again on reboot

I've just started using Gulp, and am having an intermittent issue, where sometimes I'll get the following error, which occurs with no change in configuration, and only goes away if I reboot, I've removed node_modules, and /tmp, and it hasn't made…
ThomasRedstone
  • 379
  • 1
  • 4
  • 13
1
vote
1 answer

Testing Laravel models with relations in repositories and phpspec

I have an EloquentUserRepository and I want to test its methods but I don't really know where to start from. Anyone could provide any light to this? public function findByProvider($provider, $user) { if (is_object($user)) { $user =…
Israel Ortuño
  • 1,084
  • 2
  • 14
  • 33
1
vote
2 answers

Testing models and services with Laravel, PHPSpec and PHPUnit

Im having difficulty deciding or understanding the best approach to testing in Laravel. I really like the behavioural side of PHPSpec testing, although it is just not compatible with testing Eloquent models or anything related to an active record…
AndrewMcLagan
  • 13,459
  • 23
  • 91
  • 158
1
vote
1 answer

How use class interfaces when using PHPSpec

When testing with PHPSpec how can I use class interfaces injected into my methods rather then the actual concrete class? For example I have a Product class that injects a VariationInterface into a method: /** * ... */ public function…
AndrewMcLagan
  • 13,459
  • 23
  • 91
  • 158
1
vote
3 answers

Mock only one method on PHPSpec stubs

Okay, so I'm trying to move one of my packages over to PHPSpec tests, but soon I ran into this problem. The packages is a shoppingcart package, so I want to test that when you add two items to the cart, the cart has a count of two, simple. But of…
Crinsane
  • 818
  • 3
  • 16
  • 28
1
vote
1 answer

phpspec Could not open input file

I have just installed phpspec into my Laravel project with composer, but when I try running phpspec I get this error: Could not open input file: /cygdrive/c/development/myproject/vendor/phpspec/phpspec/bin/phpspec It's the same when I try to run it…
Nicolas
  • 1,256
  • 1
  • 10
  • 22
1
vote
0 answers

Confused about PhpSpec stubs and mocks again

I'm building a Laravel 5 application at the moment and have gotten myself confused about how to mock things in PhpSpec. I'm building a schedule times validator that requires the intended schedule to be checked against all current schedules and see…
alexleonard
  • 1,314
  • 3
  • 21
  • 37
1
vote
1 answer

How to catch exceptions with phpspec2

I'm trying to catch exceptions with my spec but i can't make it works. This is my code: $this->edit('updated comment', $comment, $user) ->shouldReturnAnInstanceOf('\Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException'); What i'm…
Paweł Mikołajczuk
  • 3,692
  • 25
  • 32
1
vote
0 answers

phpspec, Doctrine: Testing that a parameter was set on an instantiated object

I'm trying to get started with PHPSpec and I've hit a wall. Things have gotten a bit convoluted in order to mock the proper things in the already-existing code I was given to work with, but in essence my question involves testing that something…
1
vote
0 answers

How to conditionally check an object with phpspec?

I just started learning phpspec and I have a question. Ok, you can check if a value is equal to some other value, and if you want to see if a value is between some values you can create a matcher like this: function getMatchers() { return [ …
Terumi
  • 347
  • 1
  • 2
  • 11
1
vote
1 answer

How to insert a sample data with PHPSpec and Laravel

I change my environment to testing on basespec with sqlite as driver and store in the memory. function it_should_validate() { // Create the user $data = array('email' => 'test@gmail.com', 'password' => 'password', 'remember'…
John Dave Decano
  • 128
  • 1
  • 1
  • 5