/** * @ticket 36790 * @dataProvider data_wp_maybe_decline_date */ public function test_wp_maybe_decline_date($test_locale, $input, $output) { global $locale, $wp_locale; add_filter('gettext_with_context', array($this, 'filter__enable_months_names_declension'), 10, 3); $month_names = $this->get_months_names($test_locale); $locale = $test_locale; $wp_locale->month = $month_names['month']; $wp_locale->month_genitive = $month_names['month_genitive']; $declined_date = wp_maybe_decline_date($input); remove_filter('gettext_with_context', array($this, 'filter__enable_months_names_declension'), 10); $this->assertEquals($output, $declined_date); }
/** * */ function test_wp_maybe_decline_date_pass_date() { global $wp_locale; add_filter('locale', array(__CLASS__, 'set_locale_to_pl')); add_filter('gettext_with_context', array(__CLASS__, 'set_gettext_to_on'), 10, 3); $month_names = array('Siječanj', 'Veljača', 'Ožujak', 'Travanj', 'Svibanj', 'Lipanj', 'Srpanj', 'Kolovoz', 'Rujan', 'Listopad', 'Studeni', 'Prosinac'); $wp_locale->month = $month_names; $month_names_genitive = array('siječnja', 'veljače', 'ožujka', 'travnja', 'svibnja', 'lipnja', 'srpnja', 'kolovoza', 'rujna', 'listopada', 'studenoga', 'prosinca'); $wp_locale->month_genitive = $month_names_genitive; foreach ($month_names as $index => $month) { $this->assertEquals(wp_maybe_decline_date('16 ' . $month . ' 2012'), '16 ' . $month_names_genitive[$index] . ' 2012'); } $this->assertEquals('16 siječnja 2012', wp_maybe_decline_date('16 Siječanj 2012')); }