SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    Foozle Reducer ServerStorm's Avatar
    Join Date
    Feb 2005
    Location
    Burlington, Canada
    Posts
    2,699
    Mentioned
    89 Post(s)
    Tagged
    2 Thread(s)

    assertWantedPattern expression not working - why?

    Hi

    I am trying to use simpleTest's assertWantedPattern method to match some html and it is reporting an error when I think the expression is correct. Here is the assertion:
    PHP Code:
    $this->assertWantedPattern('~<span class="invalid"><input[^>]+></span>$~i'
    $html); 
    where
    PHP Code:
    $html = <span class="invalid"><input type="text" 
    name="email" value=""  class="noclass"</span
    . It should match but I get following error
    Fail: WidgetTestCase -> testInvalid -> Pattern [~<span class="invalid"><input[^>]+></span>$~i] not detected in [String: <span class="invalid"><input type="text" name="email" value="" class="noclass"</span>] at [/var/www/expresslead/tests/form_test.php line 25]
    2/2 test cases complete: 8 passes, 1 fails and 0 exceptions.
    The PCRE expression should work can you see why this expression fails?

    Regards,
    Steve
    ictus==""

  2. #2
    Foozle Reducer ServerStorm's Avatar
    Join Date
    Feb 2005
    Location
    Burlington, Canada
    Posts
    2,699
    Mentioned
    89 Post(s)
    Tagged
    2 Thread(s)
    Well the expression is correct... this was the problem
    Code:
    $html = <span class="invalid"><input type="text" 
    name="email" value=""  class="noclass"></span>  
    missing the '>' to close the <input> tag.
    ictus==""

  3. #3
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    I use assertPattern() - is that an old method assertWantedPattern() ?

  4. #4
    Foozle Reducer ServerStorm's Avatar
    Join Date
    Feb 2005
    Location
    Burlington, Canada
    Posts
    2,699
    Mentioned
    89 Post(s)
    Tagged
    2 Thread(s)
    Hi Cups,
    I use assertPattern() - is that an old method assertWantedPattern() ?
    Yes it is and it appears to work the same as assertPattern().


    Steve
    ictus==""


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •