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

How to test class which create items using PHPSpec

I have class which mostly to this $newItem = new SeriesDiscountDecorator($item); $cart->remove($item); $cart->add($newItem); And my spec looks like $decoratedItem1->beConstructedWith([$item1]); $cart->add($decoratedItem1)->shouldBeCalled(); But…
0
votes
1 answer

Laravel Elixir change PHPSpec binary path

Ok, currently adding a task to run PHPSpec tests via Laravel Elixir is not working for me because I changed my composer file to store all binary applications under my ./bin folder instead of ./vendor/bin and by default the PHPSpec task looks for the…
Peter Fox
  • 1,809
  • 2
  • 20
  • 34
0
votes
1 answer

testing with phpspec - mocking method from the current class

I'm learning phpspec and can't figure out why a test is not passing. Here is my function: public function isTaskForChange($task) { $supportedTasks = array_keys($this->availableTasks()); $isTaskForChange = in_array($task, $supportedTasks); …
RossTsachev
  • 921
  • 1
  • 7
  • 19
0
votes
1 answer

how to spec createQueryBuilder() in controller

I'm writing phpspec test for controller In action I am calling another method with this: $this->getDoctrine()->getManager()->createQueryBuilder(); I cannot pass this in phpspec. What I'm getting is method…
greg606
  • 491
  • 3
  • 17
0
votes
0 answers

Phpspec wants to create a class when interface class already exists

I'm starting to work with phpspec and I'm struggling with this problem. I'm having a spec code like this : class OrderItemSpec extends ObjectBehavior { function it_is_initializable() { …
eMZet
  • 1
  • 1
  • 2
0
votes
1 answer

PhpSpec Can not find appropriate suite scope for class error

I am just starting out with PhpSpec. When I do this: bin/phpspec desc src/CRMPicco/GolfBundle/Controller/CourseGuideController I get the following error: [PhpSpec\Exception\Locator\ResourceCreationException] Can not find appropriate suite scope…
crmpicco
  • 16,605
  • 26
  • 134
  • 210
0
votes
1 answer

How to write a test for method in Laravel using phpspec

Hi I would like to test very simple method in Laravel 4.1. I am starting with tests in laravel and I would appreciate a little help here. I am using phpspec.. Here is method: public function hasTag($codename) { $tag =…
Dusan Plavak
  • 4,457
  • 4
  • 24
  • 35
0
votes
1 answer

Testing a class in phpspec involving Guzzle

I'm trying to build a class that queries an external API. Each method that corresponds to an endpoint makes a call to a 'master call' method responsible for actually sending a request to the API. For example: // $this->http is Guzzlehttp\Client…
johnRivs
  • 135
  • 2
  • 4
  • 19
0
votes
1 answer

custom constructor and phpspec

I have this class I want to test in phpspec: class Something { protected $property; public function __construct($someId) { $this->property = Model::find($someId); } } Model::find() returns a Model instance. And I don't want phpspec to…
Christophe
  • 192
  • 1
  • 8
0
votes
1 answer

Laravel 5.1 testing with PHPUnit and PHPSpec

Laravel 5.1 have been released. But I don't know how to use it's testing features because I'm still new with TDD stuffs. For example, I want to test my Eloquent Model (relationships etc.) Anyone could explain with clear explanation? Thanks in…
Ibnu Madini
  • 175
  • 1
  • 11
0
votes
1 answer

Testing Use of Class Optionally Included in Project

I have a class that goes something like the following: class Foo { /** * @var array|Bar */ protected $source; public function __construct($source = []) { if (class_exists(Bar::class)) { $source = new Bar($source); } …
deefour
  • 34,974
  • 7
  • 97
  • 90
0
votes
1 answer

Why does PHPSpec fail to test thrown exceptions using ::shouldThrow()?

I am trying to test whether a method throws an exception in PHPSpec. Here is the method being tested; it is either running a Callable or a controller's action. I am trying to test whether the exception at the end is being thrown. function…
0
votes
1 answer

PHPspec assign value and test update

I have the following class class Customer {} and it has properties like Id, Name, City and Country and methods like findById and findByCity. I want to write a spec test that will test that my Customer::save() function works like this function…
kristian nissen
  • 2,809
  • 5
  • 44
  • 68
0
votes
1 answer

PHPSpec class construction per test

I am looking for a way to represent the following per test method in PHPSpec, each test needs a class constructor created like this $config = new Config( 'path_to_config' ); $client = new SOAPService( $config ); $debtor = new Debtor( $client…
kristian nissen
  • 2,809
  • 5
  • 44
  • 68
0
votes
2 answers

Using let in phpspec

I am trying to test a class in phpspec. The class is a regular Service class to be used in ZF2. class GuestService implements ServiceLocatorAwareInterface { public static function createWithServiceManager(ServiceLocatorInterface…
John Doe
  • 35
  • 3