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
2 answers

Is there a way to check if a phpspec array has a key in a multidimensional array

Given a multidimensional array, I try to run somearray->shouldHaveKey('somekey') but it only searches at the first dimension and not down through the multidimensional array
user1686342
  • 1,265
  • 1
  • 18
  • 24
0
votes
1 answer

Can I run phpspec tests (that use the network) without running a apache server

Beginner question here but is it possible to run a PHPSpec test suite that contains tests that make REST calls without actually running a server.
user1686342
  • 1,265
  • 1
  • 18
  • 24
0
votes
1 answer

phpSpec no beCalled([array:0]) matcher found for null

I'm trying to get into the workfow of using phpSpec to desing my classes. I have stumbled on testing a handle method on one of my event handlers. My spec: use App\Order; use App\Models\Payments\Payment; use…
Andres Zapata
  • 1,710
  • 1
  • 16
  • 32
0
votes
2 answers

How do I make Bamboo understand phpspec tests?

Bamboo gives us the ability to run phpunit tests, but likely given a lower popularity, nothing for phpspec. I suspect however (Googling) that it must be possible! https://revive.beccati.com/bamboo/browse/PHP-PHPSPEC-813/test Has anyone successfully…
Saeven
  • 2,280
  • 1
  • 20
  • 33
0
votes
1 answer

phpspec doctrine queryBuilder - mock

I'm writing a test in PHPSpec 2.0.0 that would use Doctrine query builder in a Symfony application. This is my class: class RedirectHandle { /** * @var string */ private $kernelEnvironment; /** * @var ContainerInterface …
0
votes
0 answers

PHPSpec: how to call factory method multiple times on single test

I trying to get my hands dirty with PHPSpec. Basically Im trying to make a TimeSpan as a practice. I want to make sure that all possible valid inputs are accepted. function it_can_be_created_from_24_format() { $hours = 24; …
Jaime Sangcap
  • 2,515
  • 6
  • 27
  • 45
0
votes
0 answers

PhpSpec - Simulate a parameter with another

I would like to know it is that possible to ignore an Exception in method and force to use willReturn method ? I have an example: In theory, the Transformer must have the same name of the entity (via this->getClassName) But in this case, how can I…
Roukmoute
  • 681
  • 1
  • 11
  • 26
0
votes
1 answer

Laravel phpspec cannot be autoloaded

I am trying to setup phpspec in a Laravel project. I have installed phpspec properly and am running phpspec inside my project without any trouble. My composer.json file has the following relevant lines: "autoload": { "classmap": [ …
Placid
  • 1,400
  • 3
  • 22
  • 33
0
votes
0 answers

can't use facades in phpspec

I'm using laravel with phpspec. The problem I've encountered is that I can't use any facades in my tests. for example using using Auth::guest()->willReturn(false); throws an exception A facade root has not been set. I can use facades in my code…
Mehrdad Shokri
  • 1,974
  • 2
  • 29
  • 45
0
votes
1 answer

phpspec Call to a member function on a non-object

I'm pretty new to Symfony and phpspec so please feel free to criticize heavily. So the issue is that I'm constantly getting PHP Fatal error: Call to a member function write() on a non-object. Basically the class which is tested should write output…
tslid
  • 315
  • 1
  • 4
  • 16
0
votes
1 answer

Creating a file in a named constructor

I have a class that creates a file via a named constructor but when I test it using phpspec it does not create the file. I can't find the reason for that, so I guess a fresh look at my code could help. Here's my File class:
Iam Zesh
  • 1,797
  • 2
  • 20
  • 42
0
votes
1 answer

Using the mock returned by another mock in phpspec

I'm new at phpspec (coming from phpunit) and I have problems setting the behavior of a mock returned by another mock. I'm creating a wrapper class around the Guzzle client and I want to check the output of the response. Here's the spec: function…
Iam Zesh
  • 1,797
  • 2
  • 20
  • 42
0
votes
1 answer

PhpSpec - check method returns an integer rather than "willReturn(x)"

Is there a way that I can test that the getNumberOfProductsForCategory method will return an integer rather than a specific value (18 in this case)? I feel simply testing for "18", although correct just now, makes my test very brittle as that value…
crmpicco
  • 16,605
  • 26
  • 134
  • 210
0
votes
1 answer

PHPSpec should return correct value

I have problem with phpspec function - shouldReturn. I have factory whitch creating image object and I want to testing that factory. public function create($imageParams) { $image = new Image; $image->setName($imagesParams['name']); return…
Matrix12
  • 446
  • 8
  • 19
0
votes
1 answer

Testing objects that are usually generated by factories with phpspec

How do you go about implementing tests that can leverage your factories to create your test objects? For example, imagine you have a Zend Framework 2 factory like so: class FooServiceFactory implements FactoryInterface{ public function…
Saeven
  • 2,280
  • 1
  • 20
  • 33