示例#1
0
 public function testConfigLog()
 {
     $userMock = $this->getMockForAbstractClass('Symfony\\Component\\Security\\Core\\User\\UserInterface');
     $this->assertEmpty($this->configLog->getId());
     $data = new \DateTime();
     $this->configLog->setLoggedAt($data);
     $this->assertEquals($data, $this->configLog->getLoggedAt());
     $this->configLog->setUser($userMock);
     $this->assertEquals($userMock, $this->configLog->getUser());
     $this->configLog->addDiff($this->configLogDiff);
     $this->assertEquals($this->configLogDiff, $this->configLog->getDiffs()->first());
     $diffsCollection = new ArrayCollection(array($this->configLogDiff));
     $this->configLog->setDiffs($diffsCollection);
     $this->assertEquals($diffsCollection, $this->configLog->getDiffs());
 }
示例#2
0
 /**
  * Creates an audit entity contains all changed configs
  *
  * @param ConfigManager $configManager
  *
  * @return ConfigLog|null
  */
 public function buildEntity(ConfigManager $configManager)
 {
     $user = $this->getUser();
     if (null === $user) {
         return null;
     }
     $log = new ConfigLog();
     foreach ($configManager->getUpdateConfig() as $config) {
         $diff = $this->computeChanges($config, $configManager);
         if (null !== $diff) {
             $log->addDiff($diff);
         }
     }
     if ($log->getDiffs()->isEmpty()) {
         return null;
     }
     $log->setUser($user);
     return $log;
 }