Skip to content

Commit 562f748

Browse files
author
Christian Blanquera
committed
unit testing and fixes
1 parent 67c8f9b commit 562f748

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+1261
-357
lines changed

phpunit.xml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
<file>test/Profiler/InspectorTrait.php</file>
3131
<file>test/Profiler/LoggerTrait.php</file>
3232
</testsuite>
33-
<testsuite name="Event Test Suite">
33+
<testsuite name="Event Test Suite">
3434
<file>test/Event/EventEmitter.php</file>
3535
<file>test/Event/EventObserver.php</file>
3636
<file>test/Event/EventTrait.php</file>
@@ -76,6 +76,7 @@
7676
<file>test/IO/Request/StageTrait.php</file>
7777
<file>test/IO/Response/ContentTrait.php</file>
7878
<file>test/IO/Response/HeaderTrait.php</file>
79+
<file>test/IO/Response/PageTrait.php</file>
7980
<file>test/IO/Response/ResponseTrait.php</file>
8081
<file>test/IO/Response/RestTrait.php</file>
8182
<file>test/IO/Response/StatusTrait.php</file>
@@ -114,6 +115,10 @@
114115
<file>test/Async/Promise.php</file>
115116
<file>test/Async/AsyncTrait.php</file>
116117
</testsuite>
118+
<testsuite name="OAuth Test Suite">
119+
<file>test/OAuth/OAuth1.php</file>
120+
<file>test/OAuth/OAuth2.php</file>
121+
</testsuite>
117122
</testsuites>
118123

119124
<coverage processUncoveredFiles="false" pathCoverage="true">
@@ -146,6 +151,7 @@
146151
<file>src/Async/map/noop.php</file>
147152
<file>src/Async/map/shutdown.php</file>
148153
<file>src/Async/map/socket.php</file>
154+
<file>src/Terminal/map.php</file>
149155
</exclude>
150156
</coverage>
151157
</phpunit>

src/Async/Promise.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,7 @@ protected function settle(int $state, SplQueue $queue = null): bool
444444

445445
//if the return value is a Promise
446446
if ($value instanceof Promise) {
447+
// @codeCoverageIgnoreStart
447448
//we need to wait for the value before continuing
448449
$fulfill = function ($value) use ($queue) {
449450
//set the value
@@ -458,6 +459,7 @@ protected function settle(int $state, SplQueue $queue = null): bool
458459
//continue to settle
459460
$this->settle(static::STATUS_REJECTED, $queue);
460461
};
462+
// @codeCoverageIgnoreEnd
461463

462464
$value->then($fulfill, $reject);
463465

src/Curl/CurlHandler.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,11 @@ public function __call($name, $args)
154154
*/
155155
public function __construct(Closure $map = null)
156156
{
157+
// @codeCoverageIgnoreStart
157158
if (is_null(self::$mapCache)) {
158159
self::$mapCache = include(__DIR__ . '/map.php');
159160
}
161+
// @codeCoverageIgnoreEnd
160162

161163
$this->map = self::$mapCache;
162164

src/Curl/Rest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,10 @@ public function __call(string $name, array $args)
112112
return $this;
113113
}
114114

115+
// @codeCoverageIgnoreStart
115116
//let the parent handle the rest
116117
return parent::__call($name, $args);
118+
// @codeCoverageIgnoreEnd
117119
}
118120

