[day 9] Problems with functional testing [Some Doctrine tutorial mistakes]

Discussion around this tutorial for symfony 1.2-1.4

[day 9] Problems with functional testing [Some Doctrine tutorial mistakes]

Postby Mitu » Wed May 06, 2009 6:37 pm

[UPDATED] please read the last post

Hi everybody!
I'm stucked in the functional testing
I have the files:
<ul type="square">
<li>lib/test/JobeetTestFunctional.class.php
<li>test/functional/frontend/jobActionsTest.php
<li>test/functional/frontend/categoryActionsTest.php
</ul>
as the ones shown on [day 9] "Learn by the Example" section, but when I execute "symfony test:functional frontend" I get this:

categoryActionsTest......................................... .........not ok
Failed tests: 7, 8, 9, 10
jobActionsTest.............................................. .........dubious
Test returned status 255
Failed Test Stat Total Fail List of Failed
------------------------------------------------------------ ------
categoryActionsTest 0 4 4 7 8 9 10
jobActionsTest 255 0 0
Failed 2/2 test scripts, 0.00% okay. 4/16 subtests failed, 75.00% okay.



Any idea?
Thanks in advance
Last edited by Mitu on Thu May 07, 2009 4:57 pm, edited 1 time in total.
Mitu
Junior Member
 
Posts: 6
Joined: Wed May 06, 2009 6:32 pm
Location: Barcelona

Re: [day 9] Problems with functional testing

Postby Mitu » Thu May 07, 2009 10:40 am

Some news
If I run the categoryActions test alone I get this:

Code: Select all
symfony test:functional frontend categoryActions
> 1 - The category page
>   1.1 - Categories on homepage are clickable
# get /
# get /category/programming
ok 1 - request parameter module is category
ok 2 - request parameter action is show
ok 3 - request parameter slug is programming
>   1.2 - Categories with more than 10 jobs also have a "more" link
# get /
# get /category/programming
ok 4 - request parameter module is category
ok 5 - request parameter action is show
ok 6 - request parameter slug is programming
>   1.3 - Only 20 jobs are listed
not ok 7 - response selector .jobs tr matches 20 times
#     Failed test (.\lib\vendor\symfony\lib\test\sfTesterResponse.class.php at line 93)
#            got: 0
#       expected: 20
>   1.4 - The job listed is paginated
not ok 8 - response selector .pagination_desc matches regex /32 jobs/
#     Failed test (.\lib\vendor\symfony\lib\test\sfTesterResponse.class.php at line 104)
#                     ''
#       doesn't match '/32 jobs/'
not ok 9 - response selector .pagination_desc matches regex #page 1/2#
#     Failed test (.\lib\vendor\symfony\lib\test\sfTesterResponse.class.php at line 104)
#                     ''
#       doesn't match '#page 1/2#'
  Cannot find the "2" link or button.
1..9
 Looks like you failed 3 tests of 9



Test 1.3, I got 20 tr inside the "jobs" class table, even if I set the class to the tr it fails

Test 1.4 seems the regexp fails
Test 1.5 seems the regexp fails

Attached source code of the page
Attachments
programming.htm
(132.18 KiB) Downloaded 72 times
Mitu
Junior Member
 
Posts: 6
Joined: Wed May 06, 2009 6:32 pm
Location: Barcelona

Re: [day 9] Problems with functional testing

Postby Mitu » Thu May 07, 2009 11:07 am

More news
The problem is that in prod enviroment, it doesn't show /categories/programming

Well, in fact it doen't show anything, only the main index.

Any idea?
Last edited by Mitu on Thu May 07, 2009 11:35 am, edited 1 time in total.
Mitu
Junior Member
 
Posts: 6
Joined: Wed May 06, 2009 6:32 pm
Location: Barcelona

Re: [day 9] Problems with functional testing

Postby Mitu » Thu May 07, 2009 11:55 am

Weird problem,
WAMP server doesn't have mod_rewrite.so active by default!

But still have a 404 on the 1.3 test



