objectManager = Bootstrap::getObjectManager(); $this->fileWriter = $this->objectManager->get(Writer::class); $this->xmlReader = $this->objectManager->create(Xml::class); $this->fileReader = $this->objectManager->get(FileReader::class); $this->envConfigBackup = $this->fileReader->load(ConfigFilePool::APP_ENV); $customEnvConfig = $this->buildCustomEnvConfigWithConsumers(); $this->fileWriter->saveConfig([ConfigFilePool::APP_ENV => $customEnvConfig]); /** @var Data data */ $configData = $this->objectManager->create( Data::class, [ 'cacheId' => uniqid(microtime()) ] ); $this->configSubject = $this->objectManager->create( Config::class, [ 'queueConfigData' => $configData ] ); } public function testGetConsumers(): void { $consumers = $this->configSubject->getConsumers(); foreach ($consumers as $consumer) { $this->assertIsString($consumer['name']); $this->assertIsArray($consumer['handlers']); } } /** * @inheritdoc */ protected function tearDown(): void { $filesystem = $this->objectManager->get(Filesystem::class); $configFilePool = $this->objectManager->get(ConfigFilePool::class); $filesystem->getDirectoryWrite(DirectoryList::CONFIG)->writeFile( $configFilePool->getPath(ConfigFilePool::APP_ENV), "fileWriter->saveConfig([ConfigFilePool::APP_ENV => $this->envConfigBackup]); } private function buildCustomEnvConfigWithConsumers(): array { $data = $this->xmlReader->read(); $names = array_keys($data['consumers']); $consumers = []; foreach ($names as $name) { $consumers[$name] = ['connection' => 'amqp']; } return [ 'queue' => [ 'amqp' => [ 'host' => 'localhost', 'port' => '5672', 'user' => 'guest', 'password' => 'guest', 'virtualhost' => '/', 'ssl' => '' ], 'consumers' => $consumers ], ]; } }