Exemplo n.º 1
0
 /**
  * @dataProvider provider
  */
 public function testAuditField($field, $dataType, $newValue, $oldValue, $expectedDataType)
 {
     $audit = new Audit();
     $auditField = new AuditField($audit, $field, $dataType, $newValue, $oldValue);
     $this->assertEquals($audit, $auditField->getAudit());
     $this->assertEquals($expectedDataType, $auditField->getDataType());
     $this->assertEquals($field, $auditField->getField());
     $this->assertEquals($newValue, $auditField->getNewValue());
     $this->assertEquals($oldValue, $auditField->getOldValue());
 }
Exemplo n.º 2
0
 /**
  * @param OrmFilterDatasourceAdapter $ds
  * @param string $objectClass
  * @param string $fieldName
  * @param array $data
  */
 protected function applyNewAuditValueFilter(OrmFilterDatasourceAdapter $ds, $objectClass, $fieldName, array $data)
 {
     if ($data['auditFilter']['type'] !== static::TYPE_CHANGED_TO_VALUE) {
         return;
     }
     $metadata = $ds->getQueryBuilder()->getEntityManager()->getClassMetadata($objectClass);
     $type = $metadata->getTypeOfField($fieldName);
     if (!$type) {
         $type = 'text';
     }
     $newValueField = sprintf('new%s', ucfirst(AuditField::normalizeDataTypeName($type)));
     $this->applyFilter($ds, $data['filter']['filter'], sprintf('%s.%s', $this->auditFieldAlias, $newValueField), $data['filter']['data']);
 }