1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-24 15:52:41 +01:00
phorge-phorge/src/view/__tests__/PhabricatorAphrontViewTestCase.php
epriestley 8ac2da9850 Provide hasChildren() to replace isEmptyContent()
Summary:
Fixes T3698. Sometimes views need to render differently depending on whether they contain content or not. The existing approach for this is `isEmptyContent()`, which doesn't work well and is sort of hacky (it implies double-rendering content, which is not always free or side-effect free).

Instead, provide a test for an element without children. This test is powerful enough to catch the easy cases of `null`, etc., and just do the expected thing, but will not catch a View which is reduced upon rendering. Since this is rare and we have no actual need for it today, just accept that as a limitation.

Test Plan:
Viewed Timeline and Feed UI examples. Viewed Feed (feed), Pholio (timelineview), and Differential (old transactionview).

{F53915}

Reviewers: chad, btrahan

Reviewed By: chad

CC: aran

Maniphest Tasks: T3698

Differential Revision: https://secure.phabricator.com/D6718
2013-08-12 07:51:01 -07:00

25 lines
515 B
PHP

<?php
final class PhabricatorAphrontViewTestCase extends PhabricatorTestCase {
public function testHasChildren() {
$view = new AphrontNullView();
$this->assertEqual(false, $view->hasChildren());
$values = array(
null,
'',
array(),
array(null, ''),
);
foreach ($values as $value) {
$view->appendChild($value);
$this->assertEqual(false, $view->hasChildren());
}
$view->appendChild("!");
$this->assertEqual(true, $view->hasChildren());
}
}