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/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php