Passed
Push — master ( 87852b...70110a )
by Tomasz
03:24
created
tests/unit/web/lib/admin/utils/CSVParserTest.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -2,19 +2,19 @@  discard block
 block discarded – undo
2 2
 
3 3
 use web\lib\admin\utils\CSVParser;
4 4
 
5
-class MockCSVParser extends CSVParser{
5
+class MockCSVParser extends CSVParser {
6 6
     
7 7
     public function __construct($fileData, $rowDelimiter, $tokenDelimiter) {
8 8
         $this->rowDelimiter = $rowDelimiter;
9 9
         $this->tokenDelimiter = $tokenDelimiter;
10
-        if($this->validate($fileData)){
10
+        if ($this->validate($fileData)) {
11 11
             $this->rows = str_getcsv($fileData['contents'], $this->rowDelimiter);
12 12
         }
13 13
     }
14 14
     
15 15
 }
16 16
 
17
-class CSVParserTest extends PHPUnit_Framework_TestCase{
17
+class CSVParserTest extends PHPUnit_Framework_TestCase {
18 18
     
19 19
     private $rowDelimiter = "\n", $tokenDelimiter = ",";
20 20
     
@@ -52,15 +52,15 @@  discard block
 block discarded – undo
52 52
             'contents' => ""
53 53
     );
54 54
     
55
-    protected function setUp(){
56
-        $this->successFileData['contents'] = "testuser1,".date('Y-m-d',strtotime("+1 month")).",2
57
-                           testuser2,".date('Y-m-d',strtotime("+2 month")).",
58
-                           testuser3,".date('Y-m-d',strtotime("+1 month")).",1
59
-                           testuser4,".date('Y-m-d',strtotime("+3 month")).",
60
-                           testuser5,".date('Y-m-d',strtotime("+1 month")).",3";
55
+    protected function setUp() {
56
+        $this->successFileData['contents'] = "testuser1," . date('Y-m-d', strtotime("+1 month")) . ",2
57
+                           testuser2,".date('Y-m-d', strtotime("+2 month")) . ",
58
+                           testuser3,".date('Y-m-d', strtotime("+1 month")) . ",1
59
+                           testuser4,".date('Y-m-d', strtotime("+3 month")) . ",
60
+                           testuser5,".date('Y-m-d', strtotime("+1 month")) . ",3";
61 61
     }
62 62
     
63
-    public function testIsValid(){
63
+    public function testIsValid() {
64 64
         $parser = new MockCSVParser($this->faultyFileData, $this->rowDelimiter, $this->tokenDelimiter);
65 65
         $this->assertFalse($parser->isValid());
66 66
         
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
         $this->assertTrue($parser->isValid());
77 77
     }
78 78
     
79
-    public function testHasMoreRows(){
79
+    public function testHasMoreRows() {
80 80
         $parser = new MockCSVParser($this->faultyFileData, $this->rowDelimiter, $this->tokenDelimiter);
81 81
         $this->assertFalse($parser->hasMoreRows());
82 82
 
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
         $this->assertTrue($parser->hasMoreRows());
88 88
     }
89 89
     
90
-    public function testNextRow(){
90
+    public function testNextRow() {
91 91
         $parser = new MockCSVParser($this->faultyFileData, $this->rowDelimiter, $this->tokenDelimiter);
92 92
         $this->assertCount(0, $parser->nextRow());
93 93
         
Please login to merge, or discard this patch.
tests/unit/web/lib/admin/storage/SessionStorageTest.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -1,14 +1,14 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 use web\lib\admin\storage\SessionStorage;
3 3
 
4
-if ( !isset( $_SESSION ) ) $_SESSION = array();
4
+if (!isset($_SESSION)) $_SESSION = array();
5 5
 
6
-class SessionStorageTest extends PHPUnit_Framework_TestCase{
7
-    protected $backupGlobalsBlacklist = array( '_SESSION' );
6
+class SessionStorageTest extends PHPUnit_Framework_TestCase {
7
+    protected $backupGlobalsBlacklist = array('_SESSION');
8 8
     private $package1 = "testpackage1";
9 9
     private $package2 = "testpackage2";
10 10
     
11
-    public function testGetInstance(){
11
+    public function testGetInstance() {
12 12
         $globalSession = SessionStorage::getInstance();
13 13
         $scopedSession1 = SessionStorage::getInstance($this->package1);
14 14
         $scopedSession2 = SessionStorage::getInstance($this->package2);
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
         $this->assertNotEquals($scopedSession1, $scopedSession2);
22 22
     }
23 23
     
24
-    public function testPut(){
24
+    public function testPut() {
25 25
         $testPutGlobal = "testputglobal";
26 26
         $globalSession = SessionStorage::getInstance();
27 27
         $globalSession->put($testPutGlobal, $testPutGlobal);
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
         $this->assertNotEquals($_SESSION[SessionStorage::INDEX][SessionStorage::SCOPED][$this->package1][$testPutScoped1], $_SESSION[SessionStorage::INDEX][SessionStorage::SCOPED][$this->package2][$testPutScoped2]);
42 42
     }
43 43
     
44
-    public function testGet(){
44
+    public function testGet() {
45 45
         $testGetGlobal = "testgetglobal";
46 46
         $globalSession = SessionStorage::getInstance();
47 47
         $_SESSION[SessionStorage::INDEX][SessionStorage::WIDE][$testGetGlobal] = $testGetGlobal;
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
         $this->assertNotEquals($scopedSession2->get($testGetScoped2), $scopedSession1->get($testGetScoped1));
63 63
     }
64 64
     
65
-    public function testDelete(){
65
+    public function testDelete() {
66 66
         $testGetGlobal = "testgetglobal";
67 67
         $globalSession = SessionStorage::getInstance();
68 68
         $_SESSION[SessionStorage::INDEX][SessionStorage::WIDE][$testGetGlobal] = $testGetGlobal;
Please login to merge, or discard this patch.
tests/unit/web/lib/admin/view/html/AttributeTest.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1,19 +1,19 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 use web\lib\admin\view\html\Attribute;
3 3
 
4
-class AttributeTest extends \PHPUnit_Framework_TestCase{
4
+class AttributeTest extends \PHPUnit_Framework_TestCase {
5 5
     
6
-    private function validateString($attribute){
6
+    private function validateString($attribute) {
7 7
         $string = $attribute->__toString();
8 8
         $this->assertNotEmpty($string);
9 9
     
10 10
         $space = substr($string, 0, 1);
11
-        $this->assertEquals($space,' ');
11
+        $this->assertEquals($space, ' ');
12 12
     
13 13
         $spaceRemoved = substr($string, 1);
14 14
         $pair = explode('=', $spaceRemoved, 2);
15 15
     
16
-        if(count($pair)>1){
16
+        if (count($pair) > 1) {
17 17
             $this->assertTrue(strlen($pair[0]) > 0);
18 18
             $this->assertTrue(strlen($pair[1]) > 2);
19 19
             $this->assertEquals(substr_count($pair[0], '"'), 0);
@@ -32,11 +32,11 @@  discard block
 block discarded – undo
32 32
         $this->assertEmpty($string);
33 33
     }
34 34
     
35
-    public function testValidToString(){
35
+    public function testValidToString() {
36 36
         $this->validateString(new Attribute("type", "button"));
37 37
     }
38 38
     
39
-    public function testFaultyToString(){
39
+    public function testFaultyToString() {
40 40
         $this->validateString(new Attribute("t\"ype", "b=ut\"ton"));
41 41
     }
42 42
     
Please login to merge, or discard this patch.
tests/unit/web/lib/admin/view/html/CompositeTagTest.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -2,13 +2,13 @@  discard block
 block discarded – undo
2 2
 use web\lib\admin\view\html\CompositeTag;
3 3
 use web\lib\admin\view\html\Tag;
4 4
 
5
-class CompositeTagTest extends \PHPUnit_Framework_TestCase{
5
+class CompositeTagTest extends \PHPUnit_Framework_TestCase {
6 6
     
7 7
     private $compositeTag;
8 8
     
9 9
     private $tag;
10 10
     
11
-    protected function setUp(){
11
+    protected function setUp() {
12 12
         $this->compositeTag = new CompositeTag('div');
13 13
         $this->tag = new Tag('p');
14 14
     }
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
         $this->assertTrue(in_array($this->tag, $tags));
24 24
     }
25 25
     
26
-    public function testToString(){
26
+    public function testToString() {
27 27
         $string = $this->compositeTag->__toString();
28 28
         $this->assertEquals('<div>', substr(trim($string), 0, 5));
29 29
         $this->assertEquals('</div>', substr(trim($string), -6));
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
         $this->assertEquals('<div>', substr(trim($string), 0, 5));
34 34
         $this->assertEquals('</div>', substr(trim($string), -6));
35 35
         
36
-        $string = str_replace(array('<div>','</div>'), '', $string);
36
+        $string = str_replace(array('<div>', '</div>'), '', $string);
37 37
         $this->assertEquals('<p>', substr(trim($string), 0, 3));
38 38
         $this->assertEquals('</p>', substr(trim($string), -4));
39 39
     }
Please login to merge, or discard this patch.
tests/unit/web/lib/admin/view/html/ButtonTest.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1,11 +1,11 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 use web\lib\admin\view\html\Button;
3 3
 
4
-class ButtonTest extends \PHPUnit_Framework_TestCase{
4
+class ButtonTest extends \PHPUnit_Framework_TestCase {
5 5
     
6 6
     private $title;
7 7
     
8
-    protected function setUp(){
8
+    protected function setUp() {
9 9
         $this->title = 'Some title';
10 10
     }
11 11
     
@@ -26,10 +26,10 @@  discard block
 block discarded – undo
26 26
         $button = new Button($this->title, $type, $name, $value, $class);
27 27
         $string = $button->__toString();
28 28
     
29
-        $this->assertNotEquals(strpos($string, 'type="'.$type.'"'), false);
30
-        $this->assertNotEquals(strpos($string, 'name="'.$name.'"'), false);
31
-        $this->assertNotEquals(strpos($string, 'value="'.$value.'"'), false);
32
-        $this->assertNotEquals(strpos($string, 'class="'.$class.'"'), false);
29
+        $this->assertNotEquals(strpos($string, 'type="' . $type . '"'), false);
30
+        $this->assertNotEquals(strpos($string, 'name="' . $name . '"'), false);
31
+        $this->assertNotEquals(strpos($string, 'value="' . $value . '"'), false);
32
+        $this->assertNotEquals(strpos($string, 'class="' . $class . '"'), false);
33 33
         $this->assertNotEquals(strpos($string, $this->title), false);
34 34
     }
35 35
     
Please login to merge, or discard this patch.
web/lib/admin/domain/Attribute.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -63,7 +63,7 @@
 block discarded – undo
63 63
      * 
64 64
      * @return string
65 65
      */
66
-    public function getType(){
66
+    public function getType() {
67 67
         return $this->type;
68 68
     }
69 69
     
Please login to merge, or discard this patch.
web/lib/admin/utils/CSVParser.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
     public function __construct($fileData, $rowDelimiter, $tokenDelimiter) {
55 55
         $this->rowDelimiter = $rowDelimiter;
56 56
         $this->tokenDelimiter = $tokenDelimiter;
57
-        if($this->validate($fileData)){
57
+        if ($this->validate($fileData)) {
58 58
             $handle = fopen($fileData['tmp_name'], "r");
59 59
             $contents = fread($handle, filesize($fileData['tmp_name']));
60 60
             fclose($handle);
@@ -68,13 +68,13 @@  discard block
 block discarded – undo
68 68
      * @param array $fileData Data array from $_FILES['yourfile']
69 69
      * @return boolean Is file data valid
70 70
      */
71
-    protected function validate($fileData){
72
-        if(empty($fileData) || empty($fileData['name']) || empty($fileData['tmp_name']) || $fileData['error']>0){
71
+    protected function validate($fileData) {
72
+        if (empty($fileData) || empty($fileData['name']) || empty($fileData['tmp_name']) || $fileData['error'] > 0) {
73 73
             $this->state = false;
74 74
         }
75 75
         
76 76
         $extension = pathinfo($fileData['name'], PATHINFO_EXTENSION);
77
-        if($extension!='csv' && $extension!='CSV'){
77
+        if ($extension != 'csv' && $extension != 'CSV') {
78 78
             $this->state = false;
79 79
         }
80 80
         return $this->state;
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
      * 
95 95
      * @return boolean
96 96
      */
97
-    public function hasMoreRows(){
97
+    public function hasMoreRows() {
98 98
         return $this->state && isset($this->rows[$this->index]);
99 99
     }
100 100
     
@@ -103,12 +103,12 @@  discard block
 block discarded – undo
103 103
      * 
104 104
      * @return array
105 105
      */
106
-    public function nextRow(){
107
-        if($this->state && $this->hasMoreRows()){
106
+    public function nextRow() {
107
+        if ($this->state && $this->hasMoreRows()) {
108 108
             $row = str_getcsv($this->rows[$this->index], $this->tokenDelimiter);
109 109
             $this->index++;
110 110
             return $row;
111
-        }else{
111
+        } else {
112 112
             return array();
113 113
         }
114 114
     }
Please login to merge, or discard this patch.
web/lib/admin/storage/SessionStorage.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @author Zilvinas Vaira
7 7
  *
8 8
  */
9
-class SessionStorage implements StorageInterface{
9
+class SessionStorage implements StorageInterface {
10 10
     
11 11
     const INDEX = 'silverbullet-storage';
12 12
     const WIDE = 'wide';
@@ -41,21 +41,21 @@  discard block
 block discarded – undo
41 41
      * 
42 42
      * @param string $package
43 43
      */
44
-    private function __construct($package = ""){
45
-        if(!isset($_SESSION)){
44
+    private function __construct($package = "") {
45
+        if (!isset($_SESSION)) {
46 46
             session_start();
47 47
         }
48
-        if(!isset($_SESSION['silverbullet-storage'])){
48
+        if (!isset($_SESSION['silverbullet-storage'])) {
49 49
             $_SESSION[self::INDEX] = array();
50 50
             $_SESSION[self::INDEX][self::WIDE] = array();
51 51
             $_SESSION[self::INDEX][self::SCOPED] = array();
52 52
         }
53
-        if (!empty($package)){
54
-            if(!isset($_SESSION[self::INDEX][self::SCOPED][$package])){
53
+        if (!empty($package)) {
54
+            if (!isset($_SESSION[self::INDEX][self::SCOPED][$package])) {
55 55
                 $_SESSION[self::INDEX][self::SCOPED][$package] = array();
56 56
             }
57 57
             $this->session = &$_SESSION[self::INDEX][self::SCOPED][$package];
58
-        }else{
58
+        } else {
59 59
             $this->session = &$_SESSION[self::INDEX][self::WIDE];
60 60
         }
61 61
         $this->package = $package;
@@ -66,22 +66,22 @@  discard block
 block discarded – undo
66 66
      * @param string $package
67 67
      * @return SessionStorage
68 68
      */
69
-    public static function getInstance($package = ""){
69
+    public static function getInstance($package = "") {
70 70
         
71
-        if(empty($package)){
72
-            if(empty(self::$instance)){
71
+        if (empty($package)) {
72
+            if (empty(self::$instance)) {
73 73
                 self::$instance = new self($package);
74 74
             }
75 75
             return self::$instance;
76
-        }else{
77
-            if(!isset(self::$pool[$package])){
76
+        } else {
77
+            if (!isset(self::$pool[$package])) {
78 78
                 self::$pool[$package] = new self($package);
79 79
             } 
80 80
             return self::$pool[$package];
81 81
         }
82 82
     }
83 83
     
84
-    public static function close(){
84
+    public static function close() {
85 85
         session_unset();
86 86
         session_destroy();
87 87
     }
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
      * {@inheritDoc}
92 92
      * @see \web\lib\admin\domain\storage\StorageInterface::put()
93 93
      */
94
-    public function put($identifier, $object){
94
+    public function put($identifier, $object) {
95 95
         $this->session[$identifier] = $object;
96 96
     }
97 97
     
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
      * {@inheritDoc}
101 101
      * @see \web\lib\admin\domain\storage\StorageInterface::add()
102 102
      */
103
-    public function add($identifier, $object){
103
+    public function add($identifier, $object) {
104 104
         $this->session[$identifier][] = $object;
105 105
     }
106 106
     
@@ -109,10 +109,10 @@  discard block
 block discarded – undo
109 109
      * {@inheritDoc}
110 110
      * @see \web\lib\admin\domain\storage\StorageInterface::get()
111 111
      */
112
-    public function get($identifier){
113
-        if(isset($this->session[$identifier])){
112
+    public function get($identifier) {
113
+        if (isset($this->session[$identifier])) {
114 114
             return $this->session[$identifier];
115
-        }else{
115
+        } else {
116 116
             return array();
117 117
         }
118 118
     }
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
     /**
121 121
      * 
122 122
      */
123
-    public function getAll(){
123
+    public function getAll() {
124 124
         return $this->session;
125 125
     }
126 126
     
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
      * {@inheritDoc}
130 130
      * @see \web\lib\admin\domain\storage\StorageInterface::delete()
131 131
      */
132
-    public function delete($identifier){
132
+    public function delete($identifier) {
133 133
         unset($this->session[$identifier]);
134 134
     }
135 135
     
Please login to merge, or discard this patch.
web/lib/admin/view/html/JSButton.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @author Zilvinas Vaira
7 7
  *
8 8
  */
9
-class JSButton extends Button{
9
+class JSButton extends Button {
10 10
     
11 11
     const REVOKE_CREDENTIAL_ACTION = 'revokeCredential';
12 12
     const DELETE_USER_ACTION = 'deleteUser';
@@ -16,12 +16,12 @@  discard block
 block discarded – undo
16 16
     
17 17
     private $action = "";
18 18
     
19
-    public function __construct($title, $action, $name = '', $value = '', $type = 'button', $class = ''){
19
+    public function __construct($title, $action, $name = '', $value = '', $type = 'button', $class = '') {
20 20
         parent::__construct($title, $type, $name, $value, $class);
21 21
         $this->action = $action;
22 22
     }
23 23
     
24 24
     protected function composeNameValueString() {
25
-        return ' onclick="'.$this->action.'(\''.$this->name.'\',\''.$this->value.'\')"';
25
+        return ' onclick="' . $this->action . '(\'' . $this->name . '\',\'' . $this->value . '\')"';
26 26
     }
27 27
 }
Please login to merge, or discard this patch.