public function testCalendarGetOption() { $calendar = new Calendar(); $this->assertEquals(1, $calendar->getFactory()->getFirstWeekday()); $calendar->setFactory(new Factory(array('first_weekday' => 0))); $this->assertEquals(0, $calendar->getFactory()->getFirstWeekday()); }
public function testGetDay() { $factory = new Calendar(); $day = $factory->getDay(new \DateTime('2012-01-01')); $this->assertInstanceOf('CalendR\\Period\\Day', $day); $day = $factory->getDay(2012, 1, 1); $this->assertInstanceOf('CalendR\\Period\\Day', $day); }
public function testSetFirstWeekday() { $factory = new Calendar(); $factory->setFirstWeekday(Day::FRIDAY); $this->assertSame(Day::FRIDAY, $factory->getFirstWeekday()); $factory->setFirstWeekday(Day::THURSDAY); $this->assertSame(Day::THURSDAY, $factory->getFirstWeekday()); }
public function testSetFirstWeekday() { $factory = new \CalendR\Calendar(); $month = $factory->getMonth(2014, 5); $this->assertSame($factory->getFirstWeekday(), $month->getFirstWeekday()); $month->setFirstWeekday(Day::FRIDAY); $this->assertSame(Day::FRIDAY, $factory->getFirstWeekday()); $month->setFirstWeekday(Day::THURSDAY); $this->assertSame(Day::THURSDAY, $factory->getFirstWeekday()); }
/** * {@inheritdoc} */ public function register(Application $app) { $app['calendr'] = $app->share(function ($app) { $calendr = new Calendar(); $calendr->setEventManager($app['calendr.event_manager']); return $calendr; }); $app['calendr.event_manager'] = $app->share(function ($app) { return new Manager(isset($app['calendr.event.providers']) ? $app['calendr.event.providers'] : array(), isset($app['calendr.event.collection.instantiator']) ? $app['calendr.event.collection.instantiator'] : null); }); }
public function testIterateOnMonth() { $calendar = new Calendar(); $month = $calendar->getMonth(2013, 3); foreach ($month as $week) { $this->assertSame(Day::MONDAY, (int) $week->getBegin()->format('w')); } $calendar->setFirstWeekday(Day::SUNDAY); $month = $calendar->getMonth(2013, 3); foreach ($month as $week) { $this->assertSame(Day::SUNDAY, (int) $week->getBegin()->format('w')); } }
/** * Register the service provider. * * @return void */ public function register() { $this->app['calendr'] = $this->app->share(function ($app) { $provider = $app['config']->get('calendr::provider'); $manager = $app['config']->get('calendr::manager'); $cal = new Calendar(); if (class_exists($manager)) { $cal->setEventManager(new $manager()); } if (class_exists($provider)) { $cal->getEventManager()->addProvider('calendrprovider', new $provider()); } return $cal; }); }
public function testStrictDates() { // When we start, the option "strict_dates" should be set to false. $calendar = new Calendar(); $this->assertSame(false, $calendar->getStrictDates()); $calendar->setStrictDates(true); $this->assertSame(true, $calendar->getStrictDates()); }
public function testGetEventManager() { $calendar = new Calendar(); $this->assertInstanceOf('CalendR\\Event\\Manager', $calendar->getEventManager()); }