-
-
Notifications
You must be signed in to change notification settings - Fork 467
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1561 from phalcon/development
0.9.10
- Loading branch information
Showing
8 changed files
with
202 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
|
||
namespace Test; | ||
|
||
class FunctionExists | ||
{ | ||
public function testWithPassedName(string func) -> bool | ||
{ | ||
return function_exists(func); | ||
} | ||
|
||
public function testBuiltInFunctions() -> array | ||
{ | ||
var func; | ||
array result = []; | ||
|
||
array functions = [ | ||
"substr", | ||
"cubstr", | ||
"ucfirst", | ||
"bcfirst", | ||
"stripos", | ||
"ktripos", | ||
"trim", | ||
"prim" | ||
]; | ||
|
||
for func in functions { | ||
let result[func] = function_exists(func); | ||
} | ||
|
||
return result; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<?php | ||
|
||
/* | ||
+--------------------------------------------------------------------------+ | ||
| Zephir Language | | ||
+--------------------------------------------------------------------------+ | ||
| Copyright (c) 2013-2017 Zephir Team and contributors | | ||
+--------------------------------------------------------------------------+ | ||
| This source file is subject the MIT license, that is bundled with | | ||
| this package in the file LICENSE, and is available through the | | ||
| world-wide-web at the following url: | | ||
| https://zephir-lang.com/license.html | | ||
| | | ||
| If you did not receive a copy of the MIT license and are unable | | ||
| to obtain it through the world-wide-web, please send a note to | | ||
| [email protected] so we can mail you a copy immediately. | | ||
+--------------------------------------------------------------------------+ | ||
*/ | ||
|
||
namespace Extension; | ||
|
||
use Test\FunctionExists; | ||
|
||
class FunctionExistsTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* @test | ||
* @dataProvider providerInternalFunctions | ||
* @issue 1547 | ||
* @param string $func The internal (built-in) function name | ||
*/ | ||
public function shouldCorrectDetectestExistenceWithPassedName($func) | ||
{ | ||
$t = new FunctionExists(); | ||
$this->assertTrue($t->testWithPassedName($func)); | ||
} | ||
|
||
/** | ||
* @test | ||
* @issue 1547 | ||
*/ | ||
public function shouldCorrectDetectestExistenceInsideTheZephirCode() | ||
{ | ||
$t = new FunctionExists(); | ||
$expected = [ | ||
"substr" => true, | ||
"cubstr" => false, | ||
"ucfirst" => true, | ||
"bcfirst" => false, | ||
"stripos" => true, | ||
"ktripos" => false, | ||
"trim" => true, | ||
"prim" => false, | ||
]; | ||
|
||
$this->assertSame($expected, $t->testBuiltInFunctions()); | ||
} | ||
|
||
public function providerInternalFunctions() | ||
{ | ||
$allFunctions = get_defined_functions(); | ||
shuffle($allFunctions['internal']); | ||
|
||
$functions = array_map( | ||
function ($value) { | ||
return [$value]; | ||
}, | ||
$allFunctions['internal'] | ||
); | ||
|
||
return array_slice($functions, 0, 10); | ||
} | ||
} |