web/vendor/thecodingmachine/safe/generator/tests/MethodTest.php
2019-03-07 12:11:50 -06:00

44 lines
1.9 KiB
PHP

<?php
namespace Safe;
use PHPUnit\Framework\TestCase;
use Safe\PhpStanFunctions\PhpStanFunctionMapReader;
class MethodTest extends TestCase
{
public function testGetFunctionName() {
$docPage = new DocPage(__DIR__ . '/../doc/doc-en/en/reference/pcre/functions/preg-match.xml');
$xmlObject = $docPage->getMethodSynopsis();
$method = new Method($xmlObject[0], $docPage->loadAndResolveFile(), $docPage->getModule(), new PhpStanFunctionMapReader());
$name = $method->getFunctionName();
$this->assertEquals('preg_match', $name);
}
public function testGetFunctionType() {
$docPage = new DocPage(__DIR__ . '/../doc/doc-en/en/reference/pcre/functions/preg-match.xml');
$xmlObject = $docPage->getMethodSynopsis();
$method = new Method($xmlObject[0], $docPage->loadAndResolveFile(), $docPage->getModule(), new PhpStanFunctionMapReader());
$type = $method->getReturnType();
$this->assertEquals('int', $type);
}
public function testGetFunctionParam() {
$docPage = new DocPage(__DIR__ . '/../doc/doc-en/en/reference/pcre/functions/preg-match.xml');
$xmlObject = $docPage->getMethodSynopsis();
$method = new Method($xmlObject[0], $docPage->loadAndResolveFile(), $docPage->getModule(), new PhpStanFunctionMapReader());
$params = $method->getParams();
$this->assertEquals('string', $params[0]->getType());
$this->assertEquals('pattern', $params[0]->getParameter());
}
public function testGetInitializer() {
$docPage = new DocPage(__DIR__ . '/../doc/doc-en/en/reference/apc/functions/apc-cache-info.xml');
$xmlObject = $docPage->getMethodSynopsis();
$method = new Method($xmlObject[0], $docPage->loadAndResolveFile(), $docPage->getModule(), new PhpStanFunctionMapReader());
$params = $method->getParams();
$this->assertEquals('', $params[0]->getDefaultValue());
}
}