How to use getContent method of has class

Best VfsStream code snippet using has.getContent

BaseSerializationTest.php

Source:BaseSerializationTest.php Github

copy

Full Screen

...125 public function testSerializeNullArray()126 {127 $arr = array('foo' => 'bar', 'baz' => null, null);128 $this->assertEquals(129 $this->getContent('nullable'),130 $this->serializer->serialize($arr, $this->getFormat(), SerializationContext::create()->setSerializeNull(true))131 );132 }133 public function testSerializeNullArrayExcludingNulls()134 {135 $arr = array('foo' => 'bar', 'baz' => null, null);136 $this->assertEquals(137 $this->getContent('nullable_skip'),138 $this->serializer->serialize($arr, $this->getFormat(), SerializationContext::create()->setSerializeNull(false))139 );140 }141 public function testObjectUsingTypeCasting()142 {143 $typeAliasing = new ObjectUsingTypeCasting();144 $typeAliasing->asString = new ObjectWithToString("8");145 $this->assertEquals(146 $this->getContent('type_casting'),147 $this->serialize($typeAliasing)148 );149 }150 public function testSerializeNullObject()151 {152 $obj = new ObjectWithNullProperty('foo', 'bar');153 $this->assertEquals(154 $this->getContent('simple_object_nullable'),155 $this->serializer->serialize($obj, $this->getFormat(), SerializationContext::create()->setSerializeNull(true))156 );157 }158 public function testDeserializeNullObject()159 {160 if (!$this->hasDeserializer()) {161 $this->markTestSkipped(sprintf('No deserializer available for format `%s`', $this->getFormat()));162 }163 $obj = new ObjectWithNullProperty('foo', 'bar');164 /** @var ObjectWithNullProperty $dObj */165 $dObj = $this->serializer->deserialize(166 $this->getContent('simple_object_nullable'),167 ObjectWithNullProperty::class,168 $this->getFormat()169 );170 $this->assertEquals($obj, $dObj);171 $this->assertNull($dObj->getNullProperty());172 }173 /**174 * @dataProvider getTypes175 */176 public function testNull($type)177 {178 $this->assertEquals($this->getContent('null'), $this->serialize(null), $type);179 if ($this->hasDeserializer()) {180 $this->assertEquals(null, $this->deserialize($this->getContent('null'), $type));181 }182 }183 public function getTypes()184 {185 return array(186 array('NULL'),187 array('integer'),188 array('double'),189 array('float'),190 array('string'),191 array('DateTime'),192 );193 }194 public function testString()195 {196 $this->assertEquals($this->getContent('string'), $this->serialize('foo'));197 if ($this->hasDeserializer()) {198 $this->assertEquals('foo', $this->deserialize($this->getContent('string'), 'string'));199 }200 }201 /**202 * @expectedException \JMS\Serializer\Exception\ExpressionLanguageRequiredException203 * @expectedExceptionMessage To use conditional exclude/expose in JMS\Serializer\Tests\Fixtures\PersonSecret you must configure the expression language.204 */205 public function testExpressionExclusionNotConfigured()206 {207 $person = new PersonSecret();208 $person->gender = 'f';209 $person->name = 'mike';210 $this->serialize($person);211 }212 public function testExpressionExclusionConfiguredWithDisjunctStrategy()213 {214 $person = new PersonSecret();215 $person->gender = 'f';216 $person->name = 'mike';217 $language = new ExpressionLanguage();218 $language->addFunction(new ExpressionFunction('show_data', function () {219 return "true";220 }, function () {221 return true;222 }));223 $serializer = new Serializer($this->factory, $this->handlerRegistry, $this->objectConstructor, $this->serializationVisitors, $this->deserializationVisitors, $this->dispatcher, null, new ExpressionEvaluator($language));224 $this->assertEquals($this->getContent('person_secret_hide'), $serializer->serialize($person, $this->getFormat()));225 }226 public function expressionFunctionProvider()227 {228 $person = new PersonSecret();229 $person->gender = 'f';230 $person->name = 'mike';231 $personMoreSecret = new PersonSecretMore();232 $personMoreSecret->gender = 'f';233 $personMoreSecret->name = 'mike';234 $personVirtual = new PersonSecretVirtual();235 $personVirtual->gender = 'f';236 $personVirtual->name = 'mike';237 $personMoreSecretVirtual = new PersonSecretMoreVirtual();238 $personMoreSecretVirtual->gender = 'f';239 $personMoreSecretVirtual->name = 'mike';240 $showGender = new ExpressionFunction('show_data', function () {241 return "true";242 }, function () {243 return true;244 });245 $hideGender = new ExpressionFunction('show_data', function () {246 return "false";247 }, function () {248 return false;249 });250 return [251 [252 $person,253 $showGender,254 'person_secret_hide'255 ],256 [257 $person,258 $hideGender,259 'person_secret_show'260 ],261 [262 $personMoreSecret,263 $showGender,264 'person_secret_show'265 ],266 [267 $personMoreSecret,268 $hideGender,269 'person_secret_hide'270 ],271 [272 $personVirtual,273 $showGender,274 'person_secret_hide'275 ],276 [277 $personVirtual,278 $hideGender,279 'person_secret_show'280 ],281 [282 $personMoreSecretVirtual,283 $showGender,284 'person_secret_show'285 ],286 [287 $personMoreSecretVirtual,288 $hideGender,289 'person_secret_hide'290 ]291 ];292 }293 /**294 * @dataProvider expressionFunctionProvider295 * @param PersonSecret|PersonSecretMore $person296 * @param ExpressionFunction $function297 * @param $json298 */299 public function testExpressionExclusion($person, ExpressionFunction $function, $json)300 {301 $language = new ExpressionLanguage();302 $language->addFunction($function);303 $serializer = new Serializer($this->factory, $this->handlerRegistry, $this->objectConstructor, $this->serializationVisitors, $this->deserializationVisitors, $this->dispatcher, null, new ExpressionEvaluator($language));304 $this->assertEquals($this->getContent($json), $serializer->serialize($person, $this->getFormat()));305 }306 /**307 * @dataProvider getBooleans308 */309 public function testBooleans($strBoolean, $boolean)310 {311 $this->assertEquals($this->getContent('boolean_' . $strBoolean), $this->serialize($boolean));312 if ($this->hasDeserializer()) {313 $this->assertSame($boolean, $this->deserialize($this->getContent('boolean_' . $strBoolean), 'boolean'));314 }315 }316 public function getBooleans()317 {318 return array(array('true', true), array('false', false));319 }320 /**321 * @dataProvider getNumerics322 */323 public function testNumerics($key, $value, $type)324 {325 $this->assertEquals($this->getContent($key), $this->serialize($value));326 if ($this->hasDeserializer()) {327 $this->assertEquals($value, $this->deserialize($this->getContent($key), $type));328 }329 }330 public function getNumerics()331 {332 return array(333 array('integer', 1, 'integer'),334 array('float', 4.533, 'double'),335 array('float', 4.533, 'float'),336 array('float_trailing_zero', 1.0, 'double'),337 array('float_trailing_zero', 1.0, 'float'),338 );339 }340 public function testSimpleInternalObject()341 {342 $this->factory = new MetadataFactory(new YamlDriver(new FileLocator([343 'JMS\Serializer\Tests\Fixtures' => __DIR__ .'/metadata/SimpleInternalObject',344 '' => __DIR__ .'/metadata/SimpleInternalObject'345 ])));346 $this->serializer = new Serializer($this->factory, $this->handlerRegistry, $this->objectConstructor, $this->serializationVisitors, $this->deserializationVisitors, $this->dispatcher);347 $obj = new SimpleInternalObject('foo', 'bar');348 $this->assertEquals($this->getContent('simple_object'), $this->serialize($obj));349 if ($this->hasDeserializer()) {350 $deserialized = $this->deserialize($this->getContent('simple_object'), get_class($obj));351 $this->assertEquals(get_class($obj), get_class($deserialized));352 }353 }354 public function testSimpleObjectStaticProp()355 {356 $this->assertEquals($this->getContent('simple_object'), $this->serialize($obj = new SimpleObjectWithStaticProp('foo', 'bar')));357 if ($this->hasDeserializer()) {358 $this->assertEquals($obj, $this->deserialize($this->getContent('simple_object'), get_class($obj)));359 }360 }361 public function testSimpleObject()362 {363 $this->assertEquals($this->getContent('simple_object'), $this->serialize($obj = new SimpleObject('foo', 'bar')));364 if ($this->hasDeserializer()) {365 $this->assertEquals($obj, $this->deserialize($this->getContent('simple_object'), get_class($obj)));366 }367 }368 public function testArrayStrings()369 {370 $data = array('foo', 'bar');371 $this->assertEquals($this->getContent('array_strings'), $this->serialize($data));372 if ($this->hasDeserializer()) {373 $this->assertEquals($data, $this->deserialize($this->getContent('array_strings'), 'array<string>'));374 }375 }376 public function testArrayBooleans()377 {378 $data = array(true, false);379 $this->assertEquals($this->getContent('array_booleans'), $this->serialize($data));380 if ($this->hasDeserializer()) {381 $this->assertEquals($data, $this->deserialize($this->getContent('array_booleans'), 'array<boolean>'));382 }383 }384 public function testArrayIntegers()385 {386 $data = array(1, 3, 4);387 $this->assertEquals($this->getContent('array_integers'), $this->serialize($data));388 if ($this->hasDeserializer()) {389 $this->assertEquals($data, $this->deserialize($this->getContent('array_integers'), 'array<integer>'));390 }391 }392 public function testArrayEmpty()393 {394 if ('xml' === $this->getFormat()) {395 $this->markTestSkipped('XML can\'t be tested for empty array');396 }397 $data = array('array' => []);398 $this->assertEquals($this->getContent('array_empty'), $this->serialize($data));399 if ($this->hasDeserializer()) {400 $this->assertEquals($data, $this->deserialize($this->getContent('array_empty'), 'array'));401 }402 }403 public function testArrayFloats()404 {405 $data = array(1.34, 3.0, 6.42);406 $this->assertEquals($this->getContent('array_floats'), $this->serialize($data));407 if ($this->hasDeserializer()) {408 $this->assertEquals($data, $this->deserialize($this->getContent('array_floats'), 'array<double>'));409 }410 }411 public function testArrayObjects()412 {413 $data = array(new SimpleObject('foo', 'bar'), new SimpleObject('baz', 'boo'));414 $this->assertEquals($this->getContent('array_objects'), $this->serialize($data));415 if ($this->hasDeserializer()) {416 $this->assertEquals($data, $this->deserialize($this->getContent('array_objects'), 'array<JMS\Serializer\Tests\Fixtures\SimpleObject>'));417 }418 }419 public function testArrayListAndMapDifference()420 {421 $arrayData = array(0 => 1, 2 => 2, 3 => 3); // Misses key 1422 $data = new ObjectWithIntListAndIntMap($arrayData, $arrayData);423 $this->assertEquals($this->getContent('array_list_and_map_difference'), $this->serialize($data));424 }425 public function testDateTimeArrays()426 {427 $data = array(428 new \DateTime('2047-01-01 12:47:47', new \DateTimeZone('UTC')),429 new \DateTime('2016-12-05 00:00:00', new \DateTimeZone('UTC'))430 );431 $object = new DateTimeArraysObject($data, $data);432 $serializedObject = $this->serialize($object);433 $this->assertEquals($this->getContent('array_datetimes_object'), $serializedObject);434 if ($this->hasDeserializer()) {435 /** @var DateTimeArraysObject $deserializedObject */436 $deserializedObject = $this->deserialize($this->getContent('array_datetimes_object'), 'Jms\Serializer\Tests\Fixtures\DateTimeArraysObject');437 /** deserialized object has a default timezone set depending on user's timezone settings. That's why we manually set the UTC timezone on the DateTime objects. */438 foreach ($deserializedObject->getArrayWithDefaultDateTime() as $dateTime) {439 $dateTime->setTimezone(new \DateTimeZone('UTC'));440 }441 foreach ($deserializedObject->getArrayWithFormattedDateTime() as $dateTime) {442 $dateTime->setTimezone(new \DateTimeZone('UTC'));443 }444 $this->assertEquals($object, $deserializedObject);445 }446 }447 public function testNamedDateTimeArrays()448 {449 $data = array(450 new \DateTime('2047-01-01 12:47:47', new \DateTimeZone('UTC')),451 new \DateTime('2016-12-05 00:00:00', new \DateTimeZone('UTC'))452 );453 $object = new NamedDateTimeArraysObject(array('testdate1' => $data[0], 'testdate2' => $data[1]));454 $serializedObject = $this->serialize($object);455 $this->assertEquals($this->getContent('array_named_datetimes_object'), $serializedObject);456 if ($this->hasDeserializer()) {457 // skip XML deserialization458 if ($this->getFormat() === 'xml') {459 return;460 }461 /** @var NamedDateTimeArraysObject $deserializedObject */462 $deserializedObject = $this->deserialize($this->getContent('array_named_datetimes_object'), 'Jms\Serializer\Tests\Fixtures\NamedDateTimeArraysObject');463 /** deserialized object has a default timezone set depending on user's timezone settings. That's why we manually set the UTC timezone on the DateTime objects. */464 foreach ($deserializedObject->getNamedArrayWithFormattedDate() as $dateTime) {465 $dateTime->setTimezone(new \DateTimeZone('UTC'));466 }467 $this->assertEquals($object, $deserializedObject);468 }469 }470 /**471 * @group datetime472 */473 public function testNamedDateTimeImmutableArrays()474 {475 $data = array(476 new \DateTimeImmutable('2047-01-01 12:47:47', new \DateTimeZone('UTC')),477 new \DateTimeImmutable('2016-12-05 00:00:00', new \DateTimeZone('UTC'))478 );479 $object = new NamedDateTimeImmutableArraysObject(array('testdate1' => $data[0], 'testdate2' => $data[1]));480 $serializedObject = $this->serialize($object);481 $this->assertEquals($this->getContent('array_named_datetimeimmutables_object'), $serializedObject);482 if ($this->hasDeserializer()) {483 if ('xml' == $this->getFormat()) {484 $this->markTestSkipped("XML deserialization does not support key-val pairs mode");485 }486 /** @var NamedDateTimeArraysObject $deserializedObject */487 $deserializedObject = $this->deserialize($this->getContent('array_named_datetimeimmutables_object'), 'Jms\Serializer\Tests\Fixtures\NamedDateTimeImmutableArraysObject');488 /** deserialized object has a default timezone set depending on user's timezone settings. That's why we manually set the UTC timezone on the DateTime objects. */489 foreach ($deserializedObject->getNamedArrayWithFormattedDate() as $dateTime) {490 $dateTime->setTimezone(new \DateTimeZone('UTC'));491 }492 $this->assertEquals($object, $deserializedObject);493 }494 }495 public function testArrayMixed()496 {497 $this->assertEquals($this->getContent('array_mixed'), $this->serialize(array('foo', 1, true, new SimpleObject('foo', 'bar'), array(1, 3, true))));498 }499 /**500 * @dataProvider getDateTime501 * @group datetime502 */503 public function testDateTime($key, $value, $type)504 {505 $this->assertEquals($this->getContent($key), $this->serialize($value));506 if ($this->hasDeserializer()) {507 $deserialized = $this->deserialize($this->getContent($key), $type);508 $this->assertTrue(is_object($deserialized));509 $this->assertEquals(get_class($value), get_class($deserialized));510 $this->assertEquals($value->getTimestamp(), $deserialized->getTimestamp());511 }512 }513 public function getDateTime()514 {515 return array(516 array('date_time', new \DateTime('2011-08-30 00:00', new \DateTimeZone('UTC')), 'DateTime'),517 );518 }519 /**520 * @dataProvider getDateTimeImmutable521 * @group datetime522 */523 public function testDateTimeImmutable($key, $value, $type)524 {525 $this->assertEquals($this->getContent($key), $this->serialize($value));526 if ($this->hasDeserializer()) {527 $deserialized = $this->deserialize($this->getContent($key), $type);528 $this->assertTrue(is_object($deserialized));529 $this->assertEquals(get_class($value), get_class($deserialized));530 $this->assertEquals($value->getTimestamp(), $deserialized->getTimestamp());531 }532 }533 public function getDateTimeImmutable()534 {535 return array(536 array('date_time_immutable', new \DateTimeImmutable('2011-08-30 00:00', new \DateTimeZone('UTC')), 'DateTimeImmutable'),537 );538 }539 public function testTimestamp()540 {541 $value = new Timestamp(new \DateTime('2016-02-11 00:00:00', new \DateTimeZone('UTC')));542 $this->assertEquals($this->getContent('timestamp'), $this->serialize($value));543 if ($this->hasDeserializer()) {544 $deserialized = $this->deserialize($this->getContent('timestamp'), Timestamp::class);545 $this->assertEquals($value, $deserialized);546 $this->assertEquals($value->getTimestamp()->getTimestamp(), $deserialized->getTimestamp()->getTimestamp());547 $deserialized = $this->deserialize($this->getContent('timestamp_prev'), Timestamp::class);548 $this->assertEquals($value, $deserialized);549 $this->assertEquals($value->getTimestamp()->getTimestamp(), $deserialized->getTimestamp()->getTimestamp());550 }551 }552 public function testDateInterval()553 {554 $duration = new \DateInterval('PT45M');555 $this->assertEquals($this->getContent('date_interval'), $this->serializer->serialize($duration, $this->getFormat()));556 if ($this->hasDeserializer()) {557 $deserialized = $this->deserialize($this->getContent('date_interval'), \DateInterval::class);558 $this->assertEquals($duration, $deserialized);559 $this->assertEquals($duration->i, $deserialized->i);560 }561 }562 public function testBlogPost()563 {564 $post = new BlogPost('This is a nice title.', $author = new Author('Foo Bar'), new \DateTime('2011-07-30 00:00', new \DateTimeZone('UTC')), new Publisher('Bar Foo'));565 $post->addComment($comment = new Comment($author, 'foo'));566 $post->addTag($tag1 = New Tag("tag1"));567 $post->addTag($tag2 = New Tag("tag2"));568 $this->assertEquals($this->getContent('blog_post'), $this->serialize($post));569 if ($this->hasDeserializer()) {570 $deserialized = $this->deserialize($this->getContent('blog_post'), get_class($post));571 $this->assertEquals('2011-07-30T00:00:00+0000', $this->getField($deserialized, 'createdAt')->format(\DateTime::ISO8601));572 $this->assertAttributeEquals('This is a nice title.', 'title', $deserialized);573 $this->assertAttributeSame(false, 'published', $deserialized);574 $this->assertAttributeSame(false, 'reviewed', $deserialized);575 $this->assertAttributeSame('1edf9bf60a32d89afbb85b2be849e3ceed5f5b10', 'etag', $deserialized);576 $this->assertAttributeEquals(new ArrayCollection(array($comment)), 'comments', $deserialized);577 $this->assertAttributeEquals(new Sequence(array($comment)), 'comments2', $deserialized);578 $this->assertAttributeEquals($author, 'author', $deserialized);579 $this->assertAttributeEquals(array($tag1, $tag2), 'tag', $deserialized);580 }581 }582 public function testDeserializingNull()583 {584 $objectConstructor = new InitializedBlogPostConstructor();585 $this->serializer = new Serializer($this->factory, $this->handlerRegistry, $objectConstructor, $this->serializationVisitors, $this->deserializationVisitors, $this->dispatcher);586 $post = new BlogPost('This is a nice title.', $author = new Author('Foo Bar'), new \DateTime('2011-07-30 00:00', new \DateTimeZone('UTC')), new Publisher('Bar Foo'));587 $this->setField($post, 'author', null);588 $this->setField($post, 'publisher', null);589 $this->assertEquals($this->getContent('blog_post_unauthored'), $this->serialize($post, SerializationContext::create()->setSerializeNull(true)));590 if ($this->hasDeserializer()) {591 $deserialized = $this->deserialize($this->getContent('blog_post_unauthored'), get_class($post), DeserializationContext::create()->setSerializeNull(true));592 $this->assertEquals('2011-07-30T00:00:00+0000', $this->getField($deserialized, 'createdAt')->format(\DateTime::ISO8601));593 $this->assertAttributeEquals('This is a nice title.', 'title', $deserialized);594 $this->assertAttributeSame(false, 'published', $deserialized);595 $this->assertAttributeSame(false, 'reviewed', $deserialized);596 $this->assertAttributeEquals(new ArrayCollection(), 'comments', $deserialized);597 $this->assertEquals(null, $this->getField($deserialized, 'author'));598 }599 }600 public function testExpressionAuthor()601 {602 $namingStrategy = new SerializedNameAnnotationStrategy(new CamelCaseNamingStrategy());603 $evaluator = new ExpressionEvaluator(new ExpressionLanguage());604 $accessor = new ExpressionAccessorStrategy($evaluator, new DefaultAccessorStrategy());605 $this->serializationVisitors = new Map(array(606 'json' => new JsonSerializationVisitor($namingStrategy, $accessor),607 'xml' => new XmlSerializationVisitor($namingStrategy, $accessor),608 'yml' => new YamlSerializationVisitor($namingStrategy, $accessor),609 ));610 $serializer = new Serializer($this->factory, $this->handlerRegistry, $this->objectConstructor, $this->serializationVisitors, $this->deserializationVisitors, $this->dispatcher, null, $evaluator);611 $author = new AuthorExpressionAccess(123, "Ruud", "Kamphuis");612 $this->assertEquals($this->getContent('author_expression'), $serializer->serialize($author, $this->getFormat()));613 }614 /**615 * @expectedException \JMS\Serializer\Exception\ExpressionLanguageRequiredException616 * @expectedExceptionMessage The property firstName on JMS\Serializer\Tests\Fixtures\AuthorExpressionAccess requires the expression accessor strategy to be enabled.617 */618 public function testExpressionAccessorStrategNotEnabled()619 {620 $author = new AuthorExpressionAccess(123, "Ruud", "Kamphuis");621 $this->assertEquals($this->getContent('author_expression'), $this->serialize($author));622 }623 public function testReadOnly()624 {625 $author = new AuthorReadOnly(123, 'Ruud Kamphuis');626 $this->assertEquals($this->getContent('readonly'), $this->serialize($author));627 if ($this->hasDeserializer()) {628 $deserialized = $this->deserialize($this->getContent('readonly'), get_class($author));629 $this->assertNull($this->getField($deserialized, 'id'));630 $this->assertEquals('Ruud Kamphuis', $this->getField($deserialized, 'name'));631 }632 }633 public function testReadOnlyClass()634 {635 $author = new AuthorReadOnlyPerClass(123, 'Ruud Kamphuis');636 $this->assertEquals($this->getContent('readonly'), $this->serialize($author));637 if ($this->hasDeserializer()) {638 $deserialized = $this->deserialize($this->getContent('readonly'), get_class($author));639 $this->assertNull($this->getField($deserialized, 'id'));640 $this->assertEquals('Ruud Kamphuis', $this->getField($deserialized, 'name'));641 }642 }643 public function testPrice()644 {645 $price = new Price(3);646 $this->assertEquals($this->getContent('price'), $this->serialize($price));647 if ($this->hasDeserializer()) {648 $deserialized = $this->deserialize($this->getContent('price'), get_class($price));649 $this->assertEquals(3, $this->getField($deserialized, 'price'));650 }651 }652 public function testOrder()653 {654 $order = new Order(new Price(12.34));655 $this->assertEquals($this->getContent('order'), $this->serialize($order));656 if ($this->hasDeserializer()) {657 $this->assertEquals($order, $this->deserialize($this->getContent('order'), get_class($order)));658 }659 }660 public function testCurrencyAwarePrice()661 {662 $price = new CurrencyAwarePrice(2.34);663 $this->assertEquals($this->getContent('currency_aware_price'), $this->serialize($price));664 if ($this->hasDeserializer()) {665 $this->assertEquals($price, $this->deserialize($this->getContent('currency_aware_price'), get_class($price)));666 }667 }668 public function testOrderWithCurrencyAwarePrice()669 {670 $order = new CurrencyAwareOrder(new CurrencyAwarePrice(1.23));671 $this->assertEquals($this->getContent('order_with_currency_aware_price'), $this->serialize($order));672 if ($this->hasDeserializer()) {673 $this->assertEquals($order, $this->deserialize($this->getContent('order_with_currency_aware_price'), get_class($order)));674 }675 }676 /**677 * @group handlerCallback678 */679 public function testArticle()680 {681 $article = new Article();682 $article->element = 'custom';683 $article->value = 'serialized';684 $result = $this->serialize($article);685 $this->assertEquals($this->getContent('article'), $result);686 if ($this->hasDeserializer()) {687 $this->assertEquals($article, $this->deserialize($result, 'JMS\Serializer\Tests\Fixtures\Article'));688 }689 }690 public function testInline()691 {692 $inline = new InlineParent();693 $result = $this->serialize($inline);694 $this->assertEquals($this->getContent('inline'), $result);695 // no deserialization support696 }697 public function testInlineEmptyChild()698 {699 $inline = new InlineParent(new InlineChildEmpty());700 $result = $this->serialize($inline);701 $this->assertEquals($this->getContent('inline_child_empty'), $result);702 // no deserialization support703 }704 public function testEmptyChild()705 {706 // by empty object707 $inline = new ParentDoNotSkipWithEmptyChild(new InlineChildEmpty());708 $this->assertEquals($this->getContent('empty_child'), $this->serialize($inline));709 // by nulls710 $inner = new InlineChild();711 $inner->a = null;712 $inner->b = null;713 $inline = new ParentDoNotSkipWithEmptyChild($inner);714 $this->assertEquals($this->getContent('empty_child'), $this->serialize($inline));715 // by exclusion strategy716 $context = SerializationContext::create()->setGroups(['Default']);717 $inline = new ParentDoNotSkipWithEmptyChild(new InlineChildWithGroups());718 $this->assertEquals($this->getContent('empty_child'), $this->serialize($inline, $context));719 }720 public function testSkipEmptyChild()721 {722 // by empty object723 $inline = new ParentSkipWithEmptyChild(new InlineChildEmpty());724 $this->assertEquals($this->getContent('empty_child_skip'), $this->serialize($inline));725 // by nulls726 $inner = new InlineChild();727 $inner->a = null;728 $inner->b = null;729 $inline = new ParentSkipWithEmptyChild($inner);730 $this->assertEquals($this->getContent('empty_child_skip'), $this->serialize($inline));731 // by exclusion strategy732 $context = SerializationContext::create()->setGroups(['Default']);733 $inline = new ParentSkipWithEmptyChild(new InlineChildWithGroups());734 $this->assertEquals($this->getContent('empty_child_skip'), $this->serialize($inline, $context));735 }736 /**737 * @group log738 */739 public function testLog()740 {741 $this->assertEquals($this->getContent('log'), $this->serialize($log = new Log()));742 if ($this->hasDeserializer()) {743 $deserialized = $this->deserialize($this->getContent('log'), get_class($log));744 $this->assertEquals($log, $deserialized);745 }746 }747 public function testCircularReference()748 {749 $object = new CircularReferenceParent();750 $this->assertEquals($this->getContent('circular_reference'), $this->serialize($object));751 if ($this->hasDeserializer()) {752 $deserialized = $this->deserialize($this->getContent('circular_reference'), get_class($object));753 $col = $this->getField($deserialized, 'collection');754 $this->assertEquals(2, count($col));755 $this->assertEquals('child1', $col[0]->getName());756 $this->assertEquals('child2', $col[1]->getName());757 $this->assertSame($deserialized, $col[0]->getParent());758 $this->assertSame($deserialized, $col[1]->getParent());759 $col = $this->getField($deserialized, 'anotherCollection');760 $this->assertEquals(2, count($col));761 $this->assertEquals('child1', $col[0]->getName());762 $this->assertEquals('child2', $col[1]->getName());763 $this->assertSame($deserialized, $col[0]->getParent());764 $this->assertSame($deserialized, $col[1]->getParent());765 }766 }767 public function testLifecycleCallbacks()768 {769 $object = new ObjectWithLifecycleCallbacks();770 $this->assertEquals($this->getContent('lifecycle_callbacks'), $this->serialize($object));771 $this->assertAttributeSame(null, 'name', $object);772 if ($this->hasDeserializer()) {773 $deserialized = $this->deserialize($this->getContent('lifecycle_callbacks'), get_class($object));774 $this->assertEquals($object, $deserialized);775 }776 }777 public function testFormErrors()778 {779 $errors = array(780 new FormError('This is the form error'),781 new FormError('Another error')782 );783 $this->assertEquals($this->getContent('form_errors'), $this->serialize($errors));784 }785 public function testNestedFormErrors()786 {787 $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock();788 $formConfigBuilder = new \Symfony\Component\Form\FormConfigBuilder('foo', null, $dispatcher);789 $formConfigBuilder->setCompound(true);790 $formConfigBuilder->setDataMapper($this->getMockBuilder('Symfony\Component\Form\DataMapperInterface')->getMock());791 $fooConfig = $formConfigBuilder->getFormConfig();792 $form = new Form($fooConfig);793 $form->addError(new FormError('This is the form error'));794 $formConfigBuilder = new \Symfony\Component\Form\FormConfigBuilder('bar', null, $dispatcher);795 $barConfig = $formConfigBuilder->getFormConfig();796 $child = new Form($barConfig);797 $child->addError(new FormError('Error of the child form'));798 $form->add($child);799 $this->assertEquals($this->getContent('nested_form_errors'), $this->serialize($form));800 }801 public function testFormErrorsWithNonFormComponents()802 {803 if (!class_exists('Symfony\Component\Form\Extension\Core\Type\SubmitType')) {804 $this->markTestSkipped('Not using Symfony Form >= 2.3 with submit type');805 }806 $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock();807 $factoryBuilder = new FormFactoryBuilder();808 $factoryBuilder->addType(new \Symfony\Component\Form\Extension\Core\Type\SubmitType);809 $factoryBuilder->addType(new \Symfony\Component\Form\Extension\Core\Type\ButtonType);810 $factory = $factoryBuilder->getFormFactory();811 $formConfigBuilder = new \Symfony\Component\Form\FormConfigBuilder('foo', null, $dispatcher);812 $formConfigBuilder->setFormFactory($factory);813 $formConfigBuilder->setCompound(true);814 $formConfigBuilder->setDataMapper($this->getMockBuilder('Symfony\Component\Form\DataMapperInterface')->getMock());815 $fooConfig = $formConfigBuilder->getFormConfig();816 $form = new Form($fooConfig);817 $form->add('save', \Symfony\Component\Form\Extension\Core\Type\SubmitType::class);818 try {819 $this->serialize($form);820 } catch (\Exception $e) {821 $this->assertTrue(false, 'Serialization should not throw an exception');822 }823 }824 public function testConstraintViolation()825 {826 $violation = new ConstraintViolation('Message of violation', 'Message of violation', array(), null, 'foo', null);827 $this->assertEquals($this->getContent('constraint_violation'), $this->serialize($violation));828 }829 public function testConstraintViolationList()830 {831 $violations = new ConstraintViolationList();832 $violations->add(new ConstraintViolation('Message of violation', 'Message of violation', array(), null, 'foo', null));833 $violations->add(new ConstraintViolation('Message of another violation', 'Message of another violation', array(), null, 'bar', null));834 $this->assertEquals($this->getContent('constraint_violation_list'), $this->serialize($violations));835 }836 public function testDoctrineProxy()837 {838 if (!class_exists('Doctrine\ORM\Version')) {839 $this->markTestSkipped('Doctrine is not available.');840 }841 $object = new SimpleObjectProxy('foo', 'bar');842 $this->assertEquals($this->getContent('orm_proxy'), $this->serialize($object));843 }844 public function testInitializedDoctrineProxy()845 {846 if (!class_exists('Doctrine\ORM\Version')) {847 $this->markTestSkipped('Doctrine is not available.');848 }849 $object = new SimpleObjectProxy('foo', 'bar');850 $object->__load();851 $this->assertEquals($this->getContent('orm_proxy'), $this->serialize($object));852 }853 public function testCustomAccessor()854 {855 $post = new IndexedCommentsBlogPost();856 $this->assertEquals($this->getContent('custom_accessor'), $this->serialize($post));857 }858 public function testMixedAccessTypes()859 {860 $object = new GetSetObject();861 $this->assertEquals($this->getContent('mixed_access_types'), $this->serialize($object));862 if ($this->hasDeserializer()) {863 $object = $this->deserialize($this->getContent('mixed_access_types'), 'JMS\Serializer\Tests\Fixtures\GetSetObject');864 $this->assertAttributeEquals(1, 'id', $object);865 $this->assertAttributeEquals('Johannes', 'name', $object);866 $this->assertAttributeEquals(42, 'readOnlyProperty', $object);867 }868 }869 public function testAccessorOrder()870 {871 $this->assertEquals($this->getContent('accessor_order_child'), $this->serialize(new AccessorOrderChild()));872 $this->assertEquals($this->getContent('accessor_order_parent'), $this->serialize(new AccessorOrderParent()));873 $this->assertEquals($this->getContent('accessor_order_methods'), $this->serialize(new AccessorOrderMethod()));874 }875 public function testGroups()876 {877 $groupsObject = new GroupsObject();878 $this->assertEquals($this->getContent('groups_all'), $this->serializer->serialize($groupsObject, $this->getFormat()));879 $this->assertEquals(880 $this->getContent('groups_foo'),881 $this->serializer->serialize($groupsObject, $this->getFormat(), SerializationContext::create()->setGroups(array('foo')))882 );883 $this->assertEquals(884 $this->getContent('groups_foobar'),885 $this->serializer->serialize($groupsObject, $this->getFormat(), SerializationContext::create()->setGroups(array('foo', 'bar')))886 );887 $this->assertEquals(888 $this->getContent('groups_all'),889 $this->serializer->serialize($groupsObject, $this->getFormat())890 );891 $this->assertEquals(892 $this->getContent('groups_default'),893 $this->serializer->serialize($groupsObject, $this->getFormat(), SerializationContext::create()->setGroups(array(GroupsExclusionStrategy::DEFAULT_GROUP)))894 );895 $this->assertEquals(896 $this->getContent('groups_default'),897 $this->serializer->serialize($groupsObject, $this->getFormat(), SerializationContext::create()->setGroups(array(GroupsExclusionStrategy::DEFAULT_GROUP)))898 );899 }900 public function testAdvancedGroups()901 {902 $adrien = new GroupsUser(903 'John',904 new GroupsUser(905 'John Manager',906 null,907 array(908 new GroupsUser(909 'John Manager friend 1',910 new GroupsUser('John Manager friend 1 manager')911 ),912 new GroupsUser('John Manager friend 2'),913 )914 ),915 array(916 new GroupsUser(917 'John friend 1',918 new GroupsUser('John friend 1 manager')919 ),920 new GroupsUser(921 'John friend 2',922 new GroupsUser('John friend 2 manager')923 )924 )925 );926 $this->assertEquals(927 $this->getContent('groups_advanced'),928 $this->serializer->serialize(929 $adrien,930 $this->getFormat(),931 SerializationContext::create()->setGroups(array(932 GroupsExclusionStrategy::DEFAULT_GROUP,933 'manager_group',934 'friends_group',935 'manager' => array(936 GroupsExclusionStrategy::DEFAULT_GROUP,937 'friends_group',938 'friends' => array('nickname_group'),939 ),940 'friends' => array(941 'manager_group'942 )943 ))944 )945 );946 }947 /**948 * @expectedException JMS\Serializer\Exception\InvalidArgumentException949 * @expectedExceptionMessage Invalid group name "foo, bar" on "JMS\Serializer\Tests\Fixtures\InvalidGroupsObject->foo", did you mean to create multiple groups?950 */951 public function testInvalidGroupName()952 {953 $groupsObject = new InvalidGroupsObject();954 $this->serializer->serialize($groupsObject, $this->getFormat());955 }956 public function testVirtualProperty()957 {958 $this->assertEquals($this->getContent('virtual_properties'), $this->serialize(new ObjectWithVirtualProperties()));959 }960 public function testVirtualVersions()961 {962 $this->assertEquals(963 $this->getContent('virtual_properties_low'),964 $this->serialize(new ObjectWithVersionedVirtualProperties(), SerializationContext::create()->setVersion(2))965 );966 $this->assertEquals(967 $this->getContent('virtual_properties_all'),968 $this->serialize(new ObjectWithVersionedVirtualProperties(), SerializationContext::create()->setVersion(7))969 );970 $this->assertEquals(971 $this->getContent('virtual_properties_high'),972 $this->serialize(new ObjectWithVersionedVirtualProperties(), SerializationContext::create()->setVersion(9))973 );974 }975 public function testCustomHandler()976 {977 if (!$this->hasDeserializer()) {978 return;979 }980 $handler = function () {981 return new CustomDeserializationObject('customly_unserialized_value');982 };983 $this->handlerRegistry->registerHandler(GraphNavigator::DIRECTION_DESERIALIZATION, 'CustomDeserializationObject', $this->getFormat(), $handler);984 $serialized = $this->serializer->serialize(new CustomDeserializationObject('sometext'), $this->getFormat());985 $object = $this->serializer->deserialize($serialized, 'CustomDeserializationObject', $this->getFormat());986 $this->assertEquals('customly_unserialized_value', $object->someProperty);987 }988 public function testInput()989 {990 $this->assertEquals($this->getContent('input'), $this->serializer->serialize(new Input(), $this->getFormat()));991 }992 public function testObjectWithEmptyHash()993 {994 $this->assertEquals($this->getContent('hash_empty'), $this->serializer->serialize(new ObjectWithEmptyHash(), $this->getFormat()));995 }996 /**997 * @group null998 */999 public function testSerializeObjectWhenNull()1000 {1001 $this->assertEquals(1002 $this->getContent('object_when_null'),1003 $this->serialize(new Comment(null, 'foo'), SerializationContext::create()->setSerializeNull(false))1004 );1005 $this->assertEquals(1006 $this->getContent('object_when_null_and_serialized'),1007 $this->serialize(new Comment(null, 'foo'), SerializationContext::create()->setSerializeNull(true))1008 );1009 }1010 /**1011 * @group polymorphic1012 */1013 public function testPolymorphicObjectsWithGroup()1014 {1015 $context = SerializationContext::create();1016 $context->setGroups(array("foo"));1017 $this->assertEquals(1018 $this->getContent('car'),1019 $this->serialize(new \JMS\Serializer\Tests\Fixtures\DiscriminatorGroup\Car(5), $context)1020 );1021 }1022 /**1023 * @group polymorphic1024 */1025 public function testPolymorphicObjects()1026 {1027 $this->assertEquals(1028 $this->getContent('car'),1029 $this->serialize(new Car(5))1030 );1031 self::assertEquals(1032 $this->getContent('post'),1033 $this->serialize(new Post('Post Title'))1034 );1035 self::assertEquals(1036 $this->getContent('image_post'),1037 $this->serialize(new ImagePost('Image Post Title'))1038 );1039 if ($this->hasDeserializer()) {1040 $this->assertEquals(1041 new Car(5),1042 $this->deserialize(1043 $this->getContent('car'),1044 'JMS\Serializer\Tests\Fixtures\Discriminator\Car'1045 ),1046 'Class is resolved correctly when concrete sub-class is used.'1047 );1048 $this->assertEquals(1049 new Car(5),1050 $this->deserialize(1051 $this->getContent('car'),1052 'JMS\Serializer\Tests\Fixtures\Discriminator\Vehicle'1053 ),1054 'Class is resolved correctly when least supertype is used.'1055 );1056 $this->assertEquals(1057 new Car(5),1058 $this->deserialize(1059 $this->getContent('car_without_type'),1060 'JMS\Serializer\Tests\Fixtures\Discriminator\Car'1061 ),1062 'Class is resolved correctly when concrete sub-class is used and no type is defined.'1063 );1064 self::assertEquals(1065 new Post('Post Title'),1066 $this->deserialize(1067 $this->getContent('post'),1068 'JMS\Serializer\Tests\Fixtures\Discriminator\Post'1069 ),1070 'Class is resolved correctly when parent class is used and type is set.'1071 );1072 self::assertEquals(1073 new ImagePost('Image Post Title'),1074 $this->deserialize(1075 $this->getContent('image_post'),1076 'JMS\Serializer\Tests\Fixtures\Discriminator\Post'1077 ),1078 'Class is resolved correctly when least supertype is used.'1079 );1080 self::assertEquals(1081 new ImagePost('Image Post Title'),1082 $this->deserialize(1083 $this->getContent('image_post'),1084 'JMS\Serializer\Tests\Fixtures\Discriminator\ImagePost'1085 ),1086 'Class is resolved correctly when concrete sub-class is used and no type is defined.'1087 );1088 }1089 }1090 /**1091 * @group polymorphic1092 */1093 public function testNestedPolymorphicObjects()1094 {1095 $garage = new Garage(array(new Car(3), new Moped(1)));1096 $this->assertEquals(1097 $this->getContent('garage'),1098 $this->serialize($garage)1099 );1100 if ($this->hasDeserializer()) {1101 $this->assertEquals(1102 $garage,1103 $this->deserialize(1104 $this->getContent('garage'),1105 'JMS\Serializer\Tests\Fixtures\Garage'1106 )1107 );1108 }1109 }1110 /**1111 * @group polymorphic1112 */1113 public function testNestedPolymorphicInterfaces()1114 {1115 $garage = new VehicleInterfaceGarage(array(new Car(3), new Moped(1)));1116 $this->assertEquals(1117 $this->getContent('garage'),1118 $this->serialize($garage)1119 );1120 if ($this->hasDeserializer()) {1121 $this->assertEquals(1122 $garage,1123 $this->deserialize(1124 $this->getContent('garage'),1125 'JMS\Serializer\Tests\Fixtures\VehicleInterfaceGarage'1126 )1127 );1128 }1129 }1130 /**1131 * @group polymorphic1132 * @expectedException LogicException1133 */1134 public function testPolymorphicObjectsInvalidDeserialization()1135 {1136 if (!$this->hasDeserializer()) {1137 throw new \LogicException('No deserializer');1138 }1139 $this->deserialize(1140 $this->getContent('car_without_type'),1141 'JMS\Serializer\Tests\Fixtures\Discriminator\Vehicle'1142 );1143 }1144 public function testDepthExclusionStrategy()1145 {1146 $context = SerializationContext::create()1147 ->addExclusionStrategy(new DepthExclusionStrategy());1148 $data = new Tree(1149 new Node(array(1150 new Node(array(1151 new Node(array(1152 new Node(array(1153 new Node(),1154 )),1155 )),1156 )),1157 ))1158 );1159 $this->assertEquals($this->getContent('tree'), $this->serializer->serialize($data, $this->getFormat(), $context));1160 }1161 public function testMaxDepthWithSkippableObject()1162 {1163 $data = new Gh236Foo();1164 $context = SerializationContext::create()->enableMaxDepthChecks();1165 $serialized = $this->serialize($data, $context);1166 $this->assertEquals($this->getContent('maxdepth_skippabe_object'), $serialized);1167 }1168 public function testDeserializingIntoExistingObject()1169 {1170 if (!$this->hasDeserializer()) {1171 return;1172 }1173 $objectConstructor = new InitializedObjectConstructor(new UnserializeObjectConstructor());1174 $serializer = new Serializer(1175 $this->factory, $this->handlerRegistry, $objectConstructor,1176 $this->serializationVisitors, $this->deserializationVisitors, $this->dispatcher1177 );1178 $order = new Order(new Price(12));1179 $context = new DeserializationContext();1180 $context->attributes->set('target', $order);1181 $deseralizedOrder = $serializer->deserialize(1182 $this->getContent('order'),1183 get_class($order),1184 $this->getFormat(),1185 $context1186 );1187 $this->assertSame($order, $deseralizedOrder);1188 $this->assertEquals(new Order(new Price(12.34)), $deseralizedOrder);1189 $this->assertAttributeInstanceOf('JMS\Serializer\Tests\Fixtures\Price', 'cost', $deseralizedOrder);1190 }1191 public function testObjectWithNullableArrays()1192 {1193 $object = new ObjectWithEmptyNullableAndEmptyArrays();1194 $this->assertEquals($this->getContent('nullable_arrays'), $this->serializer->serialize($object, $this->getFormat()));1195 }1196 abstract protected function getContent($key);1197 abstract protected function getFormat();1198 protected function hasDeserializer()1199 {1200 return true;1201 }1202 protected function serialize($data, Context $context = null)1203 {1204 return $this->serializer->serialize($data, $this->getFormat(), $context);1205 }1206 protected function deserialize($content, $type, Context $context = null)1207 {1208 return $this->serializer->deserialize($content, $type, $this->getFormat(), $context);1209 }1210 protected function setUp()...

Full Screen

Full Screen

getContent

Using AI Code Generation

copy

Full Screen

1$has = new Has();2echo $has->getContent();3$has = new Has();4echo $has->getContent();5$has = new Has();6echo $has->getContent();7$has = new Has();8echo $has->getContent();9$has = new Has();10echo $has->getContent();11$has = new Has();12echo $has->getContent();13$has = new Has();14echo $has->getContent();15$has = new Has();16echo $has->getContent();17$has = new Has();18echo $has->getContent();19$has = new Has();20echo $has->getContent();21$has = new Has();22echo $has->getContent();23$has = new Has();24echo $has->getContent();25$has = new Has();26echo $has->getContent();27$has = new Has();28echo $has->getContent();29$has = new Has();30echo $has->getContent();31$has = new Has();32echo $has->getContent();33$has = new Has();34echo $has->getContent();

Full Screen

Full Screen

getContent

Using AI Code Generation

copy

Full Screen

1$has = new Has();2$has->getContent();3$has = new Has();4$has->getContent();5$has = new Has();6$has->getContent();7$has = new Has();8$has->getContent();9$has = new Has();10$has->getContent();11$has = new Has();12$has->getContent();13$has = new Has();14$has->getContent();15$has = new Has();16$has->getContent();17$has = new Has();18$has->getContent();19$has = new Has();20$has->getContent();21$has = new Has();22$has->getContent();23$has = new Has();24$has->getContent();25$has = new Has();26$has->getContent();27$has = new Has();28$has->getContent();29$has = new Has();30$has->getContent();31$has = new Has();32$has->getContent();33$has = new Has();34$has->getContent();35$has = new Has();36$has->getContent();

Full Screen

Full Screen

getContent

Using AI Code Generation

copy

Full Screen

1$has = new Has();2$has->getContent(2);3$has = new Has();4$has->getContent(3);5$has = new Has();6$has->getContent(4);7$has = new Has();8$has->getContent(5);9$has = new Has();10$has->getContent(6);11$has = new Has();12$has->getContent(7);13$has = new Has();14$has->getContent(8);15$has = new Has();16$has->getContent(9);17$has = new Has();18$has->getContent(10);19$has = new Has();20$has->getContent(11);21$has = new Has();22$has->getContent(12);23$has = new Has();24$has->getContent(13);25$has = new Has();26$has->getContent(14);27$has = new Has();28$has->getContent(15);29$has = new Has();30$has->getContent(16);31$has = new Has();32$has->getContent(17);33$has = new Has();34$has->getContent(18);

Full Screen

Full Screen

getContent

Using AI Code Generation

copy

Full Screen

1$has = new Has();2$has->getContent();3$has = new Has();4$has->getContent();5$has = new Has();6$has->getContent();7$has = new Has();8$has->getContent();9$has = new Has();10$has->getContent();11$has = new Has();12$has->getContent();13$has = new Has();14$has->getContent();15$has = new Has();16$has->getContent();17$has = new Has();18$has->getContent();19$has = new Has();20$has->getContent();21$has = new Has();22$has->getContent();23$has = new Has();24$has->getContent();25$has = new Has();26$has->getContent();

Full Screen

Full Screen

getContent

Using AI Code Generation

copy

Full Screen

1$has = new Has();2echo $has->getContent();3PHP: How to Use PHP Namespaces with Multiple Files in Different Directories and Subdirectories (Part 2)4PHP: How to Use PHP Namespaces with Multiple Files in Different Directories and Subdirectories (Part 3)5PHP: How to Use PHP Namespaces with Multiple Files in Different Directories and Subdirectories (Part 4)6PHP: How to Use PHP Namespaces with Multiple Files in Different Directories and Subdirectories (Part 5)7PHP: How to Use PHP Namespaces with Multiple Files in Different Directories and Subdirectories (Part 6)8PHP: How to Use PHP Namespaces with Multiple Files in Different Directories and Subdirectories (Part 7)9PHP: How to Use PHP Namespaces with Multiple Files in Different Directories and Subdirectories (Part 8)10PHP: How to Use PHP Namespaces with Multiple Files in Different Directories and Subdirectories (Part 9)11PHP: How to Use PHP Namespaces with Multiple Files in Different Directories and Subdirectories (Part 10)12PHP: How to Use PHP Namespaces with Multiple Files in Different Directories and Subdirectories (Part 11)13PHP: How to Use PHP Namespaces with Multiple Files in Different Directories and Subdirectories (Part 12)14PHP: How to Use PHP Namespaces with Multiple Files in Different Directories and Subdirectories (Part 13)15PHP: How to Use PHP Namespaces with Multiple Files in Different Directories and Subdirectories (Part 14)16PHP: How to Use PHP Namespaces with Multiple Files in Different Directories and Subdirectories (Part 15)17PHP: How to Use PHP Namespaces with Multiple Files in Different Directories and Subdirectories (Part 16)

Full Screen

Full Screen

getContent

Using AI Code Generation

copy

Full Screen

1echo $hash->getContent();2hash::hash ( string $algo , string $data [, bool $raw_output = false ] )3$hash = new Hash();4$hash->setData('Hello World!');5$hash->setAlgorithm('md5');6echo $hash->getHash();7hash::hash_file ( string $algo , string $filename [, bool $raw_output = false ] )8$hash = new Hash();9$hash->setFile('1.php');10$hash->setAlgorithm('md5');11echo $hash->getHash();12hash::hash_hmac ( string $algo , string $data , string $key [, bool $raw_output = false ]

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run VfsStream automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Trigger getContent code on LambdaTest Cloud Grid

Execute automation tests with getContent on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.

Test now for Free

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful