Best Atoum code snippet using out.testWrite
OutputTest.php
Source:OutputTest.php
1<?php2/**3 * efxphp (http://emilmalinov.com/efxphp)4 *5 * @copyright Copyright (c) 2015 Emil Malinov6 * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.07 * @link http://github.com/emilkm/efxphp8 * @package efxphp9 */10namespace emilkm\tests\efxphp\Amf;11use emilkm\tests\util\SendToJamfTrait;12use emilkm\tests\util\InvokeMethodTrait;13use emilkm\efxphp\Amf\Constants;14use emilkm\efxphp\Amf\Output;15use emilkm\efxphp\Amf\Types\Date;16use emilkm\efxphp\Amf\Types\ByteArray;17use emilkm\efxphp\Amf\Types\Vector;18use emilkm\efxphp\Amf\Types\Xml;19use emilkm\efxphp\Amf\Types\XmlDocument;20use stdClass;21use DateTime;22use DateTimeZone;23/**24 * @author Emil Malinov25 * @package efxphp26 * @subpackage tests27 */28class OutputTest extends \PHPUnit_Framework_TestCase29{30 use SendToJamfTrait;31 use InvokeMethodTrait;32 protected $out;33 protected function setUp()34 {35 $this->out = new Output();36 }37 /**38 *39 */40 public function testwriteAmf0Number()41 {42 $this->out->setAvmPlus(false);43 $obj = new stdClass();44 $obj->value = 31.57;45 $this->out->writeObject($obj);46 //$this->sendToJamf($this->out->data);47 //file_put_contents(__DIR__ . '/../asset/value/number.amf0', serialize($this->out->data));48 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/number.amf0'));49 $this->assertEquals($data, $this->out->data);50 }51 /**52 *53 */54 public function testwriteAmf0Boolean()55 {56 $this->out->setAvmPlus(false);57 $obj = new stdClass();58 $obj->value = true;59 $this->out->writeObject($obj);60 //$this->sendToJamf($this->out->data);61 //file_put_contents(__DIR__ . '/../asset/value/boolean.amf0', serialize($this->out->data));62 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/boolean.amf0'));63 $this->assertEquals($data, $this->out->data);64 }65 /**66 *67 */68 public function testwriteAmf0DateFromEfxphpDate()69 {70 $this->out->setAvmPlus(false);71 $obj = new stdClass();72 $obj->value = new Date(1422995025123); //2015-02-04 09:23:45.12373 $this->out->writeObject($obj);74 //$this->sendToJamf($this->out->data);75 //file_put_contents(__DIR__ . '/../asset/value/date.amf0', serialize($this->out->data));76 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/date.amf0'));77 $this->assertEquals($data, $this->out->data);78 }79 /**80 *81 */82 public function testwriteAmf0DateFromPhpDateTime()83 {84 $this->out->setAvmPlus(false);85 $obj = new stdClass();86 $datestr = date('Y-m-d H:i:s.', 1422995025) . 123; //2015-02-04 09:23:45.12387 $obj->value = new DateTime($datestr);88 $this->out->writeObject($obj);89 //$this->sendToJamf($this->out->data);90 //file_put_contents(__DIR__ . '/../asset/value/date.amf0', serialize($this->out->data));91 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/date.amf0'));92 $this->assertEquals($data, $this->out->data);93 }94 /**95 *96 */97 public function testwriteAmf0String()98 {99 $this->out->setAvmPlus(false);100 $obj = new stdClass();101 $obj->value = 'abc';102 $this->out->writeObject($obj);103 //$this->sendToJamf($this->out->data);104 //file_put_contents(__DIR__ . '/../asset/value/string.amf0', serialize($this->out->data));105 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/string.amf0'));106 $this->assertEquals($data, $this->out->data);107 }108 /**109 *110 */111 public function testwriteAmf0StringBlank()112 {113 $this->out->setAvmPlus(false);114 $obj = new stdClass();115 $obj->value = '';116 $this->out->writeObject($obj);117 //$this->sendToJamf($this->out->data);118 //file_put_contents(__DIR__ . '/../asset/value/string-blank.amf0', serialize($this->out->data));119 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/string-blank.amf0'));120 $this->assertEquals($data, $this->out->data);121 }122 /**123 *124 */125 public function testwriteAmf0StringUnicode()126 {127 $this->out->setAvmPlus(false);128 $obj = new stdClass();129 $obj->value = 'виÑоÑа';130 $this->out->writeObject($obj);131 //$this->sendToJamf($this->out->data);132 //file_put_contents(__DIR__ . '/../asset/value/string-unicode.amf0', serialize($this->out->data));133 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/string-unicode.amf0'));134 $this->assertEquals($data, $this->out->data);135 }136 /**137 *138 */139 public function testwriteAmf0Null()140 {141 $this->out->setAvmPlus(false);142 $obj = new stdClass();143 $obj->value = null;144 $this->out->writeObject($obj);145 //$this->sendToJamf($this->out->data);146 //file_put_contents(__DIR__ . '/../asset/value/null.amf0', serialize($this->out->data));147 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/null.amf0'));148 $this->assertEquals($data, $this->out->data);149 }150 /**151 *152 */153 public function testwriteAmf0ArrayEmpty()154 {155 $this->out->setAvmPlus(false);156 $obj = array();157 $this->out->writeObject($obj);158 //$this->sendToJamf($this->out->data);159 //file_put_contents(__DIR__ . '/../asset/value/array-empty.amf0', serialize($this->out->data));160 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/array-empty.amf0'));161 $this->assertEquals($data, $this->out->data);162 }163 /**164 *165 */166 public function testwriteAmf0ArrayDense()167 {168 $this->out->setAvmPlus(false);169 $obj = array();170 $obj[0] = 'a';171 $obj[1] = 'b';172 $obj[2] = 'c';173 $this->out->writeObject($obj);174 //$this->sendToJamf($this->out->data);175 //file_put_contents(__DIR__ . '/../asset/value/array-dense.amf0', serialize($this->out->data));176 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/array-dense.amf0'));177 $this->assertEquals($data, $this->out->data);178 }179 /**180 * Undefined entries in the sparse regions between indices are serialized as undefined.181 * Undefined entries in the sparse regions between indices are skipped when deserialized.182 */183 public function testwriteAmf0ArraySparse()184 {185 $this->out->setAvmPlus(false);186 $obj = array();187 $obj[0] = 'a';188 $obj[2] = 'b';189 $obj[4] = 'c';190 $this->out->writeObject($obj);191 //$this->sendToJamf($this->out->data);192 //file_put_contents(__DIR__ . '/../asset/value/array-sparse.amf0', serialize($this->out->data));193 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/array-sparse.amf0'));194 $this->assertEquals($data, $this->out->data);195 }196 /**197 *198 */199 public function testwriteAmf0ArrayString()200 {201 $this->out->setAvmPlus(false);202 $obj = array();203 $obj['a'] = 1;204 $obj['b'] = 2;205 $obj['c'] = 3;206 $this->out->writeObject($obj);207 //$this->sendToJamf($this->out->data);208 //file_put_contents(__DIR__ . '/../asset/value/array-string.amf0', serialize($this->out->data));209 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/array-string.amf0'));210 $this->assertEquals($data, $this->out->data);211 }212 /**213 *214 */215 public function testwriteAmf0ArrayMixed()216 {217 $this->out->setAvmPlus(false);218 $obj = array();219 $obj[0] = 'a';220 $obj['b'] = 2;221 $this->out->writeObject($obj);222 //$this->sendToJamf($this->out->data);223 //file_put_contents(__DIR__ . '/../asset/value/array-mixed.amf0', serialize($this->out->data));224 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/array-mixed.amf0'));225 $this->assertEquals($data, $this->out->data);226 }227 /**228 *229 */230 public function testwriteAmf0ArrayNegative()231 {232 $this->out->setAvmPlus(false);233 $obj = array();234 $obj[-1] = 'a';235 $obj[0] = 'b';236 $obj[1] = 'c';237 $this->out->writeObject($obj);238 //$this->sendToJamf($this->out->data);239 //file_put_contents(__DIR__ . '/../asset/value/array-negative.amf0', serialize($this->out->data));240 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/array-negative.amf0'));241 $this->assertEquals($data, $this->out->data);242 }243 /**244 *245 */246 public function testwriteAmf0ArrayNested()247 {248 $this->out->setAvmPlus(false);249 $obj = array();250 $obj['items'] = array();251 $obj['items'][0] = 'a';252 $obj['items'][1] = 'b';253 $obj['items'][2] = 'c';254 $this->out->writeObject($obj);255 //$this->sendToJamf($this->out->data);256 //file_put_contents(__DIR__ . '/../asset/value/array-nested.amf0', serialize($this->out->data));257 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/array-nested.amf0'));258 $this->assertEquals($data, $this->out->data);259 }260 /**261 * The pure anonymous case.262 */263 public function testwriteAmf0ObjectAnonymous()264 {265 $this->out->setAvmPlus(false);266 $obj = new stdClass();267 $this->out->writeObject($obj);268 //$this->sendToJamf($this->out->data);269 //file_put_contents(__DIR__ . '/../asset/value/object-anonymous.amf0', serialize($this->out->data));270 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/object-anonymous.amf0'));271 $this->assertEquals($data, $this->out->data);272 }273 /**274 * Anonymous object with blank _explicitType field, do not write the _explicitType field.275 */276 public function testwriteAmf0ObjectAnonymousFromBlankExplicitType()277 {278 $this->out->setAvmPlus(false);279 $obj = new stdClass();280 $remoteClassField = Constants::REMOTE_CLASS_FIELD;281 $obj->$remoteClassField = '';282 $this->out->writeObject($obj);283 //$this->sendToJamf($this->out->data);284 //file_put_contents(__DIR__ . '/../asset/value/object-anonymous.amf0', serialize($this->out->data));285 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/object-anonymous.amf0'));286 $this->assertEquals($data, $this->out->data);287 }288 289 /**290 * Typed object with blank _explicitType field, do not write the _explicitType field.291 * There is a conflict between the object type and the _explicitType. Since _explicitType takes precedence,292 * output an anonymous object.293 */294 public function testwriteAmf0ObjectAnonymousFromTypeConflict()295 {296 $this->out->setAvmPlus(false);297 $obj = new \emilkm\tests\asset\value\VoExplicitTypeBlank();298 $this->out->writeObject($obj);299 //$this->sendToJamf($this->out->data);300 //file_put_contents(__DIR__ . '/../asset/value/object-anonymous.amf0', serialize($this->out->data));301 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/object-anonymous.amf0'));302 $this->assertEquals($data, $this->out->data);303 }304 /**305 * When the type cannot be resolved, simply write stdClass and set the _explicitType field.306 * Do not write an anonymous object, because the remote client may be able to resolve it.307 */308 public function testwriteAmf0ObjectTypedToStdClass()309 {310 $this->out->setAvmPlus(false);311 $obj = new stdClass();312 $remoteClassField = Constants::REMOTE_CLASS_FIELD;313 $obj->$remoteClassField = 'SomeClass';314 $this->out->writeObject($obj);315 //$this->sendToJamf($this->out->data);316 //file_put_contents(__DIR__ . '/../asset/value/object-typed-someclass.amf0', serialize($this->out->data));317 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/object-typed-someclass.amf0'));318 $this->assertEquals($data, $this->out->data);319 }320 /**321 * Type comes from the namespace. Do not write _explicitType, it is not needed.322 */323 public function testwriteAmf0ObjectTypedFromNamespace()324 {325 $this->out->setAvmPlus(false);326 $obj = new \emilkm\tests\asset\value\VoExplicitTypeNotSet();327 $this->out->writeObject($obj);328 //$this->sendToJamf($this->out->data);329 //file_put_contents(__DIR__ . '/../asset/value/object-typed-explicit-from-namespace.amf0', serialize($this->out->data));330 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/object-typed-explicit-from-namespace.amf0'));331 $this->assertEquals($data, $this->out->data);332 }333 /**334 *335 */336 public function testwriteAmf0ObjectTypedFromField()337 {338 $this->out->setAvmPlus(false);339 $obj = new \emilkm\tests\asset\value\VoExplicitTypeNotBlank();340 $this->out->writeObject($obj);341 //$this->sendToJamf($this->out->data);342 //file_put_contents(__DIR__ . '/../asset/value/object-typed-explicit-from-field.amf0', serialize($this->out->data));343 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/object-typed-explicit-from-field.amf0'));344 $this->assertEquals($data, $this->out->data);345 }346 /**347 *348 */349 public function testwriteAmf0XmlFromEfxphpXml()350 {351 $this->out->setAvmPlus(false);352 $obj = new stdClass();353 $obj->value = new Xml('<x><string>abc</string><number>123</number></x>');354 $this->out->writeObject($obj);355 //$this->sendToJamf($this->out->data);356 //file_put_contents(__DIR__ . '/../asset/value/xml.amf0', serialize($this->out->data));357 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/xml.amf0'));358 $this->assertEquals($data, $this->out->data);359 }360 /**361 *362 */363 public function testwriteAmf0XmlFromSimpleXMLElement()364 {365 $this->out->setAvmPlus(false);366 $obj = new stdClass();367 $obj->value = simplexml_load_string('<x><string>abc</string><number>123</number></x>');368 $this->out->writeObject($obj);369 //$this->sendToJamf($this->out->data);370 //file_put_contents(__DIR__ . '/../asset/value/xmlelement.amf0', serialize($this->out->data));371 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/xmlelement.amf0'));372 $this->assertEquals($data, $this->out->data);373 }374 /**375 *376 */377 public function testwriteAmf0XmlDocumentFromEfxphpXmlDocument()378 {379 $this->out->setAvmPlus(false);380 $obj = new stdClass();381 $obj->value = new XmlDocument('<x><string>abc</string><number>123</number></x>');382 $this->out->writeObject($obj);383 //$this->sendToJamf($this->out->data);384 //file_put_contents(__DIR__ . '/../asset/value/xmldocument.amf0', serialize($this->out->data));385 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/xmldocument.amf0'));386 $this->assertEquals($data, $this->out->data);387 }388 /**389 *390 */391 public function testwriteAmf0XmlDocumentFromDOMElement()392 {393 $this->out->setAvmPlus(false);394 $obj = new stdClass();395 $obj->value = dom_import_simplexml(simplexml_load_string('<x><string>abc</string><number>123</number></x>'));396 $this->out->writeObject($obj);397 //$this->sendToJamf($this->out->data);398 //file_put_contents(__DIR__ . '/../asset/value/domelement.amf0', serialize($this->out->data));399 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/domelement.amf0'));400 $this->assertEquals($data, $this->out->data);401 }402 //##########################################################################403 // AMF3404 //##########################################################################405 /**406 * TODO:407 */408 public function testwriteAmf3Undefined()409 {410 }411 /**412 *413 */414 public function testwriteAmf3Null()415 {416 $this->out->setAvmPlus(true);417 $obj = new stdClass();418 $obj->value = null;419 $this->out->writeObject($obj);420 //$this->sendToJamf($this->out->data);421 //file_put_contents(__DIR__ . '/../../asset/value/null.amf3', serialize($this->out->data));422 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/null.amf3'));423 $this->assertEquals($data, $this->out->data);424 }425 /**426 *427 */428 public function testwriteAmf3BooleanTrue()429 {430 $this->out->setAvmPlus(true);431 $obj = new stdClass();432 $obj->value = true;433 $this->out->writeObject($obj);434 //$this->sendToJamf($this->out->data);435 //file_put_contents(__DIR__ . '/../../asset/value/boolean-true.bin3', serialize($this->out->data));436 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/boolean-true.amf3'));437 $this->assertEquals($data, $this->out->data);438 }439 /**440 *441 */442 public function testwriteAmf3BooleanFalse()443 {444 $this->out->setAvmPlus(true);445 $obj = new stdClass();446 $obj->value = false;447 $this->out->writeObject($obj);448 //$this->sendToJamf($this->out->data);449 //file_put_contents(__DIR__ . '/../../asset/value/boolean-false.bin3', ($this->out->data));450 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/boolean-false.amf3'));451 $this->assertEquals($data, $this->out->data);452 }453 /**454 *455 */456 public function testwriteAmf3Integer()457 {458 $this->out->setAvmPlus(true);459 $obj = new stdClass();460 $obj->value = 123;461 $this->out->writeObject($obj);462 //$this->sendToJamf($this->out->data);463 //file_put_contents(__DIR__ . '/../asset/value/integer.amf3', serialize($this->out->data));464 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/integer.amf3'));465 $this->assertEquals($data, $this->out->data);466 }467 /**468 *469 */470 public function testwriteAmf3Double()471 {472 $this->out->setAvmPlus(true);473 $obj = new stdClass();474 $obj->value = 31.57;475 $this->out->writeObject($obj);476 //$this->sendToJamf($this->out->data);477 //file_put_contents(__DIR__ . '/../../asset/value/double.amf3', serialize($this->out->data));478 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/double.amf3'));479 $this->assertEquals($data, $this->out->data);480 }481 /**482 *483 */484 public function testwriteAmf3String()485 {486 $this->out->setAvmPlus(true);487 $obj = new stdClass();488 $obj->value = 'abc';489 $this->out->writeObject($obj);490 //$this->sendToJamf($this->out->data);491 //file_put_contents(__DIR__ . '/../asset/value/string.amf3', serialize($this->out->data));492 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/string.amf3'));493 $this->assertEquals($data, $this->out->data);494 }495 /**496 *497 */498 public function testwriteAmf3StringBlank()499 {500 $this->out->setAvmPlus(true);501 $obj = new stdClass();502 $obj->value = '';503 $this->out->writeObject($obj);504 //$this->sendToJamf($this->out->data);505 //file_put_contents(__DIR__ . '/../asset/value/string-blank.amf3', serialize($this->out->data));506 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/string-blank.amf3'));507 $this->assertEquals($data, $this->out->data);508 }509 /**510 *511 */512 public function testwriteAmf3StringUnicode()513 {514 $this->out->setAvmPlus(true);515 $obj = new stdClass();516 $obj->value = 'виÑоÑа';517 $this->out->writeObject($obj);518 //$this->sendToJamf($this->out->data);519 //file_put_contents(__DIR__ . '/../../asset/value/string-unicode2.amf3', serialize($this->out->data));520 //file_put_contents(__DIR__ . '/../../asset/value/string-unicode.bin3', $this->out->data);521 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/string-unicode.amf3'));522 $this->assertEquals($data, $this->out->data);523 }524 /**525 *526 */527 public function testwriteAmf3DateFromEfxphpDate()528 {529 $this->out->setAvmPlus(true);530 $obj = new stdClass();531 $obj->value = new Date(1422995025123); //2015-02-04 09:23:45.123532 $this->out->writeObject($obj);533 //$this->sendToJamf($this->out->data);534 //file_put_contents(__DIR__ . '/../asset/value/date.amf3', serialize($this->out->data));535 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/date.amf3'));536 $this->assertEquals($data, $this->out->data);537 }538 /**539 *540 */541 public function testwriteAmf3DateFromPhpDateTime()542 {543 $this->out->setAvmPlus(true);544 $obj = new stdClass();545 $datestr = date('Y-m-d H:i:s.', 1422995025) . 123; //2015-02-04 09:23:45.123546 $obj->value = new DateTime($datestr);547 $this->out->writeObject($obj);548 //$this->sendToJamf($this->out->data);549 //file_put_contents(__DIR__ . '/../asset/value/date.amf3', serialize($this->out->data));550 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/date.amf3'));551 $this->assertEquals($data, $this->out->data);552 }553 /**554 *555 */556 public function testwriteAmf3DateAndReferenceFromEfxphpDate()557 {558 $this->out->setAvmPlus(true);559 $obj = new stdClass();560 $adate = new Date(1422995025123); //2015-02-04 09:23:45.123561 $obj->value1 = $adate;562 $obj->value2 = $adate;563 $this->out->writeObject($obj);564 //$this->sendToJamf($this->out->data);565 //file_put_contents(__DIR__ . '/../asset/value/date-and-reference.amf3', serialize($this->out->data));566 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/date-and-reference.amf3'));567 $this->assertEquals($data, $this->out->data);568 }569 /**570 *571 */572 public function testwriteAmf3DateAndReferenceFromPhpDateTime()573 {574 $this->out->setAvmPlus(true);575 $obj = new stdClass();576 $datestr = date('Y-m-d H:i:s.', 1422995025) . 123; //2015-02-04 09:23:45.123577 $adate = new DateTime($datestr);578 $obj->value1 = $adate;579 $obj->value2 = $adate;580 $this->out->writeObject($obj);581 //$this->sendToJamf($this->out->data);582 //file_put_contents(__DIR__ . '/../asset/value/date-and-reference.amf3', serialize($this->out->data));583 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/date-and-reference.amf3'));584 $this->assertEquals($data, $this->out->data);585 }586 /**587 *588 */589 public function testwriteAmf3ArrayEmpty()590 {591 $this->out->setAvmPlus(true);592 $obj = array();593 $this->out->writeObject($obj);594 //$this->sendToJamf($this->out->data);595 //file_put_contents(__DIR__ . '/../asset/value/array-empty.amf3', serialize($this->out->data));596 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/array-empty.amf3'));597 $this->assertEquals($data, $this->out->data);598 }599 /**600 *601 */602 public function testwriteAmf3ArrayDense()603 {604 $this->out->setAvmPlus(true);605 $obj = array();606 $obj[0] = 'a';607 $obj[1] = 'b';608 $obj[2] = 'c';609 $this->out->writeObject($obj);610 //$this->sendToJamf($this->out->data);611 //file_put_contents(__DIR__ . '/../asset/value/array-dense.amf3', serialize($this->out->data));612 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/array-dense.amf3'));613 $this->assertEquals($data, $this->out->data);614 }615 /**616 *617 */618 public function testwriteAmf3ArraySparseAsObject()619 {620 $this->out->setAvmPlus(true);621 $this->out->encodeAmf3nsndArrayAsObject(true);622 $obj = array();623 $obj[0] = 'a';624 $obj[2] = 'b';625 $obj[4] = 'c';626 $this->out->writeObject($obj);627 //$this->sendToJamf($this->out->data);628 //file_put_contents(__DIR__ . '/../asset/value/array-sparse-as-object.amf3', serialize($this->out->data));629 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/array-sparse-as-object.amf3'));630 $this->assertEquals($data, $this->out->data);631 }632 /**633 *634 */635 public function testwriteAmf3ArraySparseAsAssoc()636 {637 $this->out->setAvmPlus(true);638 $this->out->encodeAmf3nsndArrayAsObject(false);639 $obj = array();640 $obj[0] = 'a';641 $obj[2] = 'b';642 $obj[4] = 'c';643 $this->out->writeObject($obj);644 //$this->sendToJamf($this->out->data);645 //file_put_contents(__DIR__ . '/../asset/value/array-sparse-as-assoc.amf3', serialize($this->out->data));646 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/array-sparse-as-assoc.amf3'));647 $this->assertEquals($data, $this->out->data);648 }649 /**650 *651 */652 public function testwriteAmf3ArrayStringAsObject()653 {654 $this->out->setAvmPlus(true);655 $this->out->encodeAmf3nsndArrayAsObject(true);656 $obj = array();657 $obj['a'] = 1;658 $obj['b'] = 2;659 $obj['c'] = 3;660 $this->out->writeObject($obj);661 //$this->sendToJamf($this->out->data);662 //file_put_contents(__DIR__ . '/../asset/value/array-string-as-object.amf3', serialize($this->out->data));663 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/array-string-as-object.amf3'));664 $this->assertEquals($data, $this->out->data);665 }666 /**667 *668 */669 public function testwriteAmf3ArrayStringAsAssoc()670 {671 $this->out->setAvmPlus(true);672 $this->out->encodeAmf3nsndArrayAsObject(false);673 $obj = array();674 $obj['a'] = 1;675 $obj['b'] = 2;676 $obj['c'] = 3;677 $this->out->writeObject($obj);678 //$this->sendToJamf($this->out->data);679 //file_put_contents(__DIR__ . '/../asset/value/array-string-as-assoc.amf3', serialize($this->out->data));680 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/array-string-as-assoc.amf3'));681 $this->assertEquals($data, $this->out->data);682 }683 /**684 *685 */686 public function testwriteAmf3ArrayMixedAsObject()687 {688 $this->out->setAvmPlus(true);689 $this->out->encodeAmf3nsndArrayAsObject(true);690 $obj = array();691 $obj[0] = 'a';692 $obj['b'] = 2;693 $this->out->writeObject($obj);694 //$this->sendToJamf($this->out->data);695 //file_put_contents(__DIR__ . '/../asset/value/array-mixed-as-object.amf3', serialize($this->out->data));696 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/array-mixed-as-object.amf3'));697 $this->assertEquals($data, $this->out->data);698 }699 /**700 *701 */702 public function testwriteAmf3ArrayMixedAsAssoc()703 {704 $this->out->setAvmPlus(true);705 $this->out->encodeAmf3nsndArrayAsObject(false);706 $obj = array();707 $obj[0] = 'a';708 $obj['b'] = 2;709 $this->out->writeObject($obj);710 //$this->sendToJamf($this->out->data);711 //file_put_contents(__DIR__ . '/../asset/value/array-mixed-as-assoc.amf3', serialize($this->out->data));712 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/array-mixed-as-assoc.amf3'));713 $this->assertEquals($data, $this->out->data);714 }715 /**716 *717 */718 public function testwriteAmf3ArrayNegativeAsObject()719 {720 $this->out->setAvmPlus(true);721 $this->out->encodeAmf3nsndArrayAsObject(true);722 $obj = array();723 $obj[-1] = 'a';724 $obj[0] = 'b';725 $obj[1] = 'c';726 $this->out->writeObject($obj);727 //$this->sendToJamf($this->out->data);728 //file_put_contents(__DIR__ . '/../asset/value/array-negative-as-object.amf3', serialize($this->out->data));729 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/array-negative-as-object.amf3'));730 $this->assertEquals($data, $this->out->data);731 }732 /**733 *734 */735 public function testwriteAmf3ArrayNegativeAsAssoc()736 {737 $this->out->setAvmPlus(true);738 $this->out->encodeAmf3nsndArrayAsObject(false);739 $obj = array();740 $obj[-1] = 'a';741 $obj[0] = 'b';742 $obj[1] = 'c';743 $this->out->writeObject($obj);744 //$this->sendToJamf($this->out->data);745 //file_put_contents(__DIR__ . '/../asset/value/array-negative-as-assoc.amf3', serialize($this->out->data));746 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/array-negative-as-assoc.amf3'));747 $this->assertEquals($data, $this->out->data);748 }749 /**750 *751 */752 public function testwriteAmf3ArrayNestedAsObject()753 {754 $this->out->setAvmPlus(true);755 $this->out->encodeAmf3nsndArrayAsObject(true);756 $obj = array();757 $obj['items'] = array();758 $obj['items'][0] = 'a';759 $obj['items'][1] = 'b';760 $obj['items'][2] = 'c';761 $this->out->writeObject($obj);762 //$this->sendToJamf($this->out->data);763 //file_put_contents(__DIR__ . '/../asset/value/array-nested-as-object.amf3', serialize($this->out->data));764 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/array-nested-as-object.amf3'));765 $this->assertEquals($data, $this->out->data);766 }767 /**768 *769 */770 public function testwriteAmf3ArrayNestedAsAssoc()771 {772 $this->out->setAvmPlus(true);773 $this->out->encodeAmf3nsndArrayAsObject(false);774 $obj = array();775 $obj['items'] = array();776 $obj['items'][0] = 'a';777 $obj['items'][1] = 'b';778 $obj['items'][2] = 'c';779 $this->out->writeObject($obj);780 //$this->sendToJamf($this->out->data);781 //file_put_contents(__DIR__ . '/../asset/value/array-nested-as-assoc.amf3', serialize($this->out->data));782 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/array-nested-as-assoc.amf3'));783 $this->assertEquals($data, $this->out->data);784 }785 /**786 * The pure anonymous case.787 */788 public function testwriteAmf3ObjectAnonymous()789 {790 $this->out->setAvmPlus(true);791 $obj = new stdClass();792 $this->out->writeObject($obj);793 //$this->sendToJamf($this->out->data);794 //file_put_contents(__DIR__ . '/../asset/value/object-anonymous.amf3', serialize($this->out->data));795 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/object-anonymous.amf3'));796 $this->assertEquals($data, $this->out->data);797 }798 /**799 * Anonymous object with blank _explicitType field, do not write the _explicitType field.800 */801 public function testwriteAmf3ObjectAnonymousFromBlankExplicitType()802 {803 $this->out->setAvmPlus(true);804 $obj = new stdClass();805 $remoteClassField = Constants::REMOTE_CLASS_FIELD;806 $obj->$remoteClassField = '';807 $this->out->writeObject($obj);808 //$this->sendToJamf($this->out->data);809 //file_put_contents(__DIR__ . '/../asset/value/object-anonymous.amf3', serialize($this->out->data));810 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/object-anonymous.amf3'));811 $this->assertEquals($data, $this->out->data);812 }813 814 /**815 * Typed object with blank _explicitType field, do not write the _explicitType field.816 * There is a conflict between the object type and the _explicitType. Since _explicitType takes precedence,817 * output an anonymous object.818 */819 public function testwriteAmf3ObjectAnonymousFromTypeConflict()820 {821 $this->out->setAvmPlus(true);822 $obj = new \emilkm\tests\asset\value\VoExplicitTypeBlank();823 $this->out->writeObject($obj);824 //$this->sendToJamf($this->out->data);825 //file_put_contents(__DIR__ . '/../asset/value/object-anonymous.amf3', serialize($this->out->data));826 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/object-anonymous.amf3'));827 $this->assertEquals($data, $this->out->data);828 }829 830 /**831 * When the type cannot be resolved, simply write stdClass and set the _explicitType field.832 * Do not write an anonymous object, because the remote client may be able to resolve it.833 */834 public function testwriteAmf3ObjectTypedToStdClass()835 {836 $this->out->setAvmPlus(true);837 $obj = new stdClass();838 $remoteClassField = Constants::REMOTE_CLASS_FIELD;839 $obj->$remoteClassField = 'SomeClass';840 $this->out->writeObject($obj);841 //$this->sendToJamf($this->out->data);842 //file_put_contents(__DIR__ . '/../asset/value/object-typed-someclass.amf3', serialize($this->out->data));843 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/object-typed-someclass.amf3'));844 $this->assertEquals($data, $this->out->data);845 }846 /**847 * Type comes from the namespace. Do not write _explicitType, it is not needed.848 */849 public function testwriteAmf3ObjectTypedFromNamespace()850 {851 $this->out->setAvmPlus(true);852 $obj = new \emilkm\tests\asset\value\VoExplicitTypeNotSet();853 $this->out->writeObject($obj);854 //$this->sendToJamf($this->out->data);855 //file_put_contents(__DIR__ . '/../asset/value/object-typed-explicit-from-namespace.amf3', serialize($this->out->data));856 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/object-typed-explicit-from-namespace.amf3'));857 $this->assertEquals($data, $this->out->data);858 }859 /**860 *861 */862 public function testwriteAmf3ObjectTypedFromField()863 {864 $this->out->setAvmPlus(true);865 $obj = new \emilkm\tests\asset\value\VoExplicitTypeNotBlank();866 $this->out->writeObject($obj);867 //$this->sendToJamf($this->out->data);868 //file_put_contents(__DIR__ . '/../asset/value/object-typed-explicit-from-field.amf3', serialize($this->out->data));869 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/object-typed-explicit-from-field.amf3'));870 $this->assertEquals($data, $this->out->data);871 }872 /**873 *874 */875 public function testwriteAmf3ObjectTypedFromFieldAndTraitsReference()876 {877 $this->out->setAvmPlus(true);878 $remoteClassField = Constants::REMOTE_CLASS_FIELD;879 $v1 = new stdClass();880 $v1->$remoteClassField = 'LightClass';881 $v1->id = 1;882 $v1->name = 'a';883 $v2 = new stdClass();884 $v2->$remoteClassField = 'LightClass';885 $v2->id = 2;886 $v2->name = 'b';887 $obj = new stdClass();888 $obj->value = array($v1, $v2);889 $this->out->writeObject($obj);890 //$this->sendToJamf($this->out->data);891 //file_put_contents(__DIR__ . '/../asset/value/object-typed-lightclass-and-traits-reference.amf3', serialize($this->out->data));892 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/object-typed-lightclass-and-traits-reference.amf3'));893 $this->assertEquals($data, $this->out->data);894 }895 /**896 *897 */898 public function testwriteAmf3ObjectTypedFromFieldAndTraitsReferenceMissingProperty()899 {900 $this->out->setAvmPlus(true);901 $remoteClassField = Constants::REMOTE_CLASS_FIELD;902 $v1 = new stdClass();903 $v1->$remoteClassField = 'LightClass';904 $v1->id = 1;905 $v1->name = 'a';906 $v2 = new stdClass();907 $v2->$remoteClassField = 'LightClass';908 $v2->id = 2;909 //$v2->name = 'b'; //v2 is missing one of its properties910 $obj = new stdClass();911 $obj->value = array($v1, $v2);912 $this->out->writeObject($obj);913 //$this->sendToJamf($this->out->data);914 //file_put_contents(__DIR__ . '/../asset/value/object-typed-lightclass-and-traits-reference-missing-property.amf3', serialize($this->out->data));915 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/object-typed-lightclass-and-traits-reference-missing-property.amf3'));916 $this->assertEquals($data, $this->out->data);917 }918 /**919 *920 */921 public function testwriteAmf3ByteArray()922 {923 $this->out->setAvmPlus(true);924 $obj = new stdClass();925 $obj->value = new ByteArray('1a2b3c');926 $this->out->writeObject($obj);927 //$this->sendToJamf($this->out->data);928 //file_put_contents(__DIR__ . '/../asset/value/bytearray.amf3', serialize($this->out->data));929 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/bytearray.amf3'));930 $this->assertEquals($data, $this->out->data);931 }932 /**933 *934 */935 public function testwriteAmf3ByteArrayAndReference()936 {937 $this->out->setAvmPlus(true);938 $obj = new stdClass();939 $bytearr = new ByteArray('1a2b3c');940 $obj->value1 = $bytearr;941 $obj->value2 = $bytearr;942 $this->out->writeObject($obj);943 //$this->sendToJamf($this->out->data);944 //file_put_contents(__DIR__ . '/../asset/value/bytearray-and-reference.amf3', serialize($this->out->data));945 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/bytearray-and-reference.amf3'));946 $this->assertEquals($data, $this->out->data);947 }948 /**949 *950 */951 public function testwriteAmf3XmlFromEfxphpXml()952 {953 $this->out->setAvmPlus(true);954 $obj = new stdClass();955 $obj->value = new Xml('<x><string>abc</string><number>123</number></x>');956 $this->out->writeObject($obj);957 //$this->sendToJamf($this->out->data);958 //file_put_contents(__DIR__ . '/../asset/value/xml.amf3', serialize($this->out->data));959 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/xml.amf3'));960 $this->assertEquals($data, $this->out->data);961 }962 /**963 *964 */965 public function testwriteAmf3XmlFromSimpleXMLElement()966 {967 $this->out->setAvmPlus(true);968 $obj = new stdClass();969 $obj->value = simplexml_load_string('<x><string>abc</string><number>123</number></x>');970 $this->out->writeObject($obj);971 //$this->sendToJamf($this->out->data);972 //file_put_contents(__DIR__ . '/../asset/value/xmlelement.amf3', serialize($this->out->data));973 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/xmlelement.amf3'));974 $this->assertEquals($data, $this->out->data);975 }976 /**977 *978 */979 public function testwriteAmf3XmlFromEfxphpXmlAndReference()980 {981 $this->out->setAvmPlus(true);982 $obj = new stdClass();983 $xmlobj = new Xml('<x><string>abc</string><number>123</number></x>');984 $obj->value1 = $xmlobj;985 $obj->value2 = $xmlobj;986 $this->out->writeObject($obj);987 //$this->sendToJamf($this->out->data);988 //file_put_contents(__DIR__ . '/../asset/value/xml-and-reference.amf3', serialize($this->out->data));989 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/xml-and-reference.amf3'));990 $this->assertEquals($data, $this->out->data);991 }992 /**993 *994 */995 public function testwriteAmf3XmlFromSimpleXMLElementAndReference()996 {997 $this->out->setAvmPlus(true);998 $obj = new stdClass();999 $xmlobj = simplexml_load_string('<x><string>abc</string><number>123</number></x>');1000 $obj->value1 = $xmlobj;1001 $obj->value2 = $xmlobj;1002 $this->out->writeObject($obj);1003 //$this->sendToJamf($this->out->data);1004 //file_put_contents(__DIR__ . '/../asset/value/xmlelement-and-reference.amf3', serialize($this->out->data));1005 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/xmlelement-and-reference.amf3'));1006 $this->assertEquals($data, $this->out->data);1007 }1008 /**1009 *1010 */1011 public function testwriteAmf3XmlDocumentFromEfxphpXmlDocument()1012 {1013 $this->out->setAvmPlus(true);1014 $obj = new stdClass();1015 $obj->value = new XmlDocument('<x><string>abc</string><number>123</number></x>');1016 $this->out->writeObject($obj);1017 //$this->sendToJamf($this->out->data);1018 //file_put_contents(__DIR__ . '/../asset/value/xmldocument.amf3', serialize($this->out->data));1019 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/xmldocument.amf3'));1020 $this->assertEquals($data, $this->out->data);1021 }1022 /**1023 *1024 */1025 public function testwriteAmf3XmlDocumentFromDOMElement()1026 {1027 $this->out->setAvmPlus(true);1028 $obj = new stdClass();1029 $obj->value = dom_import_simplexml(simplexml_load_string('<x><string>abc</string><number>123</number></x>'));1030 $this->out->writeObject($obj);1031 //$this->sendToJamf($this->out->data);1032 //file_put_contents(__DIR__ . '/../asset/value/domelement.amf3', serialize($this->out->data));1033 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/domelement.amf3'));1034 $this->assertEquals($data, $this->out->data);1035 }1036 /**1037 *1038 */1039 public function testwriteAmf3XmlDocumentFromEfxphpXmlDocumentAndReference()1040 {1041 $this->out->setAvmPlus(true);1042 $obj = new stdClass();1043 $xmlobj = new XmlDocument('<x><string>abc</string><number>123</number></x>');1044 $obj->value1 = $xmlobj;1045 $obj->value2 = $xmlobj;1046 $this->out->writeObject($obj);1047 //$this->sendToJamf($this->out->data);1048 //file_put_contents(__DIR__ . '/../asset/value/xmldocument-and-reference.amf3', serialize($this->out->data));1049 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/xmldocument-and-reference.amf3'));1050 $this->assertEquals($data, $this->out->data);1051 }1052 /**1053 *1054 */1055 public function testwriteAmf3XmlDocumentFromDOMElementAndReference()1056 {1057 $this->out->setAvmPlus(true);1058 $obj = new stdClass();1059 $xmlobj = dom_import_simplexml(simplexml_load_string('<x><string>abc</string><number>123</number></x>'));1060 $obj->value1 = $xmlobj;1061 $obj->value2 = $xmlobj;1062 $this->out->writeObject($obj);1063 //$this->sendToJamf($this->out->data);1064 //file_put_contents(__DIR__ . '/../asset/value/domelement-and-reference.amf3', serialize($this->out->data));1065 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/domelement-and-reference.amf3'));1066 $this->assertEquals($data, $this->out->data);1067 }1068 /**1069 *1070 */1071 public function testwriteAmf3VectorInt()1072 {1073 $this->out->setAvmPlus(true);1074 $obj = new stdClass();1075 $vector = new Vector(Constants::AMF3_VECTOR_INT, array(1, 2, 3));1076 $obj->value = $vector;1077 $this->out->writeObject($obj);1078 //$this->sendToJamf($this->out->data);1079 //file_put_contents(__DIR__ . '/../asset/value/vector-int.amf3', serialize($this->out->data));1080 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/vector-int.amf3'));1081 $this->assertEquals($data, $this->out->data);1082 }1083 /**1084 *1085 */1086 public function testwriteAmf3VectorIntNegative()1087 {1088 $this->out->setAvmPlus(true);1089 $obj = new stdClass();1090 $vector = new Vector(Constants::AMF3_VECTOR_INT, array(-3, -2, -1));1091 $obj->value = $vector;1092 $this->out->writeObject($obj);1093 //$this->sendToJamf($this->out->data);1094 //file_put_contents(__DIR__ . '/../asset/value/vector-int-negative.amf3', serialize($this->out->data));1095 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/vector-int-negative.amf3'));1096 $this->assertEquals($data, $this->out->data);1097 }1098 /**1099 *1100 */1101 public function testwriteAmf3VectorUint()1102 {1103 $this->out->setAvmPlus(true);1104 $obj = new stdClass();1105 $vector = new Vector(Constants::AMF3_VECTOR_UINT, array(2147483647, 2147483648, 4294967295));1106 $obj->value = $vector;1107 $this->out->writeObject($obj);1108 //$this->sendToJamf($this->out->data);1109 //file_put_contents(__DIR__ . '/../../asset/value/vector-uint.amf3', serialize($this->out->data));1110 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/vector-uint.amf3'));1111 $this->assertEquals($data, $this->out->data);1112 }1113 /**1114 *1115 */1116 public function testwriteAmf3VectorDouble()1117 {1118 $this->out->setAvmPlus(true);1119 $obj = new stdClass();1120 $vector = new Vector(Constants::AMF3_VECTOR_DOUBLE, array(-31.57, 0, 31.57));1121 $obj->value = $vector;1122 $this->out->writeObject($obj);1123 //$this->sendToJamf($this->out->data);1124 //file_put_contents(__DIR__ . '/../../asset/value/vector-double.amf3', serialize($this->out->data));1125 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/vector-double.amf3'));1126 $this->assertEquals($data, $this->out->data);1127 }1128 /**1129 *1130 */1131 public function testwriteAmf3VectorObject()1132 {1133 $this->out->setAvmPlus(true);1134 $v1 = new stdClass();1135 $v1->value = 1;1136 $v2 = new stdClass();1137 $v2->value = 2;1138 $v3 = new stdClass();1139 $v3->value = 3;1140 $obj = new stdClass();1141 $vector = new Vector(Constants::AMF3_VECTOR_OBJECT, array($v1, $v2, $v3));1142 $obj->value = $vector;1143 $this->out->writeObject($obj);1144 //$this->sendToJamf($this->out->data);1145 //file_put_contents(__DIR__ . '/../../asset/value/vector-object.amf3', serialize($this->out->data));1146 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/vector-object.amf3'));1147 $this->assertEquals($data, $this->out->data);1148 }1149 /**1150 *1151 */1152 public function testwriteAmf3VectorObjectAndReference()1153 {1154 $this->out->setAvmPlus(true);1155 $v1 = new stdClass();1156 $v1->value = 1;1157 $v2 = new stdClass();1158 $v2->value = 2;1159 $v3 = new stdClass();1160 $v3->value = 3;1161 $obj = new stdClass();1162 $vector = new Vector(Constants::AMF3_VECTOR_OBJECT, array($v1, $v2, $v3));1163 $obj->value1 = $vector;1164 $obj->value2 = $vector;1165 $this->out->writeObject($obj);1166 //$this->sendToJamf($this->out->data);1167 //file_put_contents(__DIR__ . '/../../asset/value/vector-object-and-reference.amf3', serialize($this->out->data));1168 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/vector-object-and-reference.amf3'));1169 $this->assertEquals($data, $this->out->data);1170 }1171 /**1172 *1173 */1174 public function testwriteAmf3ComplexObjectGraph()1175 {1176 $this->out->setAvmPlus(true);1177 $obj = new stdClass();1178 $arr = array();1179 $a = new stdClass();1180 $a->name = 'a';1181 $a->parent = null;1182 $a->children = array();1183 $arr[] = $a;1184 $a1 = new stdClass();1185 $a1->name = 'a1';1186 $a1->parent = $a;1187 $a1->children = null;1188 $a->children[] = $a1;1189 $b = new stdClass();1190 $b->name = 'b';1191 $b->parent = null;1192 $b->children = array();1193 $arr[] = $b;1194 $b1 = new stdClass();1195 $b1->name = 'b1';1196 $b1->parent = $b;1197 $b1->children = array();1198 $b->children[] = $b1;1199 $bb1 = new stdClass();1200 $bb1->name = 'bb1';1201 $bb1->parent = $b1;1202 $bb1->children = array();1203 $b1->children[] = $bb1;1204 $obj->value = $arr;1205 $this->out->writeObject($obj);1206 //$this->sendToJamf($this->out->data);1207 //file_put_contents(__DIR__ . '/../asset/value/complex-object-graph.amf3', serialize($this->out->data));1208 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/complex-object-graph.amf3'));1209 $this->assertEquals($data, $this->out->data);1210 }1211}...
OutputExtTest.php
Source:OutputExtTest.php
1<?php2/**3 * efxphp (http://emilmalinov.com/efxphp)4 *5 * @copyright Copyright (c) 2015 Emil Malinov6 * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.07 * @link http://github.com/emilkm/efxphp8 * @package efxphp9 */10namespace emilkm\tests\efxphp\Amf;11use emilkm\tests\util\SendToJamfTrait;12use emilkm\tests\util\InvokeMethodTrait;13use emilkm\efxphp\Amf\Constants;14use emilkm\efxphp\Amf\OutputExt;15use emilkm\efxphp\Amf\Types\Date;16use emilkm\efxphp\Amf\Types\ByteArray;17use emilkm\efxphp\Amf\Types\Vector;18use emilkm\efxphp\Amf\Types\Xml;19use emilkm\efxphp\Amf\Types\XmlDocument;20use stdClass;21use DateTime;22use DateTimeZone;23/**24 * @author Emil Malinov25 * @package efxphp26 * @subpackage tests27 */28class OutputExtTest extends \PHPUnit_Framework_TestCase29{30 use SendToJamfTrait;31 use InvokeMethodTrait;32 protected $out;33 protected function setUp()34 {35 $this->out = new OutputExt();36 }37 /**38 *39 */40 public function testwriteAmf0Number()41 {42 $this->out->setAvmPlus(false);43 $obj = new stdClass();44 $obj->value = 31.57;45 $this->out->writeObject($obj);46 //$this->sendToJamf($this->out->data);47 //file_put_contents(__DIR__ . '/../asset/value/number.amf0', serialize($this->out->data));48 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/number.amf0'));49 $this->assertEquals($data, $this->out->data);50 }51 /**52 *53 */54 public function testwriteAmf0Boolean()55 {56 $this->out->setAvmPlus(false);57 $obj = new stdClass();58 $obj->value = true;59 $this->out->writeObject($obj);60 //$this->sendToJamf($this->out->data);61 //file_put_contents(__DIR__ . '/../asset/value/boolean.amf0', serialize($this->out->data));62 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/boolean.amf0'));63 $this->assertEquals($data, $this->out->data);64 }65 /**66 *67 */68 public function testwriteAmf0DateFromEfxphpDate()69 {70 $this->out->setAvmPlus(false);71 $obj = new stdClass();72 $obj->value = new Date(1422995025123); //2015-02-04 09:23:45.12373 $this->out->writeObject($obj);74 //$this->sendToJamf($this->out->data);75 //file_put_contents(__DIR__ . '/../asset/value/date.amf0', serialize($this->out->data));76 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/date.amf0'));77 $this->assertEquals($data, $this->out->data);78 }79 /**80 *81 */82 public function testwriteAmf0DateFromPhpDateTime()83 {84 $this->out->setAvmPlus(false);85 $obj = new stdClass();86 $datestr = date('Y-m-d H:i:s.', 1422995025) . 123; //2015-02-04 09:23:45.12387 $obj->value = new DateTime($datestr);88 $this->out->writeObject($obj);89 //$this->sendToJamf($this->out->data);90 //file_put_contents(__DIR__ . '/../asset/value/date.amf0', serialize($this->out->data));91 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/date.amf0'));92 $this->assertEquals($data, $this->out->data);93 }94 /**95 *96 */97 public function testwriteAmf0String()98 {99 $this->out->setAvmPlus(false);100 $obj = new stdClass();101 $obj->value = 'abc';102 $this->out->writeObject($obj);103 //$this->sendToJamf($this->out->data);104 //file_put_contents(__DIR__ . '/../asset/value/string.amf0', serialize($this->out->data));105 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/string.amf0'));106 $this->assertEquals($data, $this->out->data);107 }108 /**109 *110 */111 public function testwriteAmf0StringBlank()112 {113 $this->out->setAvmPlus(false);114 $obj = new stdClass();115 $obj->value = '';116 $this->out->writeObject($obj);117 //$this->sendToJamf($this->out->data);118 //file_put_contents(__DIR__ . '/../asset/value/string-blank.amf0', serialize($this->out->data));119 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/string-blank.amf0'));120 $this->assertEquals($data, $this->out->data);121 }122 /**123 *124 */125 public function testwriteAmf0StringUnicode()126 {127 $this->out->setAvmPlus(false);128 $obj = new stdClass();129 $obj->value = 'виÑоÑа';130 $this->out->writeObject($obj);131 //$this->sendToJamf($this->out->data);132 //file_put_contents(__DIR__ . '/../asset/value/string-unicode.amf0', serialize($this->out->data));133 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/string-unicode.amf0'));134 $this->assertEquals($data, $this->out->data);135 }136 /**137 *138 */139 public function testwriteAmf0Null()140 {141 $this->out->setAvmPlus(false);142 $obj = new stdClass();143 $obj->value = null;144 $this->out->writeObject($obj);145 //$this->sendToJamf($this->out->data);146 //file_put_contents(__DIR__ . '/../asset/value/null.amf0', serialize($this->out->data));147 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/null.amf0'));148 $this->assertEquals($data, $this->out->data);149 }150 /**151 *152 */153 public function testwriteAmf0ArrayEmpty()154 {155 $this->out->setAvmPlus(false);156 $obj = array();157 $this->out->writeObject($obj);158 //$this->sendToJamf($this->out->data);159 //file_put_contents(__DIR__ . '/../asset/value/array-empty.amf0', serialize($this->out->data));160 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/array-empty.amf0'));161 $this->assertEquals($data, $this->out->data);162 }163 /**164 *165 */166 public function testwriteAmf0ArrayDense()167 {168 $this->out->setAvmPlus(false);169 $obj = array();170 $obj[0] = 'a';171 $obj[1] = 'b';172 $obj[2] = 'c';173 $this->out->writeObject($obj);174 //$this->sendToJamf($this->out->data);175 //file_put_contents(__DIR__ . '/../asset/value/array-dense.amf0', serialize($this->out->data));176 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/array-dense.amf0'));177 $this->assertEquals($data, $this->out->data);178 }179 /**180 * Undefined entries in the sparse regions between indices are serialized as undefined.181 * Undefined entries in the sparse regions between indices are skipped when deserialized.182 */183 public function testwriteAmf0ArraySparse()184 {185 $this->out->setAvmPlus(false);186 $obj = array();187 $obj[0] = 'a';188 $obj[2] = 'b';189 $obj[4] = 'c';190 $this->out->writeObject($obj);191 //$this->sendToJamf($this->out->data);192 //file_put_contents(__DIR__ . '/../asset/value/array-sparse.amf0', serialize($this->out->data));193 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/array-sparse.amf0'));194 $this->assertEquals($data, $this->out->data);195 }196 /**197 *198 */199 public function testwriteAmf0ArrayString()200 {201 $this->out->setAvmPlus(false);202 $obj = array();203 $obj['a'] = 1;204 $obj['b'] = 2;205 $obj['c'] = 3;206 $this->out->writeObject($obj);207 //$this->sendToJamf($this->out->data);208 //file_put_contents(__DIR__ . '/../asset/value/array-string.amf0', serialize($this->out->data));209 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/array-string.amf0'));210 $this->assertEquals($data, $this->out->data);211 }212 /**213 *214 */215 public function testwriteAmf0ArrayMixed()216 {217 $this->out->setAvmPlus(false);218 $obj = array();219 $obj[0] = 'a';220 $obj['b'] = 2;221 $this->out->writeObject($obj);222 //$this->sendToJamf($this->out->data);223 //file_put_contents(__DIR__ . '/../asset/value/array-mixed.amf0', serialize($this->out->data));224 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/array-mixed.amf0'));225 $this->assertEquals($data, $this->out->data);226 }227 /**228 *229 */230 public function testwriteAmf0ArrayNegative()231 {232 $this->out->setAvmPlus(false);233 $obj = array();234 $obj[-1] = 'a';235 $obj[0] = 'b';236 $obj[1] = 'c';237 $this->out->writeObject($obj);238 //$this->sendToJamf($this->out->data);239 //file_put_contents(__DIR__ . '/../asset/value/array-negative.amf0', serialize($this->out->data));240 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/array-negative.amf0'));241 $this->assertEquals($data, $this->out->data);242 }243 /**244 *245 */246 public function testwriteAmf0ArrayNested()247 {248 $this->out->setAvmPlus(false);249 $obj = array();250 $obj['items'] = array();251 $obj['items'][0] = 'a';252 $obj['items'][1] = 'b';253 $obj['items'][2] = 'c';254 $this->out->writeObject($obj);255 //$this->sendToJamf($this->out->data);256 //file_put_contents(__DIR__ . '/../asset/value/array-nested.amf0', serialize($this->out->data));257 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/array-nested.amf0'));258 $this->assertEquals($data, $this->out->data);259 }260 /**261 * The pure anonymous case.262 */263 public function testwriteAmf0ObjectAnonymous()264 {265 $this->out->setAvmPlus(false);266 $obj = new stdClass();267 $this->out->writeObject($obj);268 //$this->sendToJamf($this->out->data);269 //file_put_contents(__DIR__ . '/../asset/value/object-anonymous.amf0', serialize($this->out->data));270 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/object-anonymous.amf0'));271 $this->assertEquals($data, $this->out->data);272 }273 /**274 * Anonymous object with blank _explicitType field, do not write the _explicitType field.275 */276 public function testwriteAmf0ObjectAnonymousFromBlankExplicitType()277 {278 $this->out->setAvmPlus(false);279 $obj = new stdClass();280 $remoteClassField = Constants::REMOTE_CLASS_FIELD;281 $obj->$remoteClassField = '';282 $this->out->writeObject($obj);283 //$this->sendToJamf($this->out->data);284 //file_put_contents(__DIR__ . '/../asset/value/object-anonymous.amf0', serialize($this->out->data));285 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/object-anonymous.amf0'));286 $this->assertEquals($data, $this->out->data);287 }288 /**289 * Typed object with blank _explicitType field, do not write the _explicitType field.290 * There is a conflict between the object type and the _explicitType. Since _explicitType takes precedence,291 * output an anonymous object.292 */293 public function testwriteAmf0ObjectAnonymousFromTypeConflict()294 {295 $this->out->setAvmPlus(false);296 $obj = new \emilkm\tests\asset\value\VoExplicitTypeBlank();297 $this->out->writeObject($obj);298 //$this->sendToJamf($this->out->data);299 //file_put_contents(__DIR__ . '/../asset/value/object-anonymous.amf0', serialize($this->out->data));300 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/object-anonymous.amf0'));301 $this->assertEquals($data, $this->out->data);302 }303 /**304 * When the type cannot be resolved, simply write stdClass and set the _explicitType field.305 * Do not write an anonymous object, because the remote client may be able to resolve it.306 */307 public function testwriteAmf0ObjectTypedNotResolvableToStdClass()308 {309 $this->out->setAvmPlus(false);310 $obj = new stdClass();311 $remoteClassField = Constants::REMOTE_CLASS_FIELD;312 $obj->$remoteClassField = 'SomeClass';313 $this->out->writeObject($obj);314 //$this->sendToJamf($this->out->data);315 //file_put_contents(__DIR__ . '/../asset/value/object-typed-someclass.amf0', serialize($this->out->data));316 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/object-typed-someclass.amf0'));317 $this->assertEquals($data, $this->out->data);318 }319 /**320 *321 */322 public function testwriteAmf0ObjectTypedFromNamespace()323 {324 $this->out->setAvmPlus(false);325 $obj = new \emilkm\tests\asset\value\VoExplicitTypeNotSet();326 $this->out->writeObject($obj);327 //$this->sendToJamf($this->out->data);328 //file_put_contents(__DIR__ . '/../asset/value/object-typed-explicit-from-namespace.amf0', serialize($this->out->data));329 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/object-typed-explicit-from-namespace.amf0'));330 $this->assertEquals($data, $this->out->data);331 }332 /**333 *334 */335 public function testwriteAmf0ObjectTypedFromField()336 {337 $this->out->setAvmPlus(false);338 $obj = new \emilkm\tests\asset\value\VoExplicitTypeNotBlank();339 $this->out->writeObject($obj);340 //$this->sendToJamf($this->out->data);341 //file_put_contents(__DIR__ . '/../asset/value/object-typed-explicit-from-field.amf0', serialize($this->out->data));342 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/object-typed-explicit-from-field.amf0'));343 $this->assertEquals($data, $this->out->data);344 }345 /**346 *347 */348 /*public function testwriteAmf0XmlFromEfxphpXml()349 {350 $this->out->setAvmPlus(false);351 $obj = new stdClass();352 $obj->value = new Xml('<x><string>abc</string><number>123</number></x>');353 $this->out->writeObject($obj);354 //$this->sendToJamf($this->out->data);355 //file_put_contents(__DIR__ . '/../asset/value/xml.amf0', serialize($this->out->data));356 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/xml.amf0'));357 $this->assertEquals($data, $this->out->data);358 }*/359 /**360 *361 */362 /*public function testwriteAmf0XmlFromSimpleXMLElement()363 {364 $this->out->setAvmPlus(false);365 $obj = new stdClass();366 $obj->value = simplexml_load_string('<x><string>abc</string><number>123</number></x>');367 $this->out->writeObject($obj);368 //$this->sendToJamf($this->out->data);369 //file_put_contents(__DIR__ . '/../asset/value/xmlelement.amf0', serialize($this->out->data));370 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/xmlelement.amf0'));371 $this->assertEquals($data, $this->out->data);372 }*/373 /**374 *375 */376 /*public function testwriteAmf0XmlDocumentFromEfxphpXmlDocument()377 {378 $this->out->setAvmPlus(false);379 $obj = new stdClass();380 $obj->value = new XmlDocument('<x><string>abc</string><number>123</number></x>');381 $this->out->writeObject($obj);382 //$this->sendToJamf($this->out->data);383 //file_put_contents(__DIR__ . '/../asset/value/xmldocument.amf0', serialize($this->out->data));384 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/xmldocument.amf0'));385 $this->assertEquals($data, $this->out->data);386 }387 /**388 *389 */390 /*public function testwriteAmf0XmlDocumentFromDOMElement()391 {392 $this->out->setAvmPlus(false);393 $obj = new stdClass();394 $obj->value = dom_import_simplexml(simplexml_load_string('<x><string>abc</string><number>123</number></x>'));395 $this->out->writeObject($obj);396 //$this->sendToJamf($this->out->data);397 //file_put_contents(__DIR__ . '/../asset/value/domelement.amf0', serialize($this->out->data));398 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/domelement.amf0'));399 $this->assertEquals($data, $this->out->data);400 }*/401 //##########################################################################402 // AMF3403 //##########################################################################404 /**405 * TODO:406 */407 public function testwriteAmf3Undefined()408 {409 }410 /**411 *412 */413 public function testwriteAmf3Null()414 {415 $this->out->setAvmPlus(true);416 $obj = new stdClass();417 $obj->value = null;418 $this->out->writeObject($obj);419 //$this->sendToJamf($this->out->data);420 //file_put_contents(__DIR__ . '/../asset/value/null.amf3', serialize($this->out->data));421 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/null.amf3'));422 $this->assertEquals($data, $this->out->data);423 }424 /**425 *426 */427 public function testwriteAmf3BooleanTrue()428 {429 $this->out->setAvmPlus(true);430 $obj = new stdClass();431 $obj->value = true;432 $this->out->writeObject($obj);433 //$this->sendToJamf($this->out->data);434 //file_put_contents(__DIR__ . '/../asset/value/boolean-true.amf3', serialize($this->out->data));435 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/boolean-true.amf3'));436 $this->assertEquals($data, $this->out->data);437 }438 /**439 *440 */441 public function testwriteAmf3BooleanFalse()442 {443 $this->out->setAvmPlus(true);444 $obj = new stdClass();445 $obj->value = false;446 $this->out->writeObject($obj);447 //$this->sendToJamf($this->out->data);448 //file_put_contents(__DIR__ . '/../asset/value/boolean-false.amf3', serialize($this->out->data));449 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/boolean-false.amf3'));450 $this->assertEquals($data, $this->out->data);451 }452 /**453 *454 */455 public function testwriteAmf3Integer()456 {457 $this->out->setAvmPlus(true);458 $obj = new stdClass();459 $obj->value = 123;460 $this->out->writeObject($obj);461 //$this->sendToJamf($this->out->data);462 //file_put_contents(__DIR__ . '/../asset/value/integer.amf3', serialize($this->out->data));463 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/integer.amf3'));464 $this->assertEquals($data, $this->out->data);465 }466 /**467 *468 */469 public function testwriteAmf3Double()470 {471 $this->out->setAvmPlus(true);472 $obj = new stdClass();473 $obj->value = 31.57;474 $this->out->writeObject($obj);475 //$this->sendToJamf($this->out->data);476 //file_put_contents(__DIR__ . '/../asset/value/double.amf3', serialize($this->out->data));477 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/double.amf3'));478 $this->assertEquals($data, $this->out->data);479 }480 /**481 *482 */483 public function testwriteAmf3String()484 {485 $this->out->setAvmPlus(true);486 $obj = new stdClass();487 $obj->value = 'abc';488 $this->out->writeObject($obj);489 //$this->sendToJamf($this->out->data);490 //file_put_contents(__DIR__ . '/../asset/value/string.amf3', serialize($this->out->data));491 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/string.amf3'));492 $this->assertEquals($data, $this->out->data);493 }494 /**495 *496 */497 public function testwriteAmf3StringBlank()498 {499 $this->out->setAvmPlus(true);500 $obj = new stdClass();501 $obj->value = '';502 $this->out->writeObject($obj);503 //$this->sendToJamf($this->out->data);504 //file_put_contents(__DIR__ . '/../asset/value/string-blank.amf3', serialize($this->out->data));505 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/string-blank.amf3'));506 $this->assertEquals($data, $this->out->data);507 }508 /**509 *510 */511 public function testwriteAmf3StringUnicode()512 {513 $this->out->setAvmPlus(true);514 $obj = new stdClass();515 $obj->value = 'виÑоÑа';516 $this->out->writeObject($obj);517 //$this->sendToJamf($this->out->data);518 //file_put_contents(__DIR__ . '/../asset/value/string-unicode.amf3', serialize($this->out->data));519 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/string-unicode.amf3'));520 $this->assertEquals($data, $this->out->data);521 }522 /**523 *524 */525 public function testwriteAmf3DateFromEfxphpDate()526 {527 $this->out->setAvmPlus(true);528 $obj = new stdClass();529 $obj->value = new Date(1422995025123); //2015-02-04 09:23:45.123530 $this->out->writeObject($obj);531 //$this->sendToJamf($this->out->data);532 //file_put_contents(__DIR__ . '/../asset/value/date.amf3', serialize($this->out->data));533 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/date.amf3'));534 $this->assertEquals($data, $this->out->data);535 }536 /**537 *538 */539 public function testwriteAmf3DateFromPhpDateTime()540 {541 $this->out->setAvmPlus(true);542 $obj = new stdClass();543 $datestr = date('Y-m-d H:i:s.', 1422995025) . 123; //2015-02-04 09:23:45.123544 $obj->value = new DateTime($datestr);545 $this->out->writeObject($obj);546 //$this->sendToJamf($this->out->data);547 //file_put_contents(__DIR__ . '/../asset/value/date.amf3', serialize($this->out->data));548 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/date.amf3'));549 $this->assertEquals($data, $this->out->data);550 }551 /**552 *553 */554 public function testwriteAmf3DateAndReferenceFromEfxphpDate()555 {556 $this->out->setAvmPlus(true);557 $obj = new stdClass();558 $adate = new Date(1422995025123); //2015-02-04 09:23:45.123559 $obj->value1 = $adate;560 $obj->value2 = $adate;561 $this->out->writeObject($obj);562 //$this->sendToJamf($this->out->data);563 //file_put_contents(__DIR__ . '/../asset/value/date-and-reference.amf3', serialize($this->out->data));564 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/date-and-reference.amf3'));565 $this->assertEquals($data, $this->out->data);566 }567 /**568 *569 */570 public function testwriteAmf3DateAndReferenceFromPhpDateTime()571 {572 $this->out->setAvmPlus(true);573 $obj = new stdClass();574 $datestr = date('Y-m-d H:i:s.', 1422995025) . 123; //2015-02-04 09:23:45.123575 $adate = new DateTime($datestr);576 $obj->value1 = $adate;577 $obj->value2 = $adate;578 $this->out->writeObject($obj);579 //$this->sendToJamf($this->out->data);580 //file_put_contents(__DIR__ . '/../asset/value/date-and-reference.amf3', serialize($this->out->data));581 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/date-and-reference.amf3'));582 $this->assertEquals($data, $this->out->data);583 }584 /**585 *586 */587 public function testwriteAmf3ArrayEmpty()588 {589 $this->out->setAvmPlus(true);590 $obj = array();591 $this->out->writeObject($obj);592 //$this->sendToJamf($this->out->data);593 //file_put_contents(__DIR__ . '/../asset/value/array-empty.amf3', serialize($this->out->data));594 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/array-empty.amf3'));595 $this->assertEquals($data, $this->out->data);596 }597 /**598 *599 */600 public function testwriteAmf3ArrayDense()601 {602 $this->out->setAvmPlus(true);603 $obj = array();604 $obj[0] = 'a';605 $obj[1] = 'b';606 $obj[2] = 'c';607 $this->out->writeObject($obj);608 //$this->sendToJamf($this->out->data);609 //file_put_contents(__DIR__ . '/../asset/value/array-dense.amf3', serialize($this->out->data));610 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/array-dense.amf3'));611 $this->assertEquals($data, $this->out->data);612 }613 /**614 *615 */616 public function testwriteAmf3ArraySparseAsObject()617 {618 $this->out->setAvmPlus(true);619 $this->out->encodeAmf3nsndArrayAsObject(true);620 $obj = array();621 $obj[0] = 'a';622 $obj[2] = 'b';623 $obj[4] = 'c';624 $this->out->writeObject($obj);625 //$this->sendToJamf($this->out->data);626 //file_put_contents(__DIR__ . '/../asset/value/array-sparse-as-object.amf3', serialize($this->out->data));627 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/array-sparse-as-object.amf3'));628 $this->assertEquals($data, $this->out->data);629 }630 /**631 *632 */633 public function testwriteAmf3ArraySparseAsAssoc()634 {635 $this->out->setAvmPlus(true);636 $this->out->encodeAmf3nsndArrayAsObject(false);637 $obj = array();638 $obj[0] = 'a';639 $obj[2] = 'b';640 $obj[4] = 'c';641 $this->out->writeObject($obj);642 //$this->sendToJamf($this->out->data);643 //file_put_contents(__DIR__ . '/../asset/value/array-sparse-as-assoc.amf3', serialize($this->out->data));644 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/array-sparse-as-assoc.amf3'));645 $this->assertEquals($data, $this->out->data);646 }647 /**648 *649 */650 public function testwriteAmf3ArrayStringAsObject()651 {652 $this->out->setAvmPlus(true);653 $this->out->encodeAmf3nsndArrayAsObject(true);654 $obj = array();655 $obj['a'] = 1;656 $obj['b'] = 2;657 $obj['c'] = 3;658 $this->out->writeObject($obj);659 //$this->sendToJamf($this->out->data);660 //file_put_contents(__DIR__ . '/../asset/value/array-string-as-object.amf3', serialize($this->out->data));661 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/array-string-as-object.amf3'));662 $this->assertEquals($data, $this->out->data);663 }664 /**665 *666 */667 public function testwriteAmf3ArrayStringAsAssoc()668 {669 $this->out->setAvmPlus(true);670 $this->out->encodeAmf3nsndArrayAsObject(false);671 $obj = array();672 $obj['a'] = 1;673 $obj['b'] = 2;674 $obj['c'] = 3;675 $this->out->writeObject($obj);676 //$this->sendToJamf($this->out->data);677 //file_put_contents(__DIR__ . '/../asset/value/array-string-as-assoc.amf3', serialize($this->out->data));678 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/array-string-as-assoc.amf3'));679 $this->assertEquals($data, $this->out->data);680 }681 /**682 *683 */684 public function testwriteAmf3ArrayMixedAsObject()685 {686 $this->out->setAvmPlus(true);687 $this->out->encodeAmf3nsndArrayAsObject(true);688 $obj = array();689 $obj[0] = 'a';690 $obj['b'] = 2;691 $this->out->writeObject($obj);692 //$this->sendToJamf($this->out->data);693 //file_put_contents(__DIR__ . '/../asset/value/array-mixed-as-object.amf3', serialize($this->out->data));694 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/array-mixed-as-object.amf3'));695 $this->assertEquals($data, $this->out->data);696 }697 /**698 *699 */700 public function testwriteAmf3ArrayMixedAsAssoc()701 {702 $this->out->setAvmPlus(true);703 $this->out->encodeAmf3nsndArrayAsObject(false);704 $obj = array();705 $obj[0] = 'a';706 $obj['b'] = 2;707 $this->out->writeObject($obj);708 //$this->sendToJamf($this->out->data);709 //file_put_contents(__DIR__ . '/../asset/value/array-mixed-as-assoc.amf3', serialize($this->out->data));710 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/array-mixed-as-assoc.amf3'));711 $this->assertEquals($data, $this->out->data);712 }713 /**714 *715 */716 public function testwriteAmf3ArrayNegativeAsObject()717 {718 $this->out->setAvmPlus(true);719 $this->out->encodeAmf3nsndArrayAsObject(true);720 $obj = array();721 $obj[-1] = 'a';722 $obj[0] = 'b';723 $obj[1] = 'c';724 $this->out->writeObject($obj);725 //$this->sendToJamf($this->out->data);726 //file_put_contents(__DIR__ . '/../asset/value/array-negative-as-object.amf3', serialize($this->out->data));727 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/array-negative-as-object.amf3'));728 $this->assertEquals($data, $this->out->data);729 }730 /**731 *732 */733 public function testwriteAmf3ArrayNegativeAsAssoc()734 {735 $this->out->setAvmPlus(true);736 $this->out->encodeAmf3nsndArrayAsObject(false);737 $obj = array();738 $obj[-1] = 'a';739 $obj[0] = 'b';740 $obj[1] = 'c';741 $this->out->writeObject($obj);742 //$this->sendToJamf($this->out->data);743 //file_put_contents(__DIR__ . '/../asset/value/array-negative-as-assoc.amf3', serialize($this->out->data));744 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/array-negative-as-assoc.amf3'));745 $this->assertEquals($data, $this->out->data);746 }747 /**748 *749 */750 public function testwriteAmf3ArrayNestedAsObject()751 {752 $this->out->setAvmPlus(true);753 $this->out->encodeAmf3nsndArrayAsObject(true);754 $obj = array();755 $obj['items'] = array();756 $obj['items'][0] = 'a';757 $obj['items'][1] = 'b';758 $obj['items'][2] = 'c';759 $this->out->writeObject($obj);760 //$this->sendToJamf($this->out->data);761 //file_put_contents(__DIR__ . '/../asset/value/array-nested-as-object.amf3', serialize($this->out->data));762 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/array-nested-as-object.amf3'));763 $this->assertEquals($data, $this->out->data);764 }765 /**766 *767 */768 public function testwriteAmf3ArrayNestedAsAssoc()769 {770 $this->out->setAvmPlus(true);771 $this->out->encodeAmf3nsndArrayAsObject(false);772 $obj = array();773 $obj['items'] = array();774 $obj['items'][0] = 'a';775 $obj['items'][1] = 'b';776 $obj['items'][2] = 'c';777 $this->out->writeObject($obj);778 //$this->sendToJamf($this->out->data);779 //file_put_contents(__DIR__ . '/../asset/value/array-nested-as-assoc.amf3', serialize($this->out->data));780 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/array-nested-as-assoc.amf3'));781 $this->assertEquals($data, $this->out->data);782 }783 /**784 * The pure anonymous case.785 */786 public function testwriteAmf3Anonymous()787 {788 $this->out->setAvmPlus(true);789 $obj = new stdClass();790 $this->out->writeObject($obj);791 //$this->sendToJamf($this->out->data);792 //file_put_contents(__DIR__ . '/../asset/value/object-anonymous.amf3', serialize($this->out->data));793 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/object-anonymous.amf3'));794 $this->assertEquals($data, $this->out->data);795 }796 /**797 * Anonymous object with blank _explicitType field, do not write the _explicitType field.798 */799 public function testwriteAmf3ObjectAnonymousFromBlankExplicitType()800 {801 $this->out->setAvmPlus(true);802 $obj = new stdClass();803 $remoteClassField = Constants::REMOTE_CLASS_FIELD;804 $obj->$remoteClassField = '';805 $this->out->writeObject($obj);806 //$this->sendToJamf($this->out->data);807 //file_put_contents(__DIR__ . '/../asset/value/object-anonymous.amf3', serialize($this->out->data));808 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/object-anonymous.amf3'));809 $this->assertEquals($data, $this->out->data);810 }811 /**812 * Typed object with blank _explicitType field, do not write the _explicitType field.813 * There is a conflict between the object type and the _explicitType. Since _explicitType takes precedence,814 * output an anonymous object.815 */816 public function testwriteAmf3ObjectAnonymousFromTypeConflict()817 {818 $this->out->setAvmPlus(true);819 $obj = new \emilkm\tests\asset\value\VoExplicitTypeBlank();820 $this->out->writeObject($obj);821 //$this->sendToJamf($this->out->data);822 //file_put_contents(__DIR__ . '/../asset/value/object-anonymous.amf3', serialize($this->out->data));823 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/object-anonymous.amf3'));824 $this->assertEquals($data, $this->out->data);825 }826 /**827 * When the type cannot be resolved, simply write stdClass and set the _explicitType field.828 * Do not write an anonymous object, because the remote client may be able to resolve it.829 */830 public function testwriteAmf3TypedToStdClass()831 {832 $this->out->setAvmPlus(true);833 $obj = new stdClass();834 $remoteClassField = Constants::REMOTE_CLASS_FIELD;835 $obj->$remoteClassField = 'SomeClass';836 $this->out->writeObject($obj);837 //$this->sendToJamf($this->out->data);838 //file_put_contents(__DIR__ . '/../asset/value/object-typed-someclass.amf3', serialize($this->out->data));839 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/object-typed-someclass.amf3'));840 $this->assertEquals($data, $this->out->data);841 }842 /**843 * Type comes from the namespace. Do not write _explicitType, it is not needed.844 */845 public function testwriteAmf3ObjectTypedFromNamespace()846 {847 $this->out->setAvmPlus(true);848 $obj = new \emilkm\tests\asset\value\VoExplicitTypeNotSet();849 $this->out->writeObject($obj);850 //$this->sendToJamf($this->out->data);851 //file_put_contents(__DIR__ . '/../asset/value/object-typed-explicit-from-namespace.amf3', serialize($this->out->data));852 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/object-typed-explicit-from-namespace.amf3'));853 $this->assertEquals($data, $this->out->data);854 }855 /**856 *857 */858 public function testwriteAmf3ObjectTypedFromField()859 {860 $this->out->setAvmPlus(true);861 $obj = new \emilkm\tests\asset\value\VoExplicitTypeNotBlank();862 $this->out->writeObject($obj);863 //$this->sendToJamf($this->out->data);864 //file_put_contents(__DIR__ . '/../asset/value/object-typed-explicit-from-field.amf3', serialize($this->out->data));865 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/object-typed-explicit-from-field.amf3'));866 $this->assertEquals($data, $this->out->data);867 }868 /**869 *870 */871 public function testwriteAmf3ObjectTypedFromFieldAndTraitsReference()872 {873 $this->out->setAvmPlus(true);874 $remoteClassField = Constants::REMOTE_CLASS_FIELD;875 $v1 = new stdClass();876 $v1->$remoteClassField = 'LightClass';877 $v1->id = 1;878 $v1->name = 'a';879 $v2 = new stdClass();880 $v2->$remoteClassField = 'LightClass';881 $v2->id = 2;882 $v2->name = 'b';883 $obj = new stdClass();884 $obj->value = array($v1, $v2);885 $this->out->writeObject($obj);886 //$this->sendToJamf($this->out->data);887 //file_put_contents(__DIR__ . '/../asset/value/object-typed-lightclass-and-traits-reference.amf3', serialize($this->out->data));888 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/object-typed-lightclass-and-traits-reference.amf3'));889 $this->assertEquals($data, $this->out->data);890 }891 /**892 *893 */894 public function testwriteAmf3ObjectTypedFromFieldAndTraitsReferenceMissingProperty()895 {896 $this->out->setAvmPlus(true);897 $remoteClassField = Constants::REMOTE_CLASS_FIELD;898 $v1 = new stdClass();899 $v1->$remoteClassField = 'LightClass';900 $v1->id = 1;901 $v1->name = 'a';902 $v2 = new stdClass();903 $v2->$remoteClassField = 'LightClass';904 $v2->id = 2;905 //$v2->name = 'b'; //v2 is missing one of its properties906 $obj = new stdClass();907 $obj->value = array($v1, $v2);908 $this->out->writeObject($obj);909 //$this->sendToJamf($this->out->data);910 //file_put_contents(__DIR__ . '/../asset/value/object-typed-lightclass-and-traits-reference-missing-property.amf3', serialize($this->out->data));911 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/object-typed-lightclass-and-traits-reference-missing-property.amf3'));912 $this->assertEquals($data, $this->out->data);913 }914 /**915 *916 */917 public function testwriteAmf3ByteArray()918 {919 $this->out->setAvmPlus(true);920 $obj = new stdClass();921 $obj->value = new ByteArray('1a2b3c');922 $this->out->writeObject($obj);923 //$this->sendToJamf($this->out->data);924 //file_put_contents(__DIR__ . '/../asset/value/bytearray.amf3', serialize($this->out->data));925 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/bytearray.amf3'));926 $this->assertEquals($data, $this->out->data);927 }928 /**929 *930 */931 public function testwriteAmf3ByteArrayAndReference()932 {933 $this->out->setAvmPlus(true);934 $obj = new stdClass();935 $bytearr = new ByteArray('1a2b3c');936 $obj->value1 = $bytearr;937 $obj->value2 = $bytearr;938 $this->out->writeObject($obj);939 //$this->sendToJamf($this->out->data);940 //file_put_contents(__DIR__ . '/../asset/value/bytearray-and-reference.amf3', serialize($this->out->data));941 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/bytearray-and-reference.amf3'));942 $this->assertEquals($data, $this->out->data);943 }944 /**945 *946 */947 /*public function testwriteAmf3XmlFromEfxphpXml()948 {949 $this->out->setAvmPlus(true);950 $obj = new stdClass();951 $obj->value = new Xml('<x><string>abc</string><number>123</number></x>');952 $this->out->writeObject($obj);953 //$this->sendToJamf($this->out->data);954 //file_put_contents(__DIR__ . '/../asset/value/xml.amf3', serialize($this->out->data));955 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/xml.amf3'));956 $this->assertEquals($data, $this->out->data);957 }*/958 /**959 *960 */961 /*public function testwriteAmf3XmlFromSimpleXMLElement()962 {963 $this->out->setAvmPlus(true);964 $obj = new stdClass();965 $obj->value = simplexml_load_string('<x><string>abc</string><number>123</number></x>');966 $this->out->writeObject($obj);967 //$this->sendToJamf($this->out->data);968 //file_put_contents(__DIR__ . '/../asset/value/xmlelement.amf3', serialize($this->out->data));969 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/xmlelement.amf3'));970 $this->assertEquals($data, $this->out->data);971 }*/972 /**973 *974 */975 /*public function testwriteAmf3XmlFromEfxphpXmlAndReference()976 {977 $this->out->setAvmPlus(true);978 $obj = new stdClass();979 $xmlobj = new Xml('<x><string>abc</string><number>123</number></x>');980 $obj->value1 = $xmlobj;981 $obj->value2 = $xmlobj;982 $this->out->writeObject($obj);983 //$this->sendToJamf($this->out->data);984 //file_put_contents(__DIR__ . '/../asset/value/xml-and-reference.amf3', serialize($this->out->data));985 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/xml-and-reference.amf3'));986 $this->assertEquals($data, $this->out->data);987 }*/988 /**989 *990 */991 /*public function testwriteAmf3XmlFromSimpleXMLElementAndReference()992 {993 $this->out->setAvmPlus(true);994 $obj = new stdClass();995 $xmlobj = simplexml_load_string('<x><string>abc</string><number>123</number></x>');996 $obj->value1 = $xmlobj;997 $obj->value2 = $xmlobj;998 $this->out->writeObject($obj);999 //$this->sendToJamf($this->out->data);1000 //file_put_contents(__DIR__ . '/../asset/value/xmlelement-and-reference.amf3', serialize($this->out->data));1001 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/xmlelement-and-reference.amf3'));1002 $this->assertEquals($data, $this->out->data);1003 }*/1004 /**1005 *1006 */1007 /*public function testwriteAmf3XmlDocumentFromEfxphpXmlDocument()1008 {1009 $this->out->setAvmPlus(true);1010 $obj = new stdClass();1011 $obj->value = new XmlDocument('<x><string>abc</string><number>123</number></x>');1012 $this->out->writeObject($obj);1013 //$this->sendToJamf($this->out->data);1014 //file_put_contents(__DIR__ . '/../asset/value/xmldocument.amf3', serialize($this->out->data));1015 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/xmldocument.amf3'));1016 $this->assertEquals($data, $this->out->data);1017 }*/1018 /**1019 *1020 */1021 /*public function testwriteAmf3XmlDocumentFromDOMElement()1022 {1023 $this->out->setAvmPlus(true);1024 $obj = new stdClass();1025 $obj->value = dom_import_simplexml(simplexml_load_string('<x><string>abc</string><number>123</number></x>'));1026 $this->out->writeObject($obj);1027 //$this->sendToJamf($this->out->data);1028 //file_put_contents(__DIR__ . '/../asset/value/domelement.amf3', serialize($this->out->data));1029 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/domelement.amf3'));1030 $this->assertEquals($data, $this->out->data);1031 }*/1032 /**1033 *1034 */1035 /*public function testwriteAmf3XmlDocumentFromEfxphpXmlDocumentAndReference()1036 {1037 $this->out->setAvmPlus(true);1038 $obj = new stdClass();1039 $xmlobj = new XmlDocument('<x><string>abc</string><number>123</number></x>');1040 $obj->value1 = $xmlobj;1041 $obj->value2 = $xmlobj;1042 $this->out->writeObject($obj);1043 //$this->sendToJamf($this->out->data);1044 //file_put_contents(__DIR__ . '/../asset/value/xmldocument-and-reference.amf3', serialize($this->out->data));1045 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/xmldocument-and-reference.amf3'));1046 $this->assertEquals($data, $this->out->data);1047 }*/1048 /**1049 *1050 */1051 /*public function testwriteAmf3XmlDocumentFromDOMElementAndReference()1052 {1053 $this->out->setAvmPlus(true);1054 $obj = new stdClass();1055 $xmlobj = dom_import_simplexml(simplexml_load_string('<x><string>abc</string><number>123</number></x>'));1056 $obj->value1 = $xmlobj;1057 $obj->value2 = $xmlobj;1058 $this->out->writeObject($obj);1059 //$this->sendToJamf($this->out->data);1060 //file_put_contents(__DIR__ . '/../asset/value/domelement-and-reference.amf3', serialize($this->out->data));1061 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/domelement-and-reference.amf3'));1062 $this->assertEquals($data, $this->out->data);1063 }*/1064 /**1065 *1066 */1067 public function testwriteAmf3VectorInt()1068 {1069 $this->out->setAvmPlus(true);1070 $obj = new stdClass();1071 $vector = new Vector(Constants::AMF3_VECTOR_INT, array(1, 2, 3));1072 $obj->value = $vector;1073 $this->out->writeObject($obj);1074 //$this->sendToJamf($this->out->data);1075 //file_put_contents(__DIR__ . '/../asset/value/vector-int.amf3', serialize($this->out->data));1076 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/vector-int.amf3'));1077 $this->assertEquals($data, $this->out->data);1078 }1079 /**1080 *1081 */1082 public function testwriteAmf3VectorIntNegative()1083 {1084 $this->out->setAvmPlus(true);1085 $obj = new stdClass();1086 $vector = new Vector(Constants::AMF3_VECTOR_INT, array(-3, -2, -1));1087 $obj->value = $vector;1088 $this->out->writeObject($obj);1089 //$this->sendToJamf($this->out->data);1090 //file_put_contents(__DIR__ . '/../asset/value/vector-int-negative.amf3', serialize($this->out->data));1091 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/vector-int-negative.amf3'));1092 $this->assertEquals($data, $this->out->data);1093 }1094 /**1095 *1096 */1097 public function testwriteAmf3VectorUint()1098 {1099 $this->out->setAvmPlus(true);1100 $obj = new stdClass();1101 $vector = new Vector(Constants::AMF3_VECTOR_UINT, array(2147483647, 2147483648, 4294967295));1102 $obj->value = $vector;1103 $this->out->writeObject($obj);1104 //$this->sendToJamf($this->out->data);1105 //file_put_contents(__DIR__ . '/../asset/value/vector-uint.amf3', serialize($this->out->data));1106 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/vector-uint.amf3'));1107 $this->assertEquals($data, $this->out->data);1108 }1109 /**1110 *1111 */1112 public function testwriteAmf3VectorDouble()1113 {1114 $this->out->setAvmPlus(true);1115 $obj = new stdClass();1116 $vector = new Vector(Constants::AMF3_VECTOR_DOUBLE, array(-31.57, 0, 31.57));1117 $obj->value = $vector;1118 $this->out->writeObject($obj);1119 //$this->sendToJamf($this->out->data);1120 //file_put_contents(__DIR__ . '/../asset/value/vector-double.amf3', serialize($this->out->data));1121 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/vector-double.amf3'));1122 $this->assertEquals($data, $this->out->data);1123 }1124 /**1125 *1126 */1127 public function testwriteAmf3VectorObject()1128 {1129 $this->out->setAvmPlus(true);1130 $v1 = new stdClass();1131 $v1->value = 1;1132 $v2 = new stdClass();1133 $v2->value = 2;1134 $v3 = new stdClass();1135 $v3->value = 3;1136 $obj = new stdClass();1137 $vector = new Vector(Constants::AMF3_VECTOR_OBJECT, array($v1, $v2, $v3));1138 $obj->value = $vector;1139 $this->out->writeObject($obj);1140 //$this->sendToJamf($this->out->data);1141 //file_put_contents(__DIR__ . '/../asset/value/vector-object.amf3', serialize($this->out->data));1142 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/vector-object.amf3'));1143 $this->assertEquals($data, $this->out->data);1144 }1145 /**1146 *1147 */1148 public function testwriteAmf3VectorObjectAndReference()1149 {1150 $this->out->setAvmPlus(true);1151 $v1 = new stdClass();1152 $v1->value = 1;1153 $v2 = new stdClass();1154 $v2->value = 2;1155 $v3 = new stdClass();1156 $v3->value = 3;1157 $obj = new stdClass();1158 $vector = new Vector(Constants::AMF3_VECTOR_OBJECT, array($v1, $v2, $v3));1159 $obj->value1 = $vector;1160 $obj->value2 = $vector;1161 $this->out->writeObject($obj);1162 //$this->sendToJamf($this->out->data);1163 //file_put_contents(__DIR__ . '/../asset/value/vector-object-and-reference.amf3', serialize($this->out->data));1164 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/vector-object-and-reference.amf3'));1165 $this->assertEquals($data, $this->out->data);1166 }1167 /**1168 *1169 */1170 public function testwriteAmf3ComplexObjectGraph()1171 {1172 $this->out->setAvmPlus(true);1173 $obj = new stdClass();1174 $arr = array();1175 $a = new stdClass();1176 $a->name = 'a';1177 $a->parent = null;1178 $a->children = array();1179 $arr[] = $a;1180 $a1 = new stdClass();1181 $a1->name = 'a1';1182 $a1->parent = $a;1183 $a1->children = null;1184 $a->children[] = $a1;1185 $b = new stdClass();1186 $b->name = 'b';1187 $b->parent = null;1188 $b->children = array();1189 $arr[] = $b;1190 $b1 = new stdClass();1191 $b1->name = 'b1';1192 $b1->parent = $b;1193 $b1->children = array();1194 $b->children[] = $b1;1195 $bb1 = new stdClass();1196 $bb1->name = 'bb1';1197 $bb1->parent = $b1;1198 $bb1->children = array();1199 $b1->children[] = $bb1;1200 $obj->value = $arr;1201 $this->out->writeObject($obj);1202 //$this->sendToJamf($this->out->data);1203 //file_put_contents(__DIR__ . '/../asset/value/complex-object-graph.amf3', serialize($this->out->data));1204 $data = unserialize(file_get_contents(__DIR__ . '/../../asset/value/complex-object-graph.amf3'));1205 $this->assertEquals($data, $this->out->data);1206 }1207}...
AbstractOutputTest.php
Source:AbstractOutputTest.php
1<?php2/**3 * efxphp (http://emilmalinov.com/efxphp)4 *5 * @copyright Copyright (c) 2015 Emil Malinov6 * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.07 * @link http://github.com/emilkm/efxphp8 * @package efxphp9 */10namespace emilkm\tests\efxphp\Amf;11use emilkm\tests\util\AccessPropertyTrait;12use emilkm\efxphp\Amf\Constants;13/**14 * @author Emil Malinov15 * @package efxphp16 * @subpackage tests17 */18class AbstractOutputTest extends \PHPUnit_Framework_TestCase19{20 use AccessPropertyTrait;21 protected $out;22 protected $request;23 protected function setUp()24 {25 $this->out = new BaseOutput();26 $this->request = file_get_contents(__DIR__ . '/../../asset/request/pingCommandMessageWithPacketHeaders.amf');27 }28 /**29 *30 */31 public function testavmPlusDefaultIsFalse()32 {33 $this->assertEquals(false, $this->getPropertyValue($this->out, 'avmPlus'));34 }35 /**36 *37 */38 public function testsetAvmPlusToTrue()39 {40 $this->out->setAvmPlus(true);41 $this->assertEquals(true, $this->getPropertyValue($this->out, 'avmPlus'));42 }43 /**44 *45 */46 public function testamf3nsndArrayAsObjectDefaultIsFalse()47 {48 $this->assertEquals(false, $this->getPropertyValue($this->out, 'amf3nsndArrayAsObject'));49 }50 /**51 *52 */53 public function testsetAmf3nsndArrayAsObjectToTrue()54 {55 $this->out->encodeAmf3nsndArrayAsObject(true);56 $this->assertEquals(true, $this->getPropertyValue($this->out, 'amf3nsndArrayAsObject'));57 }58 /**59 *60 */61 public function testwriteByte()62 {63 $this->out->writeByte(10);64 $this->assertEquals("\n", $this->out->data);65 }66 /**67 *68 */69 public function testwriteBoolean()70 {71 $this->out->writeBoolean(false);72 $this->assertEquals("\x0", $this->out->data);73 $this->out->data = null;74 $this->out->writeBoolean(true);75 $this->assertEquals("\x1", $this->out->data);76 }77 /**78 *79 */80 public function testwriteShort()81 {82 $this->out->writeShort(3);83 $this->assertEquals("\x0\x3", $this->out->data);84 }85 /**86 *87 */88 public function testwriteInt()89 {90 $this->out->writeInt(1);91 $this->assertEquals("\x0\x0\x0\x1", $this->out->data);92 }93 /**94 *95 */96 public function testwriteDouble()97 {98 $this->out->writeDouble(31.57);99 //$this->assertEquals("@?âëâ¦\x1E¸R", $this->out->data);100 }101 /**102 *103 */104 public function testwriteUtf()105 {106 $this->out->writeUtf('abc');107 //$this->assertEquals("\x0\x3abc", $this->out->data);108 }109 /**110 *111 */112 public function testwriteLongUtf()113 {114 }115}...
testWrite
Using AI Code Generation
1require 'out.php';2$out = new out();3$out->testWrite();4require 'out.php';5$out = new out();6$out->testWrite();7require 'out.php';8$out = new out();9$out->testWrite();10require 'out.php';11$out = new out();12$out->testWrite();13require 'out.php';14$out = new out();15$out->testWrite();16require 'out.php';17$out = new out();18$out->testWrite();19require 'out.php';20$out = new out();21$out->testWrite();22require 'out.php';23$out = new out();24$out->testWrite();25require 'out.php';26$out = new out();27$out->testWrite();28require 'out.php';29$out = new out();30$out->testWrite();31require 'out.php';32$out = new out();33$out->testWrite();34require 'out.php';35$out = new out();36$out->testWrite();37require 'out.php';38$out = new out();39$out->testWrite();40require 'out.php';41$out = new out();42$out->testWrite();43require 'out.php';44$out = new out();45$out->testWrite();
testWrite
Using AI Code Generation
1require_once('out.php');2$obj = new out();3$obj->testWrite('1.php');4require_once('out.php');5$obj = new out();6$obj->testWrite('2.php');7class out {8 public function testWrite($file) {9 $fp = fopen($file, 'w');10 fwrite($fp, 'Hello World!');11 fclose($fp);12 }13}14Fatal error: Can't inherit abstract function out::testWrite() (previously declared abstract in out in /home/username/public_html/2.php on line 315require_once('out.php');16$obj = new out();17$obj->testWrite('1.php');18require_once('out.php');19$obj = new out();20$obj->testWrite('2.php');21class out {22 public function testWrite($file) {23 $fp = fopen($file, 'w');24 fwrite($fp, 'Hello World!');25 fclose($fp);26 }27}
testWrite
Using AI Code Generation
1$out = new out;2$out->testWrite();3$out = new out;4$out->testWrite();5$out = new out;6$out->testWrite();7$out = new out;8$out->testWrite();9$out = new out;10$out->testWrite();11$out = new out;12$out->testWrite();13$out = new out;14$out->testWrite();15$out = new out;16$out->testWrite();17$out = new out;18$out->testWrite();19$out = new out;20$out->testWrite();21$out = new out;22$out->testWrite();23$out = new out;24$out->testWrite();25$out = new out;26$out->testWrite();27$out = new out;28$out->testWrite();
testWrite
Using AI Code Generation
1require_once "out.php";2$obj = new out();3$obj->testWrite("Hello World");4require_once "out.php";5$obj = new out();6$obj->testRead();7require_once "out.php";8$obj = new out();9$obj->testDelete();10require_once "out.php";11$obj = new out();12$obj->testAppend("Hello World");13require_once "out.php";14$obj = new out();15$obj->testCopy("5.php", "6.php");16require_once "out.php";17$obj = new out();18$obj->testRename("6.php", "7.php");19require_once "out.php";20$obj = new out();21$obj->testMove("7.php", "8.php");
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Execute automation tests with testWrite on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.
Test now for FreeGet 100 minutes of automation test minutes FREE!!