getMock('CI_Lang', array('load', 'line')); $lang->expects($this->any())->method('line')->will($this->returnValue(FALSE)); $this->ci_instance_var('lang', $lang); $this->calendar = new CI_Calendar(); } function test_initialize() { $this->calendar->initialize(array( 'month_type' => 'short', 'start_day' => 'monday' )); $this->assertEquals('short', $this->calendar->month_type); $this->assertEquals('monday', $this->calendar->start_day); } function test_generate() { $no_events = '
September 2011
SuMoTuWeThFrSa
    123
45678910
11121314151617
18192021222324
252627282930 
'; $this->assertEquals($no_events, $this->calendar->generate(2011, 9)); $data = array( 3 => 'http://example.com/news/article/2006/03/', 7 => 'http://example.com/news/article/2006/07/', 13 => 'http://example.com/news/article/2006/13/', 26 => 'http://example.com/news/article/2006/26/' ); $events = '
September 2011
SuMoTuWeThFrSa
    123
45678910
11121314151617
18192021222324
252627282930 
'; $this->assertEquals($events, $this->calendar->generate(2011, 9, $data)); } function test_get_month_name() { $this->calendar->month_type = NULL; $this->assertEquals('January', $this->calendar->get_month_name('01')); $this->calendar->month_type = 'short'; $this->assertEquals('Jan', $this->calendar->get_month_name('01')); } function test_get_day_names() { $this->assertEquals(array( 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday' ), $this->calendar->get_day_names('long')); $this->assertEquals(array( 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat' ), $this->calendar->get_day_names('short')); $this->calendar->day_type = NULL; $this->assertEquals(array( 'Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa' ), $this->calendar->get_day_names()); } function test_adjust_date() { $this->assertEquals(array('month' => 8, 'year' => 2012), $this->calendar->adjust_date(8, 2012)); $this->assertEquals(array('month' => 1, 'year' => 2013), $this->calendar->adjust_date(13, 2012)); } function test_get_total_days() { $this->assertEquals(0, $this->calendar->get_total_days(13, 2012)); $this->assertEquals(31, $this->calendar->get_total_days(1, 2012)); $this->assertEquals(28, $this->calendar->get_total_days(2, 2011)); $this->assertEquals(29, $this->calendar->get_total_days(2, 2012)); $this->assertEquals(31, $this->calendar->get_total_days(3, 2012)); $this->assertEquals(30, $this->calendar->get_total_days(4, 2012)); $this->assertEquals(31, $this->calendar->get_total_days(5, 2012)); $this->assertEquals(30, $this->calendar->get_total_days(6, 2012)); $this->assertEquals(31, $this->calendar->get_total_days(7, 2012)); $this->assertEquals(31, $this->calendar->get_total_days(8, 2012)); $this->assertEquals(30, $this->calendar->get_total_days(9, 2012)); $this->assertEquals(31, $this->calendar->get_total_days(10, 2012)); $this->assertEquals(30, $this->calendar->get_total_days(11, 2012)); $this->assertEquals(31, $this->calendar->get_total_days(12, 2012)); } function test_default_template() { $array = array( 'table_open' => '', 'heading_row_start' => '', 'heading_previous_cell' => '', 'heading_title_cell' => '', 'heading_next_cell' => '', 'heading_row_end' => '', 'week_row_start' => '', 'week_day_cell' => '', 'week_row_end' => '', 'cal_row_start' => '', 'cal_cell_start' => '', 'cal_cell_end_today' => '', 'cal_row_end' => '', 'table_close' => '
<<{heading}>>
{week_day}
', 'cal_cell_start_today' => '', 'cal_cell_content' => '{day}', 'cal_cell_content_today' => '{day}', 'cal_cell_no_content' => '{day}', 'cal_cell_no_content_today' => '{day}', 'cal_cell_blank' => ' ', 'cal_cell_end' => '
' ); $this->assertEquals($array, $this->calendar->default_template()); } }