Skip to content

Commit ebeff09

Browse files
committed
improve tests, reformat file.
1 parent 29ba91a commit ebeff09

3 files changed

Lines changed: 60 additions & 42 deletions

File tree

.phptidy-config.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?php
2+
3+
$indent_char = " ";
4+
?>

report-samm.php

Lines changed: 39 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -22,59 +22,56 @@
2222

2323

2424
foreach (getActions($dimensions) as list($dimension, $subdimensions, $element)) {
25-
if ($dimension != $old_dimension) {
26-
echo "<h1>Dimension $dimension</h1>";
27-
$old_dimension = $dimension;
28-
}
25+
if ($dimension != $old_dimension) {
26+
echo "<h1>Dimension $dimension</h1>";
27+
$old_dimension = $dimension;
28+
}
2929

30-
$mappingExists[$subdimension] = array();
31-
$noMappingExists[$subdimension] = array();
32-
echo "<h2>Sub-Dimension $subdimension</h2>";
30+
$mappingExists[$subdimension] = array();
31+
$noMappingExists[$subdimension] = array();
32+
echo "<h2>Sub-Dimension $subdimension</h2>";
3333

34-
echo "<h3 style='color:green;'>With SAMM2 Mapping</h3>";
35-
for ($i = 1; $i <= 4; $i++) {
36-
$tableContent .= "<td><ul>";
37-
foreach ($element as $activityName => $content) {
38-
if (array_key_exists("samm2", $content) && !preg_match("/TODO/i", $content["samm2"])) {
39-
$content2 = getContentForLevelFromSubdimensions($i, $content, $activityName);
34+
echo "<h3 style='color:green;'>With SAMM2 Mapping</h3>";
35+
for ($i = 1; $i <= 4; $i++) {
36+
$tableContent .= "<td><ul>";
37+
foreach ($element as $activityName => $content) {
38+
if (array_key_exists("samm2", $content) && !preg_match("/TODO/i", $content["samm2"])) {
39+
$content2 = getContentForLevelFromSubdimensions($i, $content, $activityName);
4040

41-
if ($content2 != "") {
42-
printDetail($dimension, $subdimension, $activityName, $dimensions, true);
43-
$mappingExists[$subdimension][$content["samm2"]][$activityName] = $content;
44-
}
41+
if ($content2 != "") {
42+
printDetail($dimension, $subdimension, $activityName, $dimensions, true);
43+
$mappingExists[$subdimension][$content["samm2"]][$activityName] = $content;
4544
}
4645
}
4746
}
47+
}
4848

49-
echo "<h3 style='color:red;'>Without SAMM2 Mapping</h3>";
50-
for ($i = 1; $i <= 4; $i++) {
51-
$tableContent .= "<td><ul>";
52-
foreach ($element as $activityName => $content) {
53-
if (!array_key_exists("samm2", $content) || preg_match("/TODO/i", $content["samm2"])) {
54-
$content2 = getContentForLevelFromSubdimensions($i, $content, $activityName);
49+
echo "<h3 style='color:red;'>Without SAMM2 Mapping</h3>";
50+
for ($i = 1; $i <= 4; $i++) {
51+
$tableContent .= "<td><ul>";
52+
foreach ($element as $activityName => $content) {
53+
if (!array_key_exists("samm2", $content) || preg_match("/TODO/i", $content["samm2"])) {
54+
$content2 = getContentForLevelFromSubdimensions($i, $content, $activityName);
5555

56-
if ($content2 != "") {
57-
printDetail($dimension, $subdimension, $activityName, $dimensions, true);
58-
$content["name"] = $activityName;
59-
$noMappingExists[$subdimension][$content["samm2"]][$activityName] = $content;
60-
}
56+
if ($content2 != "") {
57+
printDetail($dimension, $subdimension, $activityName, $dimensions, true);
58+
$content["name"] = $activityName;
59+
$noMappingExists[$subdimension][$content["samm2"]][$activityName] = $content;
6160
}
6261
}
6362
}
6463
}
65-
foreach ($mappingExists as $dimension => $category) {
66-
//var_dump($mappingExists);
67-
echo "<h1>".$dimension ."</h1>";
68-
foreach ($category as $category => $content) {
69-
//var_dump($content);exit;
70-
echo $category . " ".count($content) . " ";
71-
foreach ($content as $activityName => $content2) {
72-
echo "$activityName" . " /"; }
73-
echo "<br>";
74-
}
64+
}
65+
foreach ($mappingExists as $dimension => $category) {
66+
//var_dump($mappingExists);
67+
echo "<h1>".$dimension ."</h1>";
68+
foreach ($category as $category => $content) {
69+
//var_dump($content);exit;
70+
echo $category . " ".count($content) . " ";
71+
foreach ($content as $activityName => $content2) {
72+
echo "$activityName" . " /"; }
73+
echo "<br>";
7574
}
75+
}
7676

77-
//var_dump($noMappingExists);
78-
79-
80-
77+
//var_dump($noMappingExists);

tests.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/sh
2+
3+
test -f phptidy.php || wget https://raw.githubusercontent.com/cmrcx/phptidy/master/phptidy.php
4+
5+
echo "
6+
Reformat code according to .phptidy-config.php
7+
in order do minimize patch differences.
8+
"
9+
php ./phptidy.php replace *.php
10+
11+
echo "
12+
Checking php syntax.
13+
"
14+
find > /tmp/php-check.out 2>&1 . -type f -name \*.php -exec php -l {} \;
15+
cat /tmp/php-check.out
16+
grep 'Errors parsing' /tmp/php-check.out && exit 1 || exit 0
17+

0 commit comments

Comments
 (0)