public function testObject() { $element = new CopixSerializableObject($object = _ioClass('fooclass'), CopixModule::getPath('copixtest') . 'classes/fooclass.class.php'); $this->assertEquals($element->getRemoteObject(), $object); $serialized = serialize($element); $elementBack = unserialize($serialized); $this->assertEquals(strtolower(get_class($elementBack->getRemoteObject())), 'fooclass'); $this->assertEquals(1, $elementBack->getParam(1)); $this->assertEquals(array(1, 2), $elementBack->getArrayWith(1, 2)); $elementBack->test = 2; $this->assertEquals($elementBack->test, 2); $this->assertEquals($elementBack->getRemoteObject()->test, 2); $elementBack->notExists = 3; $this->assertEquals($elementBack->notExists, 3); $this->assertEquals($elementBack->getRemoteObject()->notExists, 3); $elementBack->setPublicPropertyTest(4); $this->assertEquals($elementBack->test, 4); $this->assertEquals($elementBack->getRemoteObject()->test, 4); $this->assertEquals($elementBack->getPublicPropertyTest(), 4); $this->assertEquals($elementBack->getRemoteObject()->getPublicPropertyTest(), 4); $elementBack->setPrivatePropertyTest(5); $this->assertEquals($elementBack->getPrivatePropertyTest(), 5); $this->assertEquals($elementBack->getRemoteObject()->getPrivatePropertyTest(), 5); $elementBack->setUnknownProperty('notexists', 6); $this->assertEquals($elementBack->getUnknownProperty('notexists'), 6); $this->assertEquals($elementBack->getRemoteObject()->getUnknownProperty('notexists'), 6); $this->assertEquals($elementBack->notexists, 6); $this->assertEquals($elementBack->getRemoteObject()->notexists, 6); }
/** * Simulation d'un constructeur "statique" */ public static function _initialize() { // Enregistre l'autoloader spl_autoload_register(array('CopixSerializableObject', 'autoload')); // Génère l'expression régulière pour analyser les chemins de modules $dirSep = preg_quote(DIRECTORY_SEPARATOR, '@'); $classDir = preg_quote(preg_replace('@[/\\x5C]@', DIRECTORY_SEPARATOR, COPIX_CLASSES_DIR), '@'); self::$_moduleClassRegex = '@^(.+)' . $dirSep . '(.+?)' . $dirSep . $classDir . '(.+?)\\.class\\.php$@i'; }