Re: Problem with AssertTag: children count wrong

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi, sorry, I forgot to include the class definition:

class GeneratedFiltersTest extends PHPUnit_Framework_Testcase {

function testUnconfiguredFilter() {
 $matcher = array(
        'tag' =>  'ul',
        'children' =>  array(
        'count' =>  3,
        'only' =>  array('tag' =>  'li')
        )
 );
$this->assertTag($matcher, $this->html, $message, $isHtml = FALSE);
}
}

I dont think that the problem is that $this does not exist. Other examples
of assertTag() and other assert* functions work perfectly well.
The only problem I have is when I use the 'children' option with assertTag,
because the count never hast the value it should have.

kind regards,
Michael
On Wed, May 2, 2012 at 9:22 PM, Jim Lucas <lists@xxxxxxxxx> wrote:

> On 05/02/2012 10:55 AM, Michael Otteneder wrote:
>
>> Hi List!
>>
>> I'm trying to use phpUnit's AssertTag function to make sure that some html
>> code contains an ul element with exactly li items in it.
>>
>> My test looks like this:
>>
>>
>> function testUnconfiguredFilter() {
>>  $matcher = array(
>> 'tag' =>  'ul',
>> 'children' =>  array(
>> 'count' =>  3,
>> 'only' =>  array('tag' =>  'li')
>> )
>> );
>> $this->assertTag($matcher, $this->html, $message, $isHtml = FALSE);
>> }
>>
>> the value of $html is:
>>
>> <div class="flFilterbox" id="**flFilterunconfiguredFilter">
>> <h3>unconfiguredFilter</h3>
>>
>> <ul class="flFilterboxInner">
>> <li><a href="">  FilterValue1</a>  ()</li>
>> <li><a href="">  FilterValue2</a>  ()</li>
>> <li><a href="">  FilterValue3</a>  ()</li>
>> </ul>
>> </div>
>>
>> So I think the assertion SHOULD work - but it does not, no matter what I
>> use for count! Sadly PHPUnit's output ist not very helpful, all it gives
>> me
>> is:
>>
>> 1) GeneratedFiltersTest::**testUnconfiguredFilter
>> Failed asserting that false is true.
>>
>
> When dealing with classes, and specifically calling a static method within
> a class, the variable $this does not exist.  You must use 'self' instead.
>
> You would need to do this instead if you wanted to use the $this way of
> things
>
> $test = new GeneratedFiltersTest;
> $test->testUnconfiguredFilter(**);
>
> Plus, I am going to assume (since I don't see your code), that the method
> "assertTag()" is in a parent class that is inherited by the class
> GeneratedFiltersTest and again, since you are calling it via a static
> method, the inheritance would not have taken place.
>
>
>
>>
>> Has someone got an idea whats going on? This is really freakin me out,
>> could not find anything about it anywhere on the web.
>>
>> Kind regards,
>> Michael
>>
>>
>
> --
> Jim Lucas
>
> http://www.cmsws.com/
> http://www.cmsws.com/examples/
> http://www.bendsource.com/
>

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux