mirror of
				https://github.com/brmlab/brmsklad.git
				synced 2025-10-31 00:03:58 +01:00 
			
		
		
		
	Upgrade CakePHP from 2.2.5 to 2.9.5
This commit is contained in:
		
							parent
							
								
									5a580df460
								
							
						
					
					
						commit
						235a541597
					
				
					 793 changed files with 60746 additions and 23753 deletions
				
			
		|  | @ -2,19 +2,18 @@ | |||
| /** | ||||
|  * MediaViewTest file | ||||
|  * | ||||
|  * PHP 5 | ||||
|  * | ||||
|  * CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html> | ||||
|  * Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org) | ||||
|  * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) | ||||
|  * | ||||
|  * Licensed under The MIT License | ||||
|  * For full copyright and license information, please see the LICENSE.txt | ||||
|  * Redistributions of files must retain the above copyright notice | ||||
|  * | ||||
|  * @copyright     Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org) | ||||
|  * @copyright     Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) | ||||
|  * @link          http://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests | ||||
|  * @package       Cake.Test.Case.View | ||||
|  * @since         CakePHP(tm) v 1.2.0.4206 | ||||
|  * @license       MIT License (http://www.opensource.org/licenses/mit-license.php) | ||||
|  * @license       http://www.opensource.org/licenses/mit-license.php MIT License | ||||
|  */ | ||||
| 
 | ||||
