diff options
author | Mark Spruiell <mes@zeroc.com> | 2014-07-23 16:49:37 -0700 |
---|---|---|
committer | Mark Spruiell <mes@zeroc.com> | 2014-07-23 16:49:37 -0700 |
commit | 771644c88e34713961ae998ddac507553af5cddb (patch) | |
tree | 95f404c423571069b9f790e0f7e70b681677c777 /php | |
parent | Merge branch 'master' of ssh://git.zeroc.com/home/git/ice (diff) | |
download | ice-771644c88e34713961ae998ddac507553af5cddb.tar.bz2 ice-771644c88e34713961ae998ddac507553af5cddb.tar.xz ice-771644c88e34713961ae998ddac507553af5cddb.zip |
ICE-5515 - proxy support for ice_staticId
Diffstat (limited to 'php')
-rw-r--r-- | php/lib/Ice.php | 18 | ||||
-rw-r--r-- | php/lib/Ice_ns.php | 18 | ||||
-rw-r--r-- | php/test/Ice/facets/Client.php | 45 | ||||
-rw-r--r-- | php/test/Ice/operations/Client.php | 15 |
4 files changed, 89 insertions, 7 deletions
diff --git a/php/lib/Ice.php b/php/lib/Ice.php index 3bbc3070631..37447a61935 100644 --- a/php/lib/Ice.php +++ b/php/lib/Ice.php @@ -87,6 +87,24 @@ abstract class Ice_ObjectImpl implements Ice_Object } } +class Ice_ObjectPrxHelper +{ + public static function checkedCast($proxy, $facetOrCtx=null, $ctx=null) + { + return $proxy->ice_checkedCast('::Ice::Object', $facetOrCtx, $ctx); + } + + public static function uncheckedCast($proxy, $facet=null) + { + return $proxy->ice_uncheckedCast('::Ice::Object', $facet); + } + + public static function ice_staticId() + { + return '::Ice::Object'; + } +} + $Ice__t_Object = IcePHP_defineClass('::Ice::Object', "Ice_Object", -1, true, false, null, null, null); $Ice__t_ObjectSeq = IcePHP_defineSequence('::Ice::ObjectSeq', $Ice__t_Object); $Ice__t_LocalObject = IcePHP_defineClass('::Ice::LocalObject', "Ice_LocalObject", -1, true, false, null, null, null); diff --git a/php/lib/Ice_ns.php b/php/lib/Ice_ns.php index 77caad431af..6218cbf1c45 100644 --- a/php/lib/Ice_ns.php +++ b/php/lib/Ice_ns.php @@ -92,6 +92,24 @@ namespace Ice } } + class ObjectPrxHelper + { + public static function checkedCast($proxy, $facetOrCtx=null, $ctx=null) + { + return $proxy->ice_checkedCast('::Ice::Object', $facetOrCtx, $ctx); + } + + public static function uncheckedCast($proxy, $facet=null) + { + return $proxy->ice_uncheckedCast('::Ice::Object', $facet); + } + + public static function ice_staticId() + { + return '::Ice::Object'; + } + } + $Ice__t_Object = IcePHP_defineClass('::Ice::Object', "\\Ice\\Object", -1, true, false, null, null, null); $Ice__t_ObjectSeq = IcePHP_defineSequence('::Ice::ObjectSeq', $Ice__t_Object); $Ice__t_LocalObject = IcePHP_defineClass('::Ice::LocalObject', "\\Ice\\LocalObject", -1, true, false, null, null, null); diff --git a/php/test/Ice/facets/Client.php b/php/test/Ice/facets/Client.php index cacfcd3f048..431736ee751 100644 --- a/php/test/Ice/facets/Client.php +++ b/php/test/Ice/facets/Client.php @@ -31,6 +31,8 @@ function test($b) function allTests($communicator) { + global $NS; + echo "testing stringToProxy... "; flush(); $ref = "d:default -p 12010"; @@ -38,12 +40,47 @@ function allTests($communicator) test($db != null); echo "ok\n"; + $objectHelper = $NS ? "Ice\\ObjectPrxHelper" : "Ice_ObjectPrxHelper"; + $dHelper = $NS ? "Test\\DPrxHelper" : "Test_DPrxHelper"; + + echo "testing unchecked cast... "; + flush(); + $prx = $objectHelper::uncheckedCast($db); + test($prx->ice_getFacet() == ""); + $prx = $objectHelper::uncheckedCast($db, "facetABCD"); + test($prx->ice_getFacet() == "facetABCD"); + $prx2 = $objectHelper::uncheckedCast($prx); + test($prx2->ice_getFacet() == "facetABCD"); + $prx3 = $objectHelper::uncheckedCast($prx, ""); + test($prx3->ice_getFacet() == ""); + $d = $dHelper::uncheckedCast($db); + test($d->ice_getFacet() == ""); + $df = $dHelper::uncheckedCast($db, "facetABCD"); + test($df->ice_getFacet() == "facetABCD"); + $df2 = $dHelper::uncheckedCast($df); + test($df2->ice_getFacet() == "facetABCD"); + $df3 = $dHelper::uncheckedCast($df, ""); + test($df3->ice_getFacet() == ""); + echo "ok\n"; + echo "testing checked cast... "; flush(); - $d = $db->ice_checkedCast("::Test::D"); - test($d != null); - test($d == $db); - test($db->ice_checkedCast("::Test::D", "bogus") == null); + $prx = $objectHelper::checkedCast($db); + test($prx->ice_getFacet() == ""); + $prx = $objectHelper::checkedCast($db, "facetABCD"); + test($prx->ice_getFacet() == "facetABCD"); + $prx2 = $objectHelper::checkedCast($prx); + test($prx2->ice_getFacet() == "facetABCD"); + $prx3 = $objectHelper::checkedCast($prx, ""); + test($prx3->ice_getFacet() == ""); + $d = $dHelper::checkedCast($db); + test($d->ice_getFacet() == ""); + $df = $dHelper::checkedCast($db, "facetABCD"); + test($df->ice_getFacet() == "facetABCD"); + $df2 = $dHelper::checkedCast($df); + test($df2->ice_getFacet() == "facetABCD"); + $df3 = $dHelper::checkedCast($df, ""); + test($df3->ice_getFacet() == ""); echo "ok\n"; echo "testing non-facets A, B, C, and D... "; diff --git a/php/test/Ice/operations/Client.php b/php/test/Ice/operations/Client.php index 6a71e960724..a7a4933565b 100644 --- a/php/test/Ice/operations/Client.php +++ b/php/test/Ice/operations/Client.php @@ -37,17 +37,26 @@ function twoways($communicator, $p) $enum2 = $NS ? constant("Test\\MyEnum::enum2") : constant("Test_MyEnum::enum2"); $enum3 = $NS ? constant("Test\\MyEnum::enum3") : constant("Test_MyEnum::enum3"); + $myDerivedClassPrxHelper = $NS ? "Test\\MyDerivedClassPrxHelper" : "Test_MyDerivedClassPrxHelper"; + $myDerivedClass = $NS ? "Test\\MyDerivedClass" : "Test_MyDerivedClass"; + $myClass = $NS ? "Test\\MyClass" : "Test_MyClass"; + $objectPrxHelper = $NS ? "Ice\\ObjectPrxHelper" : "Ice_ObjectPrxHelper"; + { $p->ice_ping(); } { - test(Test_MyDerivedClassPrxHelper::ice_staticId() == Test_MyDerivedClass::ice_staticId()); + test($myDerivedClassPrxHelper::ice_staticId() == $myDerivedClass::ice_staticId()); + test($objectPrxHelper::ice_staticId() == "::Ice::Object"); + } + + { + test($p->ice_isA($myClass::ice_staticId())); } - { - test($p->ice_isA("::Test::MyClass")); + test($p->ice_id() == $myDerivedClass::ice_staticId()); } { |