/** * Construct calendar response * * @param Calendar $calendar Calendar * @param int $status Response status * @param array $headers Response headers */ public function __construct(Calendar $calendar, $status = 200, $headers = array()) { $this->calendar = $calendar; $content = utf8_encode($calendar->createCalendar()); $headers = array_merge($this->getDefaultHeaders(), $headers); parent::__construct($content, $status, $headers); }
/** * Calendar attachment constructor * * @param Calendar $calendar */ public function __construct(Calendar $calendar) { $data = $calendar->createCalendar(); $filename = $calendar->getConfig('filename'); $contentType = $calendar->getContentType(); parent::__construct($data, $filename, $contentType); }
/** * Testing calendar attachment * * @param Calendar $calendar * * @dataProvider getCalendarTestData */ public function testCalendarAttachment(Calendar $calendar) { $attachment = new CalendarAttachment($calendar); $this->assertInstanceOf('Swift_Attachment', $attachment); $this->assertInstanceOf('Dyvelop\\ICalCreatorBundle\\Mailer\\CalendarAttachment', $attachment); $this->assertEquals($calendar->createCalendar(), $attachment->getBody()); $this->assertEquals($calendar->getConfig('filename'), $attachment->getFilename()); $this->assertEquals($calendar->getContentType(), $attachment->getContentType()); }
/** * Testing calendar response * * @param Calendar $calendar Calendar * @param array $headers Additional response headers * * @dataProvider getCalendarTestData */ public function testCalendarResponse(Calendar $calendar, $headers = array()) { $response = new CalendarResponse($calendar, 200, $headers); $this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\Response', $response); $this->assertInstanceOf('Dyvelop\\ICalCreatorBundle\\Response\\CalendarResponse', $response); $this->assertEquals(200, $response->getStatusCode()); $this->assertEquals($calendar->createCalendar(), $response->getContent()); foreach ($headers as $key => $value) { $this->assertEquals($value, $response->headers->get($key)); } $this->assertContains($calendar->getContentType(), $response->headers->get('Content-Type')); $this->assertContains($calendar->getConfig('filename'), $response->headers->get('Content-Disposition')); }