public function testListDiffFromIsEmptyWhenNewListing()
 {
     $list1 = ['In voting phase' => ['Generator Delegation' => ['Generator Delegation', 'generator_delegation'], 'In Operator' => ['In Operator', 'in_operator']]];
     $list2 = ['In voting phase' => ['Generator Delegation' => ['Generator Delegation', 'generator_delegation']]];
     $expected = ['In Operator' => ['to' => 'In voting phase', 'from' => '']];
     $actual = $this->diffService->listDiff($list1, $list2);
     $this->assertSame($expected, $actual);
 }
Exemplo n.º 2
0
 /**
  * @param InputInterface  $input
  * @param OutputInterface $output
  */
 public function execute(InputInterface $input, OutputInterface $output)
 {
     if (posix_isatty(STDOUT)) {
         $output->writeln('<info>щ(ºДºщ) This command is pointless when not run on a cron</info>');
     }
     $currRfcList = $this->rfcService->getLists();
     $storageFile = sprintf('%s/rfcList.json', $this->config->get('storagePath'));
     if (!file_exists($storageFile)) {
         file_put_contents($storageFile, json_encode($currRfcList));
         return;
     }
     $prevRfcList = json_decode(file_get_contents($storageFile), true);
     $diffs = $this->diffService->listDiff($currRfcList, $prevRfcList);
     if (empty($diffs)) {
         file_put_contents($storageFile, json_encode($currRfcList));
         return;
     }
     $email = $this->twig->render('list.twig', ['changes' => $diffs]);
     $message = $this->mailer->createMessage()->setSubject('Some RFCs have moved!')->setFrom('*****@*****.**')->setTo($input->getArgument('email'))->setBody($email, 'text/html');
     $this->mailer->send($message);
     file_put_contents($storageFile, json_encode($currRfcList));
 }