-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFetchThePhpWebsiteSitemapsTest.php
More file actions
68 lines (53 loc) · 1.79 KB
/
Copy pathFetchThePhpWebsiteSitemapsTest.php
File metadata and controls
68 lines (53 loc) · 1.79 KB
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
64
65
66
67
68
<?php
declare(strict_types=1);
namespace Nawarian\Requirements;
use Generator;
use PHPUnit\Framework\TestCase;
class FetchThePhpWebsiteSitemapsTest extends TestCase
{
private Resolver $resolver;
protected function setUp(): void
{
$this->resolver = new Resolver();
}
public function testResolverFetchesSitemapsFromThePhpWebsite(): void
{
$service = new class {
public string $en;
public string $br;
public function fetchSitemaps(): Generator
{
$this->en = yield wrap($this)->getSitemap('en');
$this->br = yield wrap($this)->getSitemap('br');
}
public function getSitemap(string $language): string
{
return file_get_contents("https://thephp.website/{$language}/sitemap.xml");
}
};
$this->resolver->resolve($service->fetchSitemaps());
$this->assertNotNull($service->en);
$this->assertNotNull($service->br);
}
public function testResolverFetchesSitemapsFromThePhpWebsiteUsingArrayYield(): void
{
$service = new class {
public string $en;
public string $br;
public function fetchSitemaps(): Generator
{
list($this->en, $this->br) = yield [
wrap($this)->getSitemap('en'),
wrap($this)->getSitemap('br'),
];
}
public function getSitemap(string $language): string
{
return file_get_contents("https://thephp.website/{$language}/sitemap.xml");
}
};
$this->resolver->resolve($service->fetchSitemaps());
$this->assertNotNull($service->en);
$this->assertNotNull($service->br);
}
}