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

Scrutinizer: build and test in a subdirectory

I have a repo with both front and backend application and i want to use scrutinizer to build and test my backend (PHP) application. How can i tell (or configure) scrutinizer to build and test my application in this subdirectory? Here is the basic…
jmleroux
  • 947
  • 6
  • 17
1
vote
1 answer

Spec-ing a class that instantiate something

Let's say I have this class that I was spec-ing (following BDD approach) class Logger { private $em; public function __construct(EntityManager $em) { $this->em = $em; } public function logMessageAsRead(Message…
DonCallisto
  • 29,419
  • 9
  • 72
  • 100
1
vote
1 answer

Testing Symfony3 best practices

I would like to know which is the best technology for testing Symfony apps. My idea is to test all the Application layers, starting with the Database (repository and queries), the services , Controllers and Views. I check about this but i'm not…
Ricardo
  • 2,427
  • 19
  • 35
1
vote
1 answer

How to access static property of Laravel Controller in PhpSpec?

I am trying to write a class which will read the routes given by the constructor it's constructed with. However, even after 1h of googling I didn't find anything how to access the getRouter method of the Laravel Controller - because it's a static…
Krenor
  • 621
  • 10
  • 27
1
vote
2 answers

How to write spec for services that change state of entity?

I have a service MoneyMover that change state of two entities: reduce amount of money from sender and adds this amount to receiver. I don't have implementation yet. And according to BDD I'm writing spec for this feature: function…
Michael Sivolobov
  • 12,388
  • 3
  • 43
  • 64
1
vote
1 answer

Testing attaching UploadedFile to form submit with PhpSpec

I am attempting to test an image importer which takes a file and submits a form with that image attached. That part of the test seems to be the part where it is falling over and i'm not sure how to resolve it. I understand the concept of not…
crmpicco
  • 16,605
  • 26
  • 134
  • 210
1
vote
1 answer

Testing implementation of Symfony 2 Finder component with PhpSpec

I get the following error when testing accessing the file system in my Symfony 2 application with the Filesystem component and then accessing the list of files in a directory with the Finder component. Call to undefined method…
crmpicco
  • 16,605
  • 26
  • 134
  • 210
1
vote
2 answers

How to test Api Restful on Laravel with phpspec

I'm using PhpSpec to test application Laravel framework. How can I test Api Restful on file Route and post data like when using PHPUnit. Example : $res = $this->call('POST', '/articles', [ 'alias' => 'This is invalid alias', …
1
vote
1 answer

Testing PHPSpec symfony logged user

I'am new in testing PHP with PHPSpec. I have a class where i inject symfony current logged user (TokenStorageInterface). And make changes with that user.
uikolas
  • 73
  • 2
  • 7
1
vote
1 answer

How can I test the type of something generated in my phpspec test?

For example: Test code function it_records_last_checked() { $this->getWrappedObject()->setServiceLocator( $this->getServiceLocator() ); $this->isAvailable( 'google.com' )->shouldReturn( false ); /** @var Url $last */ $last =…
Saeven
  • 2,280
  • 1
  • 20
  • 33
1
vote
1 answer

Testing call of multiple methods in phpspec

In the past i always stumbled across a certain problem with phpspec: Lets assume i have a method which calls multiple methods on another object class Caller { public function call(){ $this->receiver->method1(); ... …
Slemgrim
  • 937
  • 2
  • 8
  • 23
1
vote
1 answer

PhpSpec error when testing Symfony2 form for choices values

I am experiencing an issue when writing a PhpSpec for my Symfony form. This is the error that PhpSpec spits out when I run the spec. When I comment out the displayMode field in my form, and the spec, the spec works fine. 46 ! builds form with…
crmpicco
  • 16,605
  • 26
  • 134
  • 210
1
vote
1 answer

PHPSpec: Configuration of Output Format

I am using PHPSpec, but whenever a test fails I get the following: It does say, where my tests fail, but it does not output what exactly was returned, thus being rather unhelpful. I tried to format the output by creating a phpspec.yml file and…
LoveAndHappiness
  • 9,735
  • 21
  • 72
  • 106
1
vote
2 answers

Test abstract class through concrete class

I'm really new to PHPSpec and BDD in general so, maybe, my assumption isn't good, in that case please correct me. Let's consider this scenario //src/myBundle/Model/FooInterface interface FooInterface { …
DonCallisto
  • 29,419
  • 9
  • 72
  • 100
1
vote
1 answer

PHPSpec: order of the class specs

I'm developing a HTTP server and for the first time I've decided to write the tests specs with PHPSpec, which is great. I have two spec classes: spec\AppSpec and spec\RequestParserSpec. Since the App is the interface between the server components…
Morgan Touverey Quilling
  • 4,181
  • 4
  • 29
  • 41