|
7 | 7 | use Leapt\FroalaEditorBundle\Utility\UConfiguration; |
8 | 8 | use PHPUnit\Framework\TestCase; |
9 | 9 | use Symfony\Component\DomCrawler\Crawler; |
| 10 | +use Symfony\Component\HttpClient\Exception\ClientException; |
10 | 11 | use Symfony\Component\HttpClient\HttpClient; |
11 | 12 |
|
12 | 13 | final class UConfigurationTest extends TestCase |
13 | 14 | { |
14 | 15 | public function testAllOptionsAreRegistered(): void |
15 | 16 | { |
16 | | - $url = 'https://froala.com/wysiwyg-editor/docs/options/'; |
17 | | - $httpClient = HttpClient::create(); |
18 | | - $crawler = new Crawler($httpClient->request('GET', $url)->getContent()); |
19 | | - $optionsFromDocs = $crawler->filter('.docs-data-list.block-box a'); |
20 | | - $registeredOptions = UConfiguration::getArrOptionAll(); |
21 | | - $proxyOrIgnoredOptions = ['Key', 'editor']; |
22 | | - $missingOptions = []; |
| 17 | + try { |
| 18 | + $url = 'https://froala.com/wysiwyg-editor/docs/options/'; |
| 19 | + $httpClient = HttpClient::create(); |
| 20 | + $crawler = new Crawler($httpClient->request('GET', $url)->getContent()); |
| 21 | + $optionsFromDocs = $crawler->filter('.docs-data-list.block-box a'); |
| 22 | + $registeredOptions = UConfiguration::getArrOptionAll(); |
| 23 | + $proxyOrIgnoredOptions = ['Key', 'editor']; |
| 24 | + $missingOptions = []; |
23 | 25 |
|
24 | | - foreach ($optionsFromDocs as $option) { |
25 | | - if (!\in_array($option->textContent, $registeredOptions, true) && !\in_array($option->textContent, $proxyOrIgnoredOptions, true)) { |
26 | | - $missingOptions[] = $option->textContent; |
| 26 | + foreach ($optionsFromDocs as $option) { |
| 27 | + if (!\in_array($option->textContent, $registeredOptions, true) && !\in_array($option->textContent, $proxyOrIgnoredOptions, true)) { |
| 28 | + $missingOptions[] = $option->textContent; |
| 29 | + } |
27 | 30 | } |
28 | | - } |
29 | 31 |
|
30 | | - self::assertSame([], $missingOptions); |
| 32 | + self::assertSame([], $missingOptions); |
| 33 | + } catch (ClientException $e) { |
| 34 | + $this->markTestSkipped(sprintf('Unable to retrieve options docs page: %s', $e->getMessage())); |
| 35 | + } |
31 | 36 | } |
32 | 37 | } |
0 commit comments