Completed
Push — scrutinizer ( 84e9d0...6a9613 )
by Fabio
22:48
created
tests/unit/Web/TAssetManagerTest.php 4 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -46,6 +46,9 @@
 block discarded – undo
46 46
 
47 47
 	}
48 48
 
49
+	/**
50
+	 * @param string $dir
51
+	 */
49 52
 	private function removeDirectory ($dir) {
50 53
 	  // Let's be sure $dir is a directory to avoir any error. Clear the cache !
51 54
 	  clearstatcache();
Please login to merge, or discard this patch.
Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -33,14 +33,14 @@  discard block
 block discarded – undo
33 33
 
34 34
 		if (self::$assetDir===null) self::$assetDir= dirname(__FILE__).'/assets';
35 35
 		// Make asset directory if not exists
36
-	    if (!file_exists (self::$assetDir)) {
37
-    		if (is_writable(dirname(self::$assetDir)))
38
-    		  mkdir (self::$assetDir) ;
39
-    		else
40
-    		  throw new Exception ('Directory '.dirname(self::$assetDir).' is not writable');
41
-	    } elseif (!is_dir (self::$assetDir)) {
42
-	       throw new Exception (self::$assetDir.' exists and is not a directory');
43
-	    }
36
+		if (!file_exists (self::$assetDir)) {
37
+			if (is_writable(dirname(self::$assetDir)))
38
+			  mkdir (self::$assetDir) ;
39
+			else
40
+			  throw new Exception ('Directory '.dirname(self::$assetDir).' is not writable');
41
+		} elseif (!is_dir (self::$assetDir)) {
42
+		   throw new Exception (self::$assetDir.' exists and is not a directory');
43
+		}
44 44
 		// Define an alias to asset directory
45 45
 		prado::setPathofAlias('AssetAlias', self::$assetDir);
46 46
 
@@ -50,22 +50,22 @@  discard block
 block discarded – undo
50 50
 	  // Let's be sure $dir is a directory to avoir any error. Clear the cache !
51 51
 	  clearstatcache();
52 52
 	  if (is_dir($dir)) {
53
-	    foreach (scandir($dir) as $content) {
54
-	      if ($content==='.' or $content==='..') continue; // skip . and ..
55
-	      $content=$dir.'/'.$content;
56
-	      if (is_dir($content))
57
-	        $this->removeDirectory ($content); // Recursivly remove directories
58
-	      else
59
-	        unlink ($content); // Remove file
60
-	    }
61
-	    // Now, directory should be empty, remove it
62
-	    rmdir ($dir);
53
+		foreach (scandir($dir) as $content) {
54
+		  if ($content==='.' or $content==='..') continue; // skip . and ..
55
+		  $content=$dir.'/'.$content;
56
+		  if (is_dir($content))
57
+			$this->removeDirectory ($content); // Recursivly remove directories
58
+		  else
59
+			unlink ($content); // Remove file
60
+		}
61
+		// Now, directory should be empty, remove it
62
+		rmdir ($dir);
63 63
 	  }
64 64
 	}
65 65
 
66 66
 	public function tearDown () {
67 67
 		// Make some cleaning :)
68
-	    $this->removeDirectory(self::$assetDir);
68
+		$this->removeDirectory(self::$assetDir);
69 69
 	}
70 70
 
71 71
 	public function testInit() {
@@ -126,27 +126,27 @@  discard block
 block discarded – undo
126 126
 		$manager->init (null);
127 127
 
128 128
 		// Try to publish a single file
129
-	    $fileToPublish=dirname(__FILE__).'/data/pradoheader.gif';
129
+		$fileToPublish=dirname(__FILE__).'/data/pradoheader.gif';
130 130
 		$publishedUrl = $manager->publishFilePath($fileToPublish);
131 131
 		$publishedFile=self::$assetDir.$publishedUrl;
132 132
 		self::assertEquals($publishedFile, $manager->getPublishedPath($fileToPublish));
133 133
 		self::assertEquals($publishedUrl, $manager->getPublishedUrl($fileToPublish));
134 134
 		self::assertTrue(is_file($publishedFile));
135 135
 
136
-	    //  try to publish invalid file
137
-	    try {
138
-	      $manager->publishFilePath('invalid_file');
139
-	      self::fail('Expected TInvalidDataValueException not thrown');
140
-	    } catch (TInvalidDataValueException $e) {}
136
+		//  try to publish invalid file
137
+		try {
138
+		  $manager->publishFilePath('invalid_file');
139
+		  self::fail('Expected TInvalidDataValueException not thrown');
140
+		} catch (TInvalidDataValueException $e) {}
141 141
 	}
142 142
 
143 143
 	public function testPublishFilePathWithDirectory () {
144
-	    $manager=new TAssetManager();
144
+		$manager=new TAssetManager();
145 145
 		$manager->setBaseUrl('/');
146 146
 		$manager->init (null);
147 147
 
148 148
 		// Try to publish a directory
149
-	    $dirToPublish=dirname(__FILE__).'/data';
149
+		$dirToPublish=dirname(__FILE__).'/data';
150 150
 		$publishedUrl = $manager->publishFilePath($dirToPublish);
151 151
 		$publishedDir=self::$assetDir.$publishedUrl;
152 152
 		self::assertEquals($publishedDir, $manager->getPublishedPath($dirToPublish));
@@ -165,17 +165,17 @@  discard block
 block discarded – undo
165 165
 		$md5File=dirname(__FILE__).'/data/aTarFile.md5';
166 166
 
167 167
 		// First, try with bad md5
168
-	    try {
169
-	      $manager->publishTarFile($tarFile, 'badMd5File');
170
-	      self::fail('Expected TInvalidDataValueException not thrown');
171
-	    } catch (TInvalidDataValueException $e) {}
172
-
173
-	    // Then, try with real md5 file
174
-	    $publishedUrl=$manager->publishTarFile($tarFile, $md5File);
175
-	    $publishedDir=self::$assetDir.$publishedUrl;
176
-	    self::assertTrue(is_dir($publishedDir));
177
-	    self::assertTrue(is_file($publishedDir.'/pradoheader.gif'));
178
-	    self::assertTrue(is_file($publishedDir.'/aTarFile.md5'));
168
+		try {
169
+		  $manager->publishTarFile($tarFile, 'badMd5File');
170
+		  self::fail('Expected TInvalidDataValueException not thrown');
171
+		} catch (TInvalidDataValueException $e) {}
172
+
173
+		// Then, try with real md5 file
174
+		$publishedUrl=$manager->publishTarFile($tarFile, $md5File);
175
+		$publishedDir=self::$assetDir.$publishedUrl;
176
+		self::assertTrue(is_dir($publishedDir));
177
+		self::assertTrue(is_file($publishedDir.'/pradoheader.gif'));
178
+		self::assertTrue(is_file($publishedDir.'/aTarFile.md5'));
179 179
 
180 180
 	}
181 181
 }
182 182
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
 	public static $app = null;
11 11
 	public static $assetDir = null;
12 12
 
