elliotchance / elliotchance/concise
SetUp() and tearDown() once fixtures
- Dominant language
- PHP
- Stars
- 45
- Forks
- 3
- PR merge metrics
- No merged PRs in 30d
Description
Theres lots of ways this can be done, but in its most basic form you want to to run methods once, like:
``` php
public function testGetAllAttendance()
{
$this->setUpOnce([$this, 'data']);
...
}
public function setUpOnce(callable $function)
{
static $setUp = [];
$key = get_class($function[0]) . '::' . $function[1];
if (!array_key_exists($key, $setUp)) {
$function();
$setUp[$key] = get_object_vars($this);
} else {
foreach ($setUp[$key] as $k => $v) {
$this->$k = $v;
}
}
}
public function data()
{
$this->company = $this->createCompany();
...
}
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.