PMCORE-4013 Wizard trigger: is using a old library thirdparty/wizard please research to use a new or Reflection
This commit is contained in:
274
tests/resources/ContentPHPSourceCode.txt
Normal file
274
tests/resources/ContentPHPSourceCode.txt
Normal file
@@ -0,0 +1,274 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace ExampleNamespace;
|
||||
|
||||
use Some\Classes\{
|
||||
ClassA,
|
||||
ClassB,
|
||||
ClassC as C
|
||||
};
|
||||
|
||||
/**
|
||||
* Test
|
||||
*/
|
||||
class Example implements Iface1, Iface2, Iface3
|
||||
{
|
||||
|
||||
#[A1("param")]
|
||||
private ClassA|ClassB|null $unionType;
|
||||
|
||||
/**
|
||||
* Test
|
||||
* @var ClassA&ClassB
|
||||
*/
|
||||
private ClassA&ClassB $intersectionType;
|
||||
|
||||
/**
|
||||
* Test
|
||||
* @param type $a
|
||||
* @param type $b
|
||||
*/
|
||||
public function ifExample($a, $b)
|
||||
{
|
||||
if (convert($a) > $b) {
|
||||
echo "a is bigger than b";
|
||||
} elseif ($a == $b) {
|
||||
echo $a . " is equal to " . $b[0];
|
||||
} else {
|
||||
$result = getText($this->property1, $this->property2);
|
||||
}
|
||||
$result = $a < $b ? $a : $b;
|
||||
}
|
||||
|
||||
/**
|
||||
* test
|
||||
*/
|
||||
public function forExample()
|
||||
{
|
||||
for ($i = 1; $i <= 10; $i++) {
|
||||
echo 'Item: ';
|
||||
echo $i;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test
|
||||
*/
|
||||
public function foreachEample()
|
||||
{
|
||||
$arr = array(1, 2, 3, 4, "b" => 5, "a" => 6);
|
||||
foreach ($arr as &$value) {
|
||||
$value = (int) $value * 2;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test
|
||||
*/
|
||||
public function whileExample()
|
||||
{
|
||||
$i = 1;
|
||||
while ($i <= 10) {
|
||||
echo $i++;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test
|
||||
* @param type $i
|
||||
*/
|
||||
public function doWhileExample($i)
|
||||
{
|
||||
do {
|
||||
echo $i--;
|
||||
} while ($i > 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test
|
||||
*/
|
||||
public function switchExample()
|
||||
{
|
||||
switch ($i) {
|
||||
case 0:
|
||||
echo "i equals 0";
|
||||
break;
|
||||
case 1:
|
||||
echo "i equals 1";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test
|
||||
*/
|
||||
public function matchExample()
|
||||
{
|
||||
$result = match ($i) {
|
||||
1, 2, 3 => "1, 2, or 3",
|
||||
4, 5, => "4 or 5",
|
||||
default => $this->getDefaultValue(),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Test
|
||||
* @return int
|
||||
*/
|
||||
public function getDefaultValue(): int
|
||||
{
|
||||
return 10;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test
|
||||
*/
|
||||
public function tryExample()
|
||||
{
|
||||
try {
|
||||
echo inverse(5) . "\n";
|
||||
} catch (Exception $e) {
|
||||
echo 'Caught exception: ' . $e->getMessage() . "\n";
|
||||
} finally {
|
||||
echo "Finally block";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test
|
||||
* @param type $arg
|
||||
* @return \ExampleNamespace\#anon#ContentPHPSourceCode_php#1
|
||||
*/
|
||||
public function anonymousClassExample($arg)
|
||||
{
|
||||
$instance = new class($arg) extends Anonymous
|
||||
{
|
||||
|
||||
public function __construct($arg)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function anon()
|
||||
{
|
||||
echo "anonymous";
|
||||
}
|
||||
};
|
||||
return $instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test
|
||||
* @param type $arg1
|
||||
* @param type $arg2
|
||||
* @param type $arg3
|
||||
* @param type $arg4
|
||||
* @param type $arg5
|
||||
*/
|
||||
public function alignParamsExample($arg1, $arg2, $arg3, $arg4, $arg5)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Test
|
||||
* @param Class1|Class2|null $object
|
||||
* @return int|float|null
|
||||
*/
|
||||
public function unionTypesExample(Class1|Class2|null $object): int|float|null
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test
|
||||
* @param ClassA&ClassB $object
|
||||
* @return ClassA&ClassB
|
||||
*/
|
||||
public function intersectionTypesExample(ClassA&ClassB $object): ClassA&ClassB
|
||||
{
|
||||
return $object;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test
|
||||
* @param object $object
|
||||
*/
|
||||
public function nullsafeOperatorExample(object $object)
|
||||
{
|
||||
$object?->nullsafe();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
enum EnumExample: string
|
||||
{
|
||||
|
||||
case FOO = 'F';
|
||||
case BAR = 'B';
|
||||
|
||||
public function example(): string
|
||||
{
|
||||
return match ($this) {
|
||||
static::FOO => 'Foo',
|
||||
static::BAR => 'Bar',
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$anonymousFunc = function ($arg) use ($param): int {
|
||||
return 1;
|
||||
};
|
||||
|
||||
// Wrapping: Method Call Arguments must be set
|
||||
(new Example())->alignParamsExample('one', 'two', 'three', 'four', 'five');
|
||||
|
||||
/**
|
||||
* Test
|
||||
* @param type $a
|
||||
* @param type $b
|
||||
*/
|
||||
function namedArguments($a, $b)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* ProcessMaker has made a number of its PHP functions available be used in triggers and conditions.
|
||||
* Most of these functions are wrappers for internal functions used in Gulliver, which is the development framework
|
||||
* used by ProcessMaker.
|
||||
* @class pmFunctions
|
||||
*
|
||||
* @name ProcessMaker Functions
|
||||
* @icon /images/pm.gif
|
||||
* @className class.pmFunctions.php
|
||||
*/
|
||||
|
||||
/**
|
||||
* @method
|
||||
*
|
||||
* Create a new user
|
||||
*
|
||||
* @name PMFNewUser
|
||||
* @label PMF New User
|
||||
*
|
||||
* @param string | $test
|
||||
*
|
||||
* @return array | $response | Response
|
||||
*/
|
||||
function testAnnotation($test){
|
||||
return [];
|
||||
}
|
||||
|
||||
namedArguments(a: 1, b: 2);
|
||||
|
||||
$shortName = 10;
|
||||
$veryLooongName = 20;
|
||||
$data = [
|
||||
'short_key' => 10,
|
||||
'very_looong_key' => 100,
|
||||
];
|
||||
|
||||
@@ -0,0 +1,102 @@
|
||||
<?php
|
||||
|
||||
namespace ProcessMaker\PHPReflectionClass;
|
||||
|
||||
use ProcessMaker\PHPReflectionClass\MethodStructure;
|
||||
use Tests\TestCase;
|
||||
|
||||
class ClassStructureTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* Instance of ClassStructure.
|
||||
* @var ClassStructure
|
||||
*/
|
||||
protected $object;
|
||||
|
||||
/**
|
||||
* This setUp method.
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->object = new ClassStructure();
|
||||
}
|
||||
|
||||
/**
|
||||
* This test the method deleteInfo.
|
||||
* @covers ProcessMaker\PHPReflectionClass\ClassStructure::deleteInfo
|
||||
* @test
|
||||
*/
|
||||
public function testDeleteInfo()
|
||||
{
|
||||
//assert false
|
||||
$result1 = $this->object->deleteInfo("test1");
|
||||
$this->assertFalse($result1);
|
||||
|
||||
//assert true
|
||||
$this->object->info["test2"] = [];
|
||||
$result2 = $this->object->deleteInfo("test2");
|
||||
$this->assertTrue($result2);
|
||||
}
|
||||
|
||||
/**
|
||||
* This test the method getInfo.
|
||||
* @covers ProcessMaker\PHPReflectionClass\ClassStructure::getInfo
|
||||
* @test
|
||||
*/
|
||||
public function testGetInfo()
|
||||
{
|
||||
//assert false
|
||||
$result1 = $this->object->getInfo("test1");
|
||||
$this->assertFalse($result1);
|
||||
|
||||
//assert true
|
||||
$this->object->info["test2"] = [];
|
||||
$result2 = $this->object->getInfo("test2");
|
||||
$this->assertEquals([], $result2);
|
||||
}
|
||||
|
||||
/**
|
||||
* This test the method parseFromFile.
|
||||
* @covers ProcessMaker\PHPReflectionClass\ClassStructure::parseFromFile
|
||||
* @test
|
||||
*/
|
||||
public function testParseFromFile()
|
||||
{
|
||||
//assert false
|
||||
$result1 = $this->object->parseFromFile("invalidPath");
|
||||
$this->assertFalse($result1);
|
||||
|
||||
$filename = PATH_TRUNK . "tests/resources/ContentPHPSourceCode.txt";
|
||||
$result2 = $this->object->parseFromFile($filename);
|
||||
$this->assertTrue($result2);
|
||||
}
|
||||
|
||||
/**
|
||||
* This test the method setInfo.
|
||||
* @covers ProcessMaker\PHPReflectionClass\ClassStructure::setInfo
|
||||
* @test
|
||||
*/
|
||||
public function testSetInfo()
|
||||
{
|
||||
$this->object->setInfo("test1", "testing");
|
||||
$this->assertEquals($this->object->info["test1"], "testing");
|
||||
}
|
||||
|
||||
/**
|
||||
* This test the method setMethod.
|
||||
* @covers ProcessMaker\PHPReflectionClass\ClassStructure::setMethod
|
||||
* @test
|
||||
*/
|
||||
public function testSetMethod()
|
||||
{
|
||||
//assert false
|
||||
$result1 = $this->object->setMethod(null);
|
||||
$this->assertFalse($result1);
|
||||
|
||||
//assert true
|
||||
$method = new MethodStructure("testing");
|
||||
$result2 = $this->object->setMethod($method);
|
||||
$this->assertTrue($result2);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace ProcessMaker\PHPReflectionClass;
|
||||
|
||||
use Tests\TestCase;
|
||||
|
||||
class MethodStructureTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* Instance of MethodStructure.
|
||||
* @var MethodStructure
|
||||
*/
|
||||
protected $object;
|
||||
|
||||
/**
|
||||
* This setUp method.
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->object = new MethodStructure("test");
|
||||
}
|
||||
|
||||
/**
|
||||
* This test the method getInfo.
|
||||
* @covers ProcessMaker\PHPReflectionClass\MethodStructure::getInfo
|
||||
* @test
|
||||
*/
|
||||
public function testGetInfo()
|
||||
{
|
||||
//assert false
|
||||
$result1 = $this->object->getInfo("test");
|
||||
$this->assertFalse($result1);
|
||||
|
||||
//assert true
|
||||
$this->object->info["test2"] = [];
|
||||
$result2 = $this->object->getInfo("test2");
|
||||
$this->assertEquals([], $result2);
|
||||
}
|
||||
|
||||
/**
|
||||
* This test the method setInfo.
|
||||
* @covers ProcessMaker\PHPReflectionClass\MethodStructure::setInfo
|
||||
* @test
|
||||
*/
|
||||
public function testSetInfo()
|
||||
{
|
||||
$this->object->setInfo("test1", "test1");
|
||||
$this->assertEquals("test1", $this->object->info["test1"]);
|
||||
}
|
||||
|
||||
/**
|
||||
* This test the method setParam.
|
||||
* @covers ProcessMaker\PHPReflectionClass\MethodStructure::setParam
|
||||
* @test
|
||||
*/
|
||||
public function testSetParam()
|
||||
{
|
||||
$this->object->setParam("test2", "test2");
|
||||
$this->assertEquals("test2", $this->object->params["test2"]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user