Ejemplo n.º 1
0
 public function testGetTableSingle()
 {
     $mockLogger = $this->getMockBuilder('\\App\\Library\\LoggerCLI')->disableOriginalConstructor()->setMethods(['info'])->getMock();
     $mockInputStrategy = $this->getMockBuilder('\\App\\Library\\StdinInput')->disableOriginalConstructor()->setMethods(['read'])->getMock();
     $mockInputStrategy->expects($this->at(0))->method('read')->willReturn("This is one line.");
     $wordFrequency = new WordFrequency($mockInputStrategy, $mockLogger);
     $table = $wordFrequency->getTable();
     $this->assertSame(['is' => 1, 'line' => 1, 'one' => 1, 'this' => 1], $table);
 }
Ejemplo n.º 2
0
 public function main(array $options)
 {
     switch (true) {
         case isset($options['url']):
             $inputStrategy = new URLInput($options['url'], $this->logger);
             break;
         case isset($options['file']):
             $inputStrategy = new FileInput($options['file'], $this->logger);
             break;
         default:
             $inputStrategy = new StdinInput($this->logger);
             break;
     }
     $cleanHTMLTags = isset($options['cleanhtml']) && $options['cleanhtml'] == true;
     $WordFrequency = new WordFrequency($inputStrategy, $this->logger, $cleanHTMLTags);
     print_r($WordFrequency->getTable());
 }