Пример #1
0
 public function testShouldNotReflectChangesOnClonedObject()
 {
     $obj = new ValueTest();
     $obj->setValue('aNamespace', 'aKey', 'foo');
     $clonedObj = \Makasim\Values\clone_object($obj);
     $clonedObj->setValue('aNamespace', 'aKey', 'bar');
     $this->assertSame('foo', $obj->getValue('aNamespace', 'aKey'));
     $this->assertSame('bar', $clonedObj->getValue('aNamespace', 'aKey'));
 }
Пример #2
0
 public function testShouldNotReflectChangesIfObjectWasCloned()
 {
     $values = ['aName' => ['aKey' => ['aSubName' => ['aSubKey' => 'aFooVal']]]];
     $obj = new ObjectTest();
     \Makasim\Values\set_values($obj, $values);
     //guard
     $this->assertEmpty(\Makasim\Values\get_changed_values($obj));
     /** @var SubObjectTest $subObj */
     $subObj = $obj->getObject('aName', 'aKey', SubObjectTest::class);
     //guard
     $this->assertInstanceOf(SubObjectTest::class, $subObj);
     $clonedSubObj = \Makasim\Values\clone_object($subObj);
     $clonedSubObj->setSelfValue('aSubKeyFoo', 'aBarVal');
     $this->assertEquals(['aName' => ['aKey' => ['aSubName' => ['aSubKey' => 'aFooVal']]]], \Makasim\Values\get_values($obj));
 }