Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fix for MediaView in CakePHP 1.3 #97

Closed
wants to merge 2 commits into from

2 participants

@CauanCabral

MediaView fixed to work correctly with file names when file extesion is UPPERCASE

CauanCabral added some commits
@CauanCabral CauanCabral Handling files with Uppercase extesion name
MediaView fixed to work correctly with file names when file extesion is UPPERCASE
a941d9f
@CauanCabral CauanCabral Updating MediaView test
UPPERCASE extesion test included
26957ad
@CauanCabral

Sure, pull updated.

@CauanCabral CauanCabral reopened this
@markstory
Owner

Thanks for the patch, test cases landed in [5fd1926]

@markstory markstory closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 27, 2011
  1. @CauanCabral

    Handling files with Uppercase extesion name

    CauanCabral authored
    MediaView fixed to work correctly with file names when file extesion is UPPERCASE
  2. @CauanCabral

    Updating MediaView test

    CauanCabral authored
    UPPERCASE extesion test included
This page is out of date. Refresh to see the latest.
View
5 cake/libs/view/media.php
@@ -131,7 +131,7 @@ function render() {
$this->mimeType = array_merge($this->mimeType, $mimeType);
}
- if (isset($extension) && isset($this->mimeType[$extension]) && connection_status() == 0) {
+ if (isset($extension) && isset($this->mimeType[strtolower($extension)]) && connection_status() == 0) {
$chunkSize = 8192;
$buffer = '';
$fileSize = @filesize($path);
@@ -202,7 +202,7 @@ function render() {
}
$this->_header(array(
'Last-Modified: ' . $modified,
- 'Content-Type: ' . $this->mimeType[$extension],
+ 'Content-Type: ' . $this->mimeType[strtolower($extension)],
'Content-Length: ' . $fileSize));
}
$this->_output();
@@ -283,3 +283,4 @@ function _flushBuffer() {
@ob_flush();
}
}
+
View
28 cake/tests/cases/libs/view/media.test.php
@@ -54,6 +54,13 @@ function download() {
$extension = 'css';
$this->set(compact('path', 'id', 'extension'));
}
+
+ function downloadUpper() {
+ $path = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'vendors' . DS .'img' . DS;
+ $id = 'test_2.JPG';
+ $extension = 'JPG';
+ $this->set(compact('path', 'id', 'extension'));
+ }
}
/**
@@ -134,8 +141,6 @@ function startTest() {
$this->Controller =& new Controller();
$this->MediaController =& new MediaController();
$this->MediaController->viewPath = 'posts';
- $this->MediaController->download();
- $this->MediaView =& new TestMediaView($this->MediaController);
}
/**
@@ -159,12 +164,29 @@ function endTest() {
*/
function testRender() {
ob_start();
+ $this->MediaController->download();
+ $this->MediaView =& new TestMediaView($this->MediaController);
$result = $this->MediaView->render();
$output = ob_get_clean();
$this->assertTrue($result !== false);
$this->assertEqual($output, 'this is the test asset css file');
}
+
+ function testRenderUpperExtesnion() {
+ ob_start();
+ $this->MediaController->downloadUpper();
+ $this->MediaView =& new TestMediaView($this->MediaController);
+ $result = $this->MediaView->render();
+ $output = ob_get_clean();
+
+ $this->assertTrue($result !== false);
+
+ $fileName = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'vendors' . DS .'img' . DS . 'test_2.JPG';
+ $file = file_get_contents($fileName, 'r');
+
+ $this->assertEqual(base64_encode($output), base64_encode($file));
+ }
/**
* testConnectionAborted method
@@ -173,6 +195,8 @@ function testRender() {
* @return void
*/
function testConnectionAborted() {
+ $this->MediaController->download();
+ $this->MediaView =& new TestMediaView($this->MediaController);
$this->MediaView->active = false;
$result = $this->MediaView->render();
$this->assertFalse($result);
View
BIN  cake/tests/test_app/vendors/img/test_2.JPG
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Something went wrong with that request. Please try again.