Tagged Questions
0
votes
1answer
31 views
Error test upload php unit symfony2
Im following the tutorial from symfony's website to make my phpunit's test for my controller.
Im trying to test an upload on a form and i have 3 fields on this form : title,description and file.
I ...
5
votes
2answers
67 views
PHPUnit: Testing form submissions with session variables stored in Symfony2
I had a small test done in PHP for a Controller I had written in Symfony2:
class DepositControllerTest extends WebTestCase {
public function testDepositSucceeds() {
$this->crawler = ...
1
vote
0answers
24 views
PHPUnit, Netbeans and Symfony2 and wrong tests location
I try to understand PHPUnit tests in Netbeans. I set correct phpunit.bat path and the phpunit-skelgen.bat file as well.
When I try to create test for some file, using the netbeans option such us ...
1
vote
3answers
33 views
How to mock symfony 2 serice in Functional test?
I have symfony service which uses redis connection in some methods but not in all methods.
class ServiceA
{
private $redis;
public function __construct($redis)
{
$this->redis ...
1
vote
0answers
35 views
Symfony2 entity form field and its attribute name
I have created a list of contact with Symfony2.3 forms using the form builder and the entity type.
I have checked the options 'expanded' and 'multiple' so that it gives me a nice list of entries with ...
1
vote
1answer
27 views
symfony 2 and phpunit crawler client does not reach ngnix
I have written this simple test:
<?php
namespace Hello\ApiBundle\Tests\Controller;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
class HelloControllerTest extends WebTestCase {
public ...
0
votes
1answer
21 views
Symfony + Doctrine functional database testing
I found only a few lines about database functional testing in the documentation: http://symfony.com/doc/current/cookbook/testing/database.html
The problem is:
I need to install database schema from ...
0
votes
2answers
55 views
Does phpunit use a different php.ini file than the one configured in MAMP?
I'm trying to run some functional tests using phpunit in Symfony2.
When I run my test, I get this error:
PDO::__construct(): [2002] No such file or directory (trying to connect via ...
2
votes
2answers
50 views
How to create tests w/Doctrine entities without persisting them (how to set id)
I'm working on tests for a Symfony2 project, and right now I'm looking for a way to create tests involving entity objects without persisting them. The problem is: id is a private field and there is no ...
2
votes
1answer
70 views
How to test update action?
I am trying to test my updateAction which allows to update my users in database but I don't know how I can test it... I have succed to test my createAction which add an user in my database. So I would ...
0
votes
0answers
39 views
PHPunit uses 50% more memory in Symfony 2.3.5 than in 2.3.3
Today I've updated from Symfony 2.3.3 to 2.3.5 and I noticed that the memory used when running PHPunit has increased a lot.
In 2.3.3: Time: 06:49, Memory: 92.25Mb
In 2.3.5: Time: 06:50, Memory: ...
0
votes
1answer
59 views
Mocking formbuilder with phpunit in symfony
So trying to write unit tests against my Symfony controller, and hit this snag.
My controller method returns a form, I'd like to check the values in that form to make sure it's as expected.
I ...
3
votes
1answer
127 views
How to log in User in Session within a Functional Test in Symfony 2.3?
I have read many posts on stackoverflow about this. But most of the methods not useful in Symfony 2.3.
So i have try to log in user manualy in test to make some actions in back-end.
Here is my ...
1
vote
1answer
109 views
Sending a POST request with PHPUnit
I have a symfony website, and Im trying to do some unit testing. I have this kind of test where I try to submit something:
<?php
namespace Acme\AcmeBundle\Tests\Controller;
use ...
0
votes
0answers
18 views
Can't set form value on a functional test
I'm currently doing this tutorial: http://tutorial.symblog.co.uk/docs/testing-unit-and-functional-phpunit.html I'm at the "Test contact page" part.
There we have defined a test called testContact() ...
0
votes
2answers
330 views
Install PHPUNIT with Composer
I have project on Symfony 2 and i would like use PHPUNIT on Windows 7.
On githut phpunit is:
Composer
Simply add a dependency on phpunit/phpunit to your project's composer.json file if you use ...
1
vote
1answer
55 views
Symfony2 - reset envirnonment based on PHPUnit configuration
I am trying to set up two specific PHPUnit test environments for Symfony2.
I am using Ant to run PHPUnit, so when I run the two commands below I would expect the following results:
ant test
Runs ...
1
vote
1answer
74 views
symfony2 test flashbag or session data
How do you test for FlashBag message?
Tried this:
public function testInvalidLogin()
{
$session = $this->client->getContainer()->get('session');
$crawler = ...
1
vote
0answers
84 views
Test blameable behavior with user in Symfony2
I'm writing a test for my entity Post, where I'm using blameable behavior from StofDoctrineExtensionsBundle. But whatever I do, there is always an error:
PDOException: SQLSTATE[23000]: Integrity ...
0
votes
1answer
113 views
phpunit-skelgen : No test file generated
I try to use phpunit-skelgen
In the doc, it is written
When you are using the skeleton generator to generate code based on a class that is declared in a namespace you have to provide the ...
0
votes
0answers
59 views
How to assert a javascript/ client side validation message in phpunit with Symfony 2
I am running phpunit tests on my symfony. i am able to assertExp of failed test with message from server side but how can i test the message for client side(javascript message)
...
0
votes
1answer
117 views
Functional tests on Symfony 2 - issue with the default autoload.php.dist
I have been trying to run FunctionalTest which extends the Symfony\Bundle\FrameworkBundle\Tests\Functional\WebTestCase with not so much success.
The issue is that:
the code in ...
1
vote
1answer
142 views
Jenkins (using Ant) not executing PHPUnit tests
I'm trying to use Jenkins with Ant in my PHP application (Symfony2) but can't get my tests execute. I can see in Jenkins 'console output' screen that the correct configuration file is being read, but ...
0
votes
1answer
100 views
Can we use Symfony\Bundle\FrameworkBundle\Test\WebTestCase for symfony 2 console commands testing?
Using Symfony\Bundle\FrameworkBundle\Test\WebTestCase, we get easy access to container, entity manager etc. We can use it for functional testing by automatic manual HTTP requests.
Can we use it to ...
1
vote
1answer
116 views
Symfony WebTestCase: File upload not deleted, assertion passing anyway
Thanks to this cookbook recipe, I have a file upload form that works great. However it doesn't do test coverage, so I've written my own assertions, which upload an image, check that the image has been ...
0
votes
0answers
23 views
Syfmony2 - Functional Test of a secured Route through Login Form
How to write a Functional Test if the Route is secured and Authentication works through a login form.
Are there any best practices?
I would create a Method that Authenticates me by filling out the ...
0
votes
0answers
39 views
Symfony2: Getting security context from with in a controller during a test
I'm trying to test a function in my controller that requires the security.context service. In my test I log in using a made up token as shown bellow:
public function testAccountType()
{
...
0
votes
1answer
80 views
PHPUnit increasing memory kills process itself
I have the problem that my unit tests for some assertions and mocks are running out of memory. The memory is increasing each second 100MB and then killing the phpunit process when it's reaching the ...
1
vote
0answers
70 views
Error with PHPUnit in Symfony2
I have a error with PHPUnit using Symfony2
In my test case I import:
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
But, when I execute it I get:
PHP Fatal error: Class ...
0
votes
1answer
67 views
Symfony 2 Functional Testing external URL
Whatever I do, I always get a
Symfony\Component\HttpKernel\Exception\NotFoundHttpException: "No
route found for [...]"
in $crawler->text(), when I try to request an external URL with ...
1
vote
0answers
101 views
Symfony2 : Functionnal testing in Request Scope using a Service depending on a Request Listener Service
I'm new with services and phpUnit.
So I'm trying to test my (working) services. Here is my services.yml :
services:
history_cookie:
class: ...
0
votes
1answer
164 views
Why is symfony2 functional test client->request() not getting successful response()?
So I've decided to delve into phpunit testing and I've shamefully written out my php code before writing my test. Anyway, I'm just writing a very simple test that tells me if I actually found the ...
0
votes
2answers
158 views
Error trying to select a form from symfony2 crawler?
I keep getting the following error:
There was 1 error:
1) Caremonk\MainSiteBundle\Tests\Controller\SecurityControllerFunctionalTest::testIndex
InvalidArgumentException: The current node list is ...
0
votes
1answer
165 views
Silex PHPUnit Functional tests
I have a question concerning the functional test in Silex/PHPUnit.
require_once '/var/www/silex/vendor/autoload.php';
class MyTest extends Silex\WebTestCase{
protected $app;
public function ...
0
votes
1answer
163 views
symfony2 phpunit session dosn't start
i have a strange problem with $_SESSION in my application
For different reasons that i don't explain here i had the necessity to set in the session the environment in my AppKernel.php
use ...
0
votes
1answer
147 views
Mock a request in phpunit
I am trying to write a unit test (phpunit) to cover a controller action. I am receiving problems regarding invalid scope for the getRequest() call.
note: I am a newbie to Symfony2 and TDD (phpunit)
...
2
votes
1answer
111 views
phpunit --debug still displays only dots
I want to see which test is currently executed during a phpunit run.
I use the --debug param but still only get dots:
$ phpunit --debug
PHPUnit 3.7.19 by Sebastian Bergmann.
Configuration read ...
0
votes
1answer
508 views
Warning: require_once(PHPUnit/Autoload.php): failed to open stream: No such file or directory in /usr/bin/phpunit on line 49
This is my complete error message:
Warning: require_once(PHPUnit/Autoload.php): failed to open stream: No such file or directory in /usr/bin/phpunit on line 49
Fatal error: require_once(): Failed ...
2
votes
0answers
39 views
Test access_control in Symfony2
I want to test that my access_control is working as expected, that certain roles don't have access to a page while other roles do.
I can do this using Functional Tests, logging in each user and ...
6
votes
2answers
529 views
Class __PHP_Incomplete_Class has no unserializer
I am trying to run the tests in PHPUnit and getting this error.
Fatal error: Uncaught exception 'ErrorException' with message 'Class
__PHP_Incomplete_Class has no unserializer' in ...
4
votes
1answer
256 views
PDO connection is not closed when phpunit is running with symfony 2.X
We have about 180 unit tests implement webtestcase class and tests are running over controllers.
However when we run the unit tests, they open too many connection to db. Because of too many active ...
2
votes
1answer
75 views
Symfony2 UnitTests fail at first run, succeeds on all subsequent runs
When I run phpunit on my Symfony2 project, the tests always fail at first run:
$ phpunit -c app src/Project/MyBundle/Tests/Controller/SomeTest.php
PHPUnit 3.7.19 by Sebastian Bergmann.
...
1
vote
2answers
244 views
Symfony 2 Service Error on unit Testing
I make some functional test with Symfony 2 and phpunit.
But i've some trouble with a Service.
Let me explain.
During my run test, i want to use some service used by the application. So i juste set my ...
1
vote
1answer
118 views
accessing entity manager inside phpunittest
I have the following unit test code in symfony:
<?php
// src/Acme/DemoBundle/Tests/Utility/CalculatorTest.php
namespace Shopious\MainBundle\Tests;
class ShippingCostTest extends ...
1
vote
1answer
208 views
codeception symfony2 unit test throws a fatal error
using the classical phpunit style I generate:test with the symfony2 helper.
I can get the service and I can assert it ok.
// tests
public function testGetServiceUrl() {
$ecservice = ...
0
votes
1answer
238 views
Using Codeception, Symfony2 Functional Testing a service how do I add assertions?
Summary: I want to use Module assertions in my Tests.
Previously I have tested Symfony2 services using PHPUnit tests. This is ok but I would like to use some of the facilities that the Codeception ...
0
votes
1answer
106 views
Get proper installation of PHPUnit Database extension in Symfony2
I've been struggling with my configuration for 2 days now.
When I launch phpunit from my bash emulator (working under windows 7)
bin/phpunit -c app
I got the following error:
Configuration ...
0
votes
3answers
235 views
Symfony 2 functional test: authenticate user of own User class
As described in answer of How to use an authenticated user in a Symfony2 functional test? there is a simple solution with Symfony\Component\Security\Core\User\User.
But I have different User class ...
0
votes
1answer
150 views
Symfony 2 SessionCsrfProvider & PHPUnit testing
EDIT
actually answered this myself, was so simple:
$session = $this->getMock(
'\Symfony\Component\HttpFoundation\Session\Session',
array(),
array(),
'',
false // don't call constructor
...
0
votes
1answer
361 views
“You cannot define a mapping item when in a sequence” when running phpunit in symfony
I'm getting the following errors when I try to run phpunit on my symfony project:
$ phpunit -c app
1) [...]\DefaultControllerTest::testIndex
...