public function testSpecialDate() { $parserFile = file_get_contents($this->rootpath . '/DateParser/AbstractParser.php'); $this->loadFiles('/Dates'); $this->loadFiles('/CommonDates'); foreach ($this->classNames as $className) { $found = strpos($parserFile, 'new ' . $className) !== false; $this->assertTrue($found, 'Class is not used in AbstractParser. Add: \'new ' . $className . '($year)\''); } $parser = new \Stefanius\SpecialDates\DateParser\Parser(); $list = $parser->getAllDates(2000); $this->assertEquals(count($this->classNames), count($list), 'There are ' . count($this->classNames) . ' valid classnames found, but there ' . count($list) . ' are returned from the parser. Fix this!'); }
/** * Test the default list in Parser on possible duplicates. */ public function testDuplication() { $parser = new \Stefanius\SpecialDates\DateParser\Parser(); $descriptions = []; $dates = $parser->getAllDates(2000); foreach ($dates as $date) { $desc = $date->slug(); if (array_key_exists($desc, $descriptions)) { $descriptions[$desc]++; } else { $descriptions[$desc] = 1; } } foreach ($descriptions as $key => $value) { $this->assertEquals(1, $value, "Possible duplicated SpecialDateDescription: '" . $key . "'. Number of occurrences: " . $value); } }