public function testItDisplaysTheStatusForAllMatchingProducts()
 {
     $this->mockInput->method('getArgument')->with('sku')->willReturn('TEST');
     $this->mockProductStatusAdapter->method('getProductStatusMatchingSku')->willReturn(['TEST1' => ProductStatusAdapterInterface::ENABLED, 'TEST2' => ProductStatusAdapterInterface::DISABLED, 'TEST3' => ProductStatusAdapterInterface::ENABLED]);
     $this->mockOutput->method('writeln')->withConsecutive(['<info>TEST1: enabled</info>'], ['<info>TEST2: disabled</info>'], ['<info>TEST3: enabled</info>']);
     $this->command->run($this->mockInput, $this->mockOutput);
 }
 /**
  * @param string $sku
  */
 private function disableProductWithSku($sku)
 {
     try {
         $this->productStatusAdapter->disableProductWithSku($sku);
     } catch (ProductAlreadyDisabledException $exception) {
     }
 }
 public function testItDisplaysExceptionsAsErrors()
 {
     $testMessage = 'Dummy Exception';
     $this->mockInput->method('getArgument')->with('sku')->willReturn('test');
     $this->mockProductStatusAdapter->method('enableProductWithSku')->willThrowException(new ProductStatusAdapterException($testMessage));
     $this->mockOutput->expects($this->once())->method('writeln')->with('<error>' . $testMessage . '</error>');
     $this->command->run($this->mockInput, $this->mockOutput);
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     try {
         $sku = $input->getArgument('sku');
         $this->productStatusAdapter->disableProductWithSku($sku);
         $output->writeln(sprintf('<info>Disabled product "%s"</info>', $sku));
     } catch (ProductStatusAdapterException $exception) {
         $output->writeln('<error>' . $exception->getMessage() . '</error>');
     }
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     try {
         $skuPattern = $input->getArgument('sku');
         $matches = $this->productStatusAdapter->getProductStatusMatchingSku($skuPattern);
         if ($matches) {
             $this->outputMatches($output, $matches);
         } else {
             $output->writeln(sprintf('<comment>No matches found for "%s"</comment>', $skuPattern));
         }
     } catch (ProductStatusAdapterException $exception) {
         $output->writeln('<error>' . $exception->getMessage() . '</error>');
     }
 }
 public function testItHidesProductAlreadyEnabledExceptions()
 {
     $this->mockProductStatusAdapter->method('enableProductWithSku')->willThrowException(new ProductAlreadyEnabledException('Dummy Exception'));
     $this->assertNotNull($this->api->set('test', 'enabled'));
 }