6 Comments

  1. Arlen
    April 21, 2011 @ 10:47 pm

    OK, tried it.

    Stability is beta, so the install line needs –stability-beta, but no real problem.

    Ran the generate-config without a hitch. Then I decided to test one of my simpler models, as a start for using this. I did:

    ./symfony phpunit:generate-unit Resource

    and that’s when the problems started. I put the usual

    $this->object = new Resource();

    in setUp(), and it crashed with:
    Doctrine_Manager_Exception: Unknown connection: doctrine

    So what’s the secret to actually getting this plugin to work?

    Reply

    • Jacob Mather
      April 22, 2011 @ 7:08 am

      Arlen,

      I think the unit test bootstrap isn’t set up for database stuff, but I could be wrong.

      I don’t actually test my doctrine objects yet (I’m working to make sure my business logic stays out of them, so it is easier to move to sf2 when I am ready).

      I think, if you copy test/phpunit/bootstrap/unit.php to test/phpunit/bootsrrap/db-unit.php and then add the following to the bottom, it might work:

      $databaseManager = new sfDatabaseManager($configuration);

      Reply

      • Arlen
        April 28, 2011 @ 10:54 pm

        The problem is, the model is where the business logic is *supposed* to go, even in symfony2.

        I’ll try that, next go-round. After I hit that error, I went back to github and pulled down the latest version of the phpunit plugin without the 2 and used it instead. While there were some bits of phpunit2plugin I liked, the other one ran with minimal effort, so I could get on with development.

        Reply

        • Jacob Mather
          May 2, 2011 @ 9:10 pm

          You can put the business logic in the model, but then your tests can have a heavy cost to create to test.

          I think it makes much more sense to build your business logic separately and then use the model as a data source or store. It keeps your test expense lightweight, and completely decouples you from the underlying storage solution.

          Granted, I am not up on sf2 yet, and perhaps Doctrine 2 uses ‘dumb’ models which don’t actually rely on the underlying ORM. If so, then all the better!

          Reply

  2. Duncan
    September 29, 2011 @ 2:47 am

    Hi, I was looking for the solution to a symfony functional test issue when I found your post.

    Can you help??

    My problem is to click a stanard onclick confirm box which pops up on my webpage (onclick=”return confirm(‘Are you sure?’);). I include a piece of test code below. Thanks in advance!

    // test the complete
    click(‘Complete!’)->

    !!! HOW DO I TEST FOR A JS CONFIRM BOX HERE

    with(‘request’)->begin()->
    isParameter(‘module’, ‘factory’)->
    isParameter(‘action’, ‘complete’)->

    Reply

    • Jacob Mather
      September 29, 2011 @ 6:31 am

      Hi Duncan,

      I unfortunately don’t have much experience with the functional tests.

      Are you sure JS even runs? I would assume that portion wouldn’t be testable in a functional test.

      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *