-
-
Notifications
You must be signed in to change notification settings - Fork 167
Expand file tree
/
Copy pathWritePhpFunctionTest.php
More file actions
36 lines (29 loc) · 1.42 KB
/
WritePhpFunctionTest.php
File metadata and controls
36 lines (29 loc) · 1.42 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
<?php
declare(strict_types=1);
namespace Safe\Generator;
use PHPUnit\Framework\TestCase;
use Safe\PhpStanFunctions\PhpStanFunctionMapReader;
use Safe\XmlDocParser\ErrorType;
use Safe\XmlDocParser\DocPage;
use Safe\XmlDocParser\Method;
class WritePhpFunctionTest extends TestCase
{
public function testGetPhpPrototypeFunctionRegular(): void
{
$docPage = new DocPage(DocPage::referenceDir() . '/pcre/functions/preg-match.xml');
$xmlObject = $docPage->getMethodSynopsis();
$method = new Method($xmlObject[0], $docPage->loadAndResolveFile(), $docPage->getModule(), new PhpStanFunctionMapReader(), ErrorType::FALSY);
$writePhpFunction = new WritePhpFunction($method);
$funcStr = $writePhpFunction->getPhpFunctionalFunction();
$this->assertStringContainsString('function preg_match(string $pattern', $funcStr);
}
public function testGetPhpPrototypeFunctionOverloaded(): void
{
$docPage = new DocPage(DocPage::referenceDir() . '/filesystem/functions/file-get-contents.xml');
$xmlObject = $docPage->getMethodSynopsis();
$method = new Method($xmlObject[0], $docPage->loadAndResolveFile(), $docPage->getModule(), new PhpStanFunctionMapReader(), ErrorType::FALSY);
$writePhpFunction = new WritePhpFunction($method);
$funcStr = $writePhpFunction->getPhpFunctionalFunction();
$this->assertStringContainsString('} else {', $funcStr);
}
}