0

I access my page at http://web.dev/web/app_behat.php and it works when I do it manually in browser.

So I set

base_url: "http://web.dev/web/app_behat.php/"

and I get no route matched for any route but if i set

base_url: "http://web.dev/app_behat.php/"

route seems to be matched but i get missing table error, i have set up SymfonyDoctrineContext to take care of schema creation.

Full behat.yml:

default:
  formatter:
    name: progress
  context:
    class:  FootballRadar\Features\Context\FeatureContext
  extensions:
    Behat\Symfony2Extension\Extension:
      mink_driver: true
      kernel:
        env: test
        debug: true
    Behat\MinkExtension\Extension:
      base_url: "http://web.dev/app_behat.php/"
      default_session: symfony2
      show_cmd: 'open -a "Google Chrome" %s'

EDIT:

My config_behat.yml:

imports:
    - { resource: "config_dev.yml" }

assetic:
    debug:   true
    use_controller:
        enabled:  true
        profiler: false

framework:
    test: ~
    session:
        storage_id: session.storage.mock_file
    profiler:
        collect: false

web_profiler:
    toolbar: false
    intercept_redirects: false

swiftmailer:
    disable_delivery: true

doctrine:
  dbal:
    connections:
      default:
        driver:  pdo_sqlite
        user:    behat
        path:    %kernel.root_dir%/behat/default.db.cache
        charset: utf8
      model:
        driver:  pdo_sqlite
        user:    behat
        path:    %kernel.root_dir%/behat/model.db.cache
        charset: utf8

monolog:
  handlers:
    test:
      type: test

Seems that all of You misunderstood my question and/or completely ignored my first sentence.

I have a working application and I access it using

http://web.dev/web/ (http://web.dev/web/app.php/) <-- for prod

http://web.dev/web/app_dev.php/ <-- for dev

http://web.dev/web/app_behat.php/ <-- for behat

all of them work as when i use them manually in chrome or other browser

That is why I am surprised why http://web.dev/web/app_behat.php/ gives me

No route found for "GET /web/app_behat.php/login"

and

http://web.dev/app_behat.php/ gives

SQLSTATE[HY000]: General error: 1 no such table: users_new

With little debugging I confirmed SymfonyDoctrineContext does read my entities mappings and issues queries to create db schema, both db files have read/write permissions (for sake of test I gave them 777)

Another thing I just realised, all this errors gets written to test.log file instead of behat.log. I create kernel with $kernel = new AppKernel('behat', true);

Maybe I just greatly misunderstood how behat is supposed to work?

EDIT2:

I have noticed that there are no entries made to apache access log when running behat feature for either of the paths

versions i'm using from composer.json

    "behat/behat": "2.5.*@dev",
    "behat/common-contexts": "1.2.*@dev",
    "behat/mink-extension":          "*",
    "behat/mink-browserkit-driver": "*",
    "behat/mink-selenium2-driver": "*",
    "behat/symfony2-extension":      "*",
Gustek
  • 3,680
  • 2
  • 22
  • 36
  • 1
    Ask yourself: How should this being answered by somebody who has never seen your code before and just having this *problem description*? (You may or may not have noticed that `web.dev` isn't available over the internet) – hek2mgl Sep 05 '14 at 14:34
  • I have no idea why I have this problem and do not now where to look to fix it. So tell me what part of my code You need to look at and I will post it. app_behat.php is copy of app_dev.php from symfony standard edition with dev replaced with bahat where necessary. And as I said my application works when I browse it manually and it something about behat or browser it uses, just guessing here. – Gustek Sep 05 '14 at 14:53
  • 1
    You need to provide the information/code which is required *to reproduce the problem* – hek2mgl Sep 05 '14 at 18:29
  • I guess that "http://web.dev/web/app_behat.php/" is reaching the prod front controller (app.php) and you don't have any route like "/web/app_behat.php". "http://web.dev/app_behat.php/" gets to the correct front controller and there is the real issue, you didn't prepare your db properly. As @hek2mgl said, we need more info. – coma Sep 06 '14 at 08:39
  • If my answer (see below) doesn't solve it for you, can you please post the exact “missing table error”? – lxg Sep 08 '14 at 08:30
  • Added some more info, hope it helps. – Gustek Sep 08 '14 at 10:22
  • http://web.dev/web/app_behat.php/ or http://web.dev/app_behat.php/ ? – coma Sep 08 '14 at 14:43
  • http://web.dev/web/app_behat.php is the one working when accessing page manually. – Gustek Sep 08 '14 at 15:20
  • Do you use any rewrite rules in Apache? What is your `DocumentRoot` directive? Could it be that there are interfering vhost configurations? (Just asking; if you don't see log entries for *some* requests, this would be one of the few sensible explainations.) – lxg Sep 13 '14 at 12:59
  • As for the missing table: Have you added all bundles in `AppKernel::registerBundles()` and run `doctrine:schema:update` after that? – lxg Sep 13 '14 at 13:02
  • Sorry that you wasted the bounty without having your problem solved. I'd be willing to continue discussing, unless you have the feeling this is going nowhere. Let me know. – lxg Sep 13 '14 at 16:16
  • @lxg I appreciate your effort. There are no other vhosts and I checked all the log files apache generates. I will repeat myself again, my application is working it is in production for some time now. I know how to work with Symfony. The problem is with Behat and how it makes its requests? – Gustek Sep 15 '14 at 10:10

1 Answers1

2

What you are experiencing are two unrelated problems.

The fact that you don't get a route with

base_url: "http://web.dev/web/app_behat.php/"

is quite obvious: the web/ directory is treated as document root by your webserver, i.e. if your web/ directory would contain a file like foo.html, then http://example.com/foo.html would return this file. Therefore, the second base_url line is correct.

(NB: Unlike “simpler” web applications, Symfony2 hides the major part of the code of from public access, in order to prevent the direct execution of library files. Only the contents of web/ are public.)

The missing table problem is not related to that. Unfortunately, we don't know the exact error message, but usually, you need to update the Doctrine schema to have the table(s) created. This can be done by running one of these commands:

app/console doctrine:schema:update --dump-sql --complete
app/console doctrine:schema:update --force --complete

The first one generates the SQL commands which you can copy/paste to an SQL shell yourself, the latter one applies the updates directly to the database.

lxg
  • 12,375
  • 12
  • 51
  • 73
  • 1
    +1 since I'm still thinking this was the real problem and is sad to see how a bounty gets lost. – coma Sep 13 '14 at 12:52