forked from spatie/laravel-sitemap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPest.php
63 lines (50 loc) · 1.54 KB
/
Pest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
use Carbon\Carbon;
use function PHPUnit\Framework\assertXmlStringEqualsXmlString;
use Spatie\TemporaryDirectory\TemporaryDirectory;
/*
|--------------------------------------------------------------------------
| Test Case
|--------------------------------------------------------------------------
*/
uses(\Spatie\Sitemap\Test\TestCase::class)
->beforeEach(function () {
$this->now = Carbon::create('2016', '1', '1', '0', '0', '0');
Carbon::setTestNow($this->now);
})
->in('.');
/*
|--------------------------------------------------------------------------
| Expectations
|--------------------------------------------------------------------------
*/
expect()->extend('toEqualXmlString', function (string $expected_xml) {
/** @var string */
$value = $this->value;
assertXmlStringEqualsXmlString($value, $expected_xml);
return $this;
});
/*
|--------------------------------------------------------------------------
| Functions
|--------------------------------------------------------------------------
*/
function checkIfTestServerIsRunning(): void
{
try {
file_get_contents('http://localhost:4020');
} catch (Throwable $e) {
handleTestServerNotRunning();
}
}
function handleTestServerNotRunning(): void
{
if (getenv('TRAVIS')) {
test()->fail('The test server is not running on Travis.');
}
test()->markTestSkipped('The test server is not running.');
}
function temporaryDirectory(): TemporaryDirectory
{
return (new TemporaryDirectory())->force()->create();
}