| App::uses('Controller', 'Controller'); | ||||
|  | @ -35,11 +34,15 @@ class MediaViewTest extends CakeTestCase { | |||
|  */ | ||||
| 	public function setUp() { | ||||
| 		parent::setUp(); | ||||
| 		$this->MediaView = $this->getMock('MediaView', array('_isActive', '_clearBuffer', '_flushBuffer')); | ||||
| 		$this->MediaView->response = $this->getMock( | ||||
| 			'CakeResponse', | ||||
| 			array('send', 'cache', 'type', 'download', 'statusCode') | ||||
| 		); | ||||
| 		$this->MediaView = new MediaView(); | ||||
| 		$this->MediaView->response = $this->getMock('CakeResponse', array( | ||||
| 			'cache', | ||||
| 			'type', | ||||
| 			'disableCache', | ||||
| 			'file', | ||||
| 			'send', | ||||
| 			'compress', | ||||
| 		)); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  | @ -52,279 +55,64 @@ class MediaViewTest extends CakeTestCase { | |||
| 		unset($this->MediaView); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * tests that rendering a file that does not exists throws an exception | ||||
|  * | ||||
|  * @expectedException NotFoundException | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testRenderNotFound() { | ||||
| 		$this->MediaView->viewVars = array( | ||||
| 			'path' => '/some/missing/folder', | ||||
| 			'id' => 'file.jpg' | ||||
| 		); | ||||
| 		$this->MediaView->render(); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * testRender method | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testRender() { | ||||
| 		$this->MediaView->viewVars = array( | ||||
| 		$vars = array( | ||||
| 			'path' => CAKE . 'Test' . DS . 'test_app' . DS . 'Vendor' . DS . 'css' . DS, | ||||
| 			'id' => 'test_asset.css' | ||||
| 		); | ||||
| 		$this->MediaView->viewVars = $vars; | ||||
| 
 | ||||
| 		$this->MediaView->response->expects($this->once()) | ||||
| 			->method('disableCache'); | ||||
| 
 | ||||
| 		$this->MediaView->response->expects($this->once()) | ||||
| 			->method('file') | ||||
| 			->with( | ||||
| 				$vars['path'] . $vars['id'], | ||||
| 				array('name' => null, 'download' => null) | ||||
| 			); | ||||
| 
 | ||||
| 		$this->MediaView->render(); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * Test render() when caching is on. | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testRenderCachingAndName() { | ||||
| 		$vars = array( | ||||
| 			'path' => CAKE . 'Test' . DS . 'test_app' . DS . 'Vendor' . DS . 'css' . DS, | ||||
| 			'id' => 'test_asset.css', | ||||
| 			'extension' => 'css', | ||||
| 			'cache' => '+1 day', | ||||
| 			'name' => 'something_special', | ||||
| 			'download' => true, | ||||
| 		); | ||||
| 		$this->MediaView->expects($this->exactly(2)) | ||||
| 			->method('_isActive') | ||||
| 			->will($this->returnValue(true)); | ||||
| 
 | ||||
| 		$this->MediaView->response->expects($this->exactly(1)) | ||||
| 			->method('type') | ||||
| 			->with('css') | ||||
| 			->will($this->returnArgument(0)); | ||||
| 
 | ||||
| 		$this->MediaView->response->expects($this->once())->method('send'); | ||||
| 		$this->MediaView->expects($this->once())->method('_clearBuffer'); | ||||
| 		$this->MediaView->expects($this->once())->method('_flushBuffer'); | ||||
| 
 | ||||
| 		ob_start(); | ||||
| 		$result = $this->MediaView->render(); | ||||
| 		$output = ob_get_clean(); | ||||
| 		$this->assertEquals('this is the test asset css file', $output); | ||||
| 		$this->assertTrue($result !== false); | ||||
| 
 | ||||
| 		$headers = $this->MediaView->response->header(); | ||||
| 		$this->assertEquals(31, $headers['Content-Length']); | ||||
| 		$this->assertEquals(0, $headers['Expires']); | ||||
| 		$this->assertEquals( | ||||
| 			'private, must-revalidate, post-check=0, pre-check=0', | ||||
| 			$headers['Cache-Control'] | ||||
| 		); | ||||
| 		$this->assertEquals('no-cache', $headers['Pragma']); | ||||
| 		$this->assertContains(gmdate('D, d M Y H:i', time()), $headers['Date']); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * testRenderWithUnknownFileTypeGeneric method | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testRenderWithUnknownFileTypeGeneric() { | ||||
| 		$currentUserAgent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : null; | ||||
| 		$_SERVER['HTTP_USER_AGENT'] = 'Some generic browser'; | ||||
| 		$this->MediaView->viewVars = array( | ||||
| 			'path' => CAKE . 'Test' . DS . 'test_app' . DS . 'Config' . DS, | ||||
| 			'id' => 'no_section.ini', | ||||
| 			'extension' => 'ini', | ||||
| 		); | ||||
| 		$this->MediaView->expects($this->exactly(2)) | ||||
| 			->method('_isActive') | ||||
| 			->will($this->returnValue(true)); | ||||
| 
 | ||||
| 		$this->MediaView->response->expects($this->exactly(1)) | ||||
| 			->method('type') | ||||
| 			->with('ini') | ||||
| 			->will($this->returnValue(false)); | ||||
| 
 | ||||
| 		$this->MediaView->response->expects($this->once()) | ||||
| 			->method('download') | ||||
| 			->with('no_section.ini'); | ||||
| 
 | ||||
| 		$this->MediaView->response->expects($this->once())->method('send'); | ||||
| 		$this->MediaView->expects($this->once())->method('_clearBuffer'); | ||||
| 		$this->MediaView->expects($this->once())->method('_flushBuffer'); | ||||
| 
 | ||||
| 		ob_start(); | ||||
| 		$result = $this->MediaView->render(); | ||||
| 		$output = ob_get_clean(); | ||||
| 		$this->assertEquals("some_key = some_value\nbool_key = 1\n", $output); | ||||
| 		$this->assertTrue($result !== false); | ||||
| 		if ($currentUserAgent !== null) { | ||||
| 			$_SERVER['HTTP_USER_AGENT'] = $currentUserAgent; | ||||
| 		} | ||||
| 
 | ||||
| 		$headers = $this->MediaView->response->header(); | ||||
| 		$this->assertEquals(35, $headers['Content-Length']); | ||||
| 		$this->assertEquals(0, $headers['Expires']); | ||||
| 		$this->assertEquals('bytes', $headers['Accept-Ranges']); | ||||
| 		$this->assertEquals( | ||||
| 			'private, must-revalidate, post-check=0, pre-check=0', | ||||
| 			$headers['Cache-Control'] | ||||
| 		); | ||||
| 		$this->assertEquals('no-cache', $headers['Pragma']); | ||||
| 		$this->assertContains(gmdate('D, d M Y H:i', time()), $headers['Date']); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * testRenderWithUnknownFileTypeOpera method | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testRenderWithUnknownFileTypeOpera() { | ||||
| 		$currentUserAgent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : null; | ||||
| 		$_SERVER['HTTP_USER_AGENT'] = 'Opera/9.80 (Windows NT 6.0; U; en) Presto/2.8.99 Version/11.10'; | ||||
| 		$this->MediaView->viewVars = array( | ||||
| 			'path' => CAKE . 'Test' . DS . 'test_app' . DS . 'Config' . DS, | ||||
| 			'id' => 'no_section.ini', | ||||
| 			'extension' => 'ini', | ||||
| 		); | ||||
| 		$this->MediaView->expects($this->exactly(2)) | ||||
| 			->method('_isActive') | ||||
| 			->will($this->returnValue(true)); | ||||
| 
 | ||||
| 		$this->MediaView->response->expects($this->at(0)) | ||||
| 			->method('type') | ||||
| 			->with('ini') | ||||
| 			->will($this->returnValue(false)); | ||||
| 
 | ||||
| 		$this->MediaView->response->expects($this->at(1)) | ||||
| 			->method('type') | ||||
| 			->with('application/octetstream') | ||||
| 			->will($this->returnValue(false)); | ||||
| 
 | ||||
| 		$this->MediaView->response->expects($this->once()) | ||||
| 			->method('download') | ||||
| 			->with('no_section.ini'); | ||||
| 
 | ||||
| 		$this->MediaView->response->expects($this->once())->method('send'); | ||||
| 		$this->MediaView->expects($this->once())->method('_clearBuffer'); | ||||
| 		$this->MediaView->expects($this->once())->method('_flushBuffer'); | ||||
| 
 | ||||
| 		ob_start(); | ||||
| 		$result = $this->MediaView->render(); | ||||
| 		$output = ob_get_clean(); | ||||
| 		$this->assertEquals("some_key = some_value\nbool_key = 1\n", $output); | ||||
| 		$this->assertTrue($result !== false); | ||||
| 		if ($currentUserAgent !== null) { | ||||
| 			$_SERVER['HTTP_USER_AGENT'] = $currentUserAgent; | ||||
| 		} | ||||
| 
 | ||||
| 		$headers = $this->MediaView->response->header(); | ||||
| 		$this->assertEquals(35, $headers['Content-Length']); | ||||
| 		$this->assertEquals(0, $headers['Expires']); | ||||
| 		$this->assertEquals('bytes', $headers['Accept-Ranges']); | ||||
| 		$this->assertEquals( | ||||
| 			'private, must-revalidate, post-check=0, pre-check=0', | ||||
| 			$headers['Cache-Control'] | ||||
| 		); | ||||
| 		$this->assertEquals('no-cache', $headers['Pragma']); | ||||
| 		$this->assertContains(gmdate('D, d M Y H:i', time()), $headers['Date']); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * testRenderWithUnknownFileTypeIE method | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testRenderWithUnknownFileTypeIE() { | ||||
| 		$currentUserAgent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : null; | ||||
| 		$_SERVER['HTTP_USER_AGENT'] = 'Mozilla/5.0 (compatible; MSIE 8.0; Windows NT 5.2; Trident/4.0; Media Center PC 4.0; SLCC1; .NET CLR 3.0.04320)'; | ||||
| 		$this->MediaView->viewVars = array( | ||||
| 			'path' => CAKE . 'Test' . DS . 'test_app' . DS . 'Config' . DS, | ||||
| 			'id' => 'no_section.ini', | ||||
| 			'extension' => 'ini', | ||||
| 			'name' => 'config' | ||||
| 		); | ||||
| 		$this->MediaView->expects($this->exactly(2)) | ||||
| 			->method('_isActive') | ||||
| 			->will($this->returnValue(true)); | ||||
| 
 | ||||
| 		$this->MediaView->response->expects($this->at(0)) | ||||
| 			->method('type') | ||||
| 			->with('ini') | ||||
| 			->will($this->returnValue(false)); | ||||
| 
 | ||||
| 		$this->MediaView->response->expects($this->at(1)) | ||||
| 			->method('type') | ||||
| 			->with('application/force-download') | ||||
| 			->will($this->returnValue(false)); | ||||
| 
 | ||||
| 		$this->MediaView->response->expects($this->once()) | ||||
| 			->method('download') | ||||
| 			->with('config.ini'); | ||||
| 
 | ||||
| 		$this->MediaView->response->expects($this->once())->method('send'); | ||||
| 		$this->MediaView->expects($this->once())->method('_clearBuffer'); | ||||
| 		$this->MediaView->expects($this->once())->method('_flushBuffer'); | ||||
| 
 | ||||
| 		ob_start(); | ||||
| 		$result = $this->MediaView->render(); | ||||
| 		$output = ob_get_clean(); | ||||
| 		$this->assertEquals("some_key = some_value\nbool_key = 1\n", $output); | ||||
| 		$this->assertTrue($result !== false); | ||||
| 		if ($currentUserAgent !== null) { | ||||
| 			$_SERVER['HTTP_USER_AGENT'] = $currentUserAgent; | ||||
| 		} | ||||
| 
 | ||||
| 		$headers = $this->MediaView->response->header(); | ||||
| 		$this->assertEquals(35, $headers['Content-Length']); | ||||
| 		$this->assertEquals(0, $headers['Expires']); | ||||
| 		$this->assertEquals('bytes', $headers['Accept-Ranges']); | ||||
| 		$this->assertEquals( | ||||
| 			'private, must-revalidate, post-check=0, pre-check=0', | ||||
| 			$headers['Cache-Control'] | ||||
| 		); | ||||
| 		$this->assertEquals('no-cache', $headers['Pragma']); | ||||
| 		$this->assertContains(gmdate('D, d M Y H:i', time()), $headers['Date']); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * testConnectionAborted method | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testConnectionAborted() { | ||||
| 		$this->MediaView->viewVars = array( | ||||
| 			'path' => CAKE . 'Test' . DS . 'test_app' . DS . 'Vendor' . DS . 'css' . DS, | ||||
| 			'id' => 'test_asset.css', | ||||
| 			'extension' => 'css', | ||||
| 		); | ||||
| 
 | ||||
| 		$this->MediaView->expects($this->once()) | ||||
| 			->method('_isActive') | ||||
| 			->will($this->returnValue(false)); | ||||
| 		$this->MediaView->viewVars = $vars; | ||||
| 
 | ||||
| 		$this->MediaView->response->expects($this->never()) | ||||
| 			->method('type'); | ||||
| 			->method('disableCache'); | ||||
| 
 | ||||
| 		$result = $this->MediaView->render(); | ||||
| 		$this->assertFalse($result); | ||||
| 	} | ||||
| 		$this->MediaView->response->expects($this->once()) | ||||
| 			->method('cache') | ||||
| 			->with($this->anything(), $vars['cache']); | ||||
| 
 | ||||
| /** | ||||
|  * testConnectionAbortedOnBuffering method | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testConnectionAbortedOnBuffering() { | ||||
| 		$this->MediaView->viewVars = array( | ||||
| 			'path' => CAKE . 'Test' . DS . 'test_app' . DS . 'Vendor' . DS . 'css' . DS, | ||||
| 			'id' => 'test_asset.css', | ||||
| 			'extension' => 'css', | ||||
| 		); | ||||
| 		$this->MediaView->response->expects($this->once()) | ||||
| 			->method('file') | ||||
| 			->with( | ||||
| 				$vars['path'] . $vars['id'], | ||||
| 				array( | ||||
| 					'name' => 'something_special.css', | ||||
| 					'download' => true | ||||
| 				) | ||||
| 			); | ||||
| 
 | ||||
| 		$this->MediaView->expects($this->at(0)) | ||||
| 			->method('_isActive') | ||||
| 			->will($this->returnValue(true)); | ||||
| 
 | ||||
| 		$this->MediaView->response->expects($this->any()) | ||||
| 			->method('type') | ||||
| 			->with('css') | ||||
| 			->will($this->returnArgument(0)); | ||||
| 
 | ||||
| 		$this->MediaView->expects($this->at(1)) | ||||
| 			->method('_isActive') | ||||
| 			->will($this->returnValue(false)); | ||||
| 
 | ||||
| 		$this->MediaView->response->expects($this->once())->method('send'); | ||||
| 		$this->MediaView->expects($this->once())->method('_clearBuffer'); | ||||
| 		$this->MediaView->expects($this->never())->method('_flushBuffer'); | ||||
| 
 | ||||
| 		$result = $this->MediaView->render(); | ||||
| 		$this->assertFalse($result); | ||||
| 		$this->MediaView->render(); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  | @ -335,8 +123,7 @@ class MediaViewTest extends CakeTestCase { | |||
| 	public function testRenderUpperExtension() { | ||||
| 		$this->MediaView->viewVars = array( | ||||
| 			'path' => CAKE . 'Test' . DS . 'test_app' . DS . 'Vendor' . DS . 'img' . DS, | ||||
| 			'id' => 'test_2.JPG', | ||||
| 			'extension' => 'JPG', | ||||
| 			'id' => 'test_2.JPG' | ||||
| 		); | ||||
| 
 | ||||
| 		$this->MediaView->response->expects($this->any()) | ||||
|  | @ -344,33 +131,6 @@ class MediaViewTest extends CakeTestCase { | |||
| 			->with('jpg') | ||||
| 			->will($this->returnArgument(0)); | ||||
| 
 | ||||
| 		$this->MediaView->expects($this->at(0)) | ||||
| 			->method('_isActive') | ||||
| 			->will($this->returnValue(true)); | ||||
| 
 | ||||
| 		$this->MediaView->render(); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * Test downloading files with extension not explicitly set. | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testRenderExtensionNotSet() { | ||||
| 		$this->MediaView->viewVars = array( | ||||
| 			'path' => CAKE . 'Test' . DS . 'test_app' . DS . 'Vendor' . DS . 'img' . DS, | ||||
| 			'id' => 'test_2.JPG', | ||||
| 		); | ||||
| 
 | ||||
| 		$this->MediaView->response->expects($this->any()) | ||||
| 			->method('type') | ||||
| 			->with('jpg') | ||||
| 			->will($this->returnArgument(0)); | ||||
| 
 | ||||
| 		$this->MediaView->expects($this->at(0)) | ||||
| 			->method('_isActive') | ||||
| 			->will($this->returnValue(true)); | ||||
| 
 | ||||
| 		$this->MediaView->render(); | ||||
| 	} | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Brm Ko
						Brm Ko