Commit 9ea10683 authored by Carsten  Rose's avatar Carsten Rose
Browse files

Fixed missing $formElement[FE_DECIMAL_FORMAT]. Add 'missing primary record'...

Fixed missing $formElement[FE_DECIMAL_FORMAT]. Add 'missing primary record' check. Fixed missing fe['id'].
parent fa73ebcf
Pipeline #1186 passed with stage
in 1 minute and 44 seconds
......@@ -75,8 +75,9 @@ class BuildFormPlainTest extends AbstractDatabaseTest {
$this->templateFormNFormElement($form, $formElement);
$build = new \qfq\BuildFormPlain($form, array(), [$formElement], $this->dbArray);
$build = new BuildFormPlain($form, array(), [$formElement], $this->dbArray);
$formElement[FE_CHECK_TYPE] = SANITIZE_ALLOW_ALL;
$formElement[FE_DECIMAL_FORMAT]='';
$label['123-l'][API_ELEMENT_CONTENT] = '<label for="name:1" class="control-label" >Name</label>';
$label['123'][API_ELEMENT_ATTRIBUTE] = ['value' => ''];
......@@ -343,6 +344,10 @@ class BuildFormPlainTest extends AbstractDatabaseTest {
// id: 1, firstName: John, name: Doe
$formElement['sql1'] = $this->dbArray[DB_INDEX_DEFAULT]->sql('SELECT id, name, firstName FROM Person ORDER BY id LIMIT 2');
$result = $build->buildSubrecord($formElement, 'name:1', '', $json);
$this->assertEquals('Please save this record first.', $result);
$this->store->setStore(['id' => 1], STORE_RECORD, true);
$result = $build->buildSubrecord($formElement, 'name:1', '', $json);
$this->assertEquals('<table class="' . SUBRECORD_TABLE_CLASS_DEFAULT . '" ><thead><tr><th>id</th><th>name</th><th>firstName</th></tr></thead><tbody><tr class="record" ><td>1</td><td>Doe</td><td>John</td></tr><tr class="record" ><td>2</td><td>Smith</td><td>Jane</td></tr></tbody></table>', $result);
......@@ -529,31 +534,35 @@ class BuildFormPlainTest extends AbstractDatabaseTest {
protected function setUp() {
$_GET['form'] = 'phpunit_person';
parent::setUp();
try {
parent::setUp();
// Use always the latest (production) FormEditor: played during QuickFormQuery()
$this->dbArray[DB_INDEX_DEFAULT]->sql("DROP TABLE IF EXISTS `Form`");
$this->dbArray[DB_INDEX_DEFAULT]->sql("DROP TABLE IF EXISTS `FormElement`");
$this->executeSQLFile(__DIR__ . '/../../../Source/sql/formEditor.sql', true);
// Use always the latest (production) FormEditor: played during QuickFormQuery()
$this->dbArray[DB_INDEX_DEFAULT]->sql("DROP TABLE IF EXISTS `Form`");
$this->dbArray[DB_INDEX_DEFAULT]->sql("DROP TABLE IF EXISTS `FormElement`");
$this->executeSQLFile(__DIR__ . '/../../../Source/sql/formEditor.sql', true);
$this->store->unsetStore(STORE_ADDITIONAL_FORM_ELEMENTS);
$this->executeSQLFile(__DIR__ . '/database/fixtures/Generic.sql', true);
$this->executeSQLFile(__DIR__ . '/database/fixtures/TestForm.sql', true);
$this->store->unsetStore(STORE_ADDITIONAL_FORM_ELEMENTS);
$this->executeSQLFile(__DIR__ . '/database/fixtures/Generic.sql', true);
$this->executeSQLFile(__DIR__ . '/database/fixtures/TestForm.sql', true);
// Defaults
$this->store->setVar('name', 'varchar(255)', STORE_TABLE_COLUMN_TYPES, true);
$this->store->setVar('deleted', "enum('yes','no')", STORE_TABLE_COLUMN_TYPES, true);
// Defaults
$this->store->setVar('name', 'varchar(255)', STORE_TABLE_COLUMN_TYPES, true);
$this->store->setVar('deleted', "enum('yes','no')", STORE_TABLE_COLUMN_TYPES, true);
// $this->store->setVar(SYSTEM_DB_INDEX_DATA, DB_INDEX_DEFAULT, true);
// $this->store->setVar(SYSTEM_DB_INDEX_QFQ, DB_INDEX_DEFAULT, true);
$GLOBALS["TSFE"] = new FakeTSFEBuildPlain();
$GLOBALS["TSFE"] = new FakeTSFEBuildPlain();
$form = new QuickFormQuery(['bodytext' => "form=form\nr=3", 'uid' => 1234], true);
$form = new QuickFormQuery(['bodytext' => "form=form\nr=3", 'uid' => 1234], true);
// After instantiating QuickFormQuery, the latest updates will be played. The SIP is by default activated which breaks current tests.
$this->dbArray[DB_INDEX_DEFAULT]->sql("UPDATE Form SET permitNew='always', permitEdit='always' WHERE name='form' ");
$form->process();
// After instantiating QuickFormQuery, the latest updates will be played. The SIP is by default activated which breaks current tests.
$this->dbArray[DB_INDEX_DEFAULT]->sql("UPDATE Form SET permitNew='always', permitEdit='always' WHERE name='form' ");
$form->process();
} catch (\Exception $e) {
echo 'unhandled exception';
}
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment