ソースを参照

Fixed the tests to run in Windows and different browsers.

Juan Basso 15 年 前
コミット
43a95a79fc

+ 1 - 1
lib/Cake/tests/Case/Cache/Engine/FileEngineTest.php

@@ -257,7 +257,7 @@ class FileEngineTest extends CakeTestCase {
 		$result = Cache::read('views.countries.something', 'file_test');
 		$this->assertEqual($result, 'here');
 
-		$result = Cache::clear();
+		$result = Cache::clear(false, 'file_test');
 		$this->assertTrue($result);
 	}
 

+ 3 - 3
lib/Cake/tests/Case/Core/AppTest.php

@@ -183,13 +183,13 @@ class AppImportTest extends CakeTestCase {
 		$this->assertEqual(array(LIBS . 'Controller' . DS), $controller);
 
 		$component = App::core('Controller/Component');
-		$this->assertEqual(array(LIBS . 'Controller' . DS . 'Component' . DS), $component);
+		$this->assertEqual(array(LIBS . 'Controller' . DS . 'Component' . DS), str_replace('/', DS, $component));
 
 		$auth = App::core('Controller/Component/Auth');
-		$this->assertEqual(array(LIBS . 'Controller' . DS . 'Component' . DS . 'Auth' . DS), $auth);
+		$this->assertEqual(array(LIBS . 'Controller' . DS . 'Component' . DS . 'Auth' . DS), str_replace('/', DS, $auth));
 
 		$datasource = App::core('Model/Datasource');
-		$this->assertEqual(array(LIBS . 'Model' . DS . 'Datasource' . DS), $datasource);
+		$this->assertEqual(array(LIBS . 'Model' . DS . 'Datasource' . DS), str_replace('/', DS, $datasource));
 	}
 
 /**

+ 2 - 2
lib/Cake/tests/Case/Error/ErrorHandlerTest.php

@@ -147,7 +147,7 @@ class ErrorHandlerTest extends CakeTestCase {
 		$result = file(LOGS . 'debug.log');
 		$this->assertEqual(count($result), 1);
 		$this->assertPattern(
-			'/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2} Notice: Notice \(8\): Undefined variable:\s+out in \[.+ line \d+\]$/',
+			'/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2} (Notice|Debug): Notice \(8\): Undefined variable:\s+out in \[.+ line \d+\]$/',
 			$result[0]
 		);
 		@unlink(LOGS . 'debug.log');
@@ -172,7 +172,7 @@ class ErrorHandlerTest extends CakeTestCase {
 
 		$result = file(LOGS . 'debug.log');
 		$this->assertPattern(
-			'/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2} Notice: Notice \(8\): Undefined variable:\s+out in \[.+ line \d+\]$/',
+			'/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2} (Notice|Debug): Notice \(8\): Undefined variable:\s+out in \[.+ line \d+\]$/',
 			$result[0]
 		);
 		$this->assertPattern('/^Trace:/', $result[1]);

+ 2 - 0
lib/Cake/tests/Case/Model/Datasource/Database/MysqlTest.php

@@ -147,6 +147,8 @@ class DboMysqlTest extends CakeTestCase {
  * @return void
  */
 	function testLocalizedFloats() {
+		$this->skipIf(DS === '\\', 'The locale is not supported in Windows and affect the others tests.');
+
 		$restore = setlocale(LC_ALL, null);
 		setlocale(LC_ALL, 'de_DE');
 

+ 9 - 1
lib/Cake/tests/Case/Network/CakeRequestTest.php

@@ -33,6 +33,11 @@ class CakeRequestTestCase extends CakeTestCase {
 		$this->_post = $_POST;
 		$this->_files = $_FILES;
 		$this->_app = Configure::read('App');
+		$this->_case = null;
+		if (isset($_GET['case'])) {
+			$this->_case = $_GET['case'];
+			unset($_GET['case']);
+		}
 
 		Configure::write('App.baseUrl', false);
 	}
@@ -48,6 +53,9 @@ class CakeRequestTestCase extends CakeTestCase {
 		$_GET = $this->_get;
 		$_POST = $this->_post;
 		$_FILES = $this->_files;
+		if (!empty($this->_case)) {
+			$_GET['case'] = $this->_case;
+		}
 		Configure::write('App', $this->_app);
 	}
 
@@ -1173,7 +1181,7 @@ class CakeRequestTestCase extends CakeTestCase {
 				),
 			),
 			array(
-				'Apache - No rewrite, document root set above top level cake dir, reques root, no PATH_INFO',
+				'Apache - No rewrite, document root set above top level cake dir, request root, no PATH_INFO',
 				array(
 					'App' => array(
 						'base' => false, 

+ 1 - 1
lib/Cake/tests/Case/Utility/DebuggerTest.php

@@ -171,7 +171,7 @@ class DebuggerTest extends CakeTestCase {
 			               '&line={:line}">{:path}</a>, line {:line}'
 		));
 		$result = Debugger::trace();
-		$this->assertPattern('/' . preg_quote('txmt://open?url=file:///', '/') . '/', $result);
+		$this->assertPattern('/' . preg_quote('txmt://open?url=file://', '/') . '(\/|[A-Z]:\\\\)' . '/', $result);
 
 		Debugger::output('xml', array(
 			'error' => '<error><code>{:code}</code><file>{:file}</file><line>{:line}</line>' .

+ 131 - 2
lib/Cake/tests/Case/View/MediaViewTest.php

@@ -111,12 +111,14 @@ class MediaViewTest extends CakeTestCase {
 	}
 
 /**
- * testRenderWithUnknownFileType method
+ * testRenderWithUnknownFileTypeGeneric method
  *
  * @access public
  * @return void
  */
-	function testRenderWithUnknownFileType() {
+	function testRenderWithUnknownFileTypeGeneric() {
+		$currentUserAgent = $_SERVER['HTTP_USER_AGENT'];
+		$_SERVER['HTTP_USER_AGENT'] = 'Some generic browser';
 		$this->MediaView->viewVars = array(
 			'path' =>  LIBS . 'tests' . DS . 'test_app' . DS . 'config' . DS,
 			'id' => 'no_section.ini',
@@ -163,6 +165,133 @@ class MediaViewTest extends CakeTestCase {
 		$output = ob_get_clean();
 		$this->assertEqual("some_key = some_value\nbool_key = 1\n", $output);
 		$this->assertTrue($result !== false);
+		$_SERVER['HTTP_USER_AGENT'] = $currentUserAgent;
+	}
+
+/**
+ * testRenderWithUnknownFileTypeOpera method
+ *
+ * @access public
+ * @return void
+ */
+	function testRenderWithUnknownFileTypeOpera() {
+		$currentUserAgent = $_SERVER['HTTP_USER_AGENT'];
+		$_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' =>  LIBS . 'tests' . 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('header')
+			->with(array(
+				'Date' => gmdate('D, d M Y H:i:s', time()) . ' GMT',
+				'Expires' => '0',
+				'Cache-Control' => 'private, must-revalidate, post-check=0, pre-check=0',
+				'Pragma' => 'no-cache'
+			));
+
+		$this->MediaView->response->expects($this->at(2))
+			->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->at(4))
+			->method('header')
+			->with(array(
+				'Accept-Ranges' => 'bytes'
+			));
+
+		$this->MediaView->response->expects($this->at(5))
+			->method('header')
+			->with('Content-Length', 35);
+
+		$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->assertEqual("some_key = some_value\nbool_key = 1\n", $output);
+		$this->assertTrue($result !== false);
+		$_SERVER['HTTP_USER_AGENT'] = $currentUserAgent;
+	}
+
+/**
+ * testRenderWithUnknownFileTypeIE method
+ *
+ * @access public
+ * @return void
+ */
+	function testRenderWithUnknownFileTypeIE() {
+		$currentUserAgent = $_SERVER['HTTP_USER_AGENT'];
+		$_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' =>  LIBS . 'tests' . 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('header')
+			->with(array(
+				'Date' => gmdate('D, d M Y H:i:s', time()) . ' GMT',
+				'Expires' => '0',
+				'Cache-Control' => 'private, must-revalidate, post-check=0, pre-check=0',
+				'Pragma' => 'no-cache'
+			));
+
+		$this->MediaView->response->expects($this->at(2))
+			->method('type')
+			->with('application/force-download')
+			->will($this->returnValue(false));
+
+		$this->MediaView->response->expects($this->once())
+			->method('download')
+			->with('no_section.ini');
+
+		$this->MediaView->response->expects($this->at(4))
+			->method('header')
+			->with(array(
+				'Accept-Ranges' => 'bytes'
+			));
+
+		$this->MediaView->response->expects($this->at(5))
+			->method('header')
+			->with('Content-Length', 35);
+
+		$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->assertEqual("some_key = some_value\nbool_key = 1\n", $output);
+		$this->assertTrue($result !== false);
+		$_SERVER['HTTP_USER_AGENT'] = $currentUserAgent;
 	}
 
 /**