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

First Shot at Testing Laravel 4 apps (PHPSpec/BDD vs. PHPUnit/TDD)

I have been wrestling with this question for far too long now. I know I need to just jump into one or the other since they are both obviously viable/useful tools, but have been stuck on the fence, researching both, for weeks. PHPUnit vs. PHPSpec -…
Erik Aybar
  • 4,761
  • 1
  • 23
  • 29
15
votes
1 answer

How to get code auto-completion with phpspec

I've just started learning phpspec with a view to replacing PHPUnit. Unfortunately, I've got rather hooked on using the PHPStorm editor's code completion feature, which makes even PHPUnit's verbose mock interface very quick to type. No such luck…
fazy
  • 2,095
  • 18
  • 30
14
votes
3 answers

PHPSpec and coverage report

Does anyone know a method to generate coverage reports from PHPSpec tests? I thought about xdebug, but as far as I know it cant generate reports for jenkins.
spamec
  • 301
  • 1
  • 5
  • 15
13
votes
1 answer

Similarities and Differences Between PHPUnit and PHPSpec

I am currently doing research into which test framework I should be using for php. The two choices I have are PHPUnit and PHPSpec. I know that PHPUnit is TDD(Test driven development) and PHPSpec is BDD(Behavior driven development). However due to…
applecrusher
  • 5,508
  • 5
  • 39
  • 89
11
votes
4 answers

Aggregating code coverage from different testing frameworks

In modern programming workflow numerous testing frameworks are used at once. For example, in PHP world, it is de-facto standard way to use unit tests, integration tests and functional/acceptance tests at once. Most of the time different frameworks…
RuslanN
  • 398
  • 3
  • 18
9
votes
1 answer

PhpSpec: How can I run only one test from a suite?

I have a phpspec class like below and I only want to run a single spec from it. I would like to run the "it_should_do_something_easy" only. Is this possible? This is how I run this spec file: $> phpspec run spec/Project/WorkerSpec.php But now I…
Dranzd
  • 95
  • 1
  • 7
8
votes
2 answers

PHPSpec Catching TypeError in PHP7

I want test an example method with scalar type hinting and strict types in PHP7. When I don't pass an argument, the method should throw a TypeError. PHPSpec return fatal error: Uncaught TypeError: Argument 1 passed to Example::test
Matrix12
  • 446
  • 8
  • 19
5
votes
1 answer

phpspec - get return value

I want to get the actual return value of the object rather than a chainable object. class Foo { public $attribute = 'data'; } class FooSpec extends ObjectBehavior { public function it_is_a_test() { $attribute = $this->attribute; //…
jaggy
  • 822
  • 1
  • 10
  • 20
4
votes
3 answers

PHPUnit force me to mock entity?

Let's take in account this scenario public class FooManager() { //somewhere in my manager class code public function merge(Foo $a, Foo $b, $id) { if ($a->getId() == $id) { //!! PAY ATTENTION !! } //and so on …
DonCallisto
  • 29,419
  • 9
  • 72
  • 100
4
votes
1 answer

How to test exception handler with phpspec

I am stumbling a bit with finding a way to test that my exception handler is being called upon thrown Exception. This is the idea that I initially working with for the testing: class ClientSpec extends ObjectBehavior { function…
Ronni Egeriis Persson
  • 2,209
  • 1
  • 21
  • 43
4
votes
2 answers

PHPUnit test classes with camel case or underscore

When writing test cases inthe xUnit style that PHPUnit follows it seems that everyone follows the camel case convention for function names: public function testObjectHasFluentInterface() { // ... } I have been naming my methods with a more…
AndrewMcLagan
  • 13,459
  • 23
  • 91
  • 158
4
votes
1 answer

how do I pass arguments to construct from a phpspec?

if I have function let(Foo bar) { $this->beConstructedWith($bar); } it works great, but how do I actually pass arguments to the construct? It only works if I have a construct with no arguments passed to it, and use setters after construction.…
4
votes
2 answers

phpspec and laravel setup

I am setting up a new Laravel project and integrating PHPSpec. I am having trouble finding a good working example of the phpspec.yml file that would work neatly with Laravel. In a similar way to RSpec in Rails. My desired folder structure would be…
Adamski
  • 3,585
  • 5
  • 42
  • 78
4
votes
2 answers

phpspec scalar value in let

I am trying to use the let function with scalar values. My problem is that the price is an Double, i expected an int 5. function let(Buyable $buyable, $price, $discount) { $buyable->getPrice()->willReturn($price); …
timg
  • 501
  • 2
  • 4
  • 13
3
votes
2 answers

PHPSpec: function returning by reference

I updated Doctrine 2.5 to 2.6 in my project and phpspec is broken. The function getEntityChangeSet() is now returned by reference. It seems not to be supported by phpspec. $unitOfWork ->getEntityChangeSet($site) ->willReturn(['_dataParent'…
1
2 3
13 14