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

How to get property from stub function argument?

I have a service, which should create an email class object and pass it to the third class (email-sender). I want to check body of email, which generates by the function. Service.php class Service { /** @var EmailService */ protected…
xorik
  • 33
  • 2
3
votes
0 answers

Is possible to check how many times collaborator's static method was called in PhpSpec?

What I'm trying to achieve is: to check if factory method was called on ContextItem to check if provided entity exists in the collection Questions: how to provide specific entity to factory method of collaborator? how to check how many times…
Rafał Łyczkowski
  • 995
  • 2
  • 11
  • 27
3
votes
1 answer

Symfony unit test Security (ACL - Annotation)

I'd like to check a method with access control, e.g. a method is only granted with a specific role. Therefore, I know two ways in Symfony: @Security annotation above the method (SensioFrameworkExtraBundle) OR Calling authorization_checker explizit…
user3746259
  • 1,491
  • 2
  • 23
  • 46
3
votes
1 answer

PhpSpec. Call to a member function on a non-object when mock must return an object

I'm new i phpspec and trying to create dummy converter for learning purposes, but I stuck with Call to a member function on a non-object error Here is my code: Conver class private $supportedFormats = ['xml', 'json']; private $handler; public…
Bogdan Dubyk
  • 4,756
  • 7
  • 30
  • 67
3
votes
8 answers

PHPSpec - fail to run, anyone using it for php development?

Searched stackoverflow for this and found no answer Coming from Ruby On Rails and Rspec, I need a tool like rspec (easier transition). Installed it through PEAR and tried to run it but it's not working (yet) Just wanna ask around if anyone's using…
edthix
  • 1,752
  • 16
  • 18
3
votes
2 answers

Unit test UploadedFile.php in PHPSpec

I am trying to test a data transfer object class which constructs with Symfony\Component\HttpFoundation\File\UploadedFile.php class in Laravel. I've had no luck testing this implementation in PHPSpec. Here is what I have so far: Test public function…
Anton
  • 172
  • 3
  • 10
3
votes
1 answer

phpspec unit testing - using ioc / service registry for delivering the concrete class to test

I am new to testing and I'm not sure I go about this the right way: I want to not to do a unit test on a specific class but on whatever class get resolved out of my ioc container. In the ioc container I bind my interfaces to concrete classes, like…
andy-bc
  • 147
  • 1
  • 9
3
votes
1 answer

PhpSpec test catching exception

I have a simple test: function it_should_return_error_response_exception(Client $httpClient,CommandInterface $commandInterface) { $httpClient->setDefaultOption('auth', array('api','api_pass', 'Basic')) ->shouldBeCalled(); …
erlangb
  • 521
  • 6
  • 13
3
votes
1 answer

Anonymous function on PHPSpec

What is the right way to test this form with query_builder's anonymous function? use Doctrine\ORM\EntityRepository; // ... $builder->add('users', 'entity', array( 'class' => 'AcmeHelloBundle:User', 'query_builder' =>…
user2359967
3
votes
2 answers

Using phpspec for testing Symfony2 Commands

I am using phpspec to test our application. Now we need to develop some commands and therefore I want to spec these as well. I am a bit stuck here, because the docs…
Coruja
  • 51
  • 3
3
votes
1 answer

phpspec - mocking return value of method

In phpspec can i mock the return value of a method? for example: class MyClass() { public function getStaffMemberNames() { // db call to get array of staff member names } public function sortStaffMemberNames() { …
Marty Wallace
  • 34,046
  • 53
  • 137
  • 200
3
votes
2 answers

Installing phpspec

I am sure I miss something obvious. But I have problems install and using phpspec. First of all I don't know if I should use phpspec or phpspec2. I have tried installing like this: - PEAR (doesn't work) - git hub (cloning and it gets downloaded…
Cudos
  • 5,733
  • 11
  • 50
  • 77
2
votes
1 answer

File structure in a PHP composer package with PHPSpec

I had a working composer package with a single files and a single class. So, now I'm trying to change the package so that it is more like SOLID. I have a file structure like this... PackageName.php addresses.php names.php interfaces names.php …
sdexp
  • 756
  • 4
  • 18
  • 36
2
votes
1 answer

laravel 5.1 phpspec command not found

I'm trying to run phpspec but when I do a command phpspec run inside root project folder it just prints: -bash: phpspec: command not found But when I do composer show -i it shows it's installed (because it's in package.json): phpspec/php-diff …
dontHaveName
  • 1,899
  • 5
  • 30
  • 54
2
votes
1 answer

Arrange/Act/Assert pattern using PHPSpec

I'm trying to follow the AAA pattern to write specifications to ClassA. This class has dependency with ClassB that will interact with ClassA as follow: class ClassA { private $objB; public function __construct(ClassB $objB) { …
Tales Santos
  • 232
  • 3
  • 10
1
2
3
13 14