public function testSaveEntityConfigValues() { $config1 = new Config(new EntityConfigId('scope1', self::ENTITY_CLASS), ['key1' => 'val1']); $config2 = new Config(new EntityConfigId('scope2', self::ENTITY_CLASS), ['key2' => 'val2']); $this->cache->expects($this->once())->method('save')->willReturnCallback(function ($key, $data) { $this->cache->expects($this->once())->method('fetch')->with($key)->willReturn($data); return true; }); $this->assertTrue($this->configCache->saveEntityConfigValues([$config1->getId()->getScope() => $config1->getValues(), $config2->getId()->getScope() => $config2->getValues()], self::ENTITY_CLASS)); // test that configs saved right $this->assertEquals($config1, $this->configCache->getEntityConfig($config1->getId()->getScope(), self::ENTITY_CLASS)); $this->assertEquals($config2, $this->configCache->getEntityConfig($config2->getId()->getScope(), self::ENTITY_CLASS)); }
/** * @return array [entity_config_id => class_name, ...] */ protected function loadConfigurableEntities() { $connection = $this->configManager->getEntityManager()->getConnection(); $entityRows = $connection->executeQuery('SELECT id, class_name, mode, data FROM oro_entity_config'); $classMap = []; $entities = []; foreach ($entityRows as $row) { $entityId = (int) $row['id']; $className = $row['class_name']; $isHidden = $row['mode'] === ConfigModel::MODE_HIDDEN; $data = array_merge($this->getEmptyData(), $connection->convertToPHPValue($row['data'], 'array')); $classMap[$entityId] = $className; $entities[$className] = ['i' => $entityId, 'h' => $isHidden]; $this->cache->saveEntityConfigValues($data, $className); } $this->cache->saveEntities($entities); return $classMap; }