Permalink
Browse files

Fix PreLoadEventArgs $data assignment by reference

  • Loading branch information...
superdweebie authored and jmikola committed Jan 30, 2014
1 parent dec2bda commit 13338b2ad0257e9e783665c392cdf928f1396eeb
@@ -43,7 +43,7 @@ class PreLoadEventArgs extends LifecycleEventArgs
public function __construct($document, DocumentManager $dm, array &$data)
{
parent::__construct($document, $dm);
- $this->data = $data;
+ $this->data =& $data;
}
/**
@@ -0,0 +1,24 @@
+<?php
+
+namespace Doctrine\ODM\MongoDB\Tests\Events;
+
+use Doctrine\ODM\MongoDB\Event\PreLoadEventArgs;
+use Documents\Group;
+
+class PreLoadEventArgsTest extends \Doctrine\ODM\MongoDB\Tests\BaseTest
+{
+ public function testGetData()
+ {
+ $document = new Group('test');
+ $dm = $this->dm;
+ $data = array('id' => '1234', 'name' => 'test');
+
+ $eventArgs = new PreLoadEventArgs($document, $dm, $data);
+
+ $this->assertEquals('test', $eventArgs->getData()['name']);
+
+ $eventArgs->getData()['name'] = 'alt name';
+
+ $this->assertEquals('alt name', $data['name']);
+ }
+}

0 comments on commit 13338b2

Please sign in to comment.