public function testFailGenerateDateString() { $test_data = ['2015-01-012' => EWrongNbpDateFormat::class, '2010-02-0' => EWrongNbpDateFormat::class]; foreach ($test_data as $fix => $expected) { $Exc = null; try { NbpDateStringFormatter::format($fix); } catch (\Exception $Exc) { } $this->assertNotNull($Exc); $this->assertInstanceOf($expected, $Exc); } }
protected function _doGetFileNameBefore($date_str, $type = 'a') { $dStr = Service\NbpDateStringFormatter::format($date_str); $dir = $this->getDir($date_str); $item = $this->_doIterateDir($dir, $dStr, $type); if (null === $item) { // try year before: $decrement = (int) substr($date_str, 0, 4) - 1; $prev_dir = $this->getDir($decrement); $dir = $prev_dir + $dir; $item = $this->_doIterateDir($dir, $dStr, $type); } if (!empty($item)) { return $item; } return null; }