Code: Select all
>   
> 1 - The category page
>   1.1 - Categories on homepage are clickable
# get /
# get /category/programming
ok 1 - request parameter module is category
ok 2 - request parameter action is show
ok 3 - request parameter slug is programming
>   1.2 - Categories with more than 10 jobs also have a "more" link
# get /
# get /category/programming
ok 4 - request parameter module is category
ok 5 - request parameter action is show
ok 6 - request parameter slug is programming
>   1.3 - Only 20 jobs are listed
 Response debug

HTTP/1.X 404
Status: 404 Not Found
Content-Type: text/html; charset=utf-8
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<link rel="shortcut icon" href="/favicon.ico" />
<!--[if lt IE 7.]>
<link rel="stylesheet" type="text/css" media="screen" href="/sf/sf_default/css/ie.css" />
<![endif]-->
<link rel="stylesheet" type="text/css" media="screen" href="/css/main.css" />
<link rel="stylesheet" type="text/css" media="screen" href="/sf/sf_default/css/screen.css" />
</head>
<body>
<div class="sfTContainer">
  <a href="http://www.symfony-project.org/"><img alt="symfony PHP Framework" class="sfTLogo" src="/sf/sf_default/images/sfTLogo.png" height="39" width="186" /></a>
<div class="sfTMessageContainer sfTAlert">
  <img alt="page not found" class="sfTMessageIcon" src="/sf/sf_default/images/icons/cancel48.png" height="48" width="48" />  <div class="sfTMessageWrap">
    <h1>Oops! Page Not Found</h1>
    <h5>The server returned a 404 response.</h5>
  </div>
</div>
<dl class="sfTMessageInfo">
  <dt>Did you type the URL?</dt>
  <dd>You may have typed the address (URL) incorrectly. Check it to make sure you've got the exact right spelling, capitalization, etc.</dd>
  <dt>Did you follow a link from somewhere else at this site?</dt>
  <dd>If you reached this page from another part of this site, please email us at <a href="mailto:[email]">[email]</a> so we can correct our mistake.</dd>
  <dt>Did you follow a link from another site?</dt>
  <dd>Links from other sites can sometimes be outdated or misspelled. Email us at <a href="mailto:[email]">[email]</a> where you came from and we can try to contact the other site in order to fix the problem.</dd>
  <dt>What's next</dt>
  <dd>
    <ul class="sfTIconList">
      <li class="sfTLinkMessage"><a href="javascript:history.go(-1)">Back to previous page</a></li>
      <li class="sfTLinkMessage"><a href="/index.php/">Go to Homepage</a></li>
    </ul>
  </dd>
</dl>
</div>
</body>
</html>
Last edited by Mitu on Thu May 07, 2009 12:49 pm, edited 1 time in total.
Mitu
Junior Member
 
Posts: 6
Joined: Wed May 06, 2009 6:32 pm
Location: Barcelona

Re: [day 9] Problems with functional testing

Postby Mitu » Thu May 07, 2009 2:40 pm

Found the main problem

every time a test is executed fixtures are loades

in my categories.yml I have

Code: Select all
# data/fixtures/categories.yml
JobeetCategory:
  design:
    name: Design
  programming:
    name: Programming
  manager:
    name: Manager
  administrator:
    name: Administrator



So the "slug" column in the db is empty, even if i add a
slug: programming
it remains empty (not if slug and name are different).
If I hack the JobeetTestFucntional.class.php to not delete the table AND I update manually the slug value to "programming" (with lower P) it works!

Then 2 questions:
1.- Why categories.yml doesn't have a slug value, tutorial mistake?
2.- Why if I set a value (equal to the name, but with lower first letter) for slug in categories.yml it doesn't update the table

Solution:
Modify categories.yml (the test one) with this

Code: Select all
# data/fixtures/categories.yml
JobeetCategory:
  design:
    name: Design
    slug: Design
  programming:
    name: Programming
    slug: Programming
  manager:
    name: Manager
    slug: MAnager
  administrator:
    name: Administrator
    slug: Administrator
