added feedback from @nunomaduro

This commit is contained in:
Adrian Nürnberger
2020-06-19 20:39:09 +02:00
parent d0a74931dd
commit 75f7ee0acf
6 changed files with 23 additions and 73 deletions

View File

@ -53,11 +53,6 @@ trait TestCase
$this->setGroups($groups);
}
public function addDependencies(array $tests): void
{
$this->setDependencies($tests);
}
/**
* Returns the test case name. Note that, in Pest
* we ignore withDataset argument as the description
@ -144,7 +139,7 @@ trait TestCase
{
return ExceptionTrace::ensure(function () use ($closure, $arguments) {
return call_user_func_array(Closure::bind($closure, $this, get_class($this)), $arguments);
})->getValue();
});
}
public function getPrintableTestCaseName(): string

View File

@ -84,20 +84,15 @@ final class TestCall
return $this;
}
public function dependsOn(string ...$tests): TestCall
public function depends(string ...$tests): TestCall
{
$this->testCaseFactory
->factoryProxies
->add(Backtrace::file(), Backtrace::line(), 'addDependencies', [$tests]);
->add(Backtrace::file(), Backtrace::line(), 'setDependencies', [$tests]);
return $this;
}
public function depends(string ...$tests): TestCall
{
return $this->dependsOn(...$tests);
}
/**
* Makes the test suite only this test case.
*/

View File

@ -18,10 +18,10 @@ final class ExceptionTrace
* Ensures the given closure reports
* the good execution context.
*/
public static function ensure(Closure $closure): Mixed
public static function ensure(Closure $closure)
{
try {
return new Mixed($closure());
return $closure();
} catch (Throwable $throwable) {
if (Str::startsWith($message = $throwable->getMessage(), self::UNDEFINED_METHOD)) {
$message = str_replace(self::UNDEFINED_METHOD, 'Call to undefined method ', $message);

View File

@ -1,32 +0,0 @@
<?php
declare(strict_types=1);
namespace Pest\Support;
/**
* @internal
*/
final class Mixed
{
/**
* @var mixed
*/
private $value;
/**
* @param mixed $value
*/
public function __construct($value)
{
$this->value = $value;
}
/**
* @return mixed
*/
public function getValue()
{
return $this->value;
}
}