Skip to content

Commit 3078fbc

Browse files
committed
phpunit test config added; closes #140
1 parent 0413f77 commit 3078fbc

File tree

12 files changed

+2722
-2
lines changed

12 files changed

+2722
-2
lines changed

.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,13 @@ modules/*
1111
!modules/index.html
1212
global/api/*
1313
!global/api/index.html
14+
15+
# vendor folder dev dependencies. Only whitelist specific dependencies
16+
vendor/*
17+
!vendor/bin/validate-json
18+
!vendor/composer
19+
!vendor/justinrainbow
20+
!vendor/ramsey
21+
!vendor/smarty
22+
!vendor/autoload.php
23+

composer.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,8 @@
1919
"smarty/smarty": "3.1.31",
2020
"ramsey/array_column": "^1.1",
2121
"justinrainbow/json-schema": "^5.2"
22+
},
23+
"require-dev": {
24+
"phpunit/phpunit": "^6.5"
2225
}
2326
}

global/code/Modules.class.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -770,8 +770,9 @@ public static function isValidModule($module_folder)
770770

771771
public static function getModuleNamespace($module_folder)
772772
{
773-
$upper_case = ucwords($module_folder, "_");
774-
return str_replace("_", "", $upper_case);
773+
$no_underscores = str_replace("_", " ", $module_folder);
774+
$upper_case = ucwords($no_underscores);
775+
return str_replace(" ", "", $upper_case);
775776
}
776777

777778
/**

phpunit.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit colors="true" bootstrap="tests/autoload.php">
3+
<testsuites>
4+
<testsuite name="PHP Unit Tests">
5+
<directory>./tests/phpunit</directory>
6+
</testsuite>
7+
</testsuites>
8+
<php>
9+
<ini name="display_errors" value="true" />
10+
</php>
11+
</phpunit>

tests/autoload.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<?php
2+
3+
require_once(__DIR__ . "/../global/library.php");

tests/phpunit/Modules.classTest.php

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
3+
namespace FormTools\Tests;
4+
5+
use PHPUnit\Framework\TestCase;
6+
use FormTools\Modules;
7+
8+
9+
class ModulesTest extends TestCase
10+
{
11+
12+
// Modules::getModuleNamespace()
13+
14+
public function testGetModuleNamespace_SameValue()
15+
{
16+
$module_folder = "Modulename";
17+
$namespace = Modules::getModuleNamespace($module_folder);
18+
$this->assertEquals($namespace, $module_folder);
19+
}
20+
21+
public function testGetModuleNamespace_Uppercases()
22+
{
23+
$module_folder = "modulename";
24+
$namespace = Modules::getModuleNamespace($module_folder);
25+
$this->assertEquals($namespace, "Modulename");
26+
}
27+
28+
public function testGetModuleNamespace_ConvertsUnderscores()
29+
{
30+
$module_folder = "module_name";
31+
$namespace = Modules::getModuleNamespace($module_folder);
32+
$this->assertEquals($namespace, "ModuleName");
33+
}
34+
35+
public function testGetModuleNamespace_MultipleWords()
36+
{
37+
$module_folder = "this_is_my_module_folder_name";
38+
$namespace = Modules::getModuleNamespace($module_folder);
39+
$this->assertEquals($namespace, "ThisIsMyModuleFolderName");
40+
}
41+
42+
}

vendor/composer/autoload_classmap.php

Lines changed: 542 additions & 0 deletions
Large diffs are not rendered by default.

vendor/composer/autoload_files.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
$baseDir = dirname($vendorDir);
77

88
return array(
9+
'6124b4c8570aa390c21fafd04a26c69f' => $vendorDir . '/myclabs/deep-copy/src/DeepCopy/deep_copy.php',
910
'f084d01b0a599f67676cffef638aa95b' => $vendorDir . '/smarty/smarty/libs/bootstrap.php',
1011
'8cd2fca4db21bffce1ad0612f7caeec4' => $vendorDir . '/ramsey/array_column/src/array_column.php',
1112
);

vendor/composer/autoload_namespaces.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@
66
$baseDir = dirname($vendorDir);
77

88
return array(
9+
'Prophecy\\' => array($vendorDir . '/phpspec/prophecy/src'),
910
);

vendor/composer/autoload_psr4.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,9 @@
66
$baseDir = dirname($vendorDir);
77

88
return array(
9+
'phpDocumentor\\Reflection\\' => array($vendorDir . '/phpdocumentor/reflection-common/src', $vendorDir . '/phpdocumentor/type-resolver/src', $vendorDir . '/phpdocumentor/reflection-docblock/src'),
10+
'Webmozart\\Assert\\' => array($vendorDir . '/webmozart/assert/src'),
911
'JsonSchema\\' => array($vendorDir . '/justinrainbow/json-schema/src/JsonSchema'),
12+
'Doctrine\\Instantiator\\' => array($vendorDir . '/doctrine/instantiator/src/Doctrine/Instantiator'),
13+
'DeepCopy\\' => array($vendorDir . '/myclabs/deep-copy/src/DeepCopy'),
1014
);

0 commit comments

Comments
 (0)