This forum is in READ-ONLY mode.
You can look around, but if you want to ask a new question, please use Stack Overflow.

Cannot access app.yml property within functional test

Discussion around this tutorial for symfony 1.2-1.4

Cannot access app.yml property within functional test

by warren2k » Wed Jul 06, 2011 5:49 pm

I'm on Day 9 of the Jobeet tutorial and am receiving the following error when running the jobActions functional test:

PHP Fatal error: Cannot access empty property in /home/sfprojects/jobeet/test/functional/frontend/jobActionsTest.php on line 24[/code]

On line 24, I have the following statement, which I copied from the "Only n jobs are listed for a category" section:

Code: Select all
    $max = sfConfig::get('app_max_jobs_on_homepage');


I've checked /apps/frontend/config/app.yml, and it contains, among other things:

Code: Select all
    max_jobs_on_homepage: 10


Can someone help me figure out what's going wrong with reading this setting from within my jobActionsTest.php file?
warren2k
Junior Member
 
Posts: 2
Joined: Wed Jul 06, 2011 5:32 pm

RESOLVED: Cannot access app.yml property within functional t

by warren2k » Wed Jul 06, 2011 6:01 pm

I figured out what I did wrong. I did not follow directions. I did not add the code at the end of the test file exactly as indicated. I placed the new code for the 1.2 test BEFORE the previous test's semicolon, which basically had me adding to that chain of function calls, like this:

Code: Select all
  with('response')->begin()->
    info('  1.1 - Expired jobs are not listed')->
    checkElement('.jobs td.position:contains("expired")', false)->
  end()

  $max = sfConfig::get('app_max_jobs_on_homepage');
 
  $browser->info('1 - The homepage')->
    get('/')->
    info(sprintf('  1.2 - Only %s jobs are listed for a category', $max))->
    with('response')->
      checkElement('.category_programming tr', $max)
  ;


Once I placed the new code AFTER the previous chained statement's semicolon, everything worked fine with reading the value from the config file:

Code: Select all
  with('response')->begin()->
    info('  1.1 - Expired jobs are not listed')->
    checkElement('.jobs td.position:contains("expired")', false)->
  end()
  ;
 
  $max = sfConfig::get('app_max_jobs_on_homepage');
 
  $browser->info('1 - The homepage')->
    get('/')->
    info(sprintf('  1.2 - Only %s jobs are listed for a category', $max))->
    with('response')->
      checkElement('.category_programming tr', $max)
  ;


It was a newbie mistake.
warren2k
Junior Member
 
Posts: 2
Joined: Wed Jul 06, 2011 5:32 pm