13
-	public function setUp () {
13
+	public function setUp() {
14 14
 		// Fake environment variables needed to determine path
15 15
 		$_SERVER['HTTP_HOST'] = 'localhost';
16 16
 		$_SERVER['SERVER_NAME'] = 'localhost';
@@ -27,66 +27,66 @@  discard block
 block discarded – undo
27 27
 		$_SERVER['HTTP_USER_AGENT'] = 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.3) Gecko/20070309 Firefox/2.0.0.3';
28 28
 		$_SERVER['REMOTE_HOST'] = 'localhost';
29 29
 
30
-		if (self::$app===null) {
31
-			self::$app=new TApplication(dirname(__FILE__).'/app');
30
+		if (self::$app === null) {
31
+			self::$app = new TApplication(dirname(__FILE__) . '/app');
32 32
 		}
33 33
 
34
-		if (self::$assetDir===null) self::$assetDir= dirname(__FILE__).'/assets';
34
+		if (self::$assetDir === null) self::$assetDir = dirname(__FILE__) . '/assets';
35 35
 		// Make asset directory if not exists
36
-	    if (!file_exists (self::$assetDir)) {
36
+	    if (!file_exists(self::$assetDir)) {
37 37
     		if (is_writable(dirname(self::$assetDir)))
38
-    		  mkdir (self::$assetDir) ;
38
+    		  mkdir(self::$assetDir);
39 39
     		else
40
-    		  throw new Exception ('Directory '.dirname(self::$assetDir).' is not writable');
41
-	    } elseif (!is_dir (self::$assetDir)) {
42
-	       throw new Exception (self::$assetDir.' exists and is not a directory');
40
+    		  throw new Exception('Directory ' . dirname(self::$assetDir) . ' is not writable');
41
+	    } elseif (!is_dir(self::$assetDir)) {
42
+	       throw new Exception(self::$assetDir . ' exists and is not a directory');
43 43
 	    }
44 44
 		// Define an alias to asset directory
45 45
 		prado::setPathofAlias('AssetAlias', self::$assetDir);
46 46
 
47 47
 	}
48 48
 
49
-	private function removeDirectory ($dir) {
49
+	private function removeDirectory($dir) {
50 50
 	  // Let's be sure $dir is a directory to avoir any error. Clear the cache !
51 51
 	  clearstatcache();
52 52
 	  if (is_dir($dir)) {
53 53
 	    foreach (scandir($dir) as $content) {
54
-	      if ($content==='.' or $content==='..') continue; // skip . and ..
55
-	      $content=$dir.'/'.$content;
54
+	      if ($content === '.' or $content === '..') continue; // skip . and ..
55
+	      $content = $dir . '/' . $content;
56 56
 	      if (is_dir($content))
57
-	        $this->removeDirectory ($content); // Recursivly remove directories
57
+	        $this->removeDirectory($content); // Recursivly remove directories
58 58
 	      else
59
-	        unlink ($content); // Remove file
59
+	        unlink($content); // Remove file
60 60
 	    }
61 61
 	    // Now, directory should be empty, remove it
62
-	    rmdir ($dir);
62
+	    rmdir($dir);
63 63
 	  }
64 64
 	}
65 65
 
66
-	public function tearDown () {
66
+	public function tearDown() {
67 67
 		// Make some cleaning :)
68 68
 	    $this->removeDirectory(self::$assetDir);
69 69
 	}
70 70
 
71 71
 	public function testInit() {
72 72
 
73
-		$manager=new TAssetManager ();
73
+		$manager = new TAssetManager();
74 74
 
75
-		$manager->init (null);
75
+		$manager->init(null);
76 76
 
77 77
 		self::assertEquals(self::$assetDir, $manager->getBasePath());
78 78
 		self::assertEquals($manager, self::$app->getAssetManager());
79 79
 
80 80
 		// No, remove asset directory, and catch the exception
81
-		if (is_dir(self::$assetDir)) $this->removeDirectory (self::$assetDir);
81
+		if (is_dir(self::$assetDir)) $this->removeDirectory(self::$assetDir);
82 82
 		try {
83
-			$manager->init (null);
84
-			self::fail ('Expected TConfigurationException not thrown');
83
+			$manager->init(null);
84
+			self::fail('Expected TConfigurationException not thrown');
85 85
 		} catch (TConfigurationException $e) {}
86 86
 	}
87 87
 
88 88
 	public function testSetBasePath() {
89
-		$manager = new TAssetManager ();
89
+		$manager = new TAssetManager();
90 90
 		// First try, invalid directory
91 91
 		try {
92 92
 			$manager->setBasePath('invalid');
@@ -95,40 +95,40 @@  discard block
 block discarded – undo
95 95
 
96 96
 		// Next, standard asset directory, should work
97 97
 
98
-		$manager->setBasePath ('AssetAlias');
98
+		$manager->setBasePath('AssetAlias');
99 99
 		self::assertEquals(self::$assetDir, $manager->getBasePath());
100 100
 
101 101
 		// Finally, test to change after init
102
-		$manager->init (null);
102
+		$manager->init(null);
103 103
 		try {
104
-			$manager->setBasePath ('test');
105
-			self::fail ('Expected TInvalidOperationException not thrown');
104
+			$manager->setBasePath('test');
105
+			self::fail('Expected TInvalidOperationException not thrown');
106 106
 		} catch (TInvalidOperationException $e) {}
107 107
 
108 108
 	}
109 109
 
110 110
 	public function testSetBaseUrl() {
111
-		$manager=new TAssetManager ();
112
-		$manager->setBaseUrl ('/assets/');
111
+		$manager = new TAssetManager();
112
+		$manager->setBaseUrl('/assets/');
113 113
 		self::assertEquals("/assets", $manager->getBaseUrl());
114 114
 
115
-		$manager->init (null);
115
+		$manager->init(null);
116 116
 		try {
117
-			$manager->setBaseUrl ('/test');
118
-			self::fail ('Expected TInvalidOperationException not thrown');
117
+			$manager->setBaseUrl('/test');
118
+			self::fail('Expected TInvalidOperationException not thrown');
119 119
 		} catch (TInvalidOperationException $e) {}
120 120
 
121 121
 	}
122 122
 
123 123
 	public function testPublishFilePath() {
124
-		$manager=new TAssetManager();
124
+		$manager = new TAssetManager();
125 125
 		$manager->setBaseUrl('/');
126
-		$manager->init (null);
126
+		$manager->init(null);
127 127
 
128 128
 		// Try to publish a single file
129
-	    $fileToPublish=dirname(__FILE__).'/data/pradoheader.gif';
129
+	    $fileToPublish = dirname(__FILE__) . '/data/pradoheader.gif';
130 130
 		$publishedUrl = $manager->publishFilePath($fileToPublish);
131
-		$publishedFile=self::$assetDir.$publishedUrl;
131
+		$publishedFile = self::$assetDir . $publishedUrl;
132 132
 		self::assertEquals($publishedFile, $manager->getPublishedPath($fileToPublish));
133 133
 		self::assertEquals($publishedUrl, $manager->getPublishedUrl($fileToPublish));
134 134
 		self::assertTrue(is_file($publishedFile));
@@ -140,29 +140,29 @@  discard block
 block discarded – undo
140 140
 	    } catch (TInvalidDataValueException $e) {}
141 141
 	}
142 142
 
143
-	public function testPublishFilePathWithDirectory () {
144
-	    $manager=new TAssetManager();
143
+	public function testPublishFilePathWithDirectory() {
144
+	    $manager = new TAssetManager();
145 145
 		$manager->setBaseUrl('/');
146
-		$manager->init (null);
146
+		$manager->init(null);
147 147
 
148 148
 		// Try to publish a directory
149
-	    $dirToPublish=dirname(__FILE__).'/data';
149
+	    $dirToPublish = dirname(__FILE__) . '/data';
150 150
 		$publishedUrl = $manager->publishFilePath($dirToPublish);
151
-		$publishedDir=self::$assetDir.$publishedUrl;
151
+		$publishedDir = self::$assetDir . $publishedUrl;
152 152
 		self::assertEquals($publishedDir, $manager->getPublishedPath($dirToPublish));
153 153
 		self::assertEquals($publishedUrl, $manager->getPublishedUrl($dirToPublish));
154 154
 		self::assertTrue(is_dir($publishedDir));
155
-		self::assertTrue(is_file($publishedDir.'/pradoheader.gif'));
155
+		self::assertTrue(is_file($publishedDir . '/pradoheader.gif'));
156 156
 
157 157
 	}
158 158
 
159 159
 	public function testPublishTarFile() {
160
-		$manager=new TAssetManager();
160
+		$manager = new TAssetManager();
161 161
 		$manager->setBaseUrl('/');
162
-		$manager->init (null);
162
+		$manager->init(null);
163 163
 
164
-		$tarFile=dirname(__FILE__).'/data/aTarFile.tar';
165
-		$md5File=dirname(__FILE__).'/data/aTarFile.md5';
164
+		$tarFile = dirname(__FILE__) . '/data/aTarFile.tar';
165
+		$md5File = dirname(__FILE__) . '/data/aTarFile.md5';
166 166
 
167 167
 		// First, try with bad md5
168 168
 	    try {
@@ -171,11 +171,11 @@  discard block
 block discarded – undo
171 171
 	    } catch (TInvalidDataValueException $e) {}
172 172
 
173 173
 	    // Then, try with real md5 file
174
-	    $publishedUrl=$manager->publishTarFile($tarFile, $md5File);
175
-	    $publishedDir=self::$assetDir.$publishedUrl;
174
+	    $publishedUrl = $manager->publishTarFile($tarFile, $md5File);
175
+	    $publishedDir = self::$assetDir . $publishedUrl;
176 176
 	    self::assertTrue(is_dir($publishedDir));
177
-	    self::assertTrue(is_file($publishedDir.'/pradoheader.gif'));
178
-	    self::assertTrue(is_file($publishedDir.'/aTarFile.md5'));
177
+	    self::assertTrue(is_file($publishedDir . '/pradoheader.gif'));
178
+	    self::assertTrue(is_file($publishedDir . '/aTarFile.md5'));
179 179
 
180 180
 	}
181 181
 }
182 182
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +23 added lines, -11 removed lines patch added patch discarded remove patch
@@ -31,13 +31,16 @@  discard block
 block discarded – undo
31 31
 			self::$app=new TApplication(dirname(__FILE__).'/app');
32 32
 		}
33 33
 
34
-		if (self::$assetDir===null) self::$assetDir= dirname(__FILE__).'/assets';
34
+		if (self::$assetDir===null) {
35
+			self::$assetDir= dirname(__FILE__).'/assets';
36
+		}
35 37
 		// Make asset directory if not exists
36 38
 	    if (!file_exists (self::$assetDir)) {
37
-    		if (is_writable(dirname(self::$assetDir)))
38
-    		  mkdir (self::$assetDir) ;
39
-    		else
40
-    		  throw new Exception ('Directory '.dirname(self::$assetDir).' is not writable');
39
+    		if (is_writable(dirname(self::$assetDir))) {
40
+    		    		  mkdir (self::$assetDir) ;
41
+    		} else {
42
+    		    		  throw new Exception ('Directory '.dirname(self::$assetDir).' is not writable');
43
+    		}
41 44
 	    } elseif (!is_dir (self::$assetDir)) {
42 45
 	       throw new Exception (self::$assetDir.' exists and is not a directory');
43 46
 	    }
@@ -51,12 +54,19 @@  discard block
 block discarded – undo
51 54
 	  clearstatcache();
52 55
 	  if (is_dir($dir)) {
53 56
 	    foreach (scandir($dir) as $content) {
54
-	      if ($content==='.' or $content==='..') continue; // skip . and ..
57
+	      if ($content==='.' or $content==='..') {
58
+	      	continue;
59
+	      }
60
+	      // skip . and ..
55 61
 	      $content=$dir.'/'.$content;
56
-	      if (is_dir($content))
57
-	        $this->removeDirectory ($content); // Recursivly remove directories
58
-	      else
59
-	        unlink ($content); // Remove file
62
+	      if (is_dir($content)) {
63
+	      	        $this->removeDirectory ($content);
64
+	      }
65
+	      // Recursivly remove directories
66
+	      else {
67
+	      	        unlink ($content);
68
+	      }
69
+	      // Remove file
60 70
 	    }
61 71
 	    // Now, directory should be empty, remove it
62 72
 	    rmdir ($dir);
@@ -78,7 +88,9 @@  discard block
 block discarded – undo
78 88
 		self::assertEquals($manager, self::$app->getAssetManager());
79 89
 
80 90
 		// No, remove asset directory, and catch the exception
81
-		if (is_dir(self::$assetDir)) $this->removeDirectory (self::$assetDir);
91
+		if (is_dir(self::$assetDir)) {
92
+			$this->removeDirectory (self::$assetDir);
93
+		}
82 94
 		try {
83 95
 			$manager->init (null);
84 96
 			self::fail ('Expected TConfigurationException not thrown');
Please login to merge, or discard this patch.
tests/unit/Web/UI/THtmlWriterTest.php 3 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -21,6 +21,9 @@
 block discarded – undo
21 21
 	}
22 22
 
23 23
 
24
+	/**
25
+	 * @param string $str
26
+	 */
24 27
 	public function write($str)
25 28
 	{
26 29
 		$this->_str.=$str;
Please login to merge, or discard this patch.
Spacing   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -9,27 +9,27 @@  discard block
 block discarded – undo
9 9
 
10 10
 class TestWriter extends TComponent implements ITextWriter
11 11
 {
12
-	private $_str='';
13
-	private $_flushedContent=null;
12
+	private $_str = '';
13
+	private $_flushedContent = null;
14 14
 
15 15
 
16 16
 	public function flush()
17 17
 	{
18
-		$this->_flushedContent=$this->_str;
19
-		$this->_str='';
18
+		$this->_flushedContent = $this->_str;
19
+		$this->_str = '';
20 20
 		return $this->_flushedContent;
21 21
 	}
22 22
 
23 23
 
24 24
 	public function write($str)
25 25
 	{
26
-		$this->_str.=$str;
26
+		$this->_str .= $str;
27 27
 	}
28 28
 
29 29
 
30
-	public function writeLine($str='')
30
+	public function writeLine($str = '')
31 31
 	{
32
-		$this->write($str."\n");
32
+		$this->write($str . "\n");
33 33
 	}
34 34
 
35 35
 	// Accessors to get value of private vars during tests
@@ -43,120 +43,120 @@  discard block
 block discarded – undo
43 43
  */
44 44
 class THtmlWriterTest extends PHPUnit_Framework_TestCase {
45 45
 
46
-	private static $output=null;
46
+	private static $output = null;
47 47
 
48
-	public function setUp () {
48
+	public function setUp() {
49 49
 		// We need an output writer, use a TestWriter for this
50
-		if (self::$output===null) self::$output=new TestWriter();
50
+		if (self::$output === null) self::$output = new TestWriter();
51 51
 	}
52 52
 
53 53
 	public function testConstruct() {
54
-		$writer=new THtmlWriter(self::$output);
54
+		$writer = new THtmlWriter(self::$output);
55 55
 		self::assertEquals(self::$output, $writer->getWriter());
56 56
 	}
57 57
 
58 58
 	public function testSetAndGetWriter() {
59
-		$writer=new THtmlWriter(null);
59
+		$writer = new THtmlWriter(null);
60 60
 		self::assertNull($writer->getWriter());
61 61
 		$writer->setWriter(self::$output);
62 62
 		self::assertEquals(self::$output, $writer->getWriter());
63 63
 	}
64 64
 
65 65
 	public function testAddAttributes() {
66
-		$writer=new THtmlWriter(self::$output);
67
-		$writer->addAttributes(array ('type' => 'text', 'value' => 'Prado & Cie'));
66
+		$writer = new THtmlWriter(self::$output);
67
+		$writer->addAttributes(array('type' => 'text', 'value' => 'Prado & Cie'));
68 68
 		// get the private var _attributes
69
-		$result=self::readAttribute($writer, '_attributes');
70
-		self::assertEquals('text',$result['type']);
69
+		$result = self::readAttribute($writer, '_attributes');
70
+		self::assertEquals('text', $result['type']);
71 71
 		self::assertEquals(THttpUtility::htmlEncode('Prado & Cie'), $result['value']);
72 72
 	}
73 73
 
74 74
 	public function testAddAttribute() {
75
-		$writer=new THtmlWriter(self::$output);
76
-		$writer->addAttribute('type','text');
77
-		$writer->addAttribute('value','Prado & Cie');
78
-		$result=self::readAttribute($writer, '_attributes');
79
-		self::assertEquals('text',$result['type']);
75
+		$writer = new THtmlWriter(self::$output);
76
+		$writer->addAttribute('type', 'text');
77
+		$writer->addAttribute('value', 'Prado & Cie');
78
+		$result = self::readAttribute($writer, '_attributes');
79
+		self::assertEquals('text', $result['type']);
80 80
 		self::assertEquals(THttpUtility::htmlEncode('Prado & Cie'), $result['value']);
81 81
 	}
82 82
 
83 83
 	public function testRemoveAttribute() {
84
-		$writer=new THtmlWriter(self::$output);
85
-		$writer->addAttribute('type','text');
86
-		$writer->addAttribute('value','Prado & Cie');
84
+		$writer = new THtmlWriter(self::$output);
85
+		$writer->addAttribute('type', 'text');
86
+		$writer->addAttribute('value', 'Prado & Cie');
87 87
 		$writer->removeAttribute('value');
88
-		$result=self::readAttribute($writer, '_attributes');
88
+		$result = self::readAttribute($writer, '_attributes');
89 89
 		// 'type' should be present, 'value' not
90 90
 		self::assertTrue(isset($result['type']));
91 91
 		self::assertFalse(isset($result['value']));
92 92
 	}
93 93
 
94 94
 	public function testAddStyleAttributes() {
95
-		$writer=new THtmlWriter(self::$output);
96
-		$writer->addStyleAttributes(array ('font-size' => '1em', 'background-image'=>'url(image.gif)'));
97
-		$result=self::readAttribute($writer, '_styles');
95
+		$writer = new THtmlWriter(self::$output);
96
+		$writer->addStyleAttributes(array('font-size' => '1em', 'background-image'=>'url(image.gif)'));
97
+		$result = self::readAttribute($writer, '_styles');
98 98
 		self::assertEquals('1em', $result['font-size']);
99 99
 		self::assertEquals(THttpUtility::htmlEncode('url(image.gif)'), $result['background-image']);
100 100
 	}
101 101
 
102 102
 	public function testAddStyleAttribute() {
103
-		$writer=new THtmlWriter(self::$output);
104
-		$writer->addStyleAttribute('font-size','1em');
105
-		$writer->addStyleAttribute('background-image','url(image.gif)');
106
-		$result=self::readAttribute($writer, '_styles');
103
+		$writer = new THtmlWriter(self::$output);
104
+		$writer->addStyleAttribute('font-size', '1em');
105
+		$writer->addStyleAttribute('background-image', 'url(image.gif)');
106
+		$result = self::readAttribute($writer, '_styles');
107 107
 		self::assertEquals('1em', $result['font-size']);
108 108
 		self::assertEquals(THttpUtility::htmlEncode('url(image.gif)'), $result['background-image']);
109 109
 	}
110 110
 
111 111
 	public function testRemoveStyleAttribute() {
112
-		$writer=new THtmlWriter(self::$output);
113
-		$writer->addStyleAttribute('font-size','1em');
114
-		$writer->addStyleAttribute('background-image','url(image.gif)');
112
+		$writer = new THtmlWriter(self::$output);
113
+		$writer->addStyleAttribute('font-size', '1em');
114
+		$writer->addStyleAttribute('background-image', 'url(image.gif)');
115 115
 		$writer->removeStyleAttribute('font-size');
116
-		$result=self::readAttribute($writer, '_styles');
116
+		$result = self::readAttribute($writer, '_styles');
117 117
 		self::assertTrue(isset($result['background-image']));
118 118
 		self::assertFalse(isset($result['font-size']));
119 119
 	}
120 120
 
121 121
 	public function testFlush() {
122
-		$writer=new THtmlWriter(self::$output);
122
+		$writer = new THtmlWriter(self::$output);
123 123
 		$writer->write('Some Text');
124 124
 		$writer->flush();
125 125
 		self::assertEquals('Some Text', self::$output->getFlushedContent());
126 126
 	}
127 127
 
128 128
 	public function testWrite() {
129
-		$writer=new THtmlWriter(self::$output);
130
-		$writer->write('Some Text');;
129
+		$writer = new THtmlWriter(self::$output);
130
+		$writer->write('Some Text'); ;
131 131
 		self::assertEquals('Some Text', self::$output->flush());
132 132
 
133 133
 	}
134 134
 
135 135
 	public function testWriteLine() {
136
-		$writer=new THtmlWriter(self::$output);
137
-		$writer->writeLine('Some Text');;
136
+		$writer = new THtmlWriter(self::$output);
137
+		$writer->writeLine('Some Text'); ;
138 138
 		self::assertEquals("Some Text\n", self::$output->flush());
139 139
 
140 140
 	}
141 141
 
142 142
 	public function testWriteBreak() {
143
-		$writer=new THtmlWriter(self::$output);
143
+		$writer = new THtmlWriter(self::$output);
144 144
 		$writer->writeBreak();
145 145
 		self::assertEquals("<br/>", self::$output->flush());
146 146
 
147 147
 	}
148 148
 
149 149
 	public function testRenderBeginTag() {
150
-		$writer=new THtmlWriter(self::$output);
151
-		$writer->addAttribute('type','text');
152
-		$writer->addAttribute('value','Prado');
153
-		$writer->addStyleAttribute('font-size','1em');
150
+		$writer = new THtmlWriter(self::$output);
151
+		$writer->addAttribute('type', 'text');
152
+		$writer->addAttribute('value', 'Prado');
153
+		$writer->addStyleAttribute('font-size', '1em');
154 154
 		$writer->renderBeginTag('input');
155 155
 		self::assertEquals('<input type="text" value="Prado" style="font-size:1em;" />', self::$output->flush());
156 156
 	}
157 157
 
158 158
 	public function testRenderEndTag() {
159
-		$writer=new THtmlWriter(self::$output);
159
+		$writer = new THtmlWriter(self::$output);
160 160
 		$writer->renderBeginTag('div');
161 161
 		$writer->write('Div Content');
162 162
 		$writer->renderEndTag();
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -47,7 +47,9 @@
 block discarded – undo
47 47
 
48 48
 	public function setUp () {
49 49
 		// We need an output writer, use a TestWriter for this
50
-		if (self::$output===null) self::$output=new TestWriter();
50
+		if (self::$output===null) {
51
+			self::$output=new TestWriter();
52
+		}
51 53
 	}
52 54
 
53 55
 	public function testConstruct() {
Please login to merge, or discard this patch.
tests/test_tools/phpunit_bootstrap.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@
 block discarded – undo
16 16
 date_default_timezone_set('UTC');
17 17
 
18 18
 if (!@include_once VENDOR_DIR.'/autoload.php') {
19
-    die('You must set up the project dependencies, run the following commands:
19
+	die('You must set up the project dependencies, run the following commands:
20 20
         wget http://getcomposer.org/composer.phar
21 21
         php composer.phar install');
22 22
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -7,21 +7,21 @@
 block discarded – undo
7 7
  */
8 8
 
9 9
 define('PRADO_TEST_RUN', true);
10
-define('PRADO_FRAMEWORK_DIR', dirname(__FILE__).'/../../framework');
11
-define('VENDOR_DIR', dirname(__FILE__).'/../../vendor');
12
-set_include_path(PRADO_FRAMEWORK_DIR.PATH_SEPARATOR.get_include_path());
10
+define('PRADO_FRAMEWORK_DIR', dirname(__FILE__) . '/../../framework');
11
+define('VENDOR_DIR', dirname(__FILE__) . '/../../vendor');
12
+set_include_path(PRADO_FRAMEWORK_DIR . PATH_SEPARATOR . get_include_path());
13 13
 // coverage tests waste a lot of memory!
14 14
 ini_set('memory_limit', '1G');
15 15
 
16 16
 date_default_timezone_set('UTC');
17 17
 
18
-if (!@include_once VENDOR_DIR.'/autoload.php') {
18
+if (!@include_once VENDOR_DIR . '/autoload.php') {
19 19
     die('You must set up the project dependencies, run the following commands:
20 20
         wget http://getcomposer.org/composer.phar
21 21
         php composer.phar install');
22 22
 }
23 23
 
24
-require_once(PRADO_FRAMEWORK_DIR.'/prado.php');
24
+require_once(PRADO_FRAMEWORK_DIR . '/prado.php');
25 25
 
26 26
 // for FunctionalTests
27
-require_once(__DIR__.'/PradoGenericSelenium2Test.php');
28 27
\ No newline at end of file
28
+require_once(__DIR__ . '/PradoGenericSelenium2Test.php');
29 29
\ No newline at end of file
Please login to merge, or discard this patch.
tests/test_tools/simpletest/reporter.php 2 patches
Indentation   +330 added lines, -330 removed lines patch added patch discarded remove patch
@@ -1,366 +1,366 @@
 block discarded – undo
1 1
 <?php
2
-    /**
3
-     *	base include file for SimpleTest
4
-     *	@package	SimpleTest
5
-     *	@subpackage	UnitTester
6
-     *	@version	$Id: reporter.php 1532 2006-12-01 12:28:55Z xue $
7
-     */
2
+	/**
3
+	 *	base include file for SimpleTest
4
+	 *	@package	SimpleTest
5
+	 *	@subpackage	UnitTester
6
+	 *	@version	$Id: reporter.php 1532 2006-12-01 12:28:55Z xue $
7
+	 */
8 8
 
9
-    /**#@+
9
+	/**#@+
10 10
      *	include other SimpleTest class files
11 11
      */
12
-    require_once(dirname(__FILE__) . '/scorer.php');
13
-    /**#@-*/
12
+	require_once(dirname(__FILE__) . '/scorer.php');
13
+	/**#@-*/
14 14
 
15
-    /**
16
-     *    Sample minimal test displayer. Generates only
17
-     *    failure messages and a pass count.
15
+	/**
16
+	 *    Sample minimal test displayer. Generates only
17
+	 *    failure messages and a pass count.
18 18
 	 *	  @package SimpleTest
19 19
 	 *	  @subpackage UnitTester
20
-     */
21
-    class HtmlReporter extends SimpleReporter {
22
-        protected $_character_set;
20
+	 */
21
+	class HtmlReporter extends SimpleReporter {
22
+		protected $_character_set;
23 23
 
24
-        /**
25
-         *    Does nothing yet. The first output will
26
-         *    be sent on the first test start. For use
27
-         *    by a web browser.
28
-         *    @access public
29
-         */
30
-        function HtmlReporter($character_set = 'ISO-8859-1') {
31
-            $this->SimpleReporter();
32
-            $this->_character_set = $character_set;
33
-        }
24
+		/**
25
+		 *    Does nothing yet. The first output will
26
+		 *    be sent on the first test start. For use
27
+		 *    by a web browser.
28
+		 *    @access public
29
+		 */
30
+		function HtmlReporter($character_set = 'ISO-8859-1') {
31
+			$this->SimpleReporter();
32
+			$this->_character_set = $character_set;
33
+		}
34 34
 
35
-        /**
36
-         *    Paints the top of the web page setting the
37
-         *    title to the name of the starting test.
38
-         *    @param string $test_name      Name class of test.
39
-         *    @access public
40
-         */
41
-        function paintHeader($test_name) {
42
-            $this->sendNoCacheHeaders();
43
-            print "<html>\n<head>\n<title>$test_name</title>\n";
44
-            print "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=" .
45
-                    $this->_character_set . "\">\n";
46
-            print "<style type=\"text/css\">\n";
47
-            print $this->_getCss() . "\n";
48
-            print "</style>\n";
49
-            print "</head>\n<body>\n";
50
-            print "<h1>$test_name</h1>\n";
51
-            flush();
52
-        }
35
+		/**
36
+		 *    Paints the top of the web page setting the
37
+		 *    title to the name of the starting test.
38
+		 *    @param string $test_name      Name class of test.
39
+		 *    @access public
40
+		 */
41
+		function paintHeader($test_name) {
42
+			$this->sendNoCacheHeaders();
43
+			print "<html>\n<head>\n<title>$test_name</title>\n";
44
+			print "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=" .
45
+					$this->_character_set . "\">\n";
46
+			print "<style type=\"text/css\">\n";
47
+			print $this->_getCss() . "\n";
48
+			print "</style>\n";
49
+			print "</head>\n<body>\n";
50
+			print "<h1>$test_name</h1>\n";
51
+			flush();
52
+		}
53 53
 
54
-        /**
55
-         *    Send the headers necessary to ensure the page is
56
-         *    reloaded on every request. Otherwise you could be
57
-         *    scratching your head over out of date test data.
58
-         *    @access public
59
-         *    @static
60
-         */
61
-        static function sendNoCacheHeaders() {
62
-            if (! headers_sent()) {
63
-                header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
64
-                header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
65
-                header("Cache-Control: no-store, no-cache, must-revalidate");
66
-                header("Cache-Control: post-check=0, pre-check=0", false);
67
-                header("Pragma: no-cache");
68
-            }
69
-        }
54
+		/**
55
+		 *    Send the headers necessary to ensure the page is
56
+		 *    reloaded on every request. Otherwise you could be
57
+		 *    scratching your head over out of date test data.
58
+		 *    @access public
59
+		 *    @static
60
+		 */
61
+		static function sendNoCacheHeaders() {
62
+			if (! headers_sent()) {
63
+				header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
64
+				header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
65
+				header("Cache-Control: no-store, no-cache, must-revalidate");
66
+				header("Cache-Control: post-check=0, pre-check=0", false);
67
+				header("Pragma: no-cache");
68
+			}
69
+		}
70 70
 
71
-        /**
72
-         *    Paints the CSS. Add additional styles here.
73
-         *    @return string            CSS code as text.
74
-         *    @access protected
75
-         */
76
-        function _getCss() {
77
-            return ".fail { color: red; } pre { background-color: lightgray; }";
78
-        }
71
+		/**
72
+		 *    Paints the CSS. Add additional styles here.
73
+		 *    @return string            CSS code as text.
74
+		 *    @access protected
75
+		 */
76
+		function _getCss() {
77
+			return ".fail { color: red; } pre { background-color: lightgray; }";
78
+		}
79 79
 
80
-        /**
81
-         *    Paints the end of the test with a summary of
82
-         *    the passes and failures.
83
-         *    @param string $test_name        Name class of test.
84
-         *    @access public
85
-         */
86
-        function paintFooter($test_name) {
87
-            $colour = ($this->getFailCount() + $this->getExceptionCount() > 0 ? "red" : "green");
88
-            print "<div style=\"";
89
-            print "padding: 8px; margin-top: 1em; background-color: $colour; color: white;";
90
-            print "\">";
91
-            print $this->getTestCaseProgress() . "/" . $this->getTestCaseCount();
92
-            print " test cases complete:\n";
93
-            print "<strong>" . $this->getPassCount() . "</strong> passes, ";
94
-            print "<strong>" . $this->getFailCount() . "</strong> fails and ";
95
-            print "<strong>" . $this->getExceptionCount() . "</strong> exceptions.";
96
-            print "</div>\n";
97
-            print "</body>\n</html>\n";
98
-        }
80
+		/**
81
+		 *    Paints the end of the test with a summary of
82
+		 *    the passes and failures.
83
+		 *    @param string $test_name        Name class of test.
84
+		 *    @access public
85
+		 */
86
+		function paintFooter($test_name) {
87
+			$colour = ($this->getFailCount() + $this->getExceptionCount() > 0 ? "red" : "green");
88
+			print "<div style=\"";
89
+			print "padding: 8px; margin-top: 1em; background-color: $colour; color: white;";
90
+			print "\">";
91
+			print $this->getTestCaseProgress() . "/" . $this->getTestCaseCount();
92
+			print " test cases complete:\n";
93
+			print "<strong>" . $this->getPassCount() . "</strong> passes, ";
94
+			print "<strong>" . $this->getFailCount() . "</strong> fails and ";
95
+			print "<strong>" . $this->getExceptionCount() . "</strong> exceptions.";
96
+			print "</div>\n";
97
+			print "</body>\n</html>\n";
98
+		}
99 99
 
100
-        /**
101
-         *    Paints the test failure with a breadcrumbs
102
-         *    trail of the nesting test suites below the
103
-         *    top level test.
104
-         *    @param string $message    Failure message displayed in
105
-         *                              the context of the other tests.
106
-         *    @access public
107
-         */
108
-        function paintFail($message) {
109
-            parent::paintFail($message);
110
-            print "<span class=\"fail\">Fail</span>: ";
111
-            $breadcrumb = $this->getTestList();
112
-            array_shift($breadcrumb);
113
-            print implode(" -&gt; ", $breadcrumb);
114
-            print " -&gt; " . $this->_htmlEntities($message) . "<br />\n";
115
-        }
100
+		/**
101
+		 *    Paints the test failure with a breadcrumbs
102
+		 *    trail of the nesting test suites below the
103
+		 *    top level test.
104
+		 *    @param string $message    Failure message displayed in
105
+		 *                              the context of the other tests.
106
+		 *    @access public
107
+		 */
108
+		function paintFail($message) {
109
+			parent::paintFail($message);
110
+			print "<span class=\"fail\">Fail</span>: ";
111
+			$breadcrumb = $this->getTestList();
112
+			array_shift($breadcrumb);
113
+			print implode(" -&gt; ", $breadcrumb);
114
+			print " -&gt; " . $this->_htmlEntities($message) . "<br />\n";
115
+		}
116 116
 
117
-        /**
118
-         *    Paints a PHP error or exception.
119
-         *    @param string $message        Message is ignored.
120
-         *    @access public
121
-         *    @abstract
122
-         */
123
-        function paintError($message) {
124
-            parent::paintError($message);
125
-            print "<span class=\"fail\">Exception</span>: ";
126
-            $breadcrumb = $this->getTestList();
127
-            array_shift($breadcrumb);
128
-            print implode(" -&gt; ", $breadcrumb);
129
-            print " -&gt; <strong>" . $this->_htmlEntities($message) . "</strong><br />\n";
130
-        }
117
+		/**
118
+		 *    Paints a PHP error or exception.
119
+		 *    @param string $message        Message is ignored.
120
+		 *    @access public
121
+		 *    @abstract
122
+		 */
123
+		function paintError($message) {
124
+			parent::paintError($message);
125
+			print "<span class=\"fail\">Exception</span>: ";
126
+			$breadcrumb = $this->getTestList();
127
+			array_shift($breadcrumb);
128
+			print implode(" -&gt; ", $breadcrumb);
129
+			print " -&gt; <strong>" . $this->_htmlEntities($message) . "</strong><br />\n";
130
+		}
131 131
 
132
-        /**
133
-         *    Paints formatted text such as dumped variables.
134
-         *    @param string $message        Text to show.
135
-         *    @access public
136
-         */
137
-        function paintFormattedMessage($message) {
138
-            print '<pre>' . $this->_htmlEntities($message) . '</pre>';
139
-        }
132
+		/**
133
+		 *    Paints formatted text such as dumped variables.
134
+		 *    @param string $message        Text to show.
135
+		 *    @access public
136
+		 */
137
+		function paintFormattedMessage($message) {
138
+			print '<pre>' . $this->_htmlEntities($message) . '</pre>';
139
+		}
140 140
 
141
-        /**
142
-         *    Character set adjusted entity conversion.
143
-         *    @param string $message    Plain text or Unicode message.
144
-         *    @return string            Browser readable message.
145
-         *    @access protected
146
-         */
147
-        function _htmlEntities($message) {
148
-            return htmlentities($message, ENT_COMPAT, $this->_character_set);
149
-        }
150
-    }
141
+		/**
142
+		 *    Character set adjusted entity conversion.
143
+		 *    @param string $message    Plain text or Unicode message.
144
+		 *    @return string            Browser readable message.
145
+		 *    @access protected
146
+		 */
147
+		function _htmlEntities($message) {
148
+			return htmlentities($message, ENT_COMPAT, $this->_character_set);
149
+		}
150
+	}
151 151
 
152
-    /**
153
-     *    Sample minimal test displayer. Generates only
154
-     *    failure messages and a pass count. For command
155
-     *    line use. I've tried to make it look like JUnit,
156
-     *    but I wanted to output the errors as they arrived
157
-     *    which meant dropping the dots.
152
+	/**
153
+	 *    Sample minimal test displayer. Generates only
154
+	 *    failure messages and a pass count. For command
155
+	 *    line use. I've tried to make it look like JUnit,
156
+	 *    but I wanted to output the errors as they arrived
157
+	 *    which meant dropping the dots.
158 158
 	 *	  @package SimpleTest
159 159
 	 *	  @subpackage UnitTester
160
-     */
161
-    class TextReporter extends SimpleReporter {
160
+	 */
161
+	class TextReporter extends SimpleReporter {
162 162
 
163
-        /**
164
-         *    Does nothing yet. The first output will
165
-         *    be sent on the first test start.
166
-         *    @access public
167
-         */
168
-        function TextReporter() {
169
-            $this->SimpleReporter();
170
-        }
163
+		/**
164
+		 *    Does nothing yet. The first output will
165
+		 *    be sent on the first test start.
166
+		 *    @access public
167
+		 */
168
+		function TextReporter() {
169
+			$this->SimpleReporter();
170
+		}
171 171
 
172
-        /**
173
-         *    Paints the title only.
174
-         *    @param string $test_name        Name class of test.
175
-         *    @access public
176
-         */
177
-        function paintHeader($test_name) {
178
-            if (! SimpleReporter::inCli()) {
179
-                header('Content-type: text/plain');
180
-            }
181
-            print "$test_name\n";
182
-            flush();
183
-        }
172
+		/**
173
+		 *    Paints the title only.
174
+		 *    @param string $test_name        Name class of test.
175
+		 *    @access public
176
+		 */
177
+		function paintHeader($test_name) {
178
+			if (! SimpleReporter::inCli()) {
179
+				header('Content-type: text/plain');
180
+			}
181
+			print "$test_name\n";
182
+			flush();
183
+		}
184 184
 
185
-        /**
186
-         *    Paints the end of the test with a summary of
187
-         *    the passes and failures.
188
-         *    @param string $test_name        Name class of test.
189
-         *    @access public
190
-         */
191
-        function paintFooter($test_name) {
192
-            if ($this->getFailCount() + $this->getExceptionCount() == 0) {
193
-                print "OK\n";
194
-            } else {
195
-                print "FAILURES!!!\n";
196
-            }
197
-            print "Test cases run: " . $this->getTestCaseProgress() .
198
-                    "/" . $this->getTestCaseCount() .
199
-                    ", Passes: " . $this->getPassCount() .
200
-                    ", Failures: " . $this->getFailCount() .
201
-                    ", Exceptions: " . $this->getExceptionCount() . "\n";
202
-        }
185
+		/**
186
+		 *    Paints the end of the test with a summary of
187
+		 *    the passes and failures.
188
+		 *    @param string $test_name        Name class of test.
189
+		 *    @access public
190
+		 */
191
+		function paintFooter($test_name) {
192
+			if ($this->getFailCount() + $this->getExceptionCount() == 0) {
193
+				print "OK\n";
194
+			} else {
195
+				print "FAILURES!!!\n";
196
+			}
197
+			print "Test cases run: " . $this->getTestCaseProgress() .
198
+					"/" . $this->getTestCaseCount() .
199
+					", Passes: " . $this->getPassCount() .
200
+					", Failures: " . $this->getFailCount() .
201
+					", Exceptions: " . $this->getExceptionCount() . "\n";
202
+		}
203 203
 
204
-        /**
205
-         *    Paints the test failure as a stack trace.
206
-         *    @param string $message    Failure message displayed in
207
-         *                              the context of the other tests.
208
-         *    @access public
209
-         */
210
-        function paintFail($message) {
211
-            parent::paintFail($message);
212
-            print $this->getFailCount() . ") $message\n";
213
-            $breadcrumb = $this->getTestList();
214
-            array_shift($breadcrumb);
215
-            print "\tin " . implode("\n\tin ", array_reverse($breadcrumb));
216
-            print "\n";
217
-        }
204
+		/**
205
+		 *    Paints the test failure as a stack trace.
206
+		 *    @param string $message    Failure message displayed in
207
+		 *                              the context of the other tests.
208
+		 *    @access public
209
+		 */
210
+		function paintFail($message) {
211
+			parent::paintFail($message);
212
+			print $this->getFailCount() . ") $message\n";
213
+			$breadcrumb = $this->getTestList();
214
+			array_shift($breadcrumb);
215
+			print "\tin " . implode("\n\tin ", array_reverse($breadcrumb));
216
+			print "\n";
217
+		}
218 218
 
219
-        /**
220
-         *    Paints a PHP error or exception.
221
-         *    @param string $message        Message is ignored.
222
-         *    @access public
223
-         *    @abstract
224
-         */
225
-        function paintError($message) {
226
-            parent::paintError($message);
227
-            print "Exception " . $this->getExceptionCount() . "!\n$message\n";
228
-        }
219
+		/**
220
+		 *    Paints a PHP error or exception.
221
+		 *    @param string $message        Message is ignored.
222
+		 *    @access public
223
+		 *    @abstract
224
+		 */
225
+		function paintError($message) {
226
+			parent::paintError($message);
227
+			print "Exception " . $this->getExceptionCount() . "!\n$message\n";
228
+		}
229 229
 
230
-        /**
231
-         *    Paints formatted text such as dumped variables.
232
-         *    @param string $message        Text to show.
233
-         *    @access public
234
-         */
235
-        function paintFormattedMessage($message) {
236
-            print "$message\n";
237
-            flush();
238
-        }
239
-    }
230
+		/**
231
+		 *    Paints formatted text such as dumped variables.
232
+		 *    @param string $message        Text to show.
233
+		 *    @access public
234
+		 */
235
+		function paintFormattedMessage($message) {
236
+			print "$message\n";
237
+			flush();
238
+		}
239
+	}
240 240
 
241
-    /**
242
-     *    Runs just a single test group, a single case or
243
-     *    even a single test within that case.
241
+	/**
242
+	 *    Runs just a single test group, a single case or
243
+	 *    even a single test within that case.
244 244
 	 *	  @package SimpleTest
245 245
 	 *	  @subpackage UnitTester
246
-     */
247
-    class SelectiveReporter extends SimpleReporterDecorator {
248
-        protected $_just_this_case =false;
249
-        protected $_just_this_test = false;
250
-        protected $_within_test_case = true;
246
+	 */
247
+	class SelectiveReporter extends SimpleReporterDecorator {
248
+		protected $_just_this_case =false;
249
+		protected $_just_this_test = false;
250
+		protected $_within_test_case = true;
251 251
 
252
-        /**
253
-         *    Selects the test case or group to be run,
254
-         *    and optionally a specific test.
255
-         *    @param SimpleScorer $reporter    Reporter to receive events.
256
-         *    @param string $just_this_case    Only this case or group will run.
257
-         *    @param string $just_this_test    Only this test method will run.
258
-         */
259
-        function SelectiveReporter($reporter, $just_this_case = false, $just_this_test = false) {
260
-            if (isset($just_this_case) && $just_this_case) {
261
-                $this->_just_this_case = strtolower($just_this_case);
262
-                $this->_within_test_case = false;
263
-            }
264
-            if (isset($just_this_test) && $just_this_test) {
265
-                $this->_just_this_test = strtolower($just_this_test);
266
-            }
267
-            $this->SimpleReporterDecorator($reporter);
268
-        }
252
+		/**
253
+		 *    Selects the test case or group to be run,
254
+		 *    and optionally a specific test.
255
+		 *    @param SimpleScorer $reporter    Reporter to receive events.
256
+		 *    @param string $just_this_case    Only this case or group will run.
257
+		 *    @param string $just_this_test    Only this test method will run.
258
+		 */
259
+		function SelectiveReporter($reporter, $just_this_case = false, $just_this_test = false) {
260
+			if (isset($just_this_case) && $just_this_case) {
261
+				$this->_just_this_case = strtolower($just_this_case);
262
+				$this->_within_test_case = false;
263
+			}
264
+			if (isset($just_this_test) && $just_this_test) {
265
+				$this->_just_this_test = strtolower($just_this_test);
266
+			}
267
+			$this->SimpleReporterDecorator($reporter);
268
+		}
269 269
 
270
-        /**
271
-         *    Compares criteria to actual the case/group name.
272
-         *    @param string $test_case    The incoming test.
273
-         *    @return boolean             True if matched.
274
-         *    @access protected
275
-         */
276
-        function _isCaseMatch($test_case) {
277
-            if ($this->_just_this_case) {
278
-                return $this->_just_this_case == strtolower($test_case);
279
-            }
280
-            return false;
281
-        }
270
+		/**
271
+		 *    Compares criteria to actual the case/group name.
272
+		 *    @param string $test_case    The incoming test.
273
+		 *    @return boolean             True if matched.
274
+		 *    @access protected
275
+		 */
276
+		function _isCaseMatch($test_case) {
277
+			if ($this->_just_this_case) {
278
+				return $this->_just_this_case == strtolower($test_case);
279
+			}
280
+			return false;
281
+		}
282 282
 
283
-        /**
284
-         *    Compares criteria to actual the test name.
285
-         *    @param string $method       The incoming test method.
286
-         *    @return boolean             True if matched.
287
-         *    @access protected
288
-         */
289
-        function _isTestMatch($method) {
290
-            if ($this->_just_this_test) {
291
-                return $this->_just_this_test == strtolower($method);
292
-            }
293
-            return true;
294
-        }
283
+		/**
284
+		 *    Compares criteria to actual the test name.
285
+		 *    @param string $method       The incoming test method.
286
+		 *    @return boolean             True if matched.
287
+		 *    @access protected
288
+		 */
289
+		function _isTestMatch($method) {
290
+			if ($this->_just_this_test) {
291
+				return $this->_just_this_test == strtolower($method);
292
+			}
293
+			return true;
294
+		}
295 295
 
296
-        /**
297
-         *    Veto everything that doesn't match the method wanted.
298
-         *    @param string $test_case       Name of test case.
299
-         *    @param string $method          Name of test method.
300
-         *    @return boolean                True if test should be run.
301
-         *    @access public
302
-         */
303
-        function shouldInvoke($test_case, $method) {
304
-            if ($this->_within_test_case && $this->_isTestMatch($method)) {
305
-                return $this->_reporter->shouldInvoke($test_case, $method);
306
-            }
307
-            return false;
308
-        }
296
+		/**
297
+		 *    Veto everything that doesn't match the method wanted.
298
+		 *    @param string $test_case       Name of test case.
299
+		 *    @param string $method          Name of test method.
300
+		 *    @return boolean                True if test should be run.
301
+		 *    @access public
302
+		 */
303
+		function shouldInvoke($test_case, $method) {
304
+			if ($this->_within_test_case && $this->_isTestMatch($method)) {
305
+				return $this->_reporter->shouldInvoke($test_case, $method);
306
+			}
307
+			return false;
308
+		}
309 309
 
310
-        /**
311
-         *    Paints the start of a group test.
312
-         *    @param string $test_case     Name of test or other label.
313
-         *    @param integer $size         Number of test cases starting.
314
-         *    @access public
315
-         */
316
-        function paintGroupStart($test_case, $size) {
317
-            if ($this->_isCaseMatch($test_case)) {
318
-                $this->_within_test_case = true;
319
-            }
320
-            if ($this->_within_test_case) {
321
-                $this->_reporter->paintGroupStart($test_case, $size);
322
-            }
323
-        }
310
+		/**
311
+		 *    Paints the start of a group test.
312
+		 *    @param string $test_case     Name of test or other label.
313
+		 *    @param integer $size         Number of test cases starting.
314
+		 *    @access public
315
+		 */
316
+		function paintGroupStart($test_case, $size) {
317
+			if ($this->_isCaseMatch($test_case)) {
318
+				$this->_within_test_case = true;
319
+			}
320
+			if ($this->_within_test_case) {
321
+				$this->_reporter->paintGroupStart($test_case, $size);
322
+			}
323
+		}
324 324
 
325
-        /**
326
-         *    Paints the end of a group test.
327
-         *    @param string $test_case     Name of test or other label.
328
-         *    @access public
329
-         */
330
-        function paintGroupEnd($test_case) {
331
-            if ($this->_within_test_case) {
332
-                $this->_reporter->paintGroupEnd($test_case);
333
-            }
334
-            if ($this->_isCaseMatch($test_case)) {
335
-                $this->_within_test_case = false;
336
-            }
337
-        }
325
+		/**
326
+		 *    Paints the end of a group test.
327
+		 *    @param string $test_case     Name of test or other label.
328
+		 *    @access public
329
+		 */
330
+		function paintGroupEnd($test_case) {
331
+			if ($this->_within_test_case) {
332
+				$this->_reporter->paintGroupEnd($test_case);
333
+			}
334
+			if ($this->_isCaseMatch($test_case)) {
335
+				$this->_within_test_case = false;
336
+			}
337
+		}
338 338
 
339
-        /**
340
-         *    Paints the start of a test case.
341
-         *    @param string $test_case     Name of test or other label.
342
-         *    @access public
343
-         */
344
-        function paintCaseStart($test_case) {
345
-            if ($this->_isCaseMatch($test_case)) {
346
-                $this->_within_test_case = true;
347
-            }
348
-            if ($this->_within_test_case) {
349
-                $this->_reporter->paintCaseStart($test_case);
350
-            }
351
-        }
339
+		/**
340
+		 *    Paints the start of a test case.
341
+		 *    @param string $test_case     Name of test or other label.
342
+		 *    @access public
343
+		 */
344
+		function paintCaseStart($test_case) {
345
+			if ($this->_isCaseMatch($test_case)) {
346
+				$this->_within_test_case = true;
347
+			}
348
+			if ($this->_within_test_case) {
349
+				$this->_reporter->paintCaseStart($test_case);
350
+			}
351
+		}
352 352
 
353
-        /**
354
-         *    Paints the end of a test case.
355
-         *    @param string $test_case     Name of test or other label.
356
-         *    @access public
357
-         */
358
-        function paintCaseEnd($test_case) {
359
-            if ($this->_within_test_case) {
360
-                $this->_reporter->paintCaseEnd($test_case);
361
-            }
362
-            if ($this->_isCaseMatch($test_case)) {
363
-                $this->_within_test_case = false;
364
-            }
365
-        }
366
-    }
367 353
\ No newline at end of file
354
+		/**
355
+		 *    Paints the end of a test case.
356
+		 *    @param string $test_case     Name of test or other label.
357
+		 *    @access public
358
+		 */
359
+		function paintCaseEnd($test_case) {
360
+			if ($this->_within_test_case) {
361
+				$this->_reporter->paintCaseEnd($test_case);
362
+			}
363
+			if ($this->_isCaseMatch($test_case)) {
364
+				$this->_within_test_case = false;
365
+			}
366
+		}
367
+	}
368 368
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
          *    @static
60 60
          */
61 61
         static function sendNoCacheHeaders() {
62
-            if (! headers_sent()) {
62
+            if (!headers_sent()) {
63 63
                 header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
64 64
                 header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
65 65
                 header("Cache-Control: no-store, no-cache, must-revalidate");
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
          *    @access public
176 176
          */
177 177
         function paintHeader($test_name) {
178
-            if (! SimpleReporter::inCli()) {
178
+            if (!SimpleReporter::inCli()) {
179 179
                 header('Content-type: text/plain');
180 180
             }
181 181
             print "$test_name\n";
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
 	 *	  @subpackage UnitTester
246 246
      */
247 247
     class SelectiveReporter extends SimpleReporterDecorator {
248
-        protected $_just_this_case =false;
248
+        protected $_just_this_case = false;
249 249
         protected $_just_this_test = false;
250 250
         protected $_within_test_case = true;
251 251
 
Please login to merge, or discard this patch.
tests/test_tools/simpletest/socket.php 2 patches
Indentation   +207 added lines, -207 removed lines patch added patch discarded remove patch
@@ -1,215 +1,215 @@
 block discarded – undo
1 1
 <?php
2
-    /**
3
-     *	base include file for SimpleTest
4
-     *	@package	SimpleTest
5
-     *	@subpackage	MockObjects
6
-     *	@version	$Id: socket.php 1398 2006-09-08 19:31:03Z xue $
7
-     */
8
-
9
-    /**#@+
2
+	/**
3
+	 *	base include file for SimpleTest
4
+	 *	@package	SimpleTest
5
+	 *	@subpackage	MockObjects
6
+	 *	@version	$Id: socket.php 1398 2006-09-08 19:31:03Z xue $
7
+	 */
8
+
9
+	/**#@+
10 10
      * include SimpleTest files
11 11
      */
12
-    require_once(dirname(__FILE__) . '/compatibility.php');
13
-    /**#@-*/
12
+	require_once(dirname(__FILE__) . '/compatibility.php');
13
+	/**#@-*/
14 14
 
15
-    /**
16
-     *    Stashes an error for later. Useful for constructors
17
-     *    until PHP gets exceptions.
15
+	/**
16
+	 *    Stashes an error for later. Useful for constructors
17
+	 *    until PHP gets exceptions.
18 18
 	 *    @package SimpleTest
19 19
 	 *    @subpackage WebTester
20
-     */
21
-    class SimpleStickyError {
22
-        protected $_error = 'Constructor not chained';
23
-
24
-        /**
25
-         *    Sets the error to empty.
26
-         *    @access public
27
-         */
28
-        function SimpleStickyError() {
29
-            $this->_clearError();
30
-        }
31
-
32
-        /**
33
-         *    Test for an outstanding error.
34
-         *    @return boolean           True if there is an error.
35
-         *    @access public
36
-         */
37
-        function isError() {
38
-            return ($this->_error != '');
39
-        }
40
-
41
-        /**
42
-         *    Accessor for an outstanding error.
43
-         *    @return string     Empty string if no error otherwise
44
-         *                       the error message.
45
-         *    @access public
46
-         */
47
-        function getError() {
48
-            return $this->_error;
49
-        }
50
-
51
-        /**
52
-         *    Sets the internal error.
53
-         *    @param string       Error message to stash.
54
-         *    @access protected
55
-         */
56
-        function _setError($error) {
57
-            $this->_error = $error;
58
-        }
59
-
60
-        /**
61
-         *    Resets the error state to no error.
62
-         *    @access protected
63
-         */
64
-        function _clearError() {
65
-            $this->_setError('');
66
-        }
67
-    }
68
-
69
-    /**
70
-     *    Wrapper for TCP/IP socket.
71
-     *    @package SimpleTest
72
-     *    @subpackage WebTester
73
-     */
74
-    class SimpleSocket extends SimpleStickyError {
75
-        protected $_handle;
76
-        protected $_is_open = false;
77
-        protected $_sent = '';
78
-        public $lock_size;
79
-
80
-        /**
81
-         *    Opens a socket for reading and writing.
82
-         *    @param string $host          Hostname to send request to.
83
-         *    @param integer $port         Port on remote machine to open.
84
-         *    @param integer $timeout      Connection timeout in seconds.
85
-         *    @param integer $block_size   Size of chunk to read.
86
-         *    @access public
87
-         */
88
-        function SimpleSocket($host, $port, $timeout, $block_size = 255) {
89
-            $this->SimpleStickyError();
90
-            if (! ($this->_handle = $this->_openSocket($host, $port, $error_number, $error, $timeout))) {
91
-                $this->_setError("Cannot open [$host:$port] with [$error] within [$timeout] seconds");
92
-                return;
93
-            }
94
-            $this->_is_open = true;
95
-            $this->_block_size = $block_size;
96
-            SimpleTestCompatibility::setTimeout($this->_handle, $timeout);
97
-        }
98
-
99
-        /**
100
-         *    Writes some data to the socket and saves alocal copy.
101
-         *    @param string $message       String to send to socket.
102
-         *    @return boolean              True if successful.
103
-         *    @access public
104
-         */
105
-        function write($message) {
106
-            if ($this->isError() || ! $this->isOpen()) {
107
-                return false;
108
-            }
109
-            $count = fwrite($this->_handle, $message);
110
-            if (! $count) {
111
-                if ($count === false) {
112
-                    $this->_setError('Cannot write to socket');
113
-                    $this->close();
114
-                }
115
-                return false;
116
-            }
117
-            fflush($this->_handle);
118
-            $this->_sent .= $message;
119
-            return true;
120
-        }
121
-
122
-        /**
123
-         *    Reads data from the socket. The error suppresion
124
-         *    is a workaround for PHP4 always throwing a warning
125
-         *    with a secure socket.
126
-         *    @return integer/boolean           Incoming bytes. False
127
-         *                                     on error.
128
-         *    @access public
129
-         */
130
-        function read() {
131
-            if ($this->isError() || ! $this->isOpen()) {
132
-                return false;
133
-            }
134
-            $raw = @fread($this->_handle, $this->_block_size);
135
-            if ($raw === false) {
136
-                $this->_setError('Cannot read from socket');
137
-                $this->close();
138
-            }
139
-            return $raw;
140
-        }
141
-
142
-        /**
143
-         *    Accessor for socket open state.
144
-         *    @return boolean           True if open.
145
-         *    @access public
146
-         */
147
-        function isOpen() {
148
-            return $this->_is_open;
149
-        }
150
-
151
-        /**
152
-         *    Closes the socket preventing further reads.
153
-         *    Cannot be reopened once closed.
154
-         *    @return boolean           True if successful.
155
-         *    @access public
156
-         */
157
-        function close() {
158
-            $this->_is_open = false;
159
-            return fclose($this->_handle);
160
-        }
161
-
162
-        /**
163
-         *    Accessor for content so far.
164
-         *    @return string        Bytes sent only.
165
-         *    @access public
166
-         */
167
-        function getSent() {
168
-            return $this->_sent;
169
-        }
170
-
171
-        /**
172
-         *    Actually opens the low level socket.
173
-         *    @param string $host          Host to connect to.
174
-         *    @param integer $port         Port on host.
175
-         *    @param integer $error_number Recipient of error code.
176
-         *    @param string $error         Recipoent of error message.
177
-         *    @param integer $timeout      Maximum time to wait for connection.
178
-         *    @access protected
179
-         */
180
-        function _openSocket($host, $port, $error_number, $error, $timeout) {
181
-            return @fsockopen($host, $port, $error_number, $error, $timeout);
182
-        }
183
-    }
184
-
185
-    /**
186
-     *    Wrapper for TCP/IP socket over TLS.
20
+	 */
21
+	class SimpleStickyError {
22
+		protected $_error = 'Constructor not chained';
23
+
24
+		/**
25
+		 *    Sets the error to empty.
26
+		 *    @access public
27
+		 */
28
+		function SimpleStickyError() {
29
+			$this->_clearError();
30
+		}
31
+
32
+		/**
33
+		 *    Test for an outstanding error.
34
+		 *    @return boolean           True if there is an error.
35
+		 *    @access public
36
+		 */
37
+		function isError() {
38
+			return ($this->_error != '');
39
+		}
40
+
41
+		/**
42
+		 *    Accessor for an outstanding error.
43
+		 *    @return string     Empty string if no error otherwise
44
+		 *                       the error message.
45
+		 *    @access public
46
+		 */
47
+		function getError() {
48
+			return $this->_error;
49
+		}
50
+
51
+		/**
52
+		 *    Sets the internal error.
53
+		 *    @param string       Error message to stash.
54
+		 *    @access protected
55
+		 */
56
+		function _setError($error) {
57
+			$this->_error = $error;
58
+		}
59
+
60
+		/**
61
+		 *    Resets the error state to no error.
62
+		 *    @access protected
63
+		 */
64
+		function _clearError() {
65
+			$this->_setError('');
66
+		}
67
+	}
68
+
69
+	/**
70
+	 *    Wrapper for TCP/IP socket.
187 71
 	 *    @package SimpleTest
188 72
 	 *    @subpackage WebTester
189
-     */
190
-    class SimpleSecureSocket extends SimpleSocket {
191
-
192
-        /**
193
-         *    Opens a secure socket for reading and writing.
194
-         *    @param string $host      Hostname to send request to.
195
-         *    @param integer $port     Port on remote machine to open.
196
-         *    @param integer $timeout  Connection timeout in seconds.
197
-         *    @access public
198
-         */
199
-        function SimpleSecureSocket($host, $port, $timeout) {
200
-            $this->SimpleSocket($host, $port, $timeout);
201
-        }
202
-
203
-        /**
204
-         *    Actually opens the low level socket.
205
-         *    @param string $host          Host to connect to.
206
-         *    @param integer $port         Port on host.
207
-         *    @param integer $error_number Recipient of error code.
208
-         *    @param string $error         Recipient of error message.
209
-         *    @param integer $timeout      Maximum time to wait for connection.
210
-         *    @access protected
211
-         */
212
-        function _openSocket($host, $port, $error_number, $error, $timeout) {
213
-            return parent::_openSocket("tls://$host", $port, $error_number, $error, $timeout);
214
-        }
215
-    }
216 73
\ No newline at end of file
74
+	 */
75
+	class SimpleSocket extends SimpleStickyError {
76
+		protected $_handle;
77
+		protected $_is_open = false;
78
+		protected $_sent = '';
79
+		public $lock_size;
80
+
81
+		/**
82
+		 *    Opens a socket for reading and writing.
83
+		 *    @param string $host          Hostname to send request to.
84
+		 *    @param integer $port         Port on remote machine to open.
85
+		 *    @param integer $timeout      Connection timeout in seconds.
86
+		 *    @param integer $block_size   Size of chunk to read.
87
+		 *    @access public
88
+		 */
89
+		function SimpleSocket($host, $port, $timeout, $block_size = 255) {
90
+			$this->SimpleStickyError();
91
+			if (! ($this->_handle = $this->_openSocket($host, $port, $error_number, $error, $timeout))) {
92
+				$this->_setError("Cannot open [$host:$port] with [$error] within [$timeout] seconds");
93
+				return;
94
+			}
95
+			$this->_is_open = true;
96
+			$this->_block_size = $block_size;
97
+			SimpleTestCompatibility::setTimeout($this->_handle, $timeout);
98
+		}
99
+
100
+		/**
101
+		 *    Writes some data to the socket and saves alocal copy.
102
+		 *    @param string $message       String to send to socket.
103
+		 *    @return boolean              True if successful.
104
+		 *    @access public
105
+		 */
106
+		function write($message) {
107
+			if ($this->isError() || ! $this->isOpen()) {
108
+				return false;
109
+			}
110
+			$count = fwrite($this->_handle, $message);
111
+			if (! $count) {
112
+				if ($count === false) {
113
+					$this->_setError('Cannot write to socket');
114
+					$this->close();
115
+				}
116
+				return false;
117
+			}
118
+			fflush($this->_handle);
119
+			$this->_sent .= $message;
120
+			return true;
121
+		}
122
+
123
+		/**
124
+		 *    Reads data from the socket. The error suppresion
125
+		 *    is a workaround for PHP4 always throwing a warning
126
+		 *    with a secure socket.
127
+		 *    @return integer/boolean           Incoming bytes. False
128
+		 *                                     on error.
129
+		 *    @access public
130
+		 */
131
+		function read() {
132
+			if ($this->isError() || ! $this->isOpen()) {
133
+				return false;
134
+			}
135
+			$raw = @fread($this->_handle, $this->_block_size);
136
+			if ($raw === false) {
137
+				$this->_setError('Cannot read from socket');
138
+				$this->close();
139
+			}
140
+			return $raw;
141
+		}
142
+
143
+		/**
144
+		 *    Accessor for socket open state.
145
+		 *    @return boolean           True if open.
146
+		 *    @access public
147
+		 */
148
+		function isOpen() {
149
+			return $this->_is_open;
150
+		}
151
+
152
+		/**
153
+		 *    Closes the socket preventing further reads.
154
+		 *    Cannot be reopened once closed.
155
+		 *    @return boolean           True if successful.
156
+		 *    @access public
157
+		 */
158
+		function close() {
159
+			$this->_is_open = false;
160
+			return fclose($this->_handle);
161
+		}
162
+
163
+		/**
164
+		 *    Accessor for content so far.
165
+		 *    @return string        Bytes sent only.
166
+		 *    @access public
167
+		 */
168
+		function getSent() {
169
+			return $this->_sent;
170
+		}
171
+
172
+		/**
173
+		 *    Actually opens the low level socket.
174
+		 *    @param string $host          Host to connect to.
175
+		 *    @param integer $port         Port on host.
176
+		 *    @param integer $error_number Recipient of error code.
177
+		 *    @param string $error         Recipoent of error message.
178
+		 *    @param integer $timeout      Maximum time to wait for connection.
179
+		 *    @access protected
180
+		 */
181
+		function _openSocket($host, $port, $error_number, $error, $timeout) {
182
+			return @fsockopen($host, $port, $error_number, $error, $timeout);
183
+		}
184
+	}
185
+
186
+	/**
187
+	 *    Wrapper for TCP/IP socket over TLS.
188
+	 *    @package SimpleTest
189
+	 *    @subpackage WebTester
190
+	 */
191
+	class SimpleSecureSocket extends SimpleSocket {
192
+
193
+		/**
194
+		 *    Opens a secure socket for reading and writing.
195
+		 *    @param string $host      Hostname to send request to.
196
+		 *    @param integer $port     Port on remote machine to open.
197
+		 *    @param integer $timeout  Connection timeout in seconds.
198
+		 *    @access public
199
+		 */
200
+		function SimpleSecureSocket($host, $port, $timeout) {
201
+			$this->SimpleSocket($host, $port, $timeout);
202
+		}
203
+
204
+		/**
205
+		 *    Actually opens the low level socket.
206
+		 *    @param string $host          Host to connect to.
207
+		 *    @param integer $port         Port on host.
208
+		 *    @param integer $error_number Recipient of error code.
209
+		 *    @param string $error         Recipient of error message.
210
+		 *    @param integer $timeout      Maximum time to wait for connection.
211
+		 *    @access protected
212
+		 */
213
+		function _openSocket($host, $port, $error_number, $error, $timeout) {
214
+			return parent::_openSocket("tls://$host", $port, $error_number, $error, $timeout);
215
+		}
216
+	}
217 217
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
          */
88 88
         function SimpleSocket($host, $port, $timeout, $block_size = 255) {
89 89
             $this->SimpleStickyError();
90
-            if (! ($this->_handle = $this->_openSocket($host, $port, $error_number, $error, $timeout))) {
90
+            if (!($this->_handle = $this->_openSocket($host, $port, $error_number, $error, $timeout))) {
91 91
                 $this->_setError("Cannot open [$host:$port] with [$error] within [$timeout] seconds");
92 92
                 return;
93 93
             }
@@ -103,11 +103,11 @@  discard block
 block discarded – undo
103 103
          *    @access public
104 104
          */
105 105
         function write($message) {
106
-            if ($this->isError() || ! $this->isOpen()) {
106
+            if ($this->isError() || !$this->isOpen()) {
107 107
                 return false;
108 108
             }
109 109
             $count = fwrite($this->_handle, $message);
110
-            if (! $count) {
110
+            if (!$count) {
111 111
                 if ($count === false) {
112 112
                     $this->_setError('Cannot write to socket');
113 113
                     $this->close();
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
          *    @access public
129 129
          */
130 130
         function read() {
131
-            if ($this->isError() || ! $this->isOpen()) {
131
+            if ($this->isError() || !$this->isOpen()) {
132 132
                 return false;
133 133
             }
134 134
             $raw = @fread($this->_handle, $this->_block_size);
Please login to merge, or discard this patch.
tests/test_tools/simpletest/dumper.php 2 patches
Indentation   +378 added lines, -378 removed lines patch added patch discarded remove patch
@@ -1,401 +1,401 @@
 block discarded – undo
1 1
 <?php
2
-    /**
3
-     *	base include file for SimpleTest
4
-     *	@package	SimpleTest
5
-     *	@subpackage	UnitTester
6
-     *	@version	$Id: dumper.php 1532 2006-12-01 12:28:55Z xue $
7
-     */
8
-    /**
9
-     * does type matter
10
-     */
11
-    if (! defined('TYPE_MATTERS')) {
12
-        define('TYPE_MATTERS', true);
13
-    }
2
+	/**
3
+	 *	base include file for SimpleTest
4
+	 *	@package	SimpleTest
5
+	 *	@subpackage	UnitTester
6
+	 *	@version	$Id: dumper.php 1532 2006-12-01 12:28:55Z xue $
7
+	 */
8
+	/**
9
+	 * does type matter
10
+	 */
11
+	if (! defined('TYPE_MATTERS')) {
12
+		define('TYPE_MATTERS', true);
13
+	}
14 14
 
15
-    /**
16
-     *    Displays variables as text and does diffs.
15
+	/**
16
+	 *    Displays variables as text and does diffs.
17 17
 	 *	  @package	SimpleTest
18 18
 	 *	  @subpackage	UnitTester
19
-     */
20
-    class SimpleDumper {
19
+	 */
20
+	class SimpleDumper {
21 21
 
22
-        /**
23
-         *    Renders a variable in a shorter form than print_r().
24
-         *    @param mixed $value      Variable to render as a string.
25
-         *    @return string           Human readable string form.
26
-         *    @access public
27
-         */
28
-        function describeValue($value) {
29
-            $type = $this->getType($value);
30
-            switch($type) {
31
-                case "Null":
32
-                    return "NULL";
33
-                case "Boolean":
34
-                    return "Boolean: " . ($value ? "true" : "false");
35
-                case "Array":
36
-                    return "Array: " . count($value) . " items";
37
-                case "Object":
38
-                    return "Object: of " . get_class($value);
39
-                case "String":
40
-                    return "String: " . $this->clipString($value, 200);
41
-                default:
42
-                    return "$type: $value";
43
-            }
44
-            return "Unknown";
45
-        }
22
+		/**
23
+		 *    Renders a variable in a shorter form than print_r().
24
+		 *    @param mixed $value      Variable to render as a string.
25
+		 *    @return string           Human readable string form.
26
+		 *    @access public
27
+		 */
28
+		function describeValue($value) {
29
+			$type = $this->getType($value);
30
+			switch($type) {
31
+				case "Null":
32
+					return "NULL";
33
+				case "Boolean":
34
+					return "Boolean: " . ($value ? "true" : "false");
35
+				case "Array":
36
+					return "Array: " . count($value) . " items";
37
+				case "Object":
38
+					return "Object: of " . get_class($value);
39
+				case "String":
40
+					return "String: " . $this->clipString($value, 200);
41
+				default:
42
+					return "$type: $value";
43
+			}
44
+			return "Unknown";
45
+		}
46 46
 
47
-        /**
48
-         *    Gets the string representation of a type.
49
-         *    @param mixed $value    Variable to check against.
50
-         *    @return string         Type.
51
-         *    @access public
52
-         */
53
-        function getType($value) {
54
-            if (! isset($value)) {
55
-                return "Null";
56
-            } elseif (is_bool($value)) {
57
-                return "Boolean";
58
-            } elseif (is_string($value)) {
59
-                return "String";
60
-            } elseif (is_integer($value)) {
61
-                return "Integer";
62
-            } elseif (is_float($value)) {
63
-                return "Float";
64
-            } elseif (is_array($value)) {
65
-                return "Array";
66
-            } elseif (is_resource($value)) {
67
-                return "Resource";
68
-            } elseif (is_object($value)) {
69
-                return "Object";
70
-            }
71
-            return "Unknown";
72
-        }
47
+		/**
48
+		 *    Gets the string representation of a type.
49
+		 *    @param mixed $value    Variable to check against.
50
+		 *    @return string         Type.
51
+		 *    @access public
52
+		 */
53
+		function getType($value) {
54
+			if (! isset($value)) {
55
+				return "Null";
56
+			} elseif (is_bool($value)) {
57
+				return "Boolean";
58
+			} elseif (is_string($value)) {
59
+				return "String";
60
+			} elseif (is_integer($value)) {
61
+				return "Integer";
62
+			} elseif (is_float($value)) {
63
+				return "Float";
64
+			} elseif (is_array($value)) {
65
+				return "Array";
66
+			} elseif (is_resource($value)) {
67
+				return "Resource";
68
+			} elseif (is_object($value)) {
69
+				return "Object";
70
+			}
71
+			return "Unknown";
72
+		}
73 73
 
74
-        /**
75
-         *    Creates a human readable description of the
76
-         *    difference between two variables. Uses a
77
-         *    dynamic call.
78
-         *    @param mixed $first        First variable.
79
-         *    @param mixed $second       Value to compare with.
80
-         *    @param boolean $identical  If true then type anomolies count.
81
-         *    @return string             Description of difference.
82
-         *    @access public
83
-         */
84
-        function describeDifference($first, $second, $identical = false) {
85
-            if ($identical) {
86
-                if (! $this->_isTypeMatch($first, $second)) {
87
-                    return "with type mismatch as [" . $this->describeValue($first) .
88
-                        "] does not match [" . $this->describeValue($second) . "]";
89
-                }
90
-            }
91
-            $type = $this->getType($first);
92
-            if ($type == "Unknown") {
93
-                return "with unknown type";
94
-            }
95
-            $method = '_describe' . $type . 'Difference';
96
-            return $this->$method($first, $second, $identical);
97
-        }
74
+		/**
75
+		 *    Creates a human readable description of the
76
+		 *    difference between two variables. Uses a
77
+		 *    dynamic call.
78
+		 *    @param mixed $first        First variable.
79
+		 *    @param mixed $second       Value to compare with.
80
+		 *    @param boolean $identical  If true then type anomolies count.
81
+		 *    @return string             Description of difference.
82
+		 *    @access public
83
+		 */
84
+		function describeDifference($first, $second, $identical = false) {
85
+			if ($identical) {
86
+				if (! $this->_isTypeMatch($first, $second)) {
87
+					return "with type mismatch as [" . $this->describeValue($first) .
88
+						"] does not match [" . $this->describeValue($second) . "]";
89
+				}
90
+			}
91
+			$type = $this->getType($first);
92
+			if ($type == "Unknown") {
93
+				return "with unknown type";
94
+			}
95
+			$method = '_describe' . $type . 'Difference';
96
+			return $this->$method($first, $second, $identical);
97
+		}
98 98
 
99
-        /**
100
-         *    Tests to see if types match.
101
-         *    @param mixed $first        First variable.
102
-         *    @param mixed $second       Value to compare with.
103
-         *    @return boolean            True if matches.
104
-         *    @access private
105
-         */
106
-        function _isTypeMatch($first, $second) {
107
-            return ($this->getType($first) == $this->getType($second));
108
-        }
99
+		/**
100
+		 *    Tests to see if types match.
101
+		 *    @param mixed $first        First variable.
102
+		 *    @param mixed $second       Value to compare with.
103
+		 *    @return boolean            True if matches.
104
+		 *    @access private
105
+		 */
106
+		function _isTypeMatch($first, $second) {
107
+			return ($this->getType($first) == $this->getType($second));
108
+		}
109 109
 
110
-        /**
111
-         *    Clips a string to a maximum length.
112
-         *    @param string $value         String to truncate.
113
-         *    @param integer $size         Minimum string size to show.
114
-         *    @param integer $position     Centre of string section.
115
-         *    @return string               Shortened version.
116
-         *    @access public
117
-         */
118
-        function clipString($value, $size, $position = 0) {
119
-            $length = strlen($value);
120
-            if ($length <= $size) {
121
-                return $value;
122
-            }
123
-            $position = min($position, $length);
124
-            $start = ($size/2 > $position ? 0 : $position - $size/2);
125
-            if ($start + $size > $length) {
126
-                $start = $length - $size;
127
-            }
128
-            $value = substr($value, $start, $size);
129
-            return ($start > 0 ? "..." : "") . $value . ($start + $size < $length ? "..." : "");
130
-        }
110
+		/**
111
+		 *    Clips a string to a maximum length.
112
+		 *    @param string $value         String to truncate.
113
+		 *    @param integer $size         Minimum string size to show.
114
+		 *    @param integer $position     Centre of string section.
115
+		 *    @return string               Shortened version.
116
+		 *    @access public
117
+		 */
118
+		function clipString($value, $size, $position = 0) {
119
+			$length = strlen($value);
120
+			if ($length <= $size) {
121
+				return $value;
122
+			}
123
+			$position = min($position, $length);
124
+			$start = ($size/2 > $position ? 0 : $position - $size/2);
125
+			if ($start + $size > $length) {
126
+				$start = $length - $size;
127
+			}
128
+			$value = substr($value, $start, $size);
129
+			return ($start > 0 ? "..." : "") . $value . ($start + $size < $length ? "..." : "");
130
+		}
131 131
 
132
-        /**
133
-         *    Creates a human readable description of the
134
-         *    difference between two variables. The minimal
135
-         *    version.
136
-         *    @param null $first          First value.
137
-         *    @param mixed $second        Value to compare with.
138
-         *    @return string              Human readable description.
139
-         *    @access private
140
-         */
141
-        function _describeGenericDifference($first, $second) {
142
-            return "as [" . $this->describeValue($first) .
143
-                    "] does not match [" .
144
-                    $this->describeValue($second) . "]";
145
-        }
132
+		/**
133
+		 *    Creates a human readable description of the
134
+		 *    difference between two variables. The minimal
135
+		 *    version.
136
+		 *    @param null $first          First value.
137
+		 *    @param mixed $second        Value to compare with.
138
+		 *    @return string              Human readable description.
139
+		 *    @access private
140
+		 */
141
+		function _describeGenericDifference($first, $second) {
142
+			return "as [" . $this->describeValue($first) .
143
+					"] does not match [" .
144
+					$this->describeValue($second) . "]";
145
+		}
146 146
 
147
-        /**
148
-         *    Creates a human readable description of the
149
-         *    difference between a null and another variable.
150
-         *    @param null $first          First null.
151
-         *    @param mixed $second        Null to compare with.
152
-         *    @param boolean $identical   If true then type anomolies count.
153
-         *    @return string              Human readable description.
154
-         *    @access private
155
-         */
156
-        function _describeNullDifference($first, $second, $identical) {
157
-            return $this->_describeGenericDifference($first, $second);
158
-        }
147
+		/**
148
+		 *    Creates a human readable description of the
149
+		 *    difference between a null and another variable.
150
+		 *    @param null $first          First null.
151
+		 *    @param mixed $second        Null to compare with.
152
+		 *    @param boolean $identical   If true then type anomolies count.
153
+		 *    @return string              Human readable description.
154
+		 *    @access private
155
+		 */
156
+		function _describeNullDifference($first, $second, $identical) {
157
+			return $this->_describeGenericDifference($first, $second);
158
+		}
159 159
 
160
-        /**
161
-         *    Creates a human readable description of the
162
-         *    difference between a boolean and another variable.
163
-         *    @param boolean $first       First boolean.
164
-         *    @param mixed $second        Boolean to compare with.
165
-         *    @param boolean $identical   If true then type anomolies count.
166
-         *    @return string              Human readable description.
167
-         *    @access private
168
-         */
169
-        function _describeBooleanDifference($first, $second, $identical) {
170
-            return $this->_describeGenericDifference($first, $second);
171
-        }
160
+		/**
161
+		 *    Creates a human readable description of the
162
+		 *    difference between a boolean and another variable.
163
+		 *    @param boolean $first       First boolean.
164
+		 *    @param mixed $second        Boolean to compare with.
165
+		 *    @param boolean $identical   If true then type anomolies count.
166
+		 *    @return string              Human readable description.
167
+		 *    @access private
168
+		 */
169
+		function _describeBooleanDifference($first, $second, $identical) {
170
+			return $this->_describeGenericDifference($first, $second);
171
+		}
172 172
 
173
-        /**
174
-         *    Creates a human readable description of the
175
-         *    difference between a string and another variable.
176
-         *    @param string $first        First string.
177
-         *    @param mixed $second        String to compare with.
178
-         *    @param boolean $identical   If true then type anomolies count.
179
-         *    @return string              Human readable description.
180
-         *    @access private
181
-         */
182
-        function _describeStringDifference($first, $second, $identical) {
183
-            if (is_object($second) || is_array($second)) {
184
-                return $this->_describeGenericDifference($first, $second);
185
-            }
186
-            $position = $this->_stringDiffersAt($first, $second);
187
-            $message = "at character $position";
188
-            $message .= " with [" .
189
-                    $this->clipString($first, 200, $position) . "] and [" .
190
-                    $this->clipString($second, 200, $position) . "]";
191
-            return $message;
192
-        }
173
+		/**
174
+		 *    Creates a human readable description of the
175
+		 *    difference between a string and another variable.
176
+		 *    @param string $first        First string.
177
+		 *    @param mixed $second        String to compare with.
178
+		 *    @param boolean $identical   If true then type anomolies count.
179
+		 *    @return string              Human readable description.
180
+		 *    @access private
181
+		 */
182
+		function _describeStringDifference($first, $second, $identical) {
183
+			if (is_object($second) || is_array($second)) {
184
+				return $this->_describeGenericDifference($first, $second);
185
+			}
186
+			$position = $this->_stringDiffersAt($first, $second);
187
+			$message = "at character $position";
188
+			$message .= " with [" .
189
+					$this->clipString($first, 200, $position) . "] and [" .
190
+					$this->clipString($second, 200, $position) . "]";
191
+			return $message;
192
+		}
193 193
 
194
-        /**
195
-         *    Creates a human readable description of the
196
-         *    difference between an integer and another variable.
197
-         *    @param integer $first       First number.
198
-         *    @param mixed $second        Number to compare with.
199
-         *    @param boolean $identical   If true then type anomolies count.
200
-         *    @return string              Human readable description.
201
-         *    @access private
202
-         */
203
-        function _describeIntegerDifference($first, $second, $identical) {
204
-            if (is_object($second) || is_array($second)) {
205
-                return $this->_describeGenericDifference($first, $second);
206
-            }
207
-            return "because [" . $this->describeValue($first) .
208
-                    "] differs from [" .
209
-                    $this->describeValue($second) . "] by " .
210
-                    abs($first - $second);
211
-        }
194
+		/**
195
+		 *    Creates a human readable description of the
196
+		 *    difference between an integer and another variable.
197
+		 *    @param integer $first       First number.
198
+		 *    @param mixed $second        Number to compare with.
199
+		 *    @param boolean $identical   If true then type anomolies count.
200
+		 *    @return string              Human readable description.
201
+		 *    @access private
202
+		 */
203
+		function _describeIntegerDifference($first, $second, $identical) {
204
+			if (is_object($second) || is_array($second)) {
205
+				return $this->_describeGenericDifference($first, $second);
206
+			}
207
+			return "because [" . $this->describeValue($first) .
208
+					"] differs from [" .
209
+					$this->describeValue($second) . "] by " .
210
+					abs($first - $second);
211
+		}
212 212
 
213
-        /**
214
-         *    Creates a human readable description of the
215
-         *    difference between two floating point numbers.
216
-         *    @param float $first         First float.
217
-         *    @param mixed $second        Float to compare with.
218
-         *    @param boolean $identical   If true then type anomolies count.
219
-         *    @return string              Human readable description.
220
-         *    @access private
221
-         */
222
-        function _describeFloatDifference($first, $second, $identical) {
223
-            if (is_object($second) || is_array($second)) {
224
-                return $this->_describeGenericDifference($first, $second);
225
-            }
226
-            return "because [" . $this->describeValue($first) .
227
-                    "] differs from [" .
228
-                    $this->describeValue($second) . "] by " .
229
-                    abs($first - $second);
230
-        }
213
+		/**
214
+		 *    Creates a human readable description of the
215
+		 *    difference between two floating point numbers.
216
+		 *    @param float $first         First float.
217
+		 *    @param mixed $second        Float to compare with.
218
+		 *    @param boolean $identical   If true then type anomolies count.
219
+		 *    @return string              Human readable description.
220
+		 *    @access private
221
+		 */
222
+		function _describeFloatDifference($first, $second, $identical) {
223
+			if (is_object($second) || is_array($second)) {
224
+				return $this->_describeGenericDifference($first, $second);
225
+			}
226
+			return "because [" . $this->describeValue($first) .
227
+					"] differs from [" .
228
+					$this->describeValue($second) . "] by " .
229
+					abs($first - $second);
230
+		}
231 231
 
232
-        /**
233
-         *    Creates a human readable description of the
234
-         *    difference between two arrays.
235
-         *    @param array $first         First array.
236
-         *    @param mixed $second        Array to compare with.
237
-         *    @param boolean $identical   If true then type anomolies count.
238
-         *    @return string              Human readable description.
239
-         *    @access private
240
-         */
241
-        function _describeArrayDifference($first, $second, $identical) {
242
-            if (! is_array($second)) {
243
-                return $this->_describeGenericDifference($first, $second);
244
-            }
245
-            if (! $this->_isMatchingKeys($first, $second, $identical)) {
246
-                return "as key list [" .
247
-                        implode(", ", array_keys($first)) . "] does not match key list [" .
248
-                        implode(", ", array_keys($second)) . "]";
249
-            }
250
-            foreach (array_keys($first) as $key) {
251
-                if ($identical && ($first[$key] === $second[$key])) {
252
-                    continue;
253
-                }
254
-                if (! $identical && ($first[$key] == $second[$key])) {
255
-                    continue;
256
-                }
257
-                return "with member [$key] " . $this->describeDifference(
258
-                        $first[$key],
259
-                        $second[$key],
260
-                        $identical);
261
-            }
262
-            return "";
263
-        }
232
+		/**
233
+		 *    Creates a human readable description of the
234
+		 *    difference between two arrays.
235
+		 *    @param array $first         First array.
236
+		 *    @param mixed $second        Array to compare with.
237
+		 *    @param boolean $identical   If true then type anomolies count.
238
+		 *    @return string              Human readable description.
239
+		 *    @access private
240
+		 */
241
+		function _describeArrayDifference($first, $second, $identical) {
242
+			if (! is_array($second)) {
243
+				return $this->_describeGenericDifference($first, $second);
244
+			}
245
+			if (! $this->_isMatchingKeys($first, $second, $identical)) {
246
+				return "as key list [" .
247
+						implode(", ", array_keys($first)) . "] does not match key list [" .
248
+						implode(", ", array_keys($second)) . "]";
249
+			}
250
+			foreach (array_keys($first) as $key) {
251
+				if ($identical && ($first[$key] === $second[$key])) {
252
+					continue;
253
+				}
254
+				if (! $identical && ($first[$key] == $second[$key])) {
255
+					continue;
256
+				}
257
+				return "with member [$key] " . $this->describeDifference(
258
+						$first[$key],
259
+						$second[$key],
260
+						$identical);
261
+			}
262
+			return "";
263
+		}
264 264
 
265
-        /**
266
-         *    Compares two arrays to see if their key lists match.
267
-         *    For an identical match, the ordering and types of the keys
268
-         *    is significant.
269
-         *    @param array $first         First array.
270
-         *    @param array $second        Array to compare with.
271
-         *    @param boolean $identical   If true then type anomolies count.
272
-         *    @return boolean             True if matching.
273
-         *    @access private
274
-         */
275
-        function _isMatchingKeys($first, $second, $identical) {
276
-            $first_keys = array_keys($first);
277
-            $second_keys = array_keys($second);
278
-            if ($identical) {
279
-                return ($first_keys === $second_keys);
280
-            }
281
-            sort($first_keys);
282
-            sort($second_keys);
283
-            return ($first_keys == $second_keys);
284
-        }
265
+		/**
266
+		 *    Compares two arrays to see if their key lists match.
267
+		 *    For an identical match, the ordering and types of the keys
268
+		 *    is significant.
269
+		 *    @param array $first         First array.
270
+		 *    @param array $second        Array to compare with.
271
+		 *    @param boolean $identical   If true then type anomolies count.
272
+		 *    @return boolean             True if matching.
273
+		 *    @access private
274
+		 */
275
+		function _isMatchingKeys($first, $second, $identical) {
276
+			$first_keys = array_keys($first);
277
+			$second_keys = array_keys($second);
278
+			if ($identical) {
279
+				return ($first_keys === $second_keys);
280
+			}
281
+			sort($first_keys);
282
+			sort($second_keys);
283
+			return ($first_keys == $second_keys);
284
+		}
285 285
 
286
-        /**
287
-         *    Creates a human readable description of the
288
-         *    difference between a resource and another variable.
289
-         *    @param resource $first       First resource.
290
-         *    @param mixed $second         Resource to compare with.
291
-         *    @param boolean $identical    If true then type anomolies count.
292
-         *    @return string              Human readable description.
293
-         *    @access private
294
-         */
295
-        function _describeResourceDifference($first, $second, $identical) {
296
-            return $this->_describeGenericDifference($first, $second);
297
-        }
286
+		/**
287
+		 *    Creates a human readable description of the
288
+		 *    difference between a resource and another variable.
289
+		 *    @param resource $first       First resource.
290
+		 *    @param mixed $second         Resource to compare with.
291
+		 *    @param boolean $identical    If true then type anomolies count.
292
+		 *    @return string              Human readable description.
293
+		 *    @access private
294
+		 */
295
+		function _describeResourceDifference($first, $second, $identical) {
296
+			return $this->_describeGenericDifference($first, $second);
297
+		}
298 298
 
299
-        /**
300
-         *    Creates a human readable description of the
301
-         *    difference between two objects.
302
-         *    @param object $first        First object.
303
-         *    @param mixed $second        Object to compare with.
304
-         *    @param boolean $identical   If true then type anomolies count.
305
-         *    @return string              Human readable description.
306
-         *    @access private
307
-         */
308
-        function _describeObjectDifference($first, $second, $identical) {
309
-            if (! is_object($second)) {
310
-                return $this->_describeGenericDifference($first, $second);
311
-            }
312
-            return $this->_describeArrayDifference(
313
-                    get_object_vars($first),
314
-                    get_object_vars($second),
315
-                    $identical);
316
-        }
299
+		/**
300
+		 *    Creates a human readable description of the
301
+		 *    difference between two objects.
302
+		 *    @param object $first        First object.
303
+		 *    @param mixed $second        Object to compare with.
304
+		 *    @param boolean $identical   If true then type anomolies count.
305
+		 *    @return string              Human readable description.
306
+		 *    @access private
307
+		 */
308
+		function _describeObjectDifference($first, $second, $identical) {
309
+			if (! is_object($second)) {
310
+				return $this->_describeGenericDifference($first, $second);
311
+			}
312
+			return $this->_describeArrayDifference(
313
+					get_object_vars($first),
314
+					get_object_vars($second),
315
+					$identical);
316
+		}
317 317
 
318
-        /**
319
-         *    Find the first character position that differs
320
-         *    in two strings by binary chop.
321
-         *    @param string $first        First string.
322
-         *    @param string $second       String to compare with.
323
-         *    @return integer             Position of first differing
324
-         *                                character.
325
-         *    @access private
326
-         */
327
-        function _stringDiffersAt($first, $second) {
328
-            if (! $first || ! $second) {
329
-                return 0;
330
-            }
331
-            if (strlen($first) < strlen($second)) {
332
-                list($first, $second) = array($second, $first);
333
-            }
334
-            $position = 0;
335
-            $step = strlen($first);
336
-            while ($step > 1) {
337
-                $step = (integer)(($step + 1) / 2);
338
-                if (strncmp($first, $second, $position + $step) == 0) {
339
-                    $position += $step;
340
-                }
341
-            }
342
-            return $position;
343
-        }
318
+		/**
319
+		 *    Find the first character position that differs
320
+		 *    in two strings by binary chop.
321
+		 *    @param string $first        First string.
322
+		 *    @param string $second       String to compare with.
323
+		 *    @return integer             Position of first differing
324
+		 *                                character.
325
+		 *    @access private
326
+		 */
327
+		function _stringDiffersAt($first, $second) {
328
+			if (! $first || ! $second) {
329
+				return 0;
330
+			}
331
+			if (strlen($first) < strlen($second)) {
332
+				list($first, $second) = array($second, $first);
333
+			}
334
+			$position = 0;
335
+			$step = strlen($first);
336
+			while ($step > 1) {
337
+				$step = (integer)(($step + 1) / 2);
338
+				if (strncmp($first, $second, $position + $step) == 0) {
339
+					$position += $step;
340
+				}
341
+			}
342
+			return $position;
343
+		}
344 344
 
345
-        /**
346
-         *    Sends a formatted dump of a variable to a string.
347
-         *    @param mixed $variable    Variable to display.
348
-         *    @return string            Output from print_r().
349
-         *    @access public
350
-         *    @static
351
-         */
352
-        static function dump($variable) {
353
-            ob_start();
354
-            print_r($variable);
355
-            $formatted = ob_get_contents();
356
-            ob_end_clean();
357
-            return $formatted;
358
-        }
345
+		/**
346
+		 *    Sends a formatted dump of a variable to a string.
347
+		 *    @param mixed $variable    Variable to display.
348
+		 *    @return string            Output from print_r().
349
+		 *    @access public
350
+		 *    @static
351
+		 */
352
+		static function dump($variable) {
353
+			ob_start();
354
+			print_r($variable);
355
+			$formatted = ob_get_contents();
356
+			ob_end_clean();
357
+			return $formatted;
358
+		}
359 359
 
360
-        /**
361
-         *    Extracts the last assertion that was not within
362
-         *    Simpletest itself. The name must start with "assert".
363
-         *    @param array $stack      List of stack frames.
364
-         *    @access public
365
-         *    @static
366
-         */
367
-        static function getFormattedAssertionLine($stack) {
368
-            foreach ($stack as $frame) {
369
-                if (isset($frame['file'])) {
370
-                    if (strpos($frame['file'], SIMPLE_TEST) !== false) {
371
-                        if (dirname($frame['file']) . '/' == SIMPLE_TEST) {
372
-                            continue;
373
-                        }
374
-                    }
375
-                }
376
-                if (SimpleDumper::_stackFrameIsAnAssertion($frame)) {
377
-                    return ' at [' . $frame['file'] . ' line ' . $frame['line'] . ']';
378
-                }
379
-            }
380
-            return '';
381
-        }
360
+		/**
361
+		 *    Extracts the last assertion that was not within
362
+		 *    Simpletest itself. The name must start with "assert".
363
+		 *    @param array $stack      List of stack frames.
364
+		 *    @access public
365
+		 *    @static
366
+		 */
367
+		static function getFormattedAssertionLine($stack) {
368
+			foreach ($stack as $frame) {
369
+				if (isset($frame['file'])) {
370
+					if (strpos($frame['file'], SIMPLE_TEST) !== false) {
371
+						if (dirname($frame['file']) . '/' == SIMPLE_TEST) {
372
+							continue;
373
+						}
374
+					}
375
+				}
376
+				if (SimpleDumper::_stackFrameIsAnAssertion($frame)) {
377
+					return ' at [' . $frame['file'] . ' line ' . $frame['line'] . ']';
378
+				}
379
+			}
380
+			return '';
381
+		}
382 382
 
383
-        /**
384
-         *    Tries to determine if the method call is an assertion.
385
-         *    @param array $frame     PHP stack frame.
386
-         *    @access private
387
-         *    @static
388
-         */
389
-        static function _stackFrameIsAnAssertion($frame) {
390
-            if (($frame['function'] == 'fail') || ($frame['function'] == 'pass')) {
391
-                return true;
392
-            }
393
-            if (strncmp($frame['function'], 'assert', 6) == 0) {
394
-                return true;
395
-            }
396
-            if (strncmp($frame['function'], 'expect', 6) == 0) {
397
-                return true;
398
-            }
399
-            return false;
400
-        }
401
-    }
402 383
\ No newline at end of file
384
+		/**
385
+		 *    Tries to determine if the method call is an assertion.
386
+		 *    @param array $frame     PHP stack frame.
387
+		 *    @access private
388
+		 *    @static
389
+		 */
390
+		static function _stackFrameIsAnAssertion($frame) {
391
+			if (($frame['function'] == 'fail') || ($frame['function'] == 'pass')) {
392
+				return true;
393
+			}
394
+			if (strncmp($frame['function'], 'assert', 6) == 0) {
395
+				return true;
396
+			}
397
+			if (strncmp($frame['function'], 'expect', 6) == 0) {
398
+				return true;
399
+			}
400
+			return false;
401
+		}
402
+	}
403 403
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
     /**
9 9
      * does type matter
10 10
      */
11
-    if (! defined('TYPE_MATTERS')) {
11
+    if (!defined('TYPE_MATTERS')) {
12 12
         define('TYPE_MATTERS', true);
13 13
     }
14 14
 
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
          */
28 28
         function describeValue($value) {
29 29
             $type = $this->getType($value);
30
-            switch($type) {
30
+            switch ($type) {
31 31
                 case "Null":
32 32
                     return "NULL";
33 33
                 case "Boolean":
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
          *    @access public
52 52
          */
53 53
         function getType($value) {
54
-            if (! isset($value)) {
54
+            if (!isset($value)) {
55 55
                 return "Null";
56 56
             } elseif (is_bool($value)) {
57 57
                 return "Boolean";
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
          */
84 84
         function describeDifference($first, $second, $identical = false) {
85 85
             if ($identical) {
86
-                if (! $this->_isTypeMatch($first, $second)) {
86
+                if (!$this->_isTypeMatch($first, $second)) {
87 87
                     return "with type mismatch as [" . $this->describeValue($first) .
88 88
                         "] does not match [" . $this->describeValue($second) . "]";
89 89
                 }
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
                 return $value;
122 122
             }
123 123
             $position = min($position, $length);
124
-            $start = ($size/2 > $position ? 0 : $position - $size/2);
124
+            $start = ($size / 2 > $position ? 0 : $position - $size / 2);
125 125
             if ($start + $size > $length) {
126 126
                 $start = $length - $size;
127 127
             }
@@ -239,10 +239,10 @@  discard block
 block discarded – undo
239 239
          *    @access private
240 240
          */
241 241
         function _describeArrayDifference($first, $second, $identical) {
242
-            if (! is_array($second)) {
242
+            if (!is_array($second)) {
243 243
                 return $this->_describeGenericDifference($first, $second);
244 244
             }
245
-            if (! $this->_isMatchingKeys($first, $second, $identical)) {
245
+            if (!$this->_isMatchingKeys($first, $second, $identical)) {
246 246
                 return "as key list [" .
247 247
                         implode(", ", array_keys($first)) . "] does not match key list [" .
248 248
                         implode(", ", array_keys($second)) . "]";
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
                 if ($identical && ($first[$key] === $second[$key])) {
252 252
                     continue;
253 253
                 }
254
-                if (! $identical && ($first[$key] == $second[$key])) {
254
+                if (!$identical && ($first[$key] == $second[$key])) {
255 255
                     continue;
256 256
                 }
257 257
                 return "with member [$key] " . $this->describeDifference(
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
          *    @access private
307 307
          */
308 308
         function _describeObjectDifference($first, $second, $identical) {
309
-            if (! is_object($second)) {
309
+            if (!is_object($second)) {
310 310
                 return $this->_describeGenericDifference($first, $second);
311 311
             }
312 312
             return $this->_describeArrayDifference(
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
          *    @access private
326 326
          */
327 327
         function _stringDiffersAt($first, $second) {
328
-            if (! $first || ! $second) {
328
+            if (!$first || !$second) {
329 329
                 return 0;
330 330
             }
331 331
             if (strlen($first) < strlen($second)) {
@@ -334,7 +334,7 @@  discard block
 block discarded – undo
334 334
             $position = 0;
335 335
             $step = strlen($first);
336 336
             while ($step > 1) {
337
-                $step = (integer)(($step + 1) / 2);
337
+                $step = (integer) (($step + 1) / 2);
338 338
                 if (strncmp($first, $second, $position + $step) == 0) {
339 339
                     $position += $step;
340 340
                 }
Please login to merge, or discard this patch.
tests/test_tools/simpletest/reflection_php5.php 2 patches
Indentation   +251 added lines, -251 removed lines patch added patch discarded remove patch
@@ -1,274 +1,274 @@
 block discarded – undo
1 1
 <?php
2
-    /**
3
-     *	base include file for SimpleTest
4
-     *	@package	SimpleTest
5
-     *	@subpackage	UnitTester
6
-     *	@version	$Id: reflection_php5.php 1398 2006-09-08 19:31:03Z xue $
7
-     */
2
+	/**
3
+	 *	base include file for SimpleTest
4
+	 *	@package	SimpleTest
5
+	 *	@subpackage	UnitTester
6
+	 *	@version	$Id: reflection_php5.php 1398 2006-09-08 19:31:03Z xue $
7
+	 */
8 8
 
9
-    /**
10
-     *    Version specific reflection API.
9
+	/**
10
+	 *    Version specific reflection API.
11 11
 	 *    @package SimpleTest
12 12
 	 *    @subpackage UnitTester
13
-     */
14
-    class SimpleReflection {
15
-        protected $_interface;
13
+	 */
14
+	class SimpleReflection {
15
+		protected $_interface;
16 16
 
17
-        /**
18
-         *    Stashes the class/interface.
19
-         *    @param string $interface    Class or interface
20
-         *                                to inspect.
21
-         */
22
-        function SimpleReflection($interface) {
23
-            $this->_interface = $interface;
24
-        }
17
+		/**
18
+		 *    Stashes the class/interface.
19
+		 *    @param string $interface    Class or interface
20
+		 *                                to inspect.
21
+		 */
22
+		function SimpleReflection($interface) {
23
+			$this->_interface = $interface;
24
+		}
25 25
 
26
-        /**
27
-         *    Checks that a class has been declared. Versions
28
-         *    before PHP5.0.2 need a check that it's not really
29
-         *    an interface.
30
-         *    @return boolean            True if defined.
31
-         *    @access public
32
-         */
33
-        function classExists() {
34
-            if (! class_exists($this->_interface)) {
35
-                return false;
36
-            }
37
-            $reflection = new ReflectionClass($this->_interface);
38
-            return ! $reflection->isInterface();
39
-        }
26
+		/**
27
+		 *    Checks that a class has been declared. Versions
28
+		 *    before PHP5.0.2 need a check that it's not really
29
+		 *    an interface.
30
+		 *    @return boolean            True if defined.
31
+		 *    @access public
32
+		 */
33
+		function classExists() {
34
+			if (! class_exists($this->_interface)) {
35
+				return false;
36
+			}
37
+			$reflection = new ReflectionClass($this->_interface);
38
+			return ! $reflection->isInterface();
39
+		}
40 40
 
41
-        /**
42
-         *    Needed to kill the autoload feature in PHP5
43
-         *    for classes created dynamically.
44
-         *    @return boolean        True if defined.
45
-         *    @access public
46
-         */
47
-        function classExistsSansAutoload() {
48
-            return class_exists($this->_interface, false);
49
-        }
41
+		/**
42
+		 *    Needed to kill the autoload feature in PHP5
43
+		 *    for classes created dynamically.
44
+		 *    @return boolean        True if defined.
45
+		 *    @access public
46
+		 */
47
+		function classExistsSansAutoload() {
48
+			return class_exists($this->_interface, false);
49
+		}
50 50
 
51
-        /**
52
-         *    Checks that a class or interface has been
53
-         *    declared.
54
-         *    @return boolean            True if defined.
55
-         *    @access public
56
-         */
57
-        function classOrInterfaceExists() {
58
-            return $this->_classOrInterfaceExistsWithAutoload($this->_interface, true);
59
-        }
51
+		/**
52
+		 *    Checks that a class or interface has been
53
+		 *    declared.
54
+		 *    @return boolean            True if defined.
55
+		 *    @access public
56
+		 */
57
+		function classOrInterfaceExists() {
58
+			return $this->_classOrInterfaceExistsWithAutoload($this->_interface, true);
59
+		}
60 60
 
61
-        /**
62
-         *    Needed to kill the autoload feature in PHP5
63
-         *    for classes created dynamically.
64
-         *    @return boolean        True if defined.
65
-         *    @access public
66
-         */
67
-        function classOrInterfaceExistsSansAutoload() {
68
-            return $this->_classOrInterfaceExistsWithAutoload($this->_interface, false);
69
-        }
61
+		/**
62
+		 *    Needed to kill the autoload feature in PHP5
63
+		 *    for classes created dynamically.
64
+		 *    @return boolean        True if defined.
65
+		 *    @access public
66
+		 */
67
+		function classOrInterfaceExistsSansAutoload() {
68
+			return $this->_classOrInterfaceExistsWithAutoload($this->_interface, false);
69
+		}
70 70
 
71
-        /**
72
-         *    Needed to select the autoload feature in PHP5
73
-         *    for classes created dynamically.
74
-         *    @param string $interface       Class or interface name.
75
-         *    @param boolean $autoload       True totriggerautoload.
76
-         *    @return boolean                True if interface defined.
77
-         *    @access private
78
-         */
79
-        function _classOrInterfaceExistsWithAutoload($interface, $autoload) {
80
-            if (function_exists('interface_exists')) {
81
-                if (interface_exists($this->_interface, $autoload)) {
82
-                    return true;
83
-                }
84
-            }
85
-            return class_exists($this->_interface, $autoload);
86
-        }
71
+		/**
72
+		 *    Needed to select the autoload feature in PHP5
73
+		 *    for classes created dynamically.
74
+		 *    @param string $interface       Class or interface name.
75
+		 *    @param boolean $autoload       True totriggerautoload.
76
+		 *    @return boolean                True if interface defined.
77
+		 *    @access private
78
+		 */
79
+		function _classOrInterfaceExistsWithAutoload($interface, $autoload) {
80
+			if (function_exists('interface_exists')) {
81
+				if (interface_exists($this->_interface, $autoload)) {
82
+					return true;
83
+				}
84
+			}
85
+			return class_exists($this->_interface, $autoload);
86
+		}
87 87
 
88
-        /**
89
-         *    Gets the list of methods on a class or
90
-         *    interface. Needs to recursively look at all of
91
-         *    the interfaces included.
92
-         *    @returns array              List of method names.
93
-         *    @access public
94
-         */
95
-        function getMethods() {
96
-            return array_unique(get_class_methods($this->_interface));
97
-        }
88
+		/**
89
+		 *    Gets the list of methods on a class or
90
+		 *    interface. Needs to recursively look at all of
91
+		 *    the interfaces included.
92
+		 *    @returns array              List of method names.
93
+		 *    @access public
94
+		 */
95
+		function getMethods() {
96
+			return array_unique(get_class_methods($this->_interface));
97
+		}
98 98
 
99
-        /**
100
-         *    Gets the list of interfaces from a class. If the
101
-         *    class name is actually an interface then just that
102
-         *    interface is returned.
103
-         *    @returns array          List of interfaces.
104
-         *    @access public
105
-         */
106
-        function getInterfaces() {
107
-            $reflection = new ReflectionClass($this->_interface);
108
-            if ($reflection->isInterface()) {
109
-            	return array($this->_interface);
110
-            }
111
-            return $this->_onlyParents($reflection->getInterfaces());
112
-        }
99
+		/**
100
+		 *    Gets the list of interfaces from a class. If the
101
+		 *    class name is actually an interface then just that
102
+		 *    interface is returned.
103
+		 *    @returns array          List of interfaces.
104
+		 *    @access public
105
+		 */
106
+		function getInterfaces() {
107
+			$reflection = new ReflectionClass($this->_interface);
108
+			if ($reflection->isInterface()) {
109
+				return array($this->_interface);
110
+			}
111
+			return $this->_onlyParents($reflection->getInterfaces());
112
+		}
113 113
 
114
-        /**
115
-         *    Gets the list of methods for the implemented
116
-         *    interfaces only.
117
-         *    @returns array      List of enforced method signatures.
118
-         *    @access public
119
-         */
120
-        function getInterfaceMethods() {
121
-            $methods = array();
122
-            foreach ($this->getInterfaces() as $interface) {
123
-                $methods = array_merge($methods, get_class_methods($interface));
124
-            }
125
-            return array_unique($methods);
126
-        }
114
+		/**
115
+		 *    Gets the list of methods for the implemented
116
+		 *    interfaces only.
117
+		 *    @returns array      List of enforced method signatures.
118
+		 *    @access public
119
+		 */
120
+		function getInterfaceMethods() {
121
+			$methods = array();
122
+			foreach ($this->getInterfaces() as $interface) {
123
+				$methods = array_merge($methods, get_class_methods($interface));
124
+			}
125
+			return array_unique($methods);
126
+		}
127 127
 
128
-        /**
129
-         *    Checks to see if the method signature has to be tightly
130
-         *    specified.
131
-         *    @param string $method        Method name.
132
-         *    @returns boolean             True if enforced.
133
-         *    @access private
134
-         */
135
-        function _isInterfaceMethod($method) {
136
-            return in_array($method, $this->getInterfaceMethods());
137
-        }
128
+		/**
129
+		 *    Checks to see if the method signature has to be tightly
130
+		 *    specified.
131
+		 *    @param string $method        Method name.
132
+		 *    @returns boolean             True if enforced.
133
+		 *    @access private
134
+		 */
135
+		function _isInterfaceMethod($method) {
136
+			return in_array($method, $this->getInterfaceMethods());
137
+		}
138 138
 
139
-        /**
140
-         *    Finds the parent class name.
141
-         *    @returns string      Parent class name.
142
-         *    @access public
143
-         */
144
-        function getParent() {
145
-            $reflection = new ReflectionClass($this->_interface);
146
-            $parent = $reflection->getParentClass();
147
-            if ($parent) {
148
-                return $parent->getName();
149
-            }
150
-            return false;
151
-        }
139
+		/**
140
+		 *    Finds the parent class name.
141
+		 *    @returns string      Parent class name.
142
+		 *    @access public
143
+		 */
144
+		function getParent() {
145
+			$reflection = new ReflectionClass($this->_interface);
146
+			$parent = $reflection->getParentClass();
147
+			if ($parent) {
148
+				return $parent->getName();
149
+			}
150
+			return false;
151
+		}
152 152
 
153
-        /**
154
-         *    Determines if the class is abstract.
155
-         *    @returns boolean      True if abstract.
156
-         *    @access public
157
-         */
158
-        function isAbstract() {
159
-            $reflection = new ReflectionClass($this->_interface);
160
-            return $reflection->isAbstract();
161
-        }
153
+		/**
154
+		 *    Determines if the class is abstract.
155
+		 *    @returns boolean      True if abstract.
156
+		 *    @access public
157
+		 */
158
+		function isAbstract() {
159
+			$reflection = new ReflectionClass($this->_interface);
160
+			return $reflection->isAbstract();
161
+		}
162 162
 
163
-        /**
164
-         *    Wittles a list of interfaces down to only the top
165
-         *    level parents.
166
-         *    @param array $interfaces     Reflection API interfaces
167
-         *                                 to reduce.
168
-         *    @returns array               List of parent interface names.
169
-         *    @access private
170
-         */
171
-        function _onlyParents($interfaces) {
172
-            $parents = array();
173
-            foreach ($interfaces as $interface) {
174
-                foreach($interfaces as $possible_parent) {
175
-                    if ($interface->getName() == $possible_parent->getName()) {
176
-                        continue;
177
-                    }
178
-                    if ($interface->isSubClassOf($possible_parent)) {
179
-                        break;
180
-                    }
181
-                }
182
-                $parents[] = $interface->getName();
183
-            }
184
-            return $parents;
185
-        }
163
+		/**
164
+		 *    Wittles a list of interfaces down to only the top
165
+		 *    level parents.
166
+		 *    @param array $interfaces     Reflection API interfaces
167
+		 *                                 to reduce.
168
+		 *    @returns array               List of parent interface names.
169
+		 *    @access private
170
+		 */
171
+		function _onlyParents($interfaces) {
172
+			$parents = array();
173
+			foreach ($interfaces as $interface) {
174
+				foreach($interfaces as $possible_parent) {
175
+					if ($interface->getName() == $possible_parent->getName()) {
176
+						continue;
177
+					}
178
+					if ($interface->isSubClassOf($possible_parent)) {
179
+						break;
180
+					}
181
+				}
182
+				$parents[] = $interface->getName();
183
+			}
184
+			return $parents;
185
+		}
186 186
 
187
-        /**
188
-         *    Gets the source code matching the declaration
189
-         *    of a method.
190
-         *    @param string $name    Method name.
191
-         *    @return string         Method signature up to last
192
-         *                           bracket.
193
-         *    @access public
194
-         */
195
-        function getSignature($name) {
196
-        	if ($name == '__get') {
197
-        		return 'function __get($key)';
198
-        	}
199
-        	if ($name == '__set') {
200
-        		return 'function __set($key, $value)';
201
-        	}
202
-        	if (! is_callable(array($this->_interface, $name))) {
203
-        		return "function $name()";
204
-        	}
205
-        	if ($this->_isInterfaceMethod($name)) {
206
-        	    return $this->_getFullSignature($name);
207
-        	}
208
-        	return "function $name()";
209
-        }
187
+		/**
188
+		 *    Gets the source code matching the declaration
189
+		 *    of a method.
190
+		 *    @param string $name    Method name.
191
+		 *    @return string         Method signature up to last
192
+		 *                           bracket.
193
+		 *    @access public
194
+		 */
195
+		function getSignature($name) {
196
+			if ($name == '__get') {
197
+				return 'function __get($key)';
198
+			}
199
+			if ($name == '__set') {
200
+				return 'function __set($key, $value)';
201
+			}
202
+			if (! is_callable(array($this->_interface, $name))) {
203
+				return "function $name()";
204
+			}
205
+			if ($this->_isInterfaceMethod($name)) {
206
+				return $this->_getFullSignature($name);
207
+			}
208
+			return "function $name()";
209
+		}
210 210
 
211
-        /**
212
-         *    For a signature specified in an interface, full
213
-         *    details must be replicated to be a valid implementation.
214
-         *    @param string $name    Method name.
215
-         *    @return string         Method signature up to last
216
-         *                           bracket.
217
-         *    @access private
218
-         */
219
-        function _getFullSignature($name) {
220
-	        $interface = new ReflectionClass($this->_interface);
221
-	        $method = $interface->getMethod($name);
222
-	        $reference = $method->returnsReference() ? '&' : '';
223
-        	return "function $reference$name(" .
224
-            		implode(', ', $this->_getParameterSignatures($method)) .
225
-            		")";
226
-        }
211
+		/**
212
+		 *    For a signature specified in an interface, full
213
+		 *    details must be replicated to be a valid implementation.
214
+		 *    @param string $name    Method name.
215
+		 *    @return string         Method signature up to last
216
+		 *                           bracket.
217
+		 *    @access private
218
+		 */
219
+		function _getFullSignature($name) {
220
+			$interface = new ReflectionClass($this->_interface);
221
+			$method = $interface->getMethod($name);
222
+			$reference = $method->returnsReference() ? '&' : '';
223
+			return "function $reference$name(" .
224
+					implode(', ', $this->_getParameterSignatures($method)) .
225
+					")";
226
+		}
227 227
 
228
-        /**
229
-         *    Gets the source code for each parameter.
230
-         *    @param ReflectionMethod $method   Method object from
231
-         *										reflection API
232
-         *    @return array                     List of strings, each
233
-         *                                      a snippet of code.
234
-         *    @access private
235
-         */
236
-        function _getParameterSignatures($method) {
237
-        	$signatures = array();
238
-            foreach ($method->getParameters() as $parameter) {
239
-                $type = $parameter->getClass();
240
-            	$signatures[] =
228
+		/**
229
+		 *    Gets the source code for each parameter.
230
+		 *    @param ReflectionMethod $method   Method object from
231
+		 *										reflection API
232
+		 *    @return array                     List of strings, each
233
+		 *                                      a snippet of code.
234
+		 *    @access private
235
+		 */
236
+		function _getParameterSignatures($method) {
237
+			$signatures = array();
238
+			foreach ($method->getParameters() as $parameter) {
239
+				$type = $parameter->getClass();
240
+				$signatures[] =
241 241
 					(! is_null($type) ? $type->getName() . ' ' : '') .
242
-            			($parameter->isPassedByReference() ? '&' : '') .
243
-            			'$' . $this->_suppressSpurious($parameter->getName()) .
244
-            			($this->_isOptional($parameter) ? ' = null' : '');
245
-            }
246
-            return $signatures;
247
-        }
242
+						($parameter->isPassedByReference() ? '&' : '') .
243
+						'$' . $this->_suppressSpurious($parameter->getName()) .
244
+						($this->_isOptional($parameter) ? ' = null' : '');
245
+			}
246
+			return $signatures;
247
+		}
248 248
 
249
-        /**
250
-         *    The SPL library has problems with the
251
-         *    Reflection library. In particular, you can
252
-         *    get extra characters in parameter names :(.
253
-         *    @param string $name    Parameter name.
254
-         *    @return string         Cleaner name.
255
-         *    @access private
256
-         */
257
-        function _suppressSpurious($name) {
258
-            return str_replace(array('[', ']', ' '), '', $name);
259
-        }
249
+		/**
250
+		 *    The SPL library has problems with the
251
+		 *    Reflection library. In particular, you can
252
+		 *    get extra characters in parameter names :(.
253
+		 *    @param string $name    Parameter name.
254
+		 *    @return string         Cleaner name.
255
+		 *    @access private
256
+		 */
257
+		function _suppressSpurious($name) {
258
+			return str_replace(array('[', ']', ' '), '', $name);
259
+		}
260 260
 
261
-        /**
262
-         *    Test of a reflection parameter being optional
263
-         *    that works with early versions of PHP5.
264
-         *    @param reflectionParameter $parameter    Is this optional.
265
-         *    @return boolean                          True if optional.
266
-         *    @access private
267
-         */
268
-        function _isOptional($parameter) {
269
-            if (method_exists($parameter, 'isOptional')) {
270
-                return $parameter->isOptional();
271
-            }
272
-            return false;
273
-        }
274
-    }
275 261
\ No newline at end of file
262
+		/**
263
+		 *    Test of a reflection parameter being optional
264
+		 *    that works with early versions of PHP5.
265
+		 *    @param reflectionParameter $parameter    Is this optional.
266
+		 *    @return boolean                          True if optional.
267
+		 *    @access private
268
+		 */
269
+		function _isOptional($parameter) {
270
+			if (method_exists($parameter, 'isOptional')) {
271
+				return $parameter->isOptional();
272
+			}
273
+			return false;
274
+		}
275
+	}
276 276
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -31,11 +31,11 @@  discard block
 block discarded – undo
31 31
          *    @access public
32 32
          */
33 33
         function classExists() {
34
-            if (! class_exists($this->_interface)) {
34
+            if (!class_exists($this->_interface)) {
35 35
                 return false;
36 36
             }
37 37
             $reflection = new ReflectionClass($this->_interface);
38
-            return ! $reflection->isInterface();
38
+            return !$reflection->isInterface();
39 39
         }
40 40
 
41 41
         /**
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
         function _onlyParents($interfaces) {
172 172
             $parents = array();
173 173
             foreach ($interfaces as $interface) {
174
-                foreach($interfaces as $possible_parent) {
174
+                foreach ($interfaces as $possible_parent) {
175 175
                     if ($interface->getName() == $possible_parent->getName()) {
176 176
                         continue;
177 177
                     }
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
         	if ($name == '__set') {
200 200
         		return 'function __set($key, $value)';
201 201
         	}
202
-        	if (! is_callable(array($this->_interface, $name))) {
202
+        	if (!is_callable(array($this->_interface, $name))) {
203 203
         		return "function $name()";
204 204
         	}
205 205
         	if ($this->_isInterfaceMethod($name)) {
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
             foreach ($method->getParameters() as $parameter) {
239 239
                 $type = $parameter->getClass();
240 240
             	$signatures[] =
241
-					(! is_null($type) ? $type->getName() . ' ' : '') .
241
+					(!is_null($type) ? $type->getName() . ' ' : '') .
242 242
             			($parameter->isPassedByReference() ? '&' : '') .
243 243
             			'$' . $this->_suppressSpurious($parameter->getName()) .
244 244
             			($this->_isOptional($parameter) ? ' = null' : '');
Please login to merge, or discard this patch.
tests/test_tools/simpletest/detached.php 3 patches
Indentation   +79 added lines, -79 removed lines patch added patch discarded remove patch
@@ -1,95 +1,95 @@
 block discarded – undo
1 1
 <?php
2
-    /**
3
-     *	base include file for SimpleTest
4
-     *	@package	SimpleTest
5
-     *	@subpackage	UnitTester
6
-     *	@version	$Id: detached.php 1398 2006-09-08 19:31:03Z xue $
7
-     */
2
+	/**
3
+	 *	base include file for SimpleTest
4
+	 *	@package	SimpleTest
5
+	 *	@subpackage	UnitTester
6
+	 *	@version	$Id: detached.php 1398 2006-09-08 19:31:03Z xue $
7
+	 */
8 8
 
9
-    /**#@+
9
+	/**#@+
10 10
      *	include other SimpleTest class files
11 11
      */
12
-    require_once(dirname(__FILE__) . '/xml.php');
13
-    require_once(dirname(__FILE__) . '/shell_tester.php');
14
-    /**#@-*/
12
+	require_once(dirname(__FILE__) . '/xml.php');
13
+	require_once(dirname(__FILE__) . '/shell_tester.php');
14
+	/**#@-*/
15 15
 
16
-    /**
17
-     *    Runs an XML formated test in a separate process.
16
+	/**
17
+	 *    Runs an XML formated test in a separate process.
18 18
 	 *	  @package SimpleTest
19 19
 	 *	  @subpackage UnitTester
20
-     */
21
-    class DetachedTestCase {
22
-        protected $_command;
23
-        protected $_dry_command;
24
-        protected $_size;
20
+	 */
21
+	class DetachedTestCase {
22
+		protected $_command;
23
+		protected $_dry_command;
24
+		protected $_size;
25 25
 
26
-        /**
27
-         *    Sets the location of the remote test.
28
-         *    @param string $command       Test script.
29
-         *    @param string $dry_command   Script for dry run.
30
-         *    @access public
31
-         */
32
-        function DetachedTestCase($command, $dry_command = false) {
33
-            $this->_command = $command;
34
-            $this->_dry_command = $dry_command ? $dry_command : $command;
35
-            $this->_size = false;
36
-        }
26
+		/**
27
+		 *    Sets the location of the remote test.
28
+		 *    @param string $command       Test script.
29
+		 *    @param string $dry_command   Script for dry run.
30
+		 *    @access public
31
+		 */
32
+		function DetachedTestCase($command, $dry_command = false) {
33
+			$this->_command = $command;
34
+			$this->_dry_command = $dry_command ? $dry_command : $command;
35
+			$this->_size = false;
36
+		}
37 37
 
38
-        /**
39
-         *    Accessor for the test name for subclasses.
40
-         *    @return string       Name of the test.
41
-         *    @access public
42
-         */
43
-        function getLabel() {
44
-            return $this->_command;
45
-        }
38
+		/**
39
+		 *    Accessor for the test name for subclasses.
40
+		 *    @return string       Name of the test.
41
+		 *    @access public
42
+		 */
43
+		function getLabel() {
44
+			return $this->_command;
45
+		}
46 46
 
47
-        /**
48
-         *    Runs the top level test for this class. Currently
49
-         *    reads the data as a single chunk. I'll fix this
50
-         *    once I have added iteration to the browser.
51
-         *    @param SimpleReporter $reporter    Target of test results.
52
-         *    @returns boolean                   True if no failures.
53
-         *    @access public
54
-         */
55
-        function run($reporter) {
47
+		/**
48
+		 *    Runs the top level test for this class. Currently
49
+		 *    reads the data as a single chunk. I'll fix this
50
+		 *    once I have added iteration to the browser.
51
+		 *    @param SimpleReporter $reporter    Target of test results.
52
+		 *    @returns boolean                   True if no failures.
53
+		 *    @access public
54
+		 */
55
+		function run($reporter) {
56 56
 			$shell = new SimpleShell();
57 57
 			$shell->execute($this->_command);
58
-            $parser = $this->_createParser($reporter);
59
-            if (! $parser->parse($shell->getOutput())) {
60
-                trigger_error('Cannot parse incoming XML from [' . $this->_command . ']');
61
-                return false;
62
-            }
63
-            return true;
64
-        }
58
+			$parser = $this->_createParser($reporter);
59
+			if (! $parser->parse($shell->getOutput())) {
60
+				trigger_error('Cannot parse incoming XML from [' . $this->_command . ']');
61
+				return false;
62
+			}
63
+			return true;
64
+		}
65 65
 
66
-        /**
67
-         *    Accessor for the number of subtests.
68
-         *    @return integer       Number of test cases.
69
-         *    @access public
70
-         */
71
-        function getSize() {
72
-            if ($this->_size === false) {
66
+		/**
67
+		 *    Accessor for the number of subtests.
68
+		 *    @return integer       Number of test cases.
69
+		 *    @access public
70
+		 */
71
+		function getSize() {
72
+			if ($this->_size === false) {
73 73
 				$shell = new SimpleShell();
74 74
 				$shell->execute($this->_dry_command);
75
-                $reporter = new SimpleReporter();
76
-                $parser = $this->_createParser($reporter);
77
-                if (! $parser->parse($shell->getOutput())) {
78
-                    trigger_error('Cannot parse incoming XML from [' . $this->_dry_command . ']');
79
-                    return false;
80
-                }
81
-                $this->_size = $reporter->getTestCaseCount();
82
-            }
83
-            return $this->_size;
84
-        }
75
+				$reporter = new SimpleReporter();
76
+				$parser = $this->_createParser($reporter);
77
+				if (! $parser->parse($shell->getOutput())) {
78
+					trigger_error('Cannot parse incoming XML from [' . $this->_dry_command . ']');
79
+					return false;
80
+				}
81
+				$this->_size = $reporter->getTestCaseCount();
82
+			}
83
+			return $this->_size;
84
+		}
85 85
 
86
-        /**
87
-         *    Creates the XML parser.
88
-         *    @param SimpleReporter $reporter    Target of test results.
89
-         *    @return SimpleTestXmlListener      XML reader.
90
-         *    @access protected
91
-         */
92
-        function &_createParser($reporter) {
93
-            return new SimpleTestXmlParser($reporter);
94
-        }
95
-    }
96 86
\ No newline at end of file
87
+		/**
88
+		 *    Creates the XML parser.
89
+		 *    @param SimpleReporter $reporter    Target of test results.
90
+		 *    @return SimpleTestXmlListener      XML reader.
91
+		 *    @access protected
92
+		 */
93
+		function &_createParser($reporter) {
94
+			return new SimpleTestXmlParser($reporter);
95
+		}
96
+	}
97 97
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 			$shell = new SimpleShell();
57 57
 			$shell->execute($this->_command);
58 58
             $parser = $this->_createParser($reporter);
59
-            if (! $parser->parse($shell->getOutput())) {
59
+            if (!$parser->parse($shell->getOutput())) {
60 60
                 trigger_error('Cannot parse incoming XML from [' . $this->_command . ']');
61 61
                 return false;
62 62
             }
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 				$shell->execute($this->_dry_command);
75 75
                 $reporter = new SimpleReporter();
76 76
                 $parser = $this->_createParser($reporter);
77
-                if (! $parser->parse($shell->getOutput())) {
77
+                if (!$parser->parse($shell->getOutput())) {
78 78
                     trigger_error('Cannot parse incoming XML from [' . $this->_dry_command . ']');
79 79
                     return false;
80 80
                 }
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -81,7 +81,7 @@
 block discarded – undo
81 81
         /**
82 82
          *    Creates the XML parser.
83 83
          *    @param SimpleReporter $reporter    Target of test results.
84
-         *    @return SimpleTestXmlListener      XML reader.
84
+         *    @return SimpleTestXmlParser      XML reader.
85 85
          *    @access protected
86 86
          */
87 87
         function &_createParser($reporter) {
Please login to merge, or discard this patch.
tests/test_tools/simpletest/exceptions.php 1 patch
Indentation   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -1,45 +1,45 @@
 block discarded – undo
1 1
 <?php
2
-    /**
3
-     *	base include file for SimpleTest
4
-     *	@package	SimpleTest
5
-     *	@subpackage	UnitTester
6
-     *	@version	$Id: exceptions.php 1398 2006-09-08 19:31:03Z xue $
7
-     */
2
+	/**
3
+	 *	base include file for SimpleTest
4
+	 *	@package	SimpleTest
5
+	 *	@subpackage	UnitTester
6
+	 *	@version	$Id: exceptions.php 1398 2006-09-08 19:31:03Z xue $
7
+	 */
8 8
 
9
-    /**#@+
9
+	/**#@+
10 10
      * Includes SimpleTest files and defined the root constant
11 11
      * for dependent libraries.
12 12
      */
13
-    require_once(dirname(__FILE__) . '/invoker.php');
13
+	require_once(dirname(__FILE__) . '/invoker.php');
14 14
 
15
-    /**
16
-     *    Extension that traps exceptions and turns them into
17
-     *    an error message.
15
+	/**
16
+	 *    Extension that traps exceptions and turns them into
17
+	 *    an error message.
18 18
 	 *	  @package SimpleTest
19 19
 	 *	  @subpackage UnitTester
20
-     */
21
-    class SimpleExceptionTrappingInvoker extends SimpleInvokerDecorator {
20
+	 */
21
+	class SimpleExceptionTrappingInvoker extends SimpleInvokerDecorator {
22 22
 
23
-        /**
24
-         *    Stores the invoker to be wrapped.
25
-         *    @param SimpleInvoker $invoker   Test method runner.
26
-         */
27
-        function SimpleExceptionTrappingInvoker($invoker) {
28
-            $this->SimpleInvokerDecorator($invoker);
29
-        }
23
+		/**
24
+		 *    Stores the invoker to be wrapped.
25
+		 *    @param SimpleInvoker $invoker   Test method runner.
26
+		 */
27
+		function SimpleExceptionTrappingInvoker($invoker) {
28
+			$this->SimpleInvokerDecorator($invoker);
29
+		}
30 30
 
31
-        /**
32
-         *    Invokes a test method and dispatches any
33
-         *    untrapped errors.
34
-         *    @param string $method    Test method to call.
35
-         *    @access public
36
-         */
37
-        function invoke($method) {
38
-            try {
39
-                parent::invoke($method);
40
-            } catch (Exception $exception) {
41
-                $test_case = $this->getTestCase();
42
-                $test_case->exception($exception);
43
-            }
44
-        }
45
-    }
46 31
\ No newline at end of file
32
+		/**
33
+		 *    Invokes a test method and dispatches any
34
+		 *    untrapped errors.
35
+		 *    @param string $method    Test method to call.
36
+		 *    @access public
37
+		 */
38
+		function invoke($method) {
39
+			try {
40
+				parent::invoke($method);
41
+			} catch (Exception $exception) {
42
+				$test_case = $this->getTestCase();
43
+				$test_case->exception($exception);
44
+			}
45
+		}
46
+	}
47 47
\ No newline at end of file
Please login to merge, or discard this patch.