Skip to content

Commit b28ec2e

Browse files
authored
Merge pull request #6 from MaplePHP/develop
Stream handling
2 parents e176c40 + 4f6c1ff commit b28ec2e

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

Unit.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ class Unit
1616
private Command $command;
1717
private bool $quite;
1818
private ?string $title = null;
19+
private string $output = "";
1920
private array $args = [];
2021
private array $units;
2122
private int $index = 0;
@@ -67,7 +68,9 @@ public function add(string $message, callable $callback): void
6768
$hasError = false;
6869
$test = $this->unitTest();
6970
// Make the tests
71+
ob_start();
7072
$callback($test);
73+
$this->output .= ob_get_clean();
7174
// Get the tests results
7275
$data = $test->getTestResult();
7376
$index = $this->index-1;
@@ -86,6 +89,35 @@ public function add(string $message, callable $callback): void
8689
}
8790
}
8891

92+
/**
93+
* Access command instance
94+
* @return Command
95+
*/
96+
public function command(): Command
97+
{
98+
return $this->command;
99+
}
100+
101+
/**
102+
* Print message
103+
* @param string $message
104+
* @return false|string
105+
*/
106+
public function message(string $message): false|string
107+
{
108+
return $this->command->message($message);
109+
}
110+
111+
/**
112+
* confirm for execute
113+
* @param string $message
114+
* @return bool
115+
*/
116+
public function confirm(string $message = "Do you wish to continue?"): bool
117+
{
118+
return $this->command->confirm($message);
119+
}
120+
89121
/**
90122
* Execute tests suite
91123
* @return void
@@ -112,6 +144,8 @@ public function execute(): void
112144
} elseif(!$this->quite) {
113145
$this->command->approve("Every test has been successfully run!");
114146
}
147+
148+
$this->command->message($this->output);
115149
}
116150

117151
/**

0 commit comments

Comments
 (0)