Last edited by Mitu on Thu May 07, 2009 4:53 pm, edited 1 time in total.
Mitu
Junior Member
 
Posts: 6
Joined: Wed May 06, 2009 6:32 pm
Location: Barcelona

Re: [day 9] Problems with functional testing

Postby Mitu » Thu May 07, 2009 4:43 pm

And the last tutorial mistake:

symfony test:functional frontend jobActions
it also reload the fixtures, but there's none with expire_at before today so "$browser->getExpiredJob()" returns an empty object hence

Code: Select all
>   2.3 - An expired job page forwards the user to a 404
Fatal error: Call to a member function getId() on a non-object in C:\wamp\www\sfprojects\jobeet\test\functional\frontend\jobActionsTest.php on line 60
Call Stack:
    0.0003      53344   1. {main}() C:\wamp\www\sfprojects\jobeet\symfony:0
    0.0068     302512   2. include('C:\wamp\www\sfprojects\jobeet\lib\vendor\symfony\lib\command\cli.php') C:\wamp\www\sfprojects\jobeet\symfony:14
    0.4751    4943824   3. sfSymfonyCommandApplication->run() C:\wamp\www\sfprojects\jobeet\lib\vendor\symfony\lib\command\cli.php:20
    0.4808    5113104   4. sfTask->runFromCLI() C:\wamp\www\sfprojects\jobeet\lib\vendor\symfony\lib\command\sfSymfonyCommandApplication.class.php:72
    0.4809    5113448   5. sfBaseTask->doRun() C:\wamp\www\sfprojects\jobeet\lib\vendor\symfony\lib\task\sfTask.class.php:75
    0.5130    5959888   6. sfTestFunctionalTask->execute() C:\wamp\www\sfprojects\jobeet\lib\vendor\symfony\lib\task\sfBaseTask.class.php:63
    0.5168    6001720   7. include('C:\wamp\www\sfprojects\jobeet\test\functional\frontend\jobActionsTest.php') C:\wamp\www\sfprojects\jobeet\lib\vendor\symfony\lib\task\test\sfTestFunctionalTask.class.php:69



So you must add another job in data/fixtures/jobs.yml with an expired date (don't change the date of an existant one, if so, then the test wouldn't find the '22' link to click!)
Like this one

Code: Select all
job_sensio_labs_2:
    JobeetCategory: programming
    type:         full-time
    company:      Sensio Labs
    logo:         sensio-labs.gif
    url:          http://www.sensiolabs.com/
    position:     Web Developer
    location:     Paris, France
    description:  |
      You've already developed websites with symfony and you want to work
      with Open-Source technologies. You have a minimum of 3 years
      experience in web development with PHP or Java and you wish to
      participate to development of Web 2.0 sites using the best
      frameworks available.
    how_to_apply: |
      Send your resume to fabien.potencier [at] sensio.com
    is_public:    true
    is_activated: true
    token:        job_sensio_labs_2
    email:        job@example.com
    expires_at:   '2009-05-01'


See you!
Last edited by Mitu on Thu May 07, 2009 4:56 pm, edited 1 time in total.
Mitu
Junior Member
 
Posts: 6
Joined: Wed May 06, 2009 6:32 pm
Location: Barcelona

Re: [day 9] Problems with functional testing

Postby gearond » Thu Jun 04, 2009 1:48 am

Shouldn't the slug field have the first letter as lower case?
gearond
Member
 
Posts: 52
Joined: Thu Apr 30, 2009 7:52 pm

Re: [day 9] I have the same problem! Please Help!

Postby Bangonkali » Sun Feb 27, 2011 1:50 pm

Edited by moderator: removed double post, post can be seen here: viewtopic.php?f=22&t=32940&start=0
User avatar
Bangonkali
Junior Member
 
Posts: 3
Joined: Sun Feb 27, 2011 11:18 am


Return to jobeet

Who is online

Users browsing this forum: No registered users and 1 guest