Get changes from a Doctrine entity

Code
<?php

use PHPSnippets\Db\Entity\Test;

/* @var $em Doctrine\ORM\EntityManager */
$uow $em->getUnitOfWork();

$entityChanges = function ($entity) use ($em$uow) {
    
// compute changes into changeset
    
$uow->computeChangeSet(
        
$em->getClassMetadata(Test::CLASS),
        
$entity
    
);

    echo 
'Is entity scheduled for update, delete, etc.?';
    
dump($uow->isEntityScheduled($entity));
    echo 
'What changed in entity (value before/after)?';
    
dump($uow->getEntityChangeSet($entity));
};

// get Test entity with id 1
$entity $em->find(Test::CLASS, 1);
dump($entity);

echo 
'<b>Set same value for entity name</b>' PHP_EOL;
$entity->name 'foo';
$entityChanges($entity);

echo 
'<b>Change value of name</b>' PHP_EOL;
$entity->name 'foobar';
$entityChanges($entity);

echo 
'<b>Change name again and date value</b>' PHP_EOL;
$entity->name 'foobar2';
$entity->creationDate = new DateTime();
$entityChanges($entity);
Result
Test {#389
+id: 1
+name: "foo"
+creationDate: DateTime {#386
+"date": "2014-07-20 11:37:29.000000"
+"timezone_type": 3
+"timezone": "Europe/Berlin"
}
}

Set same value for entity name
Is entity scheduled for update, delete, etc.?
false

What changed in entity (value before/after)?
[]

Change value of name
Is entity scheduled for update, delete, etc.?
true

What changed in entity (value before/after)?
array:1 [
"name" => array:2 [
0 => "foo"
1 => "foobar"
]
]

Change name again and date value
Is entity scheduled for update, delete, etc.?
true

What changed in entity (value before/after)?
array:2 [
"name" => array:2 [
0 => "foobar"
1 => "foobar2"
]
"creationDate" => array:2 [
0 => DateTime {#386
+"date": "2014-07-20 11:37:29.000000"
+"timezone_type": 3
+"timezone": "Europe/Berlin"
}
1 => DateTime {#392
+"date": "2017-08-22 20:48:50.402544"
+"timezone_type": 3
+"timezone": "Europe/Berlin"
}
]
]
Used Versions
PHP 7.1, Zend 3.0, Symfony 3.2, Laravel 5.2, PHPUnit 5.6, Doctrine 2.6