119121
/**
@@ -309,9 +311,11 @@ public function send(string $method, string $path)
309311
case CurlHandler::ENCODE_JSON:
310312
$response = $request->getJsonResponse(); // get the json response
311313
break;
314+
// @codeCoverageIgnoreStart
312315
case CurlHandler::ENCODE_XML:
313316
$response = $request->getSimpleXmlResponse(); // get the xml response
314317
break;
318+
// @codeCoverageIgnoreEnd
315319
case CurlHandler::ENCODE_RAW:
316320
default:
317321
$response = $request->getResponse(); // get the raw response

src/Data/DotTrait.php

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,6 @@ public function getDot(string $notation, string $separator = '.')
3131
{
3232
$args = explode($separator, $notation);
3333

34-
if (count($args) == 0) {
35-
return null;
36-
}
37-
3834
$last = array_pop($args);
3935
$pointer = &$this->data;
4036

@@ -65,10 +61,6 @@ public function isDot(string $notation, string $separator = '.'): bool
6561
{
6662
$args = explode($separator, $notation);
6763

68-
if (count($args) == 0) {
69-
return false;
70-
}
71-
7264
$last = array_pop($args);
7365

7466
$pointer = &$this->data;
@@ -101,10 +93,6 @@ public function removeDot(string $notation, string $separator = '.')
10193
{
10294
$args = explode($separator, $notation);
10395

104-
if (count($args) === 0) {
105-
return $this;
106-
}
107-
10896
$last = array_pop($args);
10997

11098
$pointer = &$this->data;
@@ -137,10 +125,6 @@ public function setDot(string $notation, $value, string $separator = '.')
137125
{
138126
$args = explode($separator, $notation);
139127

140-
if (count($args) === 0) {
141-
return $this;
142-
}
143-
144128
$last = array_pop($args);
145129

146130
$pointer = &$this->data;

src/Event/EventEmitter.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,12 @@ public function emit(string $event, ...$args): EventInterface
7979
foreach ($matches as $match) {
8080
$event = $match['pattern'];
8181

82+
// @codeCoverageIgnoreStart
8283
//if no direct observers
8384
if (!isset($this->observers[$event])) {
8485
continue;
8586
}
87+
// @codeCoverageIgnoreEnd
8688

8789
//add args on to match
8890
$match['args'] = $args;
@@ -293,12 +295,6 @@ protected function unbindByCallback(callable $callback): EventInterface
293295
*/
294296
protected function unbindByEvent(string $event, callable $callback): EventInterface
295297
{
296-
//if event isn't set
297-
if (!isset($this->observers[$event])) {
298-
//do nothing
299-
return $this;
300-
}
301-
302298
//'foobar' => array(
303299
foreach ($this->observers[$event] as $i => $observer) {
304300
//0 => callback

src/Http/HttpDispatcher.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public function __construct(Closure $output = null, Closure $redirect = null)
8080
* Starts to process the request
8181
*
8282
* @param ResponseInterface $response The response object to evaluate
83-
* @param bool $emulate If you really want it to echo (for testing)
83+
* @param bool $emulate If you really want it to echo (for testing)
8484
*
8585
* @return array with request and response inside
8686
*/
@@ -116,7 +116,7 @@ public function dispatch(ResponseInterface $response, bool $emulate = false)
116116
* output. Then of course, output it
117117
*
118118
* @param ResponseInterface $response The response object to evaluate
119-
* @param bool $emulate If you really want it to echo (for testing)
119+
* @param bool $emulate If you really want it to echo (for testing)
120120
*
121121
* @return HttpHandler
122122
*/
@@ -145,9 +145,9 @@ public function output(ResponseInterface $response, bool $emulate = false)
145145
/**
146146
* Browser redirect
147147
*
148-
* @param *string $path Where to redirect to
149-
* @param bool $force Whether if you want to exit immediately
150-
* @param bool $emulate If you really want it to redirect (for testing)
148+
* @param *string $path Where to redirect to
149+
* @param bool $force Whether if you want to exit immediately
150+
* @param bool $emulate If you really want it to redirect (for testing)
151151
*
152152
* @return HttpDispatcher
153153
*/

src/Http/HttpTrait.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,15 @@ protected function hasRedirect(): bool
102102
return true;
103103
}
104104

105+
// @codeCoverageIgnoreStart
105106
//we need to also check the PHP headers
106107
foreach (headers_list() as $header) {
107108
//if there was a redirect set
108109
if (strpos(strtolower($header), 'location:') === 0) {
109110
return true;
110111
}
111112
}
113+
// @codeCoverageIgnoreEnd
112114

113115
//no redirect was found
114116
return false;

src/Http/Router.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,6 @@ public function route(
7777
callable $callback,
7878
int $priority = 0
7979
): RouterInterface {
80-
//hard requirement
81-
if (!is_callable($callback)) {
82-
throw HttpException::forInvalidRouteCallback();
83-
}
84-
8580
if (strtoupper($method) === 'ALL') {
8681
$method = '[a-zA-Z0-9]+';
8782
}

src/I18n/Timezone.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,9 @@ public function toRelative(
287287
return $difference . ' ' . $relative . ($difference === 1 ? '' : 's') . $suffix;
288288
}
289289

290+
// @codeCoverageIgnoreStart
290291
return date($default, $this->time);
292+
// @codeCoverageIgnoreEnd
291293
}
292294

293295
/**
@@ -408,7 +410,9 @@ protected function getOffsetFromUtc(string $zone)
408410
return ($hour+$minute) * ($add?1:-1);
409411
}
410412

413+
// @codeCoverageIgnoreStart
411414
return 0;
415+
// @codeCoverageIgnoreEnd
412416
}
413417

414418
/**

0 commit comments

Comments
 (0)