regexunit-testingcakephpsimpletest

How to write an AssertTags test in SimpleTest with regex?


I wish to test a function that will generate lorem ipsum text, but it does so within html tags. So I cant know in advance the textual content, but i know the html structure. That is what I want to test. And maybe that the length of the texts are within certain limits. So what I am wondering is if the assertTags can do this in a way paraphrased bellow:

Result = "<p>Some text</p>";
Expected = array( 
   '<p' ,
   'regex',
   '/p'
);
assertTags(resutl, expected)

I am using SimpleTest with CakePHP, but I think it should be a general question.


Solution

  • $expected = array(
        '<p',
        'preg:/[A-Za-z\.\s\,]+/',
        '/p'
    );