use Buzzwords\BuzzwordReader; require_once __DIR__ . '/vendor/autoload.php'; $buzzwords = []; $buzzwordReader = new BuzzwordReader(); // parse command options $shortOpts = "h"; $longOpts = ["file::", "url::"]; $options = getopt($shortOpts, $longOpts); // Read from file if (isset($options['file'])) { $file = "testfile.txt"; // Default state. if ($options['file']) { $file = $options['file']; } $buzzwords = $buzzwordReader->readFileContent($file); } elseif (isset($options['url'])) { $url = "https://nerdery.com"; // Default state. if ($options['url']) { $url = $options['url']; } $buzzwords = $buzzwordReader->readUrlContent($url); } else { $buzzwordText = (string) isset($argv[1]) ? $argv[1] : false; if ($buzzwordText) { $buzzwords = $buzzwordReader->readTextContent($buzzwordText); } } $help = (bool) isset($options['h']) ? true : false; if ($help || count($buzzwords) < 1) {
/** * Test File Content reader. * * @return void */ public function testFileReader() { $reader = new BuzzwordReader(); $words = $reader->readFileContent("testfile.txt"); $this->assertCount(8, $words); }