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:

$this->assertWantedPattern('~<span class="invalid"><input[^>]+></span>$~i'
, $html);

where

$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

Well the expression is correct… this was the problem

[COLOR=#000000][COLOR=#0000bb]$html [/COLOR][COLOR=#007700]= <[/COLOR][COLOR=#0000bb]span [/COLOR][COLOR=#007700]class=[/COLOR][COLOR=#dd0000]"invalid"[/COLOR][COLOR=#007700]><[/COLOR][COLOR=#0000bb]input type[/COLOR][COLOR=#007700]=[/COLOR][COLOR=#dd0000]"text" 
[/COLOR][COLOR=#0000bb]name[/COLOR][COLOR=#007700]=[/COLOR][COLOR=#dd0000]"email" [/COLOR][COLOR=#0000bb]value[/COLOR][COLOR=#007700]=[/COLOR][COLOR=#dd0000]""  [/COLOR][COLOR=#007700]class=[/COLOR][COLOR=#dd0000]"noclass"[/COLOR][COLOR=#007700][SIZE=5][B][COLOR=Purple]>[/COLOR][/B][/SIZE]</[/COLOR][COLOR=#0000bb]span[/COLOR][COLOR=#007700]>  [/COLOR][/COLOR]

missing the ‘>’ to close the <input> tag.

I use assertPattern() - is that an old method assertWantedPattern() ?

Hi Cups,

I use assertPattern() - is that an old method assertWantedPattern() ?

Yes it is and it appears to work the same as assertPattern().

:slight_smile:
Steve