@@ -1,132 +1,132 @@ |
||
1 | 1 | <?php |
2 | - /** |
|
3 | - * Base include file for SimpleTest. |
|
4 | - * @package SimpleTest |
|
5 | - * @subpackage WebTester |
|
6 | - * @version $Id: selector.php 1398 2006-09-08 19:31:03Z xue $ |
|
7 | - */ |
|
2 | + /** |
|
3 | + * Base include file for SimpleTest. |
|
4 | + * @package SimpleTest |
|
5 | + * @subpackage WebTester |
|
6 | + * @version $Id: selector.php 1398 2006-09-08 19:31:03Z xue $ |
|
7 | + */ |
|
8 | 8 | |
9 | - /**#@+ |
|
9 | + /**#@+ |
|
10 | 10 | * include SimpleTest files |
11 | 11 | */ |
12 | - require_once(dirname(__FILE__) . '/tag.php'); |
|
13 | - require_once(dirname(__FILE__) . '/encoding.php'); |
|
14 | - /**#@-*/ |
|
12 | + require_once(dirname(__FILE__) . '/tag.php'); |
|
13 | + require_once(dirname(__FILE__) . '/encoding.php'); |
|
14 | + /**#@-*/ |
|
15 | 15 | |
16 | - /** |
|
17 | - * Used to extract form elements for testing against. |
|
18 | - * Searches by name attribute. |
|
16 | + /** |
|
17 | + * Used to extract form elements for testing against. |
|
18 | + * Searches by name attribute. |
|
19 | 19 | * @package SimpleTest |
20 | 20 | * @subpackage WebTester |
21 | - */ |
|
22 | - class SimpleByName { |
|
23 | - protected $_name; |
|
21 | + */ |
|
22 | + class SimpleByName { |
|
23 | + protected $_name; |
|
24 | 24 | |
25 | - /** |
|
26 | - * Stashes the name for later comparison. |
|
27 | - * @param string $name Name attribute to match. |
|
28 | - */ |
|
29 | - function SimpleByName($name) { |
|
30 | - $this->_name = $name; |
|
31 | - } |
|
25 | + /** |
|
26 | + * Stashes the name for later comparison. |
|
27 | + * @param string $name Name attribute to match. |
|
28 | + */ |
|
29 | + function SimpleByName($name) { |
|
30 | + $this->_name = $name; |
|
31 | + } |
|
32 | 32 | |
33 | - /** |
|
34 | - * Compares with name attribute of widget. |
|
35 | - * @param SimpleWidget $widget Control to compare. |
|
36 | - * @access public |
|
37 | - */ |
|
38 | - function isMatch($widget) { |
|
39 | - return ($widget->getName() == $this->_name); |
|
40 | - } |
|
41 | - } |
|
33 | + /** |
|
34 | + * Compares with name attribute of widget. |
|
35 | + * @param SimpleWidget $widget Control to compare. |
|
36 | + * @access public |
|
37 | + */ |
|
38 | + function isMatch($widget) { |
|
39 | + return ($widget->getName() == $this->_name); |
|
40 | + } |
|
41 | + } |
|
42 | 42 | |
43 | - /** |
|
44 | - * Used to extract form elements for testing against. |
|
45 | - * Searches by visible label or alt text. |
|
43 | + /** |
|
44 | + * Used to extract form elements for testing against. |
|
45 | + * Searches by visible label or alt text. |
|
46 | 46 | * @package SimpleTest |
47 | 47 | * @subpackage WebTester |
48 | - */ |
|
49 | - class SimpleByLabel { |
|
50 | - protected $_label; |
|
48 | + */ |
|
49 | + class SimpleByLabel { |
|
50 | + protected $_label; |
|
51 | 51 | |
52 | - /** |
|
53 | - * Stashes the name for later comparison. |
|
54 | - * @param string $label Visible text to match. |
|
55 | - */ |
|
56 | - function SimpleByLabel($label) { |
|
57 | - $this->_label = $label; |
|
58 | - } |
|
52 | + /** |
|
53 | + * Stashes the name for later comparison. |
|
54 | + * @param string $label Visible text to match. |
|
55 | + */ |
|
56 | + function SimpleByLabel($label) { |
|
57 | + $this->_label = $label; |
|
58 | + } |
|
59 | 59 | |
60 | - /** |
|
61 | - * Comparison. Compares visible text of widget or |
|
62 | - * related label. |
|
63 | - * @param SimpleWidget $widget Control to compare. |
|
64 | - * @access public |
|
65 | - */ |
|
66 | - function isMatch($widget) { |
|
67 | - if (! method_exists($widget, 'isLabel')) { |
|
68 | - return false; |
|
69 | - } |
|
70 | - return $widget->isLabel($this->_label); |
|
71 | - } |
|
72 | - } |
|
60 | + /** |
|
61 | + * Comparison. Compares visible text of widget or |
|
62 | + * related label. |
|
63 | + * @param SimpleWidget $widget Control to compare. |
|
64 | + * @access public |
|
65 | + */ |
|
66 | + function isMatch($widget) { |
|
67 | + if (! method_exists($widget, 'isLabel')) { |
|
68 | + return false; |
|
69 | + } |
|
70 | + return $widget->isLabel($this->_label); |
|
71 | + } |
|
72 | + } |
|
73 | 73 | |
74 | - /** |
|
75 | - * Used to extract form elements for testing against. |
|
76 | - * Searches dy id attribute. |
|
74 | + /** |
|
75 | + * Used to extract form elements for testing against. |
|
76 | + * Searches dy id attribute. |
|
77 | 77 | * @package SimpleTest |
78 | 78 | * @subpackage WebTester |
79 | - */ |
|
80 | - class SimpleById { |
|
81 | - protected $_id; |
|
79 | + */ |
|
80 | + class SimpleById { |
|
81 | + protected $_id; |
|
82 | 82 | |
83 | - /** |
|
84 | - * Stashes the name for later comparison. |
|
85 | - * @param string $id ID atribute to match. |
|
86 | - */ |
|
87 | - function SimpleById($id) { |
|
88 | - $this->_id = $id; |
|
89 | - } |
|
83 | + /** |
|
84 | + * Stashes the name for later comparison. |
|
85 | + * @param string $id ID atribute to match. |
|
86 | + */ |
|
87 | + function SimpleById($id) { |
|
88 | + $this->_id = $id; |
|
89 | + } |
|
90 | 90 | |
91 | - /** |
|
92 | - * Comparison. Compares id attribute of widget. |
|
93 | - * @param SimpleWidget $widget Control to compare. |
|
94 | - * @access public |
|
95 | - */ |
|
96 | - function isMatch($widget) { |
|
97 | - return $widget->isId($this->_id); |
|
98 | - } |
|
99 | - } |
|
91 | + /** |
|
92 | + * Comparison. Compares id attribute of widget. |
|
93 | + * @param SimpleWidget $widget Control to compare. |
|
94 | + * @access public |
|
95 | + */ |
|
96 | + function isMatch($widget) { |
|
97 | + return $widget->isId($this->_id); |
|
98 | + } |
|
99 | + } |
|
100 | 100 | |
101 | - /** |
|
102 | - * Used to extract form elements for testing against. |
|
103 | - * Searches by visible label, name or alt text. |
|
101 | + /** |
|
102 | + * Used to extract form elements for testing against. |
|
103 | + * Searches by visible label, name or alt text. |
|
104 | 104 | * @package SimpleTest |
105 | 105 | * @subpackage WebTester |
106 | - */ |
|
107 | - class SimpleByLabelOrName { |
|
108 | - protected $_label; |
|
106 | + */ |
|
107 | + class SimpleByLabelOrName { |
|
108 | + protected $_label; |
|
109 | 109 | |
110 | - /** |
|
111 | - * Stashes the name/label for later comparison. |
|
112 | - * @param string $label Visible text to match. |
|
113 | - */ |
|
114 | - function SimpleByLabelOrName($label) { |
|
115 | - $this->_label = $label; |
|
116 | - } |
|
110 | + /** |
|
111 | + * Stashes the name/label for later comparison. |
|
112 | + * @param string $label Visible text to match. |
|
113 | + */ |
|
114 | + function SimpleByLabelOrName($label) { |
|
115 | + $this->_label = $label; |
|
116 | + } |
|
117 | 117 | |
118 | - /** |
|
119 | - * Comparison. Compares visible text of widget or |
|
120 | - * related label or name. |
|
121 | - * @param SimpleWidget $widget Control to compare. |
|
122 | - * @access public |
|
123 | - */ |
|
124 | - function isMatch($widget) { |
|
125 | - if (method_exists($widget, 'isLabel')) { |
|
126 | - if ($widget->isLabel($this->_label)) { |
|
127 | - return true; |
|
128 | - } |
|
129 | - } |
|
130 | - return ($widget->getName() == $this->_label); |
|
131 | - } |
|
132 | - } |
|
133 | 118 | \ No newline at end of file |
119 | + /** |
|
120 | + * Comparison. Compares visible text of widget or |
|
121 | + * related label or name. |
|
122 | + * @param SimpleWidget $widget Control to compare. |
|
123 | + * @access public |
|
124 | + */ |
|
125 | + function isMatch($widget) { |
|
126 | + if (method_exists($widget, 'isLabel')) { |
|
127 | + if ($widget->isLabel($this->_label)) { |
|
128 | + return true; |
|
129 | + } |
|
130 | + } |
|
131 | + return ($widget->getName() == $this->_label); |
|
132 | + } |
|
133 | + } |
|
134 | 134 | \ No newline at end of file |
@@ -64,7 +64,7 @@ |
||
64 | 64 | * @access public |
65 | 65 | */ |
66 | 66 | function isMatch($widget) { |
67 | - if (! method_exists($widget, 'isLabel')) { |
|
67 | + if (!method_exists($widget, 'isLabel')) { |
|
68 | 68 | return false; |
69 | 69 | } |
70 | 70 | return $widget->isLabel($this->_label); |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | $list = new TPagedList(); |
64 | 64 | try { |
65 | 65 | $list->PageSize = 0; |
66 | - } catch(TInvalidDataValueException $e) { |
|
66 | + } catch (TInvalidDataValueException $e) { |
|
67 | 67 | return; |
68 | 68 | } |
69 | 69 | self::fail('An expected TInvalidDataValueException was not raised'); |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | $myList = new MyPagedList(); |
97 | 97 | $list->attachEventHandler('OnFetchData', array($myList, 'fetchData')); |
98 | 98 | self::assertEquals(false, $myList->hasFetchedData()); |
99 | - $list->onFetchData(new TPagedListFetchDataEventParameter($list->CurrentPageIndex, $list->PageSize*$list->CurrentPageIndex, $list->PageSize)); |
|
99 | + $list->onFetchData(new TPagedListFetchDataEventParameter($list->CurrentPageIndex, $list->PageSize * $list->CurrentPageIndex, $list->PageSize)); |
|
100 | 100 | self::assertEquals(true, $myList->hasFetchedData()); |
101 | 101 | } |
102 | 102 | |
@@ -174,13 +174,13 @@ discard block |
||
174 | 174 | self::assertInstanceOf('ArrayIterator', $list->getIterator()); |
175 | 175 | $n = 0; |
176 | 176 | $found = 0; |
177 | - foreach($list as $index => $item) { |
|
178 | - foreach($list as $a => $b); // test of iterator |
|
177 | + foreach ($list as $index => $item) { |
|
178 | + foreach ($list as $a => $b); // test of iterator |
|
179 | 179 | $n++; |
180 | - if($index === 0 && $item === 1) { |
|
180 | + if ($index === 0 && $item === 1) { |
|
181 | 181 | $found++; |
182 | 182 | } |
183 | - if($index === 1 && $item === 2) { |
|
183 | + if ($index === 1 && $item === 2) { |
|
184 | 184 | $found++; |
185 | 185 | } |
186 | 186 | } |
@@ -12,27 +12,27 @@ discard block |
||
12 | 12 | protected $item1,$item2,$item3; |
13 | 13 | |
14 | 14 | public function setUp() { |
15 | - $this->map=new TMap; |
|
16 | - $this->item1=new TMapTest_MapItem; |
|
17 | - $this->item2=new TMapTest_MapItem; |
|
18 | - $this->item3=new TMapTest_MapItem; |
|
19 | - $this->map->add('key1',$this->item1); |
|
20 | - $this->map->add('key2',$this->item2); |
|
15 | + $this->map=new TMap; |
|
16 | + $this->item1=new TMapTest_MapItem; |
|
17 | + $this->item2=new TMapTest_MapItem; |
|
18 | + $this->item3=new TMapTest_MapItem; |
|
19 | + $this->map->add('key1',$this->item1); |
|
20 | + $this->map->add('key2',$this->item2); |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | public function tearDown() { |
24 | - $this->map=null; |
|
25 | - $this->item1=null; |
|
26 | - $this->item2=null; |
|
27 | - $this->item3=null; |
|
24 | + $this->map=null; |
|
25 | + $this->item1=null; |
|
26 | + $this->item2=null; |
|
27 | + $this->item3=null; |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | public function testConstruct() { |
31 | - $a=array(1,2,'key3'=>3); |
|
32 | - $map=new TMap($a); |
|
33 | - $this->assertEquals(3,$map->getCount()); |
|
34 | - $map2=new TMap($this->map); |
|
35 | - $this->assertEquals(2,$map2->getCount()); |
|
31 | + $a=array(1,2,'key3'=>3); |
|
32 | + $map=new TMap($a); |
|
33 | + $this->assertEquals(3,$map->getCount()); |
|
34 | + $map2=new TMap($this->map); |
|
35 | + $this->assertEquals(2,$map2->getCount()); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | public function testGetReadOnly() { |
@@ -43,12 +43,12 @@ discard block |
||
43 | 43 | } |
44 | 44 | |
45 | 45 | public function testGetCount() { |
46 | - $this->assertEquals(2,$this->map->getCount()); |
|
46 | + $this->assertEquals(2,$this->map->getCount()); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | public function testGetKeys() { |
50 | - $keys=$this->map->getKeys(); |
|
51 | - $this->assertTrue(count($keys)===2 && $keys[0]==='key1' && $keys[1]==='key2'); |
|
50 | + $keys=$this->map->getKeys(); |
|
51 | + $this->assertTrue(count($keys)===2 && $keys[0]==='key1' && $keys[1]==='key2'); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | public function testAdd() |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | class TMapTest_MapItem { |
4 | - public $data='data'; |
|
4 | + public $data = 'data'; |
|
5 | 5 | } |
6 | 6 | |
7 | 7 | /** |
@@ -9,30 +9,30 @@ discard block |
||
9 | 9 | */ |
10 | 10 | class TMapTest extends PHPUnit_Framework_TestCase { |
11 | 11 | protected $map; |
12 | - protected $item1,$item2,$item3; |
|
12 | + protected $item1, $item2, $item3; |
|
13 | 13 | |
14 | 14 | public function setUp() { |
15 | - $this->map=new TMap; |
|
16 | - $this->item1=new TMapTest_MapItem; |
|
17 | - $this->item2=new TMapTest_MapItem; |
|
18 | - $this->item3=new TMapTest_MapItem; |
|
19 | - $this->map->add('key1',$this->item1); |
|
20 | - $this->map->add('key2',$this->item2); |
|
15 | + $this->map = new TMap; |
|
16 | + $this->item1 = new TMapTest_MapItem; |
|
17 | + $this->item2 = new TMapTest_MapItem; |
|
18 | + $this->item3 = new TMapTest_MapItem; |
|
19 | + $this->map->add('key1', $this->item1); |
|
20 | + $this->map->add('key2', $this->item2); |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | public function tearDown() { |
24 | - $this->map=null; |
|
25 | - $this->item1=null; |
|
26 | - $this->item2=null; |
|
27 | - $this->item3=null; |
|
24 | + $this->map = null; |
|
25 | + $this->item1 = null; |
|
26 | + $this->item2 = null; |
|
27 | + $this->item3 = null; |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | public function testConstruct() { |
31 | - $a=array(1,2,'key3'=>3); |
|
32 | - $map=new TMap($a); |
|
33 | - $this->assertEquals(3,$map->getCount()); |
|
34 | - $map2=new TMap($this->map); |
|
35 | - $this->assertEquals(2,$map2->getCount()); |
|
31 | + $a = array(1, 2, 'key3'=>3); |
|
32 | + $map = new TMap($a); |
|
33 | + $this->assertEquals(3, $map->getCount()); |
|
34 | + $map2 = new TMap($this->map); |
|
35 | + $this->assertEquals(2, $map2->getCount()); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | public function testGetReadOnly() { |
@@ -43,25 +43,25 @@ discard block |
||
43 | 43 | } |
44 | 44 | |
45 | 45 | public function testGetCount() { |
46 | - $this->assertEquals(2,$this->map->getCount()); |
|
46 | + $this->assertEquals(2, $this->map->getCount()); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | public function testGetKeys() { |
50 | - $keys=$this->map->getKeys(); |
|
51 | - $this->assertTrue(count($keys)===2 && $keys[0]==='key1' && $keys[1]==='key2'); |
|
50 | + $keys = $this->map->getKeys(); |
|
51 | + $this->assertTrue(count($keys) === 2 && $keys[0] === 'key1' && $keys[1] === 'key2'); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | public function testAdd() |
55 | 55 | { |
56 | - $this->map->add('key3',$this->item3); |
|
57 | - $this->assertTrue($this->map->getCount()==3 && $this->map->contains('key3')); |
|
56 | + $this->map->add('key3', $this->item3); |
|
57 | + $this->assertTrue($this->map->getCount() == 3 && $this->map->contains('key3')); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | public function testCanNotAddWhenReadOnly() { |
61 | 61 | $map = new TMap(array(), true); |
62 | 62 | try { |
63 | 63 | $map->add('key', 'value'); |
64 | - } catch(TInvalidOperationException $e) { |
|
64 | + } catch (TInvalidOperationException $e) { |
|
65 | 65 | return; |
66 | 66 | } |
67 | 67 | self::fail('An expected TInvalidOperationException was not raised'); |
@@ -70,15 +70,15 @@ discard block |
||
70 | 70 | public function testRemove() |
71 | 71 | { |
72 | 72 | $this->map->remove('key1'); |
73 | - $this->assertTrue($this->map->getCount()==1 && !$this->map->contains('key1')); |
|
74 | - $this->assertTrue($this->map->remove('unknown key')===null); |
|
73 | + $this->assertTrue($this->map->getCount() == 1 && !$this->map->contains('key1')); |
|
74 | + $this->assertTrue($this->map->remove('unknown key') === null); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | public function testCanNotRemoveWhenReadOnly() { |
78 | 78 | $map = new TMap(array('key' => 'value'), true); |
79 | 79 | try { |
80 | 80 | $map->remove('key'); |
81 | - } catch(TInvalidOperationException $e) { |
|
81 | + } catch (TInvalidOperationException $e) { |
|
82 | 82 | return; |
83 | 83 | } |
84 | 84 | self::fail('An expected TInvalidOperationException was not raised'); |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | public function testClear() |
88 | 88 | { |
89 | 89 | $this->map->clear(); |
90 | - $this->assertTrue($this->map->getCount()==0 && !$this->map->contains('key1') && !$this->map->contains('key2')); |
|
90 | + $this->assertTrue($this->map->getCount() == 0 && !$this->map->contains('key1') && !$this->map->contains('key2')); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | public function testContains() |
@@ -99,15 +99,15 @@ discard block |
||
99 | 99 | |
100 | 100 | public function testCopyFrom() |
101 | 101 | { |
102 | - $array=array('key3'=>$this->item3,'key4'=>$this->item1); |
|
102 | + $array = array('key3'=>$this->item3, 'key4'=>$this->item1); |
|
103 | 103 | $this->map->copyFrom($array); |
104 | - $this->assertTrue($this->map->getCount()==2 && $this->map['key3']===$this->item3 && $this->map['key4']===$this->item1); |
|
104 | + $this->assertTrue($this->map->getCount() == 2 && $this->map['key3'] === $this->item3 && $this->map['key4'] === $this->item1); |
|
105 | 105 | try |
106 | 106 | { |
107 | 107 | $this->map->copyFrom($this); |
108 | 108 | $this->fail('no exception raised when copying a non-traversable object'); |
109 | 109 | } |
110 | - catch(TInvalidDataTypeException $e) |
|
110 | + catch (TInvalidDataTypeException $e) |
|
111 | 111 | { |
112 | 112 | |
113 | 113 | } |
@@ -115,15 +115,15 @@ discard block |
||
115 | 115 | |
116 | 116 | public function testMergeWith() |
117 | 117 | { |
118 | - $array=array('key2'=>$this->item1,'key3'=>$this->item3); |
|
118 | + $array = array('key2'=>$this->item1, 'key3'=>$this->item3); |
|
119 | 119 | $this->map->mergeWith($array); |
120 | - $this->assertTrue($this->map->getCount()==3 && $this->map['key2']===$this->item1 && $this->map['key3']===$this->item3); |
|
120 | + $this->assertTrue($this->map->getCount() == 3 && $this->map['key2'] === $this->item1 && $this->map['key3'] === $this->item3); |
|
121 | 121 | try |
122 | 122 | { |
123 | 123 | $this->map->mergeWith($this); |
124 | 124 | $this->fail('no exception raised when copying a non-traversable object'); |
125 | 125 | } |
126 | - catch(TInvalidDataTypeException $e) |
|
126 | + catch (TInvalidDataTypeException $e) |
|
127 | 127 | { |
128 | 128 | |
129 | 129 | } |
@@ -131,25 +131,25 @@ discard block |
||
131 | 131 | |
132 | 132 | public function testArrayRead() |
133 | 133 | { |
134 | - $this->assertTrue($this->map['key1']===$this->item1); |
|
135 | - $this->assertTrue($this->map['key2']===$this->item2); |
|
136 | - $this->assertEquals(null,$this->map['key3']); |
|
134 | + $this->assertTrue($this->map['key1'] === $this->item1); |
|
135 | + $this->assertTrue($this->map['key2'] === $this->item2); |
|
136 | + $this->assertEquals(null, $this->map['key3']); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | public function testArrayWrite() |
140 | 140 | { |
141 | - $this->map['key3']=$this->item3; |
|
142 | - $this->assertTrue($this->map['key3']===$this->item3 && $this->map->getCount()===3); |
|
143 | - $this->map['key1']=$this->item3; |
|
144 | - $this->assertTrue($this->map['key1']===$this->item3 && $this->map->getCount()===3); |
|
141 | + $this->map['key3'] = $this->item3; |
|
142 | + $this->assertTrue($this->map['key3'] === $this->item3 && $this->map->getCount() === 3); |
|
143 | + $this->map['key1'] = $this->item3; |
|
144 | + $this->assertTrue($this->map['key1'] === $this->item3 && $this->map->getCount() === 3); |
|
145 | 145 | unset($this->map['key2']); |
146 | - $this->assertTrue($this->map->getCount()===2 && !$this->map->contains('key2')); |
|
146 | + $this->assertTrue($this->map->getCount() === 2 && !$this->map->contains('key2')); |
|
147 | 147 | try |
148 | 148 | { |
149 | 149 | unset($this->map['unknown key']); |
150 | 150 | |
151 | 151 | } |
152 | - catch(Exception $e) |
|
152 | + catch (Exception $e) |
|
153 | 153 | { |
154 | 154 | $this->fail('exception raised when unsetting element with unknown key'); |
155 | 155 | } |
@@ -157,22 +157,22 @@ discard block |
||
157 | 157 | |
158 | 158 | public function testArrayForeach() |
159 | 159 | { |
160 | - $n=0; |
|
161 | - $found=0; |
|
162 | - foreach($this->map as $index=>$item) |
|
160 | + $n = 0; |
|
161 | + $found = 0; |
|
162 | + foreach ($this->map as $index=>$item) |
|
163 | 163 | { |
164 | 164 | $n++; |
165 | - if($index==='key1' && $item===$this->item1) |
|
165 | + if ($index === 'key1' && $item === $this->item1) |
|
166 | 166 | $found++; |
167 | - if($index==='key2' && $item===$this->item2) |
|
167 | + if ($index === 'key2' && $item === $this->item2) |
|
168 | 168 | $found++; |
169 | 169 | } |
170 | - $this->assertTrue($n==2 && $found==2); |
|
170 | + $this->assertTrue($n == 2 && $found == 2); |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | public function testArrayMisc() |
174 | 174 | { |
175 | - $this->assertEquals($this->map->Count,count($this->map)); |
|
175 | + $this->assertEquals($this->map->Count, count($this->map)); |
|
176 | 176 | $this->assertTrue(isset($this->map['key1'])); |
177 | 177 | $this->assertFalse(isset($this->map['unknown key'])); |
178 | 178 | } |
@@ -127,8 +127,7 @@ discard block |
||
127 | 127 | { |
128 | 128 | $this->map->copyFrom($this); |
129 | 129 | $this->fail('no exception raised when copying a non-traversable object'); |
130 | - } |
|
131 | - catch(TInvalidDataTypeException $e) |
|
130 | + } catch(TInvalidDataTypeException $e) |
|
132 | 131 | { |
133 | 132 | |
134 | 133 | } |
@@ -145,8 +144,7 @@ discard block |
||
145 | 144 | { |
146 | 145 | $this->map->mergeWith($this); |
147 | 146 | $this->fail('no exception raised when copying a non-traversable object'); |
148 | - } |
|
149 | - catch(TInvalidDataTypeException $e) |
|
147 | + } catch(TInvalidDataTypeException $e) |
|
150 | 148 | { |
151 | 149 | |
152 | 150 | } |
@@ -174,8 +172,7 @@ discard block |
||
174 | 172 | { |
175 | 173 | unset($this->map['unknown key']); |
176 | 174 | |
177 | - } |
|
178 | - catch(Exception $e) |
|
175 | + } catch(Exception $e) |
|
179 | 176 | { |
180 | 177 | $this->fail('exception raised when unsetting element with unknown key'); |
181 | 178 | } |
@@ -188,10 +185,12 @@ discard block |
||
188 | 185 | foreach($this->map as $index=>$item) |
189 | 186 | { |
190 | 187 | $n++; |
191 | - if($index==='key1' && $item===$this->item1) |
|
192 | - $found++; |
|
193 | - if($index==='key2' && $item===$this->item2) |
|
194 | - $found++; |
|
188 | + if($index==='key1' && $item===$this->item1) { |
|
189 | + $found++; |
|
190 | + } |
|
191 | + if($index==='key2' && $item===$this->item2) { |
|
192 | + $found++; |
|
193 | + } |
|
195 | 194 | } |
196 | 195 | $this->assertTrue($n==2 && $found==2); |
197 | 196 | } |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | $data = new stdClass(); |
38 | 38 | try { |
39 | 39 | $stack->copyFrom($data); |
40 | - } catch(TInvalidDataTypeException $e) { |
|
40 | + } catch (TInvalidDataTypeException $e) { |
|
41 | 41 | return; |
42 | 42 | } |
43 | 43 | self::fail('An expected TInvalidDataTypeException was not raised'); |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | $stack = new TStack(); |
65 | 65 | try { |
66 | 66 | $item = $stack->peek(); |
67 | - } catch(TInvalidOperationException $e) { |
|
67 | + } catch (TInvalidOperationException $e) { |
|
68 | 68 | return; |
69 | 69 | } |
70 | 70 | self::fail('An expected TInvalidOperationException was not raised'); |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | $stack = new TStack(); |
82 | 82 | try { |
83 | 83 | $item = $stack->pop(); |
84 | - } catch(TInvalidOperationException $e) { |
|
84 | + } catch (TInvalidOperationException $e) { |
|
85 | 85 | return; |
86 | 86 | } |
87 | 87 | self::fail('An expected TInvalidOperationException was not raised'); |
@@ -98,13 +98,13 @@ discard block |
||
98 | 98 | self::assertInstanceOf('ArrayIterator', $stack->getIterator()); |
99 | 99 | $n = 0; |
100 | 100 | $found = 0; |
101 | - foreach($stack as $index => $item) { |
|
102 | - foreach($stack as $a => $b); // test of iterator |
|
101 | + foreach ($stack as $index => $item) { |
|
102 | + foreach ($stack as $a => $b); // test of iterator |
|
103 | 103 | $n++; |
104 | - if($index === 0 && $item === 1) { |
|
104 | + if ($index === 0 && $item === 1) { |
|
105 | 105 | $found++; |
106 | 106 | } |
107 | - if($index === 1 && $item === 2) { |
|
107 | + if ($index === 1 && $item === 2) { |
|
108 | 108 | $found++; |
109 | 109 | } |
110 | 110 | } |
@@ -112,7 +112,7 @@ |
||
112 | 112 | } |
113 | 113 | |
114 | 114 | public function testGetCount() { |
115 | - $queue = new TQueue(); |
|
115 | + $queue = new TQueue(); |
|
116 | 116 | self::assertEquals(0, $queue->getCount()); |
117 | 117 | $queue = new TQueue(array(1, 2, 3)); |
118 | 118 | self::assertEquals(3, $queue->getCount()); |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | $data = new stdClass(); |
38 | 38 | try { |
39 | 39 | $queue->copyFrom($data); |
40 | - } catch(TInvalidDataTypeException $e) { |
|
40 | + } catch (TInvalidDataTypeException $e) { |
|
41 | 41 | return; |
42 | 42 | } |
43 | 43 | self::fail('An expected TInvalidDataTypeException was not raised'); |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | } |
57 | 57 | |
58 | 58 | public function testPeek() { |
59 | - $queue = new TQueue(array(1,2,3)); |
|
59 | + $queue = new TQueue(array(1, 2, 3)); |
|
60 | 60 | self::assertEquals(1, $queue->peek()); |
61 | 61 | } |
62 | 62 | |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | $queue = new TQueue(); |
65 | 65 | try { |
66 | 66 | $item = $queue->peek(); |
67 | - } catch(TInvalidOperationException $e) { |
|
67 | + } catch (TInvalidOperationException $e) { |
|
68 | 68 | return; |
69 | 69 | } |
70 | 70 | self::fail('An expected TInvalidOperationException was not raised'); |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | $queue = new TQueue(); |
82 | 82 | try { |
83 | 83 | $item = $queue->dequeue(); |
84 | - } catch(TInvalidOperationException $e) { |
|
84 | + } catch (TInvalidOperationException $e) { |
|
85 | 85 | return; |
86 | 86 | } |
87 | 87 | self::fail('An expected TInvalidOperationException was not raised'); |
@@ -98,13 +98,13 @@ discard block |
||
98 | 98 | self::assertInstanceOf('ArrayIterator', $queue->getIterator()); |
99 | 99 | $n = 0; |
100 | 100 | $found = 0; |
101 | - foreach($queue as $index => $item) { |
|
102 | - foreach($queue as $a => $b); // test of iterator |
|
101 | + foreach ($queue as $index => $item) { |
|
102 | + foreach ($queue as $a => $b); // test of iterator |
|
103 | 103 | $n++; |
104 | - if($index === 0 && $item === 1) { |
|
104 | + if ($index === 0 && $item === 1) { |
|
105 | 105 | $found++; |
106 | 106 | } |
107 | - if($index === 1 && $item === 2) { |
|
107 | + if ($index === 1 && $item === 2) { |
|
108 | 108 | $found++; |
109 | 109 | } |
110 | 110 | } |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | self::assertEquals(false, $collection->canGetProperty('Property')); |
26 | 26 | try { |
27 | 27 | $value = $collection->Property; |
28 | - } catch(TInvalidOperationException $e) { |
|
28 | + } catch (TInvalidOperationException $e) { |
|
29 | 29 | return; |
30 | 30 | } |
31 | 31 | self::fail('An expected TInvalidOperationException was not raised'); |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | $collection = new TAttributeCollection(array(), true); |
43 | 43 | try { |
44 | 44 | $collection->Property = 'value'; |
45 | - } catch(TInvalidOperationException $e) { |
|
45 | + } catch (TInvalidOperationException $e) { |
|
46 | 46 | return; |
47 | 47 | } |
48 | 48 | self::fail('An expected TInvalidOperationException was not raised'); |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | class ListItem { |
4 | - public $data='data'; |
|
4 | + public $data='data'; |
|
5 | 5 | } |
6 | 6 | |
7 | 7 | /** |
@@ -9,17 +9,17 @@ discard block |
||
9 | 9 | */ |
10 | 10 | class TListTest extends PHPUnit_Framework_TestCase { |
11 | 11 | |
12 | - protected $list; |
|
13 | - protected $item1, $item2, $item3, $item4; |
|
12 | + protected $list; |
|
13 | + protected $item1, $item2, $item3, $item4; |
|
14 | 14 | |
15 | 15 | public function setUp() { |
16 | - $this->list=new TList; |
|
17 | - $this->item1=new ListItem; |
|
18 | - $this->item2=new ListItem; |
|
19 | - $this->item3=new ListItem; |
|
20 | - $this->item4=new ListItem; |
|
21 | - $this->list->add($this->item1); |
|
22 | - $this->list->add($this->item2); |
|
16 | + $this->list=new TList; |
|
17 | + $this->item1=new ListItem; |
|
18 | + $this->item2=new ListItem; |
|
19 | + $this->item3=new ListItem; |
|
20 | + $this->item4=new ListItem; |
|
21 | + $this->list->add($this->item1); |
|
22 | + $this->list->add($this->item2); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | public function tearDown() { |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | class ListItem { |
4 | - public $data='data'; |
|
4 | + public $data = 'data'; |
|
5 | 5 | } |
6 | 6 | |
7 | 7 | /** |
@@ -13,29 +13,29 @@ discard block |
||
13 | 13 | protected $item1, $item2, $item3, $item4; |
14 | 14 | |
15 | 15 | public function setUp() { |
16 | - $this->list=new TList; |
|
17 | - $this->item1=new ListItem; |
|
18 | - $this->item2=new ListItem; |
|
19 | - $this->item3=new ListItem; |
|
20 | - $this->item4=new ListItem; |
|
16 | + $this->list = new TList; |
|
17 | + $this->item1 = new ListItem; |
|
18 | + $this->item2 = new ListItem; |
|
19 | + $this->item3 = new ListItem; |
|
20 | + $this->item4 = new ListItem; |
|
21 | 21 | $this->list->add($this->item1); |
22 | 22 | $this->list->add($this->item2); |
23 | 23 | } |
24 | 24 | |
25 | 25 | public function tearDown() { |
26 | - $this->list=null; |
|
27 | - $this->item1=null; |
|
28 | - $this->item2=null; |
|
29 | - $this->item3=null; |
|
30 | - $this->item4=null; |
|
26 | + $this->list = null; |
|
27 | + $this->item1 = null; |
|
28 | + $this->item2 = null; |
|
29 | + $this->item3 = null; |
|
30 | + $this->item4 = null; |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | public function testConstruct() { |
34 | - $a=array(1,2,3); |
|
35 | - $list=new TList($a); |
|
36 | - $this->assertEquals(3,$list->getCount()); |
|
37 | - $list2=new TList($this->list); |
|
38 | - $this->assertEquals(2,$list2->getCount()); |
|
34 | + $a = array(1, 2, 3); |
|
35 | + $list = new TList($a); |
|
36 | + $this->assertEquals(3, $list->getCount()); |
|
37 | + $list2 = new TList($this->list); |
|
38 | + $this->assertEquals(2, $list2->getCount()); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | public function testGetReadOnly() { |
@@ -46,8 +46,8 @@ discard block |
||
46 | 46 | } |
47 | 47 | |
48 | 48 | public function testGetCount() { |
49 | - $this->assertEquals(2,$this->list->getCount()); |
|
50 | - $this->assertEquals(2,$this->list->Count); |
|
49 | + $this->assertEquals(2, $this->list->getCount()); |
|
50 | + $this->assertEquals(2, $this->list->Count); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | public function testItemAt() { |
@@ -56,15 +56,15 @@ discard block |
||
56 | 56 | try { |
57 | 57 | $this->list->itemAt(2); |
58 | 58 | $this->fail('exception not raised when adding item at an out-of-range index'); |
59 | - } catch(TInvalidDataValueException $e) { |
|
59 | + } catch (TInvalidDataValueException $e) { |
|
60 | 60 | } |
61 | 61 | } |
62 | 62 | |
63 | 63 | public function testAdd() { |
64 | - $this->assertEquals(2,$this->list->add(null)); |
|
65 | - $this->assertEquals(3,$this->list->add($this->item3)); |
|
66 | - $this->assertEquals(4,$this->list->getCount()); |
|
67 | - $this->assertEquals(3,$this->list->indexOf($this->item3)); |
|
64 | + $this->assertEquals(2, $this->list->add(null)); |
|
65 | + $this->assertEquals(3, $this->list->add($this->item3)); |
|
66 | + $this->assertEquals(4, $this->list->getCount()); |
|
67 | + $this->assertEquals(3, $this->list->indexOf($this->item3)); |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | public function testCanNotAddWhenReadOnly() { |
@@ -72,20 +72,20 @@ discard block |
||
72 | 72 | try { |
73 | 73 | $list->add(1); |
74 | 74 | self::fail('An expected TInvalidOperationException was not raised'); |
75 | - } catch(TInvalidOperationException $e) { |
|
75 | + } catch (TInvalidOperationException $e) { |
|
76 | 76 | } |
77 | 77 | } |
78 | 78 | |
79 | 79 | public function testInsertAt() { |
80 | - $this->assertNull($this->list->insertAt(0,$this->item3)); |
|
81 | - $this->assertEquals(3,$this->list->getCount()); |
|
82 | - $this->assertEquals(2,$this->list->indexOf($this->item2)); |
|
83 | - $this->assertEquals(0,$this->list->indexOf($this->item3)); |
|
84 | - $this->assertEquals(1,$this->list->indexOf($this->item1)); |
|
80 | + $this->assertNull($this->list->insertAt(0, $this->item3)); |
|
81 | + $this->assertEquals(3, $this->list->getCount()); |
|
82 | + $this->assertEquals(2, $this->list->indexOf($this->item2)); |
|
83 | + $this->assertEquals(0, $this->list->indexOf($this->item3)); |
|
84 | + $this->assertEquals(1, $this->list->indexOf($this->item1)); |
|
85 | 85 | try { |
86 | - $this->list->insertAt(4,$this->item3); |
|
86 | + $this->list->insertAt(4, $this->item3); |
|
87 | 87 | $this->fail('exception not raised when adding item at an out-of-range index'); |
88 | - } catch(TInvalidDataValueException $e) { |
|
88 | + } catch (TInvalidDataValueException $e) { |
|
89 | 89 | } |
90 | 90 | } |
91 | 91 | |
@@ -94,27 +94,27 @@ discard block |
||
94 | 94 | try { |
95 | 95 | $list->insertAt(1, 2); |
96 | 96 | self::fail('An expected TInvalidOperationException was not raised'); |
97 | - } catch(TInvalidOperationException $e) { |
|
97 | + } catch (TInvalidOperationException $e) { |
|
98 | 98 | } |
99 | 99 | try { |
100 | 100 | $list->insertAt(0, 2); |
101 | 101 | self::fail('An expected TInvalidOperationException was not raised'); |
102 | - } catch(TInvalidOperationException $e) { |
|
102 | + } catch (TInvalidOperationException $e) { |
|
103 | 103 | } |
104 | 104 | } |
105 | 105 | |
106 | 106 | public function testInsertBefore() { |
107 | 107 | try { |
108 | - $this->list->insertBefore($this->item4,$this->item3); |
|
108 | + $this->list->insertBefore($this->item4, $this->item3); |
|
109 | 109 | $this->fail('exception not raised when adding item before a non-existant base item'); |
110 | - } catch(TInvalidDataValueException $e) { |
|
110 | + } catch (TInvalidDataValueException $e) { |
|
111 | 111 | } |
112 | - $this->assertEquals(2,$this->list->getCount()); |
|
113 | - $this->assertEquals(0,$this->list->insertBefore($this->item1,$this->item3)); |
|
114 | - $this->assertEquals(3,$this->list->getCount()); |
|
115 | - $this->assertEquals(0,$this->list->indexOf($this->item3)); |
|
116 | - $this->assertEquals(1,$this->list->indexOf($this->item1)); |
|
117 | - $this->assertEquals(2,$this->list->indexOf($this->item2)); |
|
112 | + $this->assertEquals(2, $this->list->getCount()); |
|
113 | + $this->assertEquals(0, $this->list->insertBefore($this->item1, $this->item3)); |
|
114 | + $this->assertEquals(3, $this->list->getCount()); |
|
115 | + $this->assertEquals(0, $this->list->indexOf($this->item3)); |
|
116 | + $this->assertEquals(1, $this->list->indexOf($this->item1)); |
|
117 | + $this->assertEquals(2, $this->list->indexOf($this->item2)); |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | public function testCanNotInsertBeforeWhenReadOnly() { |
@@ -122,27 +122,27 @@ discard block |
||
122 | 122 | try { |
123 | 123 | $list->insertBefore(5, 6); |
124 | 124 | self::fail('An expected TInvalidOperationException was not raised'); |
125 | - } catch(TInvalidOperationException $e) { |
|
125 | + } catch (TInvalidOperationException $e) { |
|
126 | 126 | } |
127 | 127 | try { |
128 | 128 | $list->insertBefore(8, 6); |
129 | 129 | self::fail('An expected TInvalidOperationException was not raised'); |
130 | - } catch(TInvalidOperationException $e) { |
|
130 | + } catch (TInvalidOperationException $e) { |
|
131 | 131 | } |
132 | 132 | } |
133 | 133 | |
134 | 134 | public function testInsertAfter() { |
135 | 135 | try { |
136 | - $this->list->insertAfter($this->item4,$this->item3); |
|
136 | + $this->list->insertAfter($this->item4, $this->item3); |
|
137 | 137 | $this->fail('exception not raised when adding item after a non-existant base item'); |
138 | - } catch(TInvalidDataValueException $e) { |
|
138 | + } catch (TInvalidDataValueException $e) { |
|
139 | 139 | } |
140 | - $this->assertEquals(2,$this->list->getCount()); |
|
141 | - $this->assertEquals(2,$this->list->insertAfter($this->item2,$this->item3)); |
|
142 | - $this->assertEquals(3,$this->list->getCount()); |
|
143 | - $this->assertEquals(0,$this->list->indexOf($this->item1)); |
|
144 | - $this->assertEquals(1,$this->list->indexOf($this->item2)); |
|
145 | - $this->assertEquals(2,$this->list->indexOf($this->item3)); |
|
140 | + $this->assertEquals(2, $this->list->getCount()); |
|
141 | + $this->assertEquals(2, $this->list->insertAfter($this->item2, $this->item3)); |
|
142 | + $this->assertEquals(3, $this->list->getCount()); |
|
143 | + $this->assertEquals(0, $this->list->indexOf($this->item1)); |
|
144 | + $this->assertEquals(1, $this->list->indexOf($this->item2)); |
|
145 | + $this->assertEquals(2, $this->list->indexOf($this->item3)); |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | public function testCanNotInsertAfterWhenReadOnly() { |
@@ -150,24 +150,24 @@ discard block |
||
150 | 150 | try { |
151 | 151 | $list->insertAfter(5, 6); |
152 | 152 | self::fail('An expected TInvalidOperationException was not raised'); |
153 | - } catch(TInvalidOperationException $e) { |
|
153 | + } catch (TInvalidOperationException $e) { |
|
154 | 154 | } |
155 | 155 | try { |
156 | 156 | $list->insertAfter(8, 6); |
157 | 157 | self::fail('An expected TInvalidOperationException was not raised'); |
158 | - } catch(TInvalidOperationException $e) { |
|
158 | + } catch (TInvalidOperationException $e) { |
|
159 | 159 | } |
160 | 160 | } |
161 | 161 | |
162 | 162 | public function testRemove() { |
163 | - $this->assertEquals(0,$this->list->remove($this->item1)); |
|
164 | - $this->assertEquals(1,$this->list->getCount()); |
|
165 | - $this->assertEquals(-1,$this->list->indexOf($this->item1)); |
|
166 | - $this->assertEquals(0,$this->list->indexOf($this->item2)); |
|
163 | + $this->assertEquals(0, $this->list->remove($this->item1)); |
|
164 | + $this->assertEquals(1, $this->list->getCount()); |
|
165 | + $this->assertEquals(-1, $this->list->indexOf($this->item1)); |
|
166 | + $this->assertEquals(0, $this->list->indexOf($this->item2)); |
|
167 | 167 | try { |
168 | 168 | $this->list->remove($this->item1); |
169 | 169 | $this->fail('exception not raised when removing nonexisting item'); |
170 | - } catch(Exception $e) { |
|
170 | + } catch (Exception $e) { |
|
171 | 171 | } |
172 | 172 | } |
173 | 173 | |
@@ -176,27 +176,27 @@ discard block |
||
176 | 176 | try { |
177 | 177 | $list->remove(2); |
178 | 178 | self::fail('An expected TInvalidOperationException was not raised'); |
179 | - } catch(TInvalidOperationException $e) { |
|
179 | + } catch (TInvalidOperationException $e) { |
|
180 | 180 | } |
181 | 181 | |
182 | 182 | $list = new TList(array(1, 2, 3), true); |
183 | 183 | try { |
184 | 184 | $list->remove(10); |
185 | 185 | self::fail('An expected TInvalidOperationException was not raised'); |
186 | - } catch(TInvalidOperationException $e) { |
|
186 | + } catch (TInvalidOperationException $e) { |
|
187 | 187 | } |
188 | 188 | } |
189 | 189 | |
190 | 190 | public function testRemoveAt() { |
191 | 191 | $this->list->add($this->item3); |
192 | 192 | $this->assertEquals($this->item2, $this->list->removeAt(1)); |
193 | - $this->assertEquals(-1,$this->list->indexOf($this->item2)); |
|
194 | - $this->assertEquals(1,$this->list->indexOf($this->item3)); |
|
195 | - $this->assertEquals(0,$this->list->indexOf($this->item1)); |
|
193 | + $this->assertEquals(-1, $this->list->indexOf($this->item2)); |
|
194 | + $this->assertEquals(1, $this->list->indexOf($this->item3)); |
|
195 | + $this->assertEquals(0, $this->list->indexOf($this->item1)); |
|
196 | 196 | try { |
197 | 197 | $this->list->removeAt(2); |
198 | 198 | $this->fail('exception not raised when removing item with invalid index'); |
199 | - } catch(TInvalidDataValueException $e) { |
|
199 | + } catch (TInvalidDataValueException $e) { |
|
200 | 200 | } |
201 | 201 | } |
202 | 202 | |
@@ -205,29 +205,29 @@ discard block |
||
205 | 205 | try { |
206 | 206 | $list->removeAt(2); |
207 | 207 | self::fail('An expected TInvalidOperationException was not raised'); |
208 | - } catch(TInvalidOperationException $e) { |
|
208 | + } catch (TInvalidOperationException $e) { |
|
209 | 209 | } |
210 | 210 | |
211 | 211 | $list = new TList(array(1, 2, 3), true); |
212 | 212 | try { |
213 | 213 | $list->removeAt(10); |
214 | 214 | self::fail('An expected TInvalidOperationException was not raised'); |
215 | - } catch(TInvalidOperationException $e) { |
|
215 | + } catch (TInvalidOperationException $e) { |
|
216 | 216 | } |
217 | 217 | } |
218 | 218 | |
219 | 219 | public function testClear() { |
220 | 220 | $this->list->clear(); |
221 | - $this->assertEquals(0,$this->list->getCount()); |
|
222 | - $this->assertEquals(-1,$this->list->indexOf($this->item1)); |
|
223 | - $this->assertEquals(-1,$this->list->indexOf($this->item2)); |
|
221 | + $this->assertEquals(0, $this->list->getCount()); |
|
222 | + $this->assertEquals(-1, $this->list->indexOf($this->item1)); |
|
223 | + $this->assertEquals(-1, $this->list->indexOf($this->item2)); |
|
224 | 224 | } |
225 | 225 | |
226 | 226 | public function testCanNotClearWhenReadOnly() { |
227 | 227 | $list = new TList(array(1, 2, 3), true); |
228 | 228 | try { |
229 | 229 | $list->clear(); |
230 | - } catch(TInvalidOperationException $e) { |
|
230 | + } catch (TInvalidOperationException $e) { |
|
231 | 231 | return; |
232 | 232 | } |
233 | 233 | self::fail('An expected TInvalidOperationException was not raised'); |
@@ -240,64 +240,64 @@ discard block |
||
240 | 240 | } |
241 | 241 | |
242 | 242 | public function testIndexOf() { |
243 | - $this->assertEquals(0,$this->list->indexOf($this->item1)); |
|
244 | - $this->assertEquals(1,$this->list->indexOf($this->item2)); |
|
245 | - $this->assertEquals(-1,$this->list->indexOf($this->item3)); |
|
243 | + $this->assertEquals(0, $this->list->indexOf($this->item1)); |
|
244 | + $this->assertEquals(1, $this->list->indexOf($this->item2)); |
|
245 | + $this->assertEquals(-1, $this->list->indexOf($this->item3)); |
|
246 | 246 | } |
247 | 247 | |
248 | 248 | public function testCopyFrom() { |
249 | - $array=array($this->item3,$this->item1); |
|
249 | + $array = array($this->item3, $this->item1); |
|
250 | 250 | $this->list->copyFrom($array); |
251 | - $this->assertTrue(count($array)==2 && $this->list[0]===$this->item3 && $this->list[1]===$this->item1); |
|
251 | + $this->assertTrue(count($array) == 2 && $this->list[0] === $this->item3 && $this->list[1] === $this->item1); |
|
252 | 252 | try { |
253 | 253 | $this->list->copyFrom($this); |
254 | 254 | $this->fail('exception not raised when copying from non-traversable object'); |
255 | - } catch(TInvalidDataTypeException $e) { |
|
255 | + } catch (TInvalidDataTypeException $e) { |
|
256 | 256 | } |
257 | 257 | } |
258 | 258 | |
259 | 259 | public function testMergeWith() { |
260 | - $array=array($this->item3,$this->item1); |
|
260 | + $array = array($this->item3, $this->item1); |
|
261 | 261 | $this->list->mergeWith($array); |
262 | - $this->assertTrue($this->list->getCount()==4 && $this->list[0]===$this->item1 && $this->list[3]===$this->item1); |
|
262 | + $this->assertTrue($this->list->getCount() == 4 && $this->list[0] === $this->item1 && $this->list[3] === $this->item1); |
|
263 | 263 | try { |
264 | 264 | $this->list->mergeWith($this); |
265 | 265 | $this->fail('exception not raised when copying from non-traversable object'); |
266 | - } catch(TInvalidDataTypeException $e) { |
|
266 | + } catch (TInvalidDataTypeException $e) { |
|
267 | 267 | } |
268 | 268 | } |
269 | 269 | |
270 | 270 | public function testToArray() { |
271 | - $array=$this->list->toArray(); |
|
272 | - $this->assertTrue(count($array)==2 && $array[0]===$this->item1 && $array[1]===$this->item2); |
|
271 | + $array = $this->list->toArray(); |
|
272 | + $this->assertTrue(count($array) == 2 && $array[0] === $this->item1 && $array[1] === $this->item2); |
|
273 | 273 | } |
274 | 274 | |
275 | 275 | public function testArrayRead() { |
276 | - $this->assertTrue($this->list[0]===$this->item1); |
|
277 | - $this->assertTrue($this->list[1]===$this->item2); |
|
276 | + $this->assertTrue($this->list[0] === $this->item1); |
|
277 | + $this->assertTrue($this->list[1] === $this->item2); |
|
278 | 278 | try { |
279 | - $a=$this->list[2]; |
|
279 | + $a = $this->list[2]; |
|
280 | 280 | $this->fail('exception not raised when accessing item with out-of-range index'); |
281 | - } catch(TInvalidDataValueException $e) { |
|
281 | + } catch (TInvalidDataValueException $e) { |
|
282 | 282 | } |
283 | 283 | } |
284 | 284 | |
285 | 285 | public function testGetIterator() { |
286 | - $n=0; |
|
287 | - $found=0; |
|
288 | - foreach($this->list as $index=>$item) { |
|
289 | - foreach($this->list as $a=>$b); // test of iterator |
|
286 | + $n = 0; |
|
287 | + $found = 0; |
|
288 | + foreach ($this->list as $index=>$item) { |
|
289 | + foreach ($this->list as $a=>$b); // test of iterator |
|
290 | 290 | $n++; |
291 | - if($index===0 && $item===$this->item1) |
|
291 | + if ($index === 0 && $item === $this->item1) |
|
292 | 292 | $found++; |
293 | - if($index===1 && $item===$this->item2) |
|
293 | + if ($index === 1 && $item === $this->item2) |
|
294 | 294 | $found++; |
295 | 295 | } |
296 | - $this->assertTrue($n==2 && $found==2); |
|
296 | + $this->assertTrue($n == 2 && $found == 2); |
|
297 | 297 | } |
298 | 298 | |
299 | 299 | public function testArrayMisc() { |
300 | - $this->assertEquals($this->list->Count,count($this->list)); |
|
300 | + $this->assertEquals($this->list->Count, count($this->list)); |
|
301 | 301 | $this->assertTrue(isset($this->list[1])); |
302 | 302 | $this->assertFalse(isset($this->list[2])); |
303 | 303 | } |
@@ -288,10 +288,12 @@ |
||
288 | 288 | foreach($this->list as $index=>$item) { |
289 | 289 | foreach($this->list as $a=>$b); // test of iterator |
290 | 290 | $n++; |
291 | - if($index===0 && $item===$this->item1) |
|
292 | - $found++; |
|
293 | - if($index===1 && $item===$this->item2) |
|
294 | - $found++; |
|
291 | + if($index===0 && $item===$this->item1) { |
|
292 | + $found++; |
|
293 | + } |
|
294 | + if($index===1 && $item===$this->item2) { |
|
295 | + $found++; |
|
296 | + } |
|
295 | 297 | } |
296 | 298 | $this->assertTrue($n==2 && $found==2); |
297 | 299 | } |
@@ -14,13 +14,13 @@ discard block |
||
14 | 14 | |
15 | 15 | class Collections_AllTests { |
16 | 16 | public static function main() { |
17 | - PHPUnit_TextUI_TestRunner::run(self::suite()); |
|
17 | + PHPUnit_TextUI_TestRunner::run(self::suite()); |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | public static function suite() { |
21 | - $suite = new PHPUnit_Framework_TestSuite('System.Collections'); |
|
21 | + $suite = new PHPUnit_Framework_TestSuite('System.Collections'); |
|
22 | 22 | |
23 | - $suite->addTestSuite('TListTest'); |
|
23 | + $suite->addTestSuite('TListTest'); |
|
24 | 24 | $suite->addTestSuite('TMapTest'); |
25 | 25 | $suite->addTestSuite('TQueueTest'); |
26 | 26 | $suite->addTestSuite('TStackTest'); |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | $suite->addTestSuite('TPagedListTest'); |
29 | 29 | $suite->addTestSuite('TPagedDataSourceTest'); |
30 | 30 | |
31 | - return $suite; |
|
31 | + return $suite; |
|
32 | 32 | } |
33 | 33 | } |
34 | 34 |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if(!defined('PHPUnit_MAIN_METHOD')) { |
|
3 | +if (!defined('PHPUnit_MAIN_METHOD')) { |
|
4 | 4 | define('PHPUnit_MAIN_METHOD', 'Collections_AllTests::main'); |
5 | 5 | } |
6 | 6 | |
@@ -32,6 +32,6 @@ discard block |
||
32 | 32 | } |
33 | 33 | } |
34 | 34 | |
35 | -if(PHPUnit_MAIN_METHOD == 'Collections_AllTests::main') { |
|
35 | +if (PHPUnit_MAIN_METHOD == 'Collections_AllTests::main') { |
|
36 | 36 | Collections_AllTests::main(); |
37 | 37 | } |
@@ -14,16 +14,16 @@ discard block |
||
14 | 14 | |
15 | 15 | public function setUp() { |
16 | 16 | // test that TPriorityMap complies with TMap |
17 | - $this->map=new TPriorityMap; |
|
18 | - $this->item1=new TPriorityMapTest_MapItem; |
|
19 | - $this->item2=new TPriorityMapTest_MapItem; |
|
20 | - $this->item3=new TPriorityMapTest_MapItem; |
|
21 | - $this->item4=new TPriorityMapTest_MapItem; |
|
22 | - $this->item5=new TPriorityMapTest_MapItem; |
|
23 | - $this->map->add('key1',$this->item1); |
|
24 | - $this->map->add('key2',$this->item2); |
|
25 | - |
|
26 | - //Test the priority capabilities |
|
17 | + $this->map=new TPriorityMap; |
|
18 | + $this->item1=new TPriorityMapTest_MapItem; |
|
19 | + $this->item2=new TPriorityMapTest_MapItem; |
|
20 | + $this->item3=new TPriorityMapTest_MapItem; |
|
21 | + $this->item4=new TPriorityMapTest_MapItem; |
|
22 | + $this->item5=new TPriorityMapTest_MapItem; |
|
23 | + $this->map->add('key1',$this->item1); |
|
24 | + $this->map->add('key2',$this->item2); |
|
25 | + |
|
26 | + //Test the priority capabilities |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | public function setUpPriorities() { |
@@ -33,24 +33,24 @@ discard block |
||
33 | 33 | } |
34 | 34 | |
35 | 35 | public function tearDown() { |
36 | - $this->map=null; |
|
37 | - $this->item1=null; |
|
38 | - $this->item2=null; |
|
39 | - $this->item3=null; |
|
36 | + $this->map=null; |
|
37 | + $this->item1=null; |
|
38 | + $this->item2=null; |
|
39 | + $this->item3=null; |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | public function testConstruct() { |
43 | - $a=array(1,2,'key3'=>3); |
|
44 | - $map=new TPriorityMap($a); |
|
45 | - $this->assertEquals(3,$map->getCount()); |
|
46 | - $map2=new TPriorityMap($this->map); |
|
47 | - $this->assertEquals(2,$map2->getCount()); |
|
43 | + $a=array(1,2,'key3'=>3); |
|
44 | + $map=new TPriorityMap($a); |
|
45 | + $this->assertEquals(3,$map->getCount()); |
|
46 | + $map2=new TPriorityMap($this->map); |
|
47 | + $this->assertEquals(2,$map2->getCount()); |
|
48 | 48 | |
49 | 49 | /* Test the priority functionality of TPriorityMap */ |
50 | 50 | |
51 | - $map3=new TPriorityMap($this->map, false, 100, -1); |
|
52 | - $this->assertEquals(100,$map3->getDefaultPriority()); |
|
53 | - $this->assertEquals(-1,$map3->getPrecision()); |
|
51 | + $map3=new TPriorityMap($this->map, false, 100, -1); |
|
52 | + $this->assertEquals(100,$map3->getDefaultPriority()); |
|
53 | + $this->assertEquals(-1,$map3->getPrecision()); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | /* Test that TPriorityMap complies with TMap */ |
@@ -64,12 +64,12 @@ discard block |
||
64 | 64 | } |
65 | 65 | |
66 | 66 | public function testGetCount() { |
67 | - $this->assertEquals(2,$this->map->getCount()); |
|
67 | + $this->assertEquals(2,$this->map->getCount()); |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | public function testGetKeys() { |
71 | - $keys=$this->map->getKeys(); |
|
72 | - $this->assertTrue(count($keys)===2 && $keys[0]==='key1' && $keys[1]==='key2'); |
|
71 | + $keys=$this->map->getKeys(); |
|
72 | + $this->assertTrue(count($keys)===2 && $keys[0]==='key1' && $keys[1]==='key2'); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | public function testAdd() |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | class TPriorityMapTest_MapItem { |
4 | - public $data='data'; |
|
4 | + public $data = 'data'; |
|
5 | 5 | } |
6 | 6 | |
7 | 7 | Prado::using('System.Collections.TPriorityMap'); |
@@ -10,18 +10,18 @@ discard block |
||
10 | 10 | */ |
11 | 11 | class TPriorityMapTest extends PHPUnit_Framework_TestCase { |
12 | 12 | protected $map; |
13 | - protected $item1,$item2,$item3,$item4,$item5; |
|
13 | + protected $item1, $item2, $item3, $item4, $item5; |
|
14 | 14 | |
15 | 15 | public function setUp() { |
16 | 16 | // test that TPriorityMap complies with TMap |
17 | - $this->map=new TPriorityMap; |
|
18 | - $this->item1=new TPriorityMapTest_MapItem; |
|
19 | - $this->item2=new TPriorityMapTest_MapItem; |
|
20 | - $this->item3=new TPriorityMapTest_MapItem; |
|
21 | - $this->item4=new TPriorityMapTest_MapItem; |
|
22 | - $this->item5=new TPriorityMapTest_MapItem; |
|
23 | - $this->map->add('key1',$this->item1); |
|
24 | - $this->map->add('key2',$this->item2); |
|
17 | + $this->map = new TPriorityMap; |
|
18 | + $this->item1 = new TPriorityMapTest_MapItem; |
|
19 | + $this->item2 = new TPriorityMapTest_MapItem; |
|
20 | + $this->item3 = new TPriorityMapTest_MapItem; |
|
21 | + $this->item4 = new TPriorityMapTest_MapItem; |
|
22 | + $this->item5 = new TPriorityMapTest_MapItem; |
|
23 | + $this->map->add('key1', $this->item1); |
|
24 | + $this->map->add('key2', $this->item2); |
|
25 | 25 | |
26 | 26 | //Test the priority capabilities |
27 | 27 | } |
@@ -33,24 +33,24 @@ discard block |
||
33 | 33 | } |
34 | 34 | |
35 | 35 | public function tearDown() { |
36 | - $this->map=null; |
|
37 | - $this->item1=null; |
|
38 | - $this->item2=null; |
|
39 | - $this->item3=null; |
|
36 | + $this->map = null; |
|
37 | + $this->item1 = null; |
|
38 | + $this->item2 = null; |
|
39 | + $this->item3 = null; |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | public function testConstruct() { |
43 | - $a=array(1,2,'key3'=>3); |
|
44 | - $map=new TPriorityMap($a); |
|
45 | - $this->assertEquals(3,$map->getCount()); |
|
46 | - $map2=new TPriorityMap($this->map); |
|
47 | - $this->assertEquals(2,$map2->getCount()); |
|
43 | + $a = array(1, 2, 'key3'=>3); |
|
44 | + $map = new TPriorityMap($a); |
|
45 | + $this->assertEquals(3, $map->getCount()); |
|
46 | + $map2 = new TPriorityMap($this->map); |
|
47 | + $this->assertEquals(2, $map2->getCount()); |
|
48 | 48 | |
49 | 49 | /* Test the priority functionality of TPriorityMap */ |
50 | 50 | |
51 | - $map3=new TPriorityMap($this->map, false, 100, -1); |
|
52 | - $this->assertEquals(100,$map3->getDefaultPriority()); |
|
53 | - $this->assertEquals(-1,$map3->getPrecision()); |
|
51 | + $map3 = new TPriorityMap($this->map, false, 100, -1); |
|
52 | + $this->assertEquals(100, $map3->getDefaultPriority()); |
|
53 | + $this->assertEquals(-1, $map3->getPrecision()); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | /* Test that TPriorityMap complies with TMap */ |
@@ -64,25 +64,25 @@ discard block |
||
64 | 64 | } |
65 | 65 | |
66 | 66 | public function testGetCount() { |
67 | - $this->assertEquals(2,$this->map->getCount()); |
|
67 | + $this->assertEquals(2, $this->map->getCount()); |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | public function testGetKeys() { |
71 | - $keys=$this->map->getKeys(); |
|
72 | - $this->assertTrue(count($keys)===2 && $keys[0]==='key1' && $keys[1]==='key2'); |
|
71 | + $keys = $this->map->getKeys(); |
|
72 | + $this->assertTrue(count($keys) === 2 && $keys[0] === 'key1' && $keys[1] === 'key2'); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | public function testAdd() |
76 | 76 | { |
77 | - $this->map->add('key3',$this->item3); |
|
78 | - $this->assertTrue($this->map->getCount()==3 && $this->map->contains('key3')); |
|
77 | + $this->map->add('key3', $this->item3); |
|
78 | + $this->assertTrue($this->map->getCount() == 3 && $this->map->contains('key3')); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | public function testCanNotAddWhenReadOnly() { |
82 | 82 | $map = new TPriorityMap(array(), true); |
83 | 83 | try { |
84 | 84 | $map->add('key', 'value'); |
85 | - } catch(TInvalidOperationException $e) { |
|
85 | + } catch (TInvalidOperationException $e) { |
|
86 | 86 | return; |
87 | 87 | } |
88 | 88 | self::fail('An expected TInvalidOperationException was not raised'); |
@@ -91,15 +91,15 @@ discard block |
||
91 | 91 | public function testRemove() |
92 | 92 | { |
93 | 93 | $this->map->remove('key1'); |
94 | - $this->assertTrue($this->map->getCount()==1 && !$this->map->contains('key1')); |
|
95 | - $this->assertTrue($this->map->remove('unknown key')===null); |
|
94 | + $this->assertTrue($this->map->getCount() == 1 && !$this->map->contains('key1')); |
|
95 | + $this->assertTrue($this->map->remove('unknown key') === null); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | public function testCanNotRemoveWhenReadOnly() { |
99 | 99 | $map = new TPriorityMap(array('key' => 'value'), true); |
100 | 100 | try { |
101 | 101 | $map->remove('key'); |
102 | - } catch(TInvalidOperationException $e) { |
|
102 | + } catch (TInvalidOperationException $e) { |
|
103 | 103 | return; |
104 | 104 | } |
105 | 105 | self::fail('An expected TInvalidOperationException was not raised'); |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | public function testClear() |
109 | 109 | { |
110 | 110 | $this->map->clear(); |
111 | - $this->assertTrue($this->map->getCount()==0 && !$this->map->contains('key1') && !$this->map->contains('key2')); |
|
111 | + $this->assertTrue($this->map->getCount() == 0 && !$this->map->contains('key1') && !$this->map->contains('key2')); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | public function testContains() |
@@ -120,15 +120,15 @@ discard block |
||
120 | 120 | |
121 | 121 | public function testCopyFrom() |
122 | 122 | { |
123 | - $array=array('key3'=>$this->item3,'key4'=>$this->item1); |
|
123 | + $array = array('key3'=>$this->item3, 'key4'=>$this->item1); |
|
124 | 124 | $this->map->copyFrom($array); |
125 | - $this->assertTrue($this->map->getCount()==2 && $this->map['key3']===$this->item3 && $this->map['key4']===$this->item1); |
|
125 | + $this->assertTrue($this->map->getCount() == 2 && $this->map['key3'] === $this->item3 && $this->map['key4'] === $this->item1); |
|
126 | 126 | try |
127 | 127 | { |
128 | 128 | $this->map->copyFrom($this); |
129 | 129 | $this->fail('no exception raised when copying a non-traversable object'); |
130 | 130 | } |
131 | - catch(TInvalidDataTypeException $e) |
|
131 | + catch (TInvalidDataTypeException $e) |
|
132 | 132 | { |
133 | 133 | |
134 | 134 | } |
@@ -136,17 +136,17 @@ discard block |
||
136 | 136 | |
137 | 137 | public function testMergeWith() |
138 | 138 | { |
139 | - $array=array('key2'=>$this->item1,'key3'=>$this->item3); |
|
139 | + $array = array('key2'=>$this->item1, 'key3'=>$this->item3); |
|
140 | 140 | $this->map->mergeWith($array); |
141 | - $this->assertEquals(3,$this->map->getCount()); |
|
142 | - $this->assertTrue($this->map['key2']===$this->item1); |
|
143 | - $this->assertTrue($this->map['key3']===$this->item3); |
|
141 | + $this->assertEquals(3, $this->map->getCount()); |
|
142 | + $this->assertTrue($this->map['key2'] === $this->item1); |
|
143 | + $this->assertTrue($this->map['key3'] === $this->item3); |
|
144 | 144 | try |
145 | 145 | { |
146 | 146 | $this->map->mergeWith($this); |
147 | 147 | $this->fail('no exception raised when copying a non-traversable object'); |
148 | 148 | } |
149 | - catch(TInvalidDataTypeException $e) |
|
149 | + catch (TInvalidDataTypeException $e) |
|
150 | 150 | { |
151 | 151 | |
152 | 152 | } |
@@ -154,28 +154,28 @@ discard block |
||
154 | 154 | |
155 | 155 | public function testArrayRead() |
156 | 156 | { |
157 | - $this->assertTrue($this->map['key1']===$this->item1); |
|
158 | - $this->assertTrue($this->map['key2']===$this->item2); |
|
159 | - $this->assertEquals(null,$this->map['key3']); |
|
157 | + $this->assertTrue($this->map['key1'] === $this->item1); |
|
158 | + $this->assertTrue($this->map['key2'] === $this->item2); |
|
159 | + $this->assertEquals(null, $this->map['key3']); |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | public function testArrayWrite() |
163 | 163 | { |
164 | - $this->map['key3']=$this->item3; |
|
165 | - $this->assertTrue($this->map['key3']===$this->item3); |
|
166 | - $this->assertEquals(3,$this->map->getCount()); |
|
167 | - $this->map['key1']=$this->item3; |
|
168 | - $this->assertTrue($this->map['key1']===$this->item3); |
|
169 | - $this->assertEquals(3,$this->map->getCount()); |
|
164 | + $this->map['key3'] = $this->item3; |
|
165 | + $this->assertTrue($this->map['key3'] === $this->item3); |
|
166 | + $this->assertEquals(3, $this->map->getCount()); |
|
167 | + $this->map['key1'] = $this->item3; |
|
168 | + $this->assertTrue($this->map['key1'] === $this->item3); |
|
169 | + $this->assertEquals(3, $this->map->getCount()); |
|
170 | 170 | unset($this->map['key2']); |
171 | - $this->assertEquals(2,$this->map->getCount()); |
|
171 | + $this->assertEquals(2, $this->map->getCount()); |
|
172 | 172 | $this->assertFalse($this->map->contains('key2')); |
173 | 173 | try |
174 | 174 | { |
175 | 175 | unset($this->map['unknown key']); |
176 | 176 | |
177 | 177 | } |
178 | - catch(Exception $e) |
|
178 | + catch (Exception $e) |
|
179 | 179 | { |
180 | 180 | $this->fail('exception raised when unsetting element with unknown key'); |
181 | 181 | } |
@@ -183,22 +183,22 @@ discard block |
||
183 | 183 | |
184 | 184 | public function testArrayForeach() |
185 | 185 | { |
186 | - $n=0; |
|
187 | - $found=0; |
|
188 | - foreach($this->map as $index=>$item) |
|
186 | + $n = 0; |
|
187 | + $found = 0; |
|
188 | + foreach ($this->map as $index=>$item) |
|
189 | 189 | { |
190 | 190 | $n++; |
191 | - if($index==='key1' && $item===$this->item1) |
|
191 | + if ($index === 'key1' && $item === $this->item1) |
|
192 | 192 | $found++; |
193 | - if($index==='key2' && $item===$this->item2) |
|
193 | + if ($index === 'key2' && $item === $this->item2) |
|
194 | 194 | $found++; |
195 | 195 | } |
196 | - $this->assertTrue($n==2 && $found==2); |
|
196 | + $this->assertTrue($n == 2 && $found == 2); |
|
197 | 197 | } |
198 | 198 | |
199 | 199 | public function testArrayMisc() |
200 | 200 | { |
201 | - $this->assertEquals($this->map->Count,count($this->map)); |
|
201 | + $this->assertEquals($this->map->Count, count($this->map)); |
|
202 | 202 | $this->assertTrue(isset($this->map['key1'])); |
203 | 203 | $this->assertFalse(isset($this->map['unknown key'])); |
204 | 204 | } |
@@ -408,7 +408,7 @@ discard block |
||
408 | 408 | $this->assertEquals($this->item1, $ordered_values[3]); |
409 | 409 | $this->assertEquals($this->item2, $ordered_values[4]); |
410 | 410 | $this->assertEquals($this->item4, $ordered_values[5]); |
411 | - $this->assertEquals('endvalue', $ordered_values[6]); |
|
411 | + $this->assertEquals('endvalue', $ordered_values[6]); |
|
412 | 412 | |
413 | 413 | $this->assertEquals(1, $map2->priorityAt('key5')); |
414 | 414 | $this->assertEquals(1, $map2->priorityOf($this->item5)); |
@@ -127,8 +127,7 @@ discard block |
||
127 | 127 | { |
128 | 128 | $this->map->copyFrom($this); |
129 | 129 | $this->fail('no exception raised when copying a non-traversable object'); |
130 | - } |
|
131 | - catch(TInvalidDataTypeException $e) |
|
130 | + } catch(TInvalidDataTypeException $e) |
|
132 | 131 | { |
133 | 132 | |
134 | 133 | } |
@@ -145,8 +144,7 @@ discard block |
||
145 | 144 | { |
146 | 145 | $this->map->mergeWith($this); |
147 | 146 | $this->fail('no exception raised when copying a non-traversable object'); |
148 | - } |
|
149 | - catch(TInvalidDataTypeException $e) |
|
147 | + } catch(TInvalidDataTypeException $e) |
|
150 | 148 | { |
151 | 149 | |
152 | 150 | } |
@@ -174,8 +172,7 @@ discard block |
||
174 | 172 | { |
175 | 173 | unset($this->map['unknown key']); |
176 | 174 | |
177 | - } |
|
178 | - catch(Exception $e) |
|
175 | + } catch(Exception $e) |
|
179 | 176 | { |
180 | 177 | $this->fail('exception raised when unsetting element with unknown key'); |
181 | 178 | } |
@@ -188,10 +185,12 @@ discard block |
||
188 | 185 | foreach($this->map as $index=>$item) |
189 | 186 | { |
190 | 187 | $n++; |
191 | - if($index==='key1' && $item===$this->item1) |
|
192 | - $found++; |
|
193 | - if($index==='key2' && $item===$this->item2) |
|
194 | - $found++; |
|
188 | + if($index==='key1' && $item===$this->item1) { |
|
189 | + $found++; |
|
190 | + } |
|
191 | + if($index==='key2' && $item===$this->item2) { |
|
192 | + $found++; |
|
193 | + } |
|
195 | 194 | } |
196 | 195 | $this->assertTrue($n==2 && $found==2); |
197 | 196 | } |