/**
  * Get default response headers for a calendar
  *
  * @return array
  */
 protected function getDefaultHeaders()
 {
     $headers = array();
     $mimeType = $this->calendar->getContentType();
     $headers['Content-Type'] = sprintf('%s; charset=utf-8', $mimeType);
     $filename = $this->calendar->getConfig('filename');
     $headers['Content-Disposition'] = sprintf('attachment; filename="%s', $filename);
     return $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'));
 }
Пример #5
0
 /**
  * Testing getter for content type
  *
  * @param array  $config      Calendar config
  * @param string $contentType Expected content type
  *
  * @dataProvider getCalendarContentTypeTestData
  */
 public function testGetContentType(array $config, $contentType)
 {
     $calendar = new Calendar($config);
     $this->assertEquals($contentType, $calendar->getContentType());
 }