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

How to test includes (PHPUnit / PHPSpec / SimpleTest / etc)

Suppose I have the following class: class FooBar { public function getArrayFromFile($file) { if (!is_readable($file)) { return []; } return include $file; } } Assuming $file contains the…
0
votes
1 answer

PHPSpec symfony2 Form types

I want to test Form types from Symfony2. I have a custom form type and my test looks like this: /** * @param \Acme\UserBundle\Entity\User $user */ function let(\Acme\UserBundle\Entity\User $user) { $this->beConstructedWith($user); } function…
Thomas
  • 503
  • 1
  • 12
  • 18
0
votes
3 answers

is it possible to use PHpspec with behat?, or just PhPunit with behat? (Symfony)

I'm playing a little with Behat these days, the thing is that I don't know if I can use PHPspec with Behat to "assert" all the stuff, this one is so readable that I would like to use it. In my case I'm using Symfony. If not, how can I use Asserts…
Francisco Albert
  • 1,577
  • 2
  • 17
  • 34
0
votes
1 answer

phpspec class not found on it_is_initializable

I'm a refactoring a symfony2 application with phpspec. But when i try to test it i keep getting the same error on the first step. bin/phpspec run -v Test/Bundle/TestBundle/Service/TestService 36 ! it is initializable class TestRepository not…
Pindabeer
  • 21
  • 4
0
votes
1 answer

phpspec tests within zend 2 module

I'm trying to move my spec folder into a zend 2 module folder. I don't totally understand how phpspec determines where the source folder is. How can I configure it to use the below folder structure. \ModuleName \spec \ModuleName …
Jeremiah
  • 751
  • 9
  • 21
0
votes
1 answer

Accessing original mock class with phpspec

I have a spec for a class which uses a stubbed collaborator. Now in my class (let's say class A), I do some manipulation on the collaborator class name (let's say class B) to transform it's own class name into something useful for the class. Problem…
0
votes
1 answer

Behat SpecBDD and StoryBDD basic featured symfony2 example application

I'm start learning the tools for Behaviour Driven Development in PHP like SpecBDD and StoryBDD with Symfony2. The official documentations of these tools are excelent, but not enough to start learning for me (and I hope for other beginners in this…
Karol F
  • 1,556
  • 2
  • 18
  • 33
0
votes
2 answers

PHPSpec and Laravel - how to handle double method not found issues

I appear to be having issues with my spec tests when it comes to stubs that are calling other methods. I've been following Laracasts 'hexagonal' approach for my controller to ensure it is only responsible for the HTTP layer. Controller
alexleonard
  • 1,314
  • 3
  • 21
  • 37
0
votes
2 answers

phpspec - assert that object has changed during method call

if i have the following method: function changeObject($object) { $object = new \stdClass(); } This is a very silly example, but it is used to illustrate my question. The object that is passed may be changed during the method call, but the…
Marty Wallace
  • 34,046
  • 53
  • 137
  • 200
0
votes
1 answer

How to use php spec with code igniter?

I have a code igniter project and I installed phpspec. My problem is that when I run a test on my class, it throws an error that it cannot find that class's base class (which is automatically loaded by the code igniter framework) namely "Class…
Bradley Trager
  • 3,570
  • 3
  • 26
  • 33
0
votes
2 answers

phpspec - thows during but use if not?

In phpspec i can test something like this: function it_must_be_constructed_with_my_variable() { $this->shouldThrow(new \Exception('bla'))->during('__construct', array('variable' => 'value')); } But what if i wanted to make sure an exception is…
Marty Wallace
  • 34,046
  • 53
  • 137
  • 200
0
votes
1 answer

PHPSpec: Mock static method

I'm testing a class with PHPSpec which is going fine until I wanted to create a mock for a class that has static functions. Class I'm testing:
tom
  • 8,189
  • 12
  • 51
  • 70
0
votes
1 answer

phpspec. checking key for array

Exist some class: class A{ protected $options; public function setDefaults($defaults){ $this->options=$defaults; } public function getOptions(){ return $this->options; } } And other class: class B{ public function…
nonlux
  • 774
  • 2
  • 6
  • 20
0
votes
1 answer

Testing exceptions of built-in function in PhpSpec

I decided to write simple MVC with BDD workflow. I want to implement method which sets some property of a class. The thing is connected with file path. In this method I want to check if path is correct and if this file exists. Final product should…
Kuba T
  • 2,893
  • 4
  • 25
  • 30
0
votes
1 answer

Using PHPSpec with array?

I've been starting to use PHPSpec 2, and am loving it with Mockery, but ran into an issue I can't figure out. I have an array returned by a static function, and I want to validate this array. Make sure all the keys needed are there, etc. I…
Jess
  • 8,628
  • 6
  • 49
  • 67
1 2 3
13
14