Changeset View
Changeset View
Standalone View
Standalone View
src/utils/__tests__/PhutilUtilsTestCase.php
Show First 20 Lines • Show All 998 Lines • ▼ Show 20 Lines | foreach ($map as $name => $item) { | ||||
$this->assertEqual($expect, $actual, pht('Partition of "%s"', $name)); | $this->assertEqual($expect, $actual, pht('Partition of "%s"', $name)); | ||||
} | } | ||||
} | } | ||||
public function testEmptyStringMethods() { | public function testEmptyStringMethods() { | ||||
$uri = new PhutilURI('http://example.org/'); | $uri = new PhutilURI('http://example.org/'); | ||||
// Each test is defined in this way: | |||||
// 0: subject $value | |||||
// 1: expected result from phutil_nonempty_string($value) | |||||
// 2: expected result from phutil_nonempty_stringlike($value) | |||||
// 3: expected result from phutil_nonempty_scalar($value) | |||||
// 4: human test name | |||||
$map = array( | $map = array( | ||||
array(null, false, false, false, 'literal null'), | array(null, false, false, false, 'literal null'), | ||||
array('', false, false, false, 'empty string'), | array('', false, false, false, 'empty string'), | ||||
array('x', true, true, true, 'nonempty string'), | array('x', true, true, true, 'nonempty string'), | ||||
array(false, null, null, null, 'bool'), | array(false, null, null, false, 'false bool'), | ||||
array(true, null, null, true, 'true bool'), | |||||
valerio.bozzolan: This is a nightmare to read but it just reflects the above change to require not an exception. | |||||
array(1, null, null, true, 'integer'), | array(1, null, null, true, 'integer'), | ||||
array($uri, null, true, true, 'uri object'), | array($uri, null, true, true, 'uri object'), | ||||
array(2.5, null, null, true, 'float'), | array(2.5, null, null, true, 'float'), | ||||
array(array(), null, null, null, 'array'), | array(array(), null, null, null, 'array'), | ||||
array((object)array(), null, null, null, 'object'), | array((object)array(), null, null, null, 'object'), | ||||
); | ); | ||||
foreach ($map as $test_case) { | foreach ($map as $test_case) { | ||||
▲ Show 20 Lines • Show All 100 Lines • Show Last 20 Lines |
Content licensed under Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) unless otherwise noted; code licensed under Apache 2.0 or other open source licenses. · CC BY-SA 4.0 · Apache 2.0
This is a nightmare to read but it just reflects the above change to require not an exception. So:
nullfalsebool"false bool"Where it's NULL it means: return an exception.