Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TestsErrors #11

Open
bizmate opened this issue Jun 3, 2014 · 4 comments
Open

TestsErrors #11

bizmate opened this issue Jun 3, 2014 · 4 comments

Comments

@bizmate
Copy link

bizmate commented Jun 3, 2014

Tests show these errors

vagrant@precise64:/var/www/symfony$ bin/phpunit -c app
PHPUnit 3.7.37 by Sebastian Bergmann.

Configuration read from /var/www/symfony/app/phpunit.xml.dist

...F.FFF.......EE

Time: 52.64 seconds, Memory: 51.50Mb

There were 2 errors:

1) BoShurik\SurveyBundle\Tests\Controller\SurveyControllerTest::testCompleteScenario
InvalidArgumentException: The current node list is empty.

/var/www/symfony/vendor/symfony/symfony/src/Symfony/Component/DomCrawler/Crawler.php:697
/var/www/symfony/src/BoShurik/SurveyBundle/Tests/Controller/SurveyControllerTest.php:18

2) BoShurik\UserBundle\Tests\Controller\RegistrationControllerTest::testRegistration
InvalidArgumentException: The current node list is empty.

/var/www/symfony/vendor/symfony/symfony/src/Symfony/Component/DomCrawler/Crawler.php:737
/var/www/symfony/src/BoShurik/UserBundle/Tests/Controller/RegistrationControllerTest.php:30

--


There were 4 failures:

1) Acme\BlogBundle\Tests\Controller\PageControllerTest::testJsonPostPageAction
{"code":400,"message":"Validation Failed","errors":{"errors":["The CSRF token is invalid. Please try to resubmit the form."],"children":{"title":[],"body":[]}}}
Failed asserting that 400 matches expected 201.

/var/www/symfony/src/Acme/BlogBundle/Tests/Controller/PageControllerTest.php:194
/var/www/symfony/src/Acme/BlogBundle/Tests/Controller/PageControllerTest.php:81

2) Acme\BlogBundle\Tests\Controller\PageControllerTest::testJsonPutPageActionShouldModify
{"code":400,"message":"Validation Failed","errors":{"errors":["The CSRF token is invalid. Please try to resubmit the form."],"children":{"title":[],"body":[]}}}
Failed asserting that 400 matches expected 204.

/var/www/symfony/src/Acme/BlogBundle/Tests/Controller/PageControllerTest.php:194
/var/www/symfony/src/Acme/BlogBundle/Tests/Controller/PageControllerTest.php:125

3) Acme\BlogBundle\Tests\Controller\PageControllerTest::testJsonPutPageActionShouldCreate
{"code":400,"message":"Validation Failed","errors":{"errors":["The CSRF token is invalid. Please try to resubmit the form."],"children":{"title":[],"body":[]}}}
Failed asserting that 400 matches expected 201.

/var/www/symfony/src/Acme/BlogBundle/Tests/Controller/PageControllerTest.php:194
/var/www/symfony/src/Acme/BlogBundle/Tests/Controller/PageControllerTest.php:155

4) Acme\BlogBundle\Tests\Controller\PageControllerTest::testJsonPatchPageAction
{"code":400,"message":"Validation Failed","errors":{"errors":["The CSRF token is invalid. Please try to resubmit the form."],"children":{"title":[],"body":[]}}}
Failed asserting that 400 matches expected 204.

/var/www/symfony/src/Acme/BlogBundle/Tests/Controller/PageControllerTest.php:194
/var/www/symfony/src/Acme/BlogBundle/Tests/Controller/PageControllerTest.php:174

FAILURES!
Tests: 17, Assertions: 47, Failures: 4, Errors: 2.

//composer file

{
    "name": "symfony/framework-standard-edition",
    "license": "MIT",
    "type": "project",
    "description": "The \"Symfony Standard Edition\" distribution",
    "autoload": {
        "psr-0": { "": "src/" }
    },
    "require": {
        "php": ">=5.3.3",
        "symfony/symfony": "~2.4",
        "doctrine/orm": "~2.2,>=2.2.3",
        "doctrine/doctrine-bundle": "~1.2",
        "twig/extensions": "~1.0",
        "symfony/assetic-bundle": "~2.3",
        "symfony/swiftmailer-bundle": "~2.3",
        "symfony/monolog-bundle": "~2.4",
        "sensio/distribution-bundle": "~2.3",
        "sensio/framework-extra-bundle": "~3.0",
        "sensio/generator-bundle": "~2.3",
        "incenteev/composer-parameter-handler": "~2.0",
        "friendsofsymfony/user-bundle": "~2.0@dev",
        "friendsofsymfony/rest-bundle": "@dev",
        "jms/serializer-bundle": "@dev",
        "nelmio/api-doc-bundle": "@dev"
    },
    "require-dev": {
        "doctrine/doctrine-fixtures-bundle": "dev-master",
        "phpunit/phpunit": "3.7.*",
        "liip/functional-test-bundle":"dev-master",
        "phpunit/php-invoker":"~1.1"
    },
    "scripts": {
        "post-install-cmd": [
            "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile"
        ],
        "post-update-cmd": [
            "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile"
        ]
    },
    "config": {
        "bin-dir": "bin"
    },
    "extra": {
        "symfony-app-dir": "app",
        "symfony-web-dir": "web",
        "incenteev-parameters": {
            "file": "app/config/parameters.yml"
        },
        "branch-alias": {
            "dev-master": "2.4-dev"
        }
    }
}
@bizmate bizmate changed the title Call to undefined method Mock_FormInterface_26f906f5::submit() TestsErrors Jun 3, 2014
@liuggio
Copy link
Owner

liuggio commented Jun 3, 2014

I added the formats

@liuggio
Copy link
Owner

liuggio commented Jun 3, 2014

ehm seems a CSRFproblem, did you add the ... : http://welcometothebundle.com/symfony2-rest-api-the-best-way-part-3/#disable_csrf_with_rest ?

@bizmate
Copy link
Author

bizmate commented Jun 4, 2014

Very likely i had not set this right as i reached the line executing the test: in http://welcometothebundle.com/symfony2-rest-api-the-best-2013-way/ where i had kind of guessed how to set configuration. I will double check tonight and close the ticket if that is the cause of the problem.
I guess i ll do some more basic reading about FOSRest as i still need to get used to how to make it work with some extra features including authentication etc. Thanks

@bizmate
Copy link
Author

bizmate commented Jun 5, 2014

Just to confirm that csrf was already disabled for api role

fos_rest:
param_fetcher_listener: true
view:
view_response_listener: 'force'
formats:
xml: true
json: true
templating_formats:
html: true
format_listener:
rules:
- { path: ^/, priorities: [ html, json, xml ], fallback_format: ~, prefer_extension: true }
exception:
codes:
'Symfony\Component\Routing\Exception\ResourceNotFoundException': 404
'Doctrine\ORM\OptimisticLockException': HTTP_CONFLICT
messages:
'Symfony\Component\Routing\Exception\ResourceNotFoundException': true
allowed_methods_listener: true
access_denied_listener:
json: true
body_listener: true
disable_csrf_role: ROLE_API

Still i get the failures in the AcmeBlogBundle

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants