aboutsummaryrefslogtreecommitdiffhomepage
path: root/main/app/sprinkles/FormGenerator/tests/Unit
diff options
context:
space:
mode:
Diffstat (limited to 'main/app/sprinkles/FormGenerator/tests/Unit')
-rw-r--r--main/app/sprinkles/FormGenerator/tests/Unit/FormGeneratorTest.php28
-rw-r--r--main/app/sprinkles/FormGenerator/tests/Unit/data/bad.json18
-rw-r--r--main/app/sprinkles/FormGenerator/tests/Unit/data/good.json128
3 files changed, 84 insertions, 90 deletions
diff --git a/main/app/sprinkles/FormGenerator/tests/Unit/FormGeneratorTest.php b/main/app/sprinkles/FormGenerator/tests/Unit/FormGeneratorTest.php
index 066e98d..d75f4f7 100644
--- a/main/app/sprinkles/FormGenerator/tests/Unit/FormGeneratorTest.php
+++ b/main/app/sprinkles/FormGenerator/tests/Unit/FormGeneratorTest.php
@@ -6,6 +6,7 @@
* @copyright Copyright (c) 2017 Louis Charette
* @license https://github.com/lcharette/UF_FormGenerator/blob/master/LICENSE (MIT License)
*/
+
namespace UserFrosting\Tests\Unit;
use UserFrosting\Tests\TestCase;
@@ -29,8 +30,7 @@ class FormGeneratorTest extends TestCase
{
var $basePath;
- public function setUp()
- {
+ public function setUp() {
parent::setUp();
$this->basePath = __DIR__ . '/data';
}
@@ -38,8 +38,7 @@ class FormGeneratorTest extends TestCase
/**
* Test the base `Test` element class works on it's own
*/
- public function testTextFormElement()
- {
+ public function testTextFormElement() {
// Get Schema
$loader = new YamlFileLoader($this->basePath . '/good.json');
$schema = new RequestSchemaRepository($loader->load());
@@ -76,8 +75,7 @@ class FormGeneratorTest extends TestCase
* value is passed to the constructor. Should return the same as the
* previous test, but with the `value` setup instead of empty
*/
- public function testTextFormElementWithData()
- {
+ public function testTextFormElementWithData() {
// Get Schema
$loader = new YamlFileLoader($this->basePath . '/good.json');
$schema = new RequestSchemaRepository($loader->load());
@@ -113,8 +111,7 @@ class FormGeneratorTest extends TestCase
* This test is the same as the one before, but we test the `owener` field with some data
* This make sure the `default` schema field will work correctly when empty data is passed
*/
- public function testTextFormElementWithEmptyData()
- {
+ public function testTextFormElementWithEmptyData() {
// Get Schema
$loader = new YamlFileLoader($this->basePath . '/good.json');
$schema = new RequestSchemaRepository($loader->load());
@@ -151,8 +148,7 @@ class FormGeneratorTest extends TestCase
* Test the Form Class.
* Run the test with no current values (empty form)
*/
- public function testForm()
- {
+ public function testForm() {
// Get Schema
$loader = new YamlFileLoader($this->basePath . '/good.json');
$schema = new RequestSchemaRepository($loader->load());
@@ -233,7 +229,7 @@ class FormGeneratorTest extends TestCase
'name' => 'active',
'id' => 'field_active',
'type' => 'checkbox',
- 'binary' => true
+ 'binary' => TRUE
],
'hidden' => [
'value' => 'Something',
@@ -257,8 +253,7 @@ class FormGeneratorTest extends TestCase
/**
* Test the Form Clas with values to make sure filled form works correctly
*/
- public function testFormWithData()
- {
+ public function testFormWithData() {
// Get Schema
$loader = new YamlFileLoader($this->basePath . '/good.json');
$schema = new RequestSchemaRepository($loader->load());
@@ -271,7 +266,7 @@ class FormGeneratorTest extends TestCase
"status" => 1,
"hiddenString" => "The Bar secret code is...",
"completion" => 12,
- "active" => true
+ "active" => TRUE
];
// Generate the form
@@ -351,7 +346,7 @@ class FormGeneratorTest extends TestCase
'id' => 'field_active',
'type' => 'checkbox',
'checked' => 'checked', //Value here !
- 'binary' => true
+ 'binary' => TRUE
],
'hidden' => [
'value' => 'Something',
@@ -376,8 +371,7 @@ class FormGeneratorTest extends TestCase
* Test a non existant input type. It's supposed to not find the class and
* default back to the `Text` element class.
*/
- public function testUndefinedFormElement()
- {
+ public function testUndefinedFormElement() {
// Get Schema
$loader = new YamlFileLoader($this->basePath . '/bad.json');
$schema = new RequestSchemaRepository($loader->load());
diff --git a/main/app/sprinkles/FormGenerator/tests/Unit/data/bad.json b/main/app/sprinkles/FormGenerator/tests/Unit/data/bad.json
index 683add2..50f1c00 100644
--- a/main/app/sprinkles/FormGenerator/tests/Unit/data/bad.json
+++ b/main/app/sprinkles/FormGenerator/tests/Unit/data/bad.json
@@ -1,12 +1,12 @@
{
- "myField" : {
- "form" : {
- "type" : "foo"
- }
- },
- "myOtherField" : {
- "form" : {
- "value" : "Bar"
- }
+ "myField": {
+ "form": {
+ "type": "foo"
}
+ },
+ "myOtherField": {
+ "form": {
+ "value": "Bar"
+ }
+ }
}
diff --git a/main/app/sprinkles/FormGenerator/tests/Unit/data/good.json b/main/app/sprinkles/FormGenerator/tests/Unit/data/good.json
index 61d5233..1592515 100644
--- a/main/app/sprinkles/FormGenerator/tests/Unit/data/good.json
+++ b/main/app/sprinkles/FormGenerator/tests/Unit/data/good.json
@@ -1,67 +1,67 @@
{
- "number" : {
- "form" : {
- "type" : "number",
- "label" : "Project Number",
- "icon" : "fa-edit",
- "placeholder" : "Project Number"
- }
- },
- "name" : {
- "form" : {
- "type" : "text",
- "label" : "Project Name",
- "icon" : "fa-flag",
- "placeholder" : "Project Name"
- }
- },
- "owner" : {
- "form" : {
- "type" : "text",
- "label" : "Project Owner",
- "icon" : "fa-user",
- "id" : "owner",
- "placeholder" : "Project Owner",
- "default" : "Foo"
- }
- },
- "description" : {
- "form" : {
- "type" : "textarea",
- "label" : "Project Description",
- "icon" : "fa-pencil",
- "placeholder" : "Project Description",
- "rows" : 5
- }
- },
- "status" : {
- "form" : {
- "type" : "select",
- "label" : "Project Status",
- "options" : {
- "0" : "Closed",
- "1" : "Open"
- }
- }
- },
- "active" : {
- "form" : {
- "type" : "checkbox",
- "label" : "Active"
- }
- },
- "hidden" : {
- "form" : {
- "type" : "hidden",
- "value" : "Something"
- }
- },
- "alert" : {
- "form" : {
- "type" : "alert",
- "class" : "alert-success",
- "icon" : "fa-check",
- "value" : "You're awesome!"
- }
+ "number": {
+ "form": {
+ "type": "number",
+ "label": "Project Number",
+ "icon": "fa-edit",
+ "placeholder": "Project Number"
}
+ },
+ "name": {
+ "form": {
+ "type": "text",
+ "label": "Project Name",
+ "icon": "fa-flag",
+ "placeholder": "Project Name"
+ }
+ },
+ "owner": {
+ "form": {
+ "type": "text",
+ "label": "Project Owner",
+ "icon": "fa-user",
+ "id": "owner",
+ "placeholder": "Project Owner",
+ "default": "Foo"
+ }
+ },
+ "description": {
+ "form": {
+ "type": "textarea",
+ "label": "Project Description",
+ "icon": "fa-pencil",
+ "placeholder": "Project Description",
+ "rows": 5
+ }
+ },
+ "status": {
+ "form": {
+ "type": "select",
+ "label": "Project Status",
+ "options": {
+ "0": "Closed",
+ "1": "Open"
+ }
+ }
+ },
+ "active": {
+ "form": {
+ "type": "checkbox",
+ "label": "Active"
+ }
+ },
+ "hidden": {
+ "form": {
+ "type": "hidden",
+ "value": "Something"
+ }
+ },
+ "alert": {
+ "form": {
+ "type": "alert",
+ "class": "alert-success",
+ "icon": "fa-check",
+ "value": "You're awesome!"
+ }
+ }
}