13 require_once
'PU_testcase_dcp.php';
25 $u->setDefinitionText($text);
27 $this->assertContains($text, $u->getUsage());
39 $u->addRequiredParameter($argNeeded, $def);
45 $this->assertContains($argNeeded,
$usage);
46 $this->assertContains($def,
$usage);
59 $u->addRequiredParameter($argNeeded, $def);
63 $error = $e->getMessage();
66 $this->assertContains($argNeeded, $error);
67 $this->assertNotContains($def, $error);
68 $this->assertContains($argNeeded,
$usage);
69 $this->assertContains($def,
$usage);
74 if ($values === null)
return sprintf(
"This is the usage for argument %s", $argName);
75 if (!is_scalar($values))
return sprintf(
"Error in usageCallback for argument %s: type of value %s must be string", $argName, gettype($values));
88 $u->addRequiredParameter(
"needed",
"A needed argument", $callback);
89 $u->addOptionalParameter(
"optional",
"An optional argument", $callback);
90 $u->addHiddenParameter(
"hidden",
"An hidden argument", $callback);
96 $this->assertEmpty(
$usage);
105 $myvar =
"myvariable";
110 $u = new \ApiUsage();
111 $u->addRequiredParameter($myvar,
"A needed argument", $callback);
115 $error = $e->getMessage();
117 $this->assertContains(
"usageCallback", $error);
118 $this->assertContains($myvar, $error);
127 $myvar =
"myvariable";
132 $u = new \ApiUsage();
133 $u->addOptionalParameter($myvar,
"An optional argument", $callback);
137 $error = $e->getMessage();
139 $this->assertContains(
"usageCallback", $error);
140 $this->assertContains($myvar, $error);
151 $u = new \ApiUsage();
152 $u->addRequiredParameter(
"needed",
"A needed argument", $callback);
153 $u->addOptionalParameter(
"optional",
"An optional argument", $callback);
154 $u->addHiddenParameter(
"hidden",
"An hidden argument", $callback);
158 $usage = $e->getMessage();
160 $this->assertContains(
"CORE0003",
$usage, sprintf(
"usage found is %s",
$usage));
161 $this->assertNotContains(
"CORE0002",
$usage, sprintf(
"usage found is %s",
$usage));
168 "\Dcp\Pu\TestUsage::usageCallback",
169 "\Dcp\Pu\simpleFunctionUsageCallback",
174 function ($values, $argName, $apiUsage)
testBadCallbackNeededUsage($callback)
static usageCallback($values, $argName, $apiUsage)
testGoodCallbackUsage($callback)
testBadCallbackOptinalUsage($callback)
testCallbackUsage($callback)
testNeededApiUsageForceException($argNeeded, $def)
testNeededApiUsage($argNeeded, $def)
simpleFunctionUsageCallback($values, $argName,\ApiUsage $apiUsage)
Verify arguments for wsh programs.