/** * @covers \Magento\Tools\Migration\Acl\Db\AbstractLogger::add() * @covers \Magento\Tools\Migration\Acl\Db\AbstractLogger::__toString() */ public function testToString() { $this->_model->add('key1', 'key2', 3); // mapped item $this->_model->add('key2', null, false); // not mapped item $this->_model->add(null, 'Some_Module::acl_resource', false); //item in actual format $expected = 'Mapped items count: 1' . PHP_EOL . 'Not mapped items count: 1' . PHP_EOL . 'Items in actual format count: 1' . PHP_EOL . '------------------------------' . PHP_EOL . 'Mapped items:' . PHP_EOL . 'key1 => key2 :: Count updated rules: 3' . PHP_EOL . '------------------------------' . PHP_EOL . 'Not mapped items:' . PHP_EOL . 'key2' . PHP_EOL . '------------------------------' . PHP_EOL . 'Items in actual format:' . PHP_EOL . 'Some_Module::acl_resource' . PHP_EOL . '------------------------------' . PHP_EOL; $this->assertEquals($expected, (string) $this->_model); }
/** * Migrate old keys to new * * @param array $map * @return void */ public function migrate($map) { foreach ($this->_reader->fetchAll() as $oldKey => $count) { $newKey = isset($map[$oldKey]) ? $map[$oldKey] : null; if (in_array($oldKey, $map)) { $newKey = $oldKey; $oldKey = null; } if ($newKey && $oldKey && $this->_mode == self::WRITE_MODE) { $this->_writer->update($oldKey, $newKey); } $this->_logger->add($oldKey, $newKey, $count); } }