Page Menu
Home
In-Portal Phabricator
Search
Configure Global Search
Log In
Files
F1092898
unknown_option_tests_v2.patch
erik (Erik Snarski [Intechnic])
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Author
erik
Created
Mon, Aug 11, 6:19 AM
Size
72 KB
Mime Type
text/x-diff
Engine
blob
Format
Raw Data
Handle
707852
Attached To
D529: INP-1917 - Validate "kOptionsFormatter::Parse" method values
unknown_option_tests_v2.patch
View Options
Index: core/install/english.lang
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/core/install/english.lang b/core/install/english.lang
--- a/core/install/english.lang (revision 16830)
+++ b/core/install/english.lang (date 1754906940206)
@@ -308,6 +308,7 @@
<PHRASE Label="la_err_Primary_Lang_Required" Module="Core" Type="1">UHJpbWFyeSBMYW5nLiB2YWx1ZSBSZXF1aXJlZA==</PHRASE>
<PHRASE Label="la_err_required" Module="Core" Type="1">RmllbGQgaXMgcmVxdWlyZWQ=</PHRASE>
<PHRASE Label="la_err_unique" Module="Core" Type="1">RmllbGQgdmFsdWUgbXVzdCBiZSB1bmlxdWU=</PHRASE>
+ <PHRASE Label="la_err_unknown_option" Module="Core" Type="1">T3B0aW9uICJ7b3B0aW9ufSIgaXMgdW5rbm93bg==</PHRASE>
<PHRASE Label="la_err_value_out_of_range" Module="Core" Type="1">RmllbGQgdmFsdWUgaXMgb3V0IG9mIHJhbmdlLCBwb3NzaWJsZSB2YWx1ZXMgZnJvbSB7bWluX3ZhbHVlfSB0byB7bWF4X3ZhbHVlfQ==</PHRASE>
<PHRASE Label="la_exportfoldernotwritable" Module="Core" Type="1">RXhwb3J0IGZvbGRlciBpcyBub3Qgd3JpdGFibGU=</PHRASE>
<PHRASE Label="la_fck_ErrorCreatingFolder" Module="Core" Type="1">RXJyb3IgY3JlYXRpbmcgZm9sZGVyLiBFcnJvciBudW1iZXI6</PHRASE>
Index: core/kernel/db/cat_event_handler.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/core/kernel/db/cat_event_handler.php b/core/kernel/db/cat_event_handler.php
--- a/core/kernel/db/cat_event_handler.php (revision 16830)
+++ b/core/kernel/db/cat_event_handler.php (date 1754906940265)
@@ -2909,9 +2909,11 @@
/** @var CategoryHelper $category_helper */
$category_helper = $this->Application->recallObject('CategoryHelper');
+ /** @var array $virtual_fields */
$virtual_fields = $this->Application->getUnitOption($event->Prefix, 'VirtualFields');
- $virtual_fields['CategoryId']['default'] = (int)$this->Application->GetVar('m_cat_id');
+ $category_id = $this->Application->GetVar('m_cat_id');
+ $virtual_fields['CategoryId']['default'] = $category_id > 0 ? (int)$category_id : null;
$virtual_fields['CategoryId']['options'] = $category_helper->getStructureTreeAsOptions();
$this->Application->setUnitOption($event->Prefix, 'VirtualFields', $virtual_fields);
Index: core/kernel/utility/formatters/options_formatter.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/core/kernel/utility/formatters/options_formatter.php b/core/kernel/utility/formatters/options_formatter.php
--- a/core/kernel/utility/formatters/options_formatter.php (revision 16830)
+++ b/core/kernel/utility/formatters/options_formatter.php (date 1754906940316)
@@ -14,6 +14,10 @@
defined('FULL_PATH') or die('restricted access!');
+
+/**
+ * TODO: Rename filename into "kOptionsFormatter.php" to match class name inside it.
+ */
class kOptionsFormatter extends kFormatter {
/**
@@ -98,35 +102,77 @@
}
/**
- * Performs basic type validation on form field value
- *
- * @param mixed $value
- * @param string $field_name
- * @param kDBItem $object
- * @return mixed
- * @access public
+ * @inheritDoc
*/
public function Parse($value, $field_name, &$object)
{
if ( $value == '' ) {
- return NULL;
+ return null;
}
- $found = $option_key = false;
+ $patched_value = $value;
$options = $object->GetFieldOptions($field_name);
$use_phrases = getArrayValue($options, 'use_phrases');
- foreach ($options['options'] as $option_key => $option_value) {
+ // Support for "value 1, value 2, ..." notation.
+ if ( strpos($patched_value, ',') !== false ) {
+ $patched_value = '|' . preg_replace('/(\s+)?,(\s+)?/', '|', $patched_value) . '|';
+ }
+
+ // Support for "|value 1|value 2|..." notation.
+ if ( strpos($patched_value, '|') !== false ) {
+ // Multiple checkboxes OR multiselect.
+ $parsed_values = array();
+
+ foreach ( explode('|', substr($patched_value, 1, -1)) as $raw_option ) {
+ $parsed_value = $this->parseOption($raw_option, $options, $use_phrases);
+
+ if ( $parsed_value !== '' ) {
+ $parsed_values[] = $parsed_value;
+ continue;
+ }
+
+ $object->SetError($field_name, 'unknown_option', null, array('option' => $raw_option));
+
+ return $value;
+ }
+
+ return '|' . implode('|', $parsed_values) . '|';
+ }
+
+ $parsed_value = $this->parseOption($value, $options, $use_phrases);
+
+ if ( $parsed_value !== '' ) {
+ return $parsed_value;
+ }
+
+ $object->SetError($field_name, 'unknown_option', null, array('option' => $value));
+
+ return $value;
+ }
+
+ /**
+ * Converts an "option title" into an "option key".
+ *
+ * @param string $value Value.
+ * @param array $options Options.
+ * @param boolean $use_phrases Use phrases.
+ *
+ * @return integer|string
+ */
+ protected function parseOption($value, array $options, $use_phrases = true)
+ {
+ foreach ( $options['options'] as $option_key => $option_value ) {
if ( $use_phrases ) {
$option_value = $this->Application->Phrase($option_value);
}
if ( "$option_value" === "$value" ) {
- $found = true;
- break;
+ return $option_key;
}
}
- return $found ? $option_key : $value;
+ return array_key_exists($value, $options['options']) ? $value : '';
}
+
}
Index: core/kernel/utility/validator.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/core/kernel/utility/validator.php b/core/kernel/utility/validator.php
--- a/core/kernel/utility/validator.php (revision 16830)
+++ b/core/kernel/utility/validator.php (date 1754906940371)
@@ -60,6 +60,7 @@
'invalid_format' => '!la_err_invalid_format!', // Incorrect data format, please use %s
'bad_date_format' => '!la_err_bad_date_format!', // Incorrect date format, please use (%s) ex. (%s)
'primary_lang_required' => '!la_err_primary_lang_required!', // Primary Lang. value Required
+ 'unknown_option' => '!la_err_unknown_option!', // Option "{option}" is unknown
);
/**
Index: core/kernel/application.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/core/kernel/application.php b/core/kernel/application.php
--- a/core/kernel/application.php (revision 16830)
+++ b/core/kernel/application.php (date 1754908409368)
@@ -798,6 +798,10 @@
$this->registerClass('QAToolsUrlBuilder', KERNEL_PATH . '/tests/Url/QAToolsUrlBuilder.php');
$this->registerClass('QAToolsUrlFactory', KERNEL_PATH . '/tests/Url/QAToolsUrlFactory.php');
$this->registerClass('AbstractTestCase', KERNEL_PATH . '/../tests/Unit/AbstractTestCase.php');
+ $this->registerClass(
+ 'AbstractUnknownOptionTestCase',
+ KERNEL_PATH . '/../tests/Functional/AbstractUnknownOptionTestCase.php'
+ );
$this->registerClass(
'AbstractBrowserTestCase',
KERNEL_PATH . '/../tests/Functional/AbstractBrowserTestCase.php'
Index: core/tests/Functional/AbstractUnknownOptionTestCase.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/core/tests/Functional/AbstractUnknownOptionTestCase.php b/core/tests/Functional/AbstractUnknownOptionTestCase.php
new file mode 100644
--- /dev/null (date 1754906940753)
+++ b/core/tests/Functional/AbstractUnknownOptionTestCase.php (date 1754906940753)
@@ -0,0 +1,207 @@
+<?php
+
+
+abstract class AbstractUnknownOptionTestCase extends AbstractTestCase
+{
+
+ /**
+ * Base Items.
+ *
+ * @var kDBItem[]
+ */
+ protected static $baseItems = array();
+
+ /**
+ * Test Categories
+ *
+ * @var CategoriesItem[]
+ */
+ protected static $categories = array();
+
+ /**
+ * @beforeClass
+ */
+ public static function setUpTestBeforeClass()
+ {
+ $db = self::getDatabaseConnection();
+
+ $db->Query('BEGIN');
+
+ $application =& kApplication::Instance();
+ $application->isAdmin = true;
+ $application->isAdminUser = true;
+
+ $sql = 'SELECT CategoryId
+ FROM ' . $application->getUnitOption('c', 'TableName') . '
+ LIMIT 0, 2';
+ $category_ids = $db->GetCol($sql);
+
+ foreach ( $category_ids as $index => $category_id ) {
+ self::$categories[$index] = $application->recallObject(
+ 'c.test' . $category_id,
+ null,
+ array('skip_autoload' => true)
+ );
+ self::$categories[$index]->Load($category_id);
+ }
+ }
+
+ /**
+ * @before
+ */
+ public function setUpTest()
+ {
+
+ }
+
+ /**
+ * @afterClass
+ */
+ public static function tearDownTestAfterClass()
+ {
+ foreach ( self::$baseItems as $base_item ) {
+ self::deleteTestRecord($base_item);
+ }
+
+ self::getDatabaseConnection()->Query('ROLLBACK');
+ }
+
+ /**
+ * @dataProvider createAndUpdateItemDataProvider
+ */
+ public function testCreateAndUpdateItem($prefix, array $create_hash, array $update_hash)
+ {
+ /** @var kDBItem $object */
+ $object = $this->Application->recallObject($prefix, null, array('skip_autoload' => true));
+ $this->prepareObjectForTest($object);
+
+ $object->Clear();
+ $object->SetFieldsFromHash($this->replaceUnitValues($object, $create_hash));
+
+ $updated = false;
+ $created = $object->Create();
+
+ if ( $created ) {
+ $object->SetFieldsFromHash($this->replaceUnitValues($object, $update_hash));
+ $updated = $object->Update();
+ }
+
+ if ( $created ) {
+ self::deleteTestRecord($object);
+ }
+
+ $unknown_option_fields = array();
+
+ if ( !$created || !$updated ) {
+ foreach ( $object->GetFieldErrors() as $field => $error ) {
+ if ( $error['pseudo'] === 'unknown_option' ) {
+ $unknown_option_fields[] = $field;
+ }
+ }
+ }
+
+ $this->assertTrue(
+ $created && $updated,
+ 'unknown_option error in ' . implode(', ', $unknown_option_fields) . ' field(s)'
+ );
+ }
+
+ /**
+ * Object changes to compensate test environment incompatibilities
+ *
+ * @param kDBItem $object Object.
+ *
+ * @return void
+ */
+ protected function prepareObjectForTest(kDBItem $object)
+ {
+
+ }
+
+ /**
+ * Replaces unit-related values
+ *
+ * @param kDBItem $object Object.
+ * @param array $field_values Field values.
+ *
+ * @return array
+ */
+ protected function replaceUnitValues(kDBItem $object, array $field_values)
+ {
+ $result = $field_values;
+
+ foreach ( $field_values as $field => $value ) {
+ if ( !is_array($value) ) {
+ continue;
+ }
+
+ $prefix = key($value);
+
+ if ( strpos($prefix, 'cat_') === 0 ) {
+ $result[$field] = self::$categories[substr($prefix, 4)]->GetDBField($value[$prefix]);
+ }
+ elseif ( $prefix === 'self' ) {
+ $field_options = array_keys($object->GetFieldOption($field, 'options'));
+ $option_position = $value[$prefix];
+ $result[$field] = $field_options[$option_position];
+ }
+ elseif ( $prefix === 'base_item' ) {
+ $base_field = $value['base_item']['field'];
+ $base_prefix = $value['base_item']['prefix'];
+ $result[$field] = self::$baseItems[$base_prefix]->GetDBField($base_field);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Deletes test record
+ *
+ * @param kDBItem $object Object.
+ *
+ * @return void
+ */
+ protected static function deleteTestRecord(kDBItem $object)
+ {
+ $sql = 'DELETE FROM ' . $object->TableName . '
+ WHERE ' . $object->IDField . ' = ' . $object->GetID();
+ self::getDatabaseConnection()->Query($sql);
+ }
+
+ /**
+ * Returns the database connection.
+ *
+ * @return IDBConnection
+ */
+ protected static function getDatabaseConnection()
+ {
+ $conn =& kApplication::Instance()->GetADODBConnection();
+
+ return $conn;
+ }
+
+ abstract public function createAndUpdateItemDataProvider();
+
+ /**
+ * Report failure to create an item.
+ *
+ * @param string $key Key.
+ * @param string $item_description Item description.
+ *
+ * @return void
+ */
+ protected static function createBaseItem($key, $item_description)
+ {
+ $item = self::$baseItems[$key];
+
+ if ( $item->Create() ) {
+ return;
+ }
+
+ self::fail(
+ 'Unable to create the ' . $item_description . '.' . PHP_EOL . print_r($item->GetFieldErrors(), true)
+ );
+ }
+
+}
Index: core/tests/Functional/CoreUnknownOptionTest.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/core/tests/Functional/CoreUnknownOptionTest.php b/core/tests/Functional/CoreUnknownOptionTest.php
new file mode 100644
--- /dev/null (date 1754910790646)
+++ b/core/tests/Functional/CoreUnknownOptionTest.php (date 1754910790646)
@@ -0,0 +1,734 @@
+<?php
+
+
+class CoreUnknownOptionTest extends AbstractUnknownOptionTestCase
+{
+
+ /**
+ * @beforeClass
+ */
+ public static function setUpTestBeforeClass()
+ {
+ parent::setUpTestBeforeClass();
+
+ $application =& kApplication::Instance();
+
+ self::$baseItems['form.first'] = $application->recallObject('form.first', null, array('skip_autoload' => true));
+ self::$baseItems['form.first']->Clear();
+ self::$baseItems['form.first']->SetDBField('Title', 'Unknown Option Tests Form');
+ self::$baseItems['form.first']->Create();
+
+ self::$baseItems['form.second'] = $application->recallObject(
+ 'form.second',
+ null,
+ array('skip_autoload' => true)
+ );
+ self::$baseItems['form.second']->Clear();
+ self::$baseItems['form.second']->SetDBField('Title', 'Unknown Option Tests Second Form');
+ self::$baseItems['form.second']->Create();
+
+ $_SERVER['REQUEST_URI'] = 'https://www.in-portal.org/';
+ $application->SetVar('email-template_site-domain', array(0 => array('Recipients' => '')));
+
+ self::$baseItems['site-domain.first'] = $application->recallObject(
+ 'site-domain.first',
+ null,
+ array('skip_autoload' => true)
+ );
+ self::$baseItems['site-domain.first']->Clear();
+ self::$baseItems['site-domain.first']->SetDBField('DomainName', 'www.UnknownOptionsTest.org');
+ self::$baseItems['site-domain.first']->Create();
+
+ self::$baseItems['lang.first'] = $application->recallObject(
+ 'lang.first',
+ null,
+ array('skip_autoload' => true)
+ );
+ self::$baseItems['lang.first']->Clear();
+ self::$baseItems['lang.first']->SetDBField('PackName', 'UnknownOptionTestBase');
+ self::$baseItems['lang.first']->SetDBField('LocalName', 'UnknownOptionTestBase');
+ self::$baseItems['lang.first']->Create();
+
+ self::$baseItems['theme.first'] = $application->recallObject(
+ 'theme.first',
+ null,
+ array('skip_autoload' => true)
+ );
+ self::$baseItems['theme.first']->Clear();
+ self::$baseItems['theme.first']->SetDBField('Name', 'UnknownOptionTestBase');
+ self::$baseItems['theme.first']->Create();
+ }
+
+ /**
+ * Object changes to compensate test environment incompatibilities
+ *
+ * @param kDBItem $object Object.
+ *
+ * @return void
+ */
+ protected function prepareObjectForTest(kDBItem $object)
+ {
+ if ( $object->Prefix == 'promo-block' ) {
+ $object->setRequired('l1_Image', false);
+ }
+ }
+
+ public function createAndUpdateItemDataProvider()
+ {
+ return array(
+ 'Ban rules' => array(
+ 'prefix' => 'ban-rule',
+ 'create_hash' => array(
+ 'ItemValue' => 'Name',
+ 'Status' => '0',
+ 'RuleType' => 1,
+ 'ItemVerb' => 2,
+ 'ItemField' => 'FirstName',
+ ),
+ 'update_hash' => array(
+ 'Status' => 1,
+ 'RuleType' => '0',
+ 'ItemVerb' => 1,
+ 'ItemField' => 'LastName',
+ ),
+ ),
+ 'Categories' => array(
+ 'prefix' => 'c',
+ 'create_hash' => array(
+ 'l1_Name' => 'Category Name',
+ 'PageCacheKey' => 'Cache Key',
+ 'ThemeId' => 3,
+ 'FormId' => array('base_item' => array('prefix' => 'form.first', 'field' => 'FormId')),
+ 'RequireLogin' => '0',
+ 'RequireSSL' => '0',
+ 'DirectLinkEnabled' => '0',
+ 'OverridePageCacheKey' => '0',
+ 'EnablePageCache' => '0',
+ 'Protected' => '0',
+ 'IsMenu' => '0',
+ 'UseMenuIconUrl' => '0',
+ 'UseExternalUrl' => '0',
+ 'NewItem' => '0',
+ 'PopItem' => '0',
+ 'HotItem' => '0',
+ 'Status' => 2,
+ 'Type' => 1,
+ 'ParentId' => array('cat_0' => 'CategoryId'),
+ 'AutomaticFilename' => '0',
+ 'EditorsPick' => '0',
+ 'Template' => '#default_design#',
+ ),
+ 'update_hash' => array(
+ 'FormId' => array('base_item' => array('prefix' => 'form.second', 'field' => 'FormId')),
+ 'RequireLogin' => 1,
+ 'RequireSSL' => 1,
+ 'DirectLinkEnabled' => 1,
+ 'OverridePageCacheKey' => 1,
+ 'EnablePageCache' => 1,
+ 'Protected' => 1,
+ 'IsMenu' => 1,
+ 'UseMenuIconUrl' => 1,
+ 'UseExternalUrl' => 1,
+ 'NewItem' => 1,
+ 'PopItem' => 1,
+ 'HotItem' => 1,
+ 'Status' => 1,
+ 'Type' => 1,
+ 'ParentId' => array('cat_1' => 'CategoryId'),
+ 'AutomaticFilename' => 1,
+ 'EditorsPick' => 1,
+ 'Priority' => '-2',
+ 'Template' => '#inherit#',
+ ),
+ ),
+ // Change logs Mot working through object when no such prefix in change log table.
+ // But usually that inserted by direct SQL.
+ /* 'Change Logs' => array(
+ 'prefix' => 'change-log',
+ 'create_hash' => array(
+ 'Action' => ChangeLog::UPDATE,
+ 'Prefix' => 'c',
+ 'ItemId' => array('cat_1' => 'CategoryId'),
+ 'MasterPrefix' => 'c',
+ ),
+ 'update_hash' => array(
+ 'Action' => ChangeLog::CREATE,
+ 'Prefix' => 'form',
+ 'ItemId' => array('base_item' => array('prefix' => 'form.first', 'field' => 'FormId')),
+ 'MasterPrefix' => 'form',
+ ),
+ ),
+ */
+ 'Config Search' => array(
+ 'prefix' => 'confs',
+ 'create_hash' => array(
+ 'TableName' => 'SearchConfig',
+ 'FieldName' => 'TableName',
+ 'DisplayName' => 'la_Yes',
+ 'ConfigHeader' => 'la_No',
+ 'FieldType' => 'text',
+ 'SimpleSearch' => '0',
+ 'AdvancedSearch' => '0',
+ 'ModuleName' => 'In-Portal',
+ ),
+ 'update_hash' => array(
+ 'FieldType' => 'date',
+ 'SimpleSearch' => 1,
+ 'AdvancedSearch' => 1,
+ 'ModuleName' => 'Custom',
+ ),
+ ),
+ 'System Settings' => array(
+ 'prefix' => 'conf',
+ 'create_hash' => array(
+ 'VariableName' => 'UnknownOptionsTest',
+ 'ModuleOwner' => 'Custom',
+ 'Section' => 'in-portal:configure_categories',
+ 'Heading' => 'la_section_SettingsWebsite',
+ 'Prompt' => 'la_config_UnknownOptionsTest',
+ 'ElementType' => 'checkbox',
+ ),
+ 'update_hash' => array(
+ 'ModuleOwner' => 'In-Portal',
+ 'ElementType' => 'select',
+ ),
+ ),
+ 'Country States' => array(
+ 'prefix' => 'country-state',
+ 'create_hash' => array(
+ 'Type' => DESTINATION_TYPE_COUNTRY,
+ 'l1_Name' => 'UnknownOptionsTest',
+ 'IsoCode' => 'UOT',
+ ),
+ 'update_hash' => array(
+ 'Type' => DESTINATION_TYPE_STATE,
+ 'StateCountryId' => 225,
+ ),
+ ),
+ 'Custom Fields' => array(
+ 'prefix' => 'cf',
+ 'create_hash' => array(
+ 'FieldName' => 'UnknownOptionsTest',
+ 'FieldLabel' => 'la_fld_UnknownOptionsTest',
+ 'Heading' => 'la_fld_UnknownOptionsTest',
+ 'ElementType' => 'text',
+ 'OnGeneralTab' => 1,
+ 'MultiLingual' => '0',
+ 'IsSystem' => 1,
+ 'IsRequired' => 1,
+ ),
+ 'update_hash' => array(
+ 'ElementType' => 'checkbox',
+ 'OnGeneralTab' => '0',
+ 'MultiLingual' => 1,
+ 'IsSystem' => '0',
+ 'IsRequired' => '0',
+ ),
+ ),
+ 'Email logs' => array(
+ 'prefix' => 'email-log',
+ 'create_hash' => array(
+ 'EventType' => 1,
+ ),
+ 'update_hash' => array(
+ 'EventType' => '0',
+ ),
+ ),
+ 'Email templates' => array(
+ 'prefix' => 'email-template',
+ 'create_hash' => array(
+ 'TemplateName' => 'UnknownOptionsTest',
+ 'AllowChangingSender' => 1,
+ 'CustomSender' => 1,
+ 'SenderAddressType' => 1,
+ 'AllowChangingRecipient' => 1,
+ 'CustomRecipient' => 1,
+ 'Enabled' => '0',
+ 'FrontEndOnly' => 1,
+ 'Type' => 1,
+ 'l1_Subject' => 'UnknownOptionsTest',
+ 'l1_HtmlBody' => 'UnknownOptionsTest',
+ 'l1_PlainTextBody' => 'UnknownOptionsTest',
+ 'Module' => 'Core',
+ ),
+ 'update_hash' => array(
+ 'AllowChangingSender' => '0',
+ 'CustomSender' => '0',
+ 'SenderAddressType' => 2,
+ 'AllowChangingRecipient' => '0',
+ 'CustomRecipient' => '0',
+ 'Enabled' => 1,
+ 'Type' => '0',
+ 'FrontEndOnly' => '0',
+ ),
+ ),
+ 'Item Filters' => array(
+ 'prefix' => 'item-filter',
+ 'create_hash' => array(
+ 'ItemPrefix' => 'u',
+ 'FilterField' => 'LastName',
+ 'FilterType' => 'text',
+ 'Enabled' => '0',
+ ),
+ 'update_hash' => array(
+ 'FilterType' => 'checkbox',
+ 'Enabled' => 1,
+ ),
+ ),
+ 'Form Fields' => array(
+ 'prefix' => 'formflds',
+ 'create_hash' => array(
+ 'FormId' => array('base_item' => array('prefix' => 'form.first', 'field' => 'FormId')),
+ 'FieldName' => 'LastName',
+ 'FieldLabel' => 'la_Yes',
+ 'Prompt' => 'la_Yes',
+ 'ElementType' => 'text',
+ 'IsSystem' => 1,
+ 'Required' => 1,
+ 'Validation' => 1,
+ 'DisplayInGrid' => '0',
+ 'Visibility' => 2,
+ 'EmailCommunicationRole' => 1,
+ ),
+ 'update_hash' => array(
+ 'ElementType' => 'checkbox',
+ 'IsSystem' => '0',
+ 'Required' => '0',
+ 'Validation' => '0',
+ 'DisplayInGrid' => 1,
+ 'Visibility' => 1,
+ 'EmailCommunicationRole' => 2,
+ ),
+ ),
+ 'Form Submissions' => array(
+ 'prefix' => 'formsubs',
+ 'create_hash' => array(
+ 'FormId' => array('base_item' => array('prefix' => 'form.first', 'field' => 'FormId')),
+ 'ReferrerURL' => 'https://www.in-portal.org',
+ 'LogStatus' => 1,
+ ),
+ 'update_hash' => array(
+ 'LogStatus' => 2,
+ ),
+ ),
+ 'Forms' => array(
+ 'prefix' => 'form',
+ 'create_hash' => array(
+ 'Title' => 'UnknownOptionTest',
+ 'RequireLogin' => 1,
+ 'UseSecurityImage' => 1,
+ 'EnableEmailCommunication' => '0',
+ 'ProcessUnmatchedEmails' => 1,
+ ),
+ 'update_hash' => array(
+ 'RequireLogin' => '0',
+ 'UseSecurityImage' => '0',
+ 'ProcessUnmatchedEmails' => '0',
+ ),
+ ),
+ 'Groups' => array(
+ 'prefix' => 'g',
+ 'create_hash' => array(
+ 'Name' => 'UnknownOptionTest',
+ 'Enabled' => '0',
+ 'FrontRegistration' => 1,
+ ),
+ 'update_hash' => array(
+ 'Enabled' => 1,
+ 'FrontRegistration' => '0',
+ ),
+ ),
+ 'Images' => array(
+ 'prefix' => 'img',
+ 'create_hash' => array(
+ 'Name' => 'UnknownOptionTest',
+ 'Enabled' => '0',
+ 'DefaultImg' => 1,
+ 'SameImages' => '0',
+ ),
+ 'update_hash' => array(
+ 'Enabled' => 1,
+ 'DefaultImg' => '0',
+ 'SameImages' => 1,
+ ),
+ ),
+ 'Languages' => array(
+ 'prefix' => 'lang',
+ 'create_hash' => array(
+ 'PackName' => 'UnknownOptionTest',
+ 'LocalName' => 'UnknownOptionTest',
+ 'Enabled' => '0',
+ 'PrimaryLang' => 1,
+ 'AdminInterfaceLang' => 1,
+ 'InputDateFormat' => 'd/m/Y',
+ 'InputTimeFormat' => 'g:i A',
+ 'UnitSystem' => 2,
+ 'Locale' => 'af-ZA',
+ 'SynchronizationModes' => 1,
+ ),
+ 'update_hash' => array(
+ 'PackName' => 'UnknownOptionTest2',
+ 'LocalName' => 'UnknownOptionTest2',
+ 'Enabled' => 1,
+ 'PrimaryLang' => '0',
+ 'AdminInterfaceLang' => '0',
+ 'InputDateFormat' => 'm/d/Y',
+ 'InputTimeFormat' => 'g:i:s A',
+ 'UnitSystem' => 1,
+ 'Locale' => 'en-US',
+ 'SynchronizationModes' => 2,
+ ),
+ ),
+ 'Mailing Lists' => array(
+ 'prefix' => 'mailing-list',
+ 'create_hash' => array(
+ 'To' => 'service@in-portal.org',
+ 'Subject' => 'UnknownOptionTest',
+ 'MessageText' => 'UnknownOptionTest',
+ 'MessageHtml' => 'UnknownOptionTest',
+ 'Status' => 2,
+ ),
+ 'update_hash' => array(
+ 'Status' => 1,
+ ),
+ ),
+ 'Modules' => array(
+ 'prefix' => 'mod',
+ 'create_hash' => array(
+ 'Loaded' => '0',
+ ),
+ 'update_hash' => array(
+ 'Loaded' => 1,
+ ),
+ ),
+ 'Page revisions' => array(
+ 'prefix' => 'page-revision',
+ 'create_hash' => array(
+ 'IsDraft' => 1,
+ 'Status' => 1,
+ ),
+ 'update_hash' => array(
+ 'IsDraft' => '0',
+ 'Status' => 2,
+ ),
+ ),
+ 'Permission types' => array(
+ 'prefix' => 'permission-type',
+ 'create_hash' => array(
+ 'PermissionName' => 'UnknownOptionTest',
+ 'Description' => 'la_Yes',
+ 'ModuleId' => 'Admin',
+ 'IsSystem' => 1,
+ ),
+ 'update_hash' => array(
+ 'ModuleId' => 'Front',
+ 'IsSystem' => '0',
+ ),
+ ),
+ 'Phrases' => array(
+ 'prefix' => 'phrases',
+ 'create_hash' => array(
+ 'Phrase' => 'la_UnknownOptionTest',
+ 'l1_Translation' => 'Test',
+ 'PhraseType' => '0',
+ 'Module' => 'In-Link',
+ ),
+ 'update_hash' => array(
+ 'PhraseType' => 1,
+ 'Module' => 'Core',
+ ),
+ ),
+ 'Promo blocks' => array(
+ 'prefix' => 'promo-block',
+ 'create_hash' => array(
+ 'PromoBlockGroupId' => 1,
+ 'l1_Title' => 'UnknownOptionTest',
+ 'Status' => '0',
+ 'Sticky' => 1,
+ 'LinkType' => 2,
+ 'ExternalLink' => 'https://www.in-portal.org/',
+ 'OpenInNewWindow' => 1,
+ 'CategoryId' => array('cat_0' => 'CategoryId'),
+ ),
+ 'update_hash' => array(
+ 'Status' => 1,
+ 'Sticky' => '0',
+ 'LinkType' => 1,
+ 'OpenInNewWindow' => '0',
+ 'CategoryId' => array('cat_1' => 'CategoryId'),
+ ),
+ ),
+ 'Promo block groups' => array(
+ 'prefix' => 'promo-block-group',
+ 'create_hash' => array(
+ 'Title' => 'UnknownOptionTest',
+ 'Status' => 1,
+ 'TransitionControls' => '0',
+ 'TransitionEffect' => 'fade',
+ 'RotationDelay' => 1,
+ 'TransitionTime' => 1,
+ ),
+ 'update_hash' => array(
+ 'Status' => '0',
+ 'TransitionControls' => 1,
+ 'TransitionEffect' => 'slide',
+ ),
+ ),
+ 'Related searches' => array(
+ 'prefix' => 'c-search',
+ 'create_hash' => array(
+ 'ResourceId' => array('cat_0' => 'ResourceId'),
+ 'Keyword' => 'UnknownOptionTest',
+ 'Enabled' => '0',
+ ),
+ 'update_hash' => array(
+ 'Enabled' => 1,
+ ),
+ ),
+ 'Relationships' => array(
+ 'prefix' => 'rel',
+ 'create_hash' => array(
+ 'SourceId' => array('cat_0' => 'CategoryId'),
+ 'TargetId' => array('cat_1' => 'CategoryId'),
+ 'SourceType' => 1,
+ 'TargetType' => 1,
+ 'Type' => 1,
+ 'Enabled' => '0',
+ ),
+ 'update_hash' => array(
+ 'Type' => '0',
+ 'Enabled' => 1,
+ ),
+ ),
+ 'Scheduled tasks' => array(
+ 'prefix' => 'scheduled-task',
+ 'create_hash' => array(
+ 'Name' => 'UnknownOptionTest',
+ 'Event' => 'c:OnCreate',
+ 'Type' => 2,
+ 'Status' => '0',
+ 'LastRunStatus' => 2,
+ 'SiteDomainLimitation' => array('base_item' => array('prefix' => 'site-domain.first', 'field' => 'DomainId')),
+ ),
+ 'update_hash' => array(
+ 'Type' => 1,
+ 'Status' => 1,
+ 'LastRunStatus' => 1,
+ 'SiteDomainLimitation' => '',
+ ),
+ ),
+ 'Search log' => array(
+ 'prefix' => 'search-log',
+ 'create_hash' => array(
+ 'SearchType' => 1,
+ ),
+ 'update_hash' => array(
+ 'SearchType' => '0',
+ ),
+ ),
+ 'Session log' => array(
+ 'prefix' => 'session-log',
+ 'create_hash' => array(
+ 'Status' => 2,
+ ),
+ 'update_hash' => array(
+ 'Status' => 1,
+ ),
+ ),
+ 'Site domains' => array(
+ 'prefix' => 'site-domain',
+ 'create_hash' => array(
+ 'DomainName' => 'www.in-portal.org',
+ 'DomainNameUsesRegExp' => 1,
+ 'SSLUrlUsesRegExp' => 1,
+ 'Country' => 'USA',
+ 'PrimaryLanguageId' => array('base_item' => array('prefix' => 'lang.first', 'field' => 'LanguageId')),
+ 'Languages' => array('base_item' => array('prefix' => 'lang.first', 'field' => 'LanguageId')),
+ 'PrimaryThemeId' => array('base_item' => array('prefix' => 'theme.first', 'field' => 'ThemeId')),
+ 'Themes' => array('base_item' => array('prefix' => 'theme.first', 'field' => 'ThemeId')),
+ 'RedirectOnIPMatch' => 1,
+ 'DomainIPRange' => '1.2.3.4',
+ ),
+ 'update_hash' => array(
+ 'DomainNameUsesRegExp' => '0',
+ 'SSLUrlUsesRegExp' => '0',
+ 'Country' => '',
+ 'PrimaryLanguageId' => '',
+ 'Languages' => '',
+ 'PrimaryThemeId' => '',
+ 'Themes' => '',
+ 'RedirectOnIPMatch' => '0',
+ 'DomainIPRange' => null,
+ ),
+ ),
+ 'Skins' => array(
+ 'prefix' => 'skin',
+ 'create_hash' => array(
+ 'Name' => 'UnknownOptionTest',
+ 'IsPrimary' => 1,
+ 'DisplaySiteNameInHeader' => '0',
+ ),
+ 'update_hash' => array(
+ 'IsPrimary' => '0',
+ 'DisplaySiteNameInHeader' => 1,
+ ),
+ ),
+ 'Structure' => array(
+ 'prefix' => 'st',
+ 'create_hash' => array(
+ 'l1_Name' => 'Category Name',
+ 'PageCacheKey' => 'Cache Key',
+ 'ThemeId' => 3,
+ 'FormId' => array('base_item' => array('prefix' => 'form.first', 'field' => 'FormId')),
+ 'RequireLogin' => '0',
+ 'RequireSSL' => '0',
+ 'DirectLinkEnabled' => '0',
+ 'OverridePageCacheKey' => '0',
+ 'EnablePageCache' => '0',
+ 'Protected' => '0',
+ 'IsMenu' => '0',
+ 'UseMenuIconUrl' => '0',
+ 'UseExternalUrl' => '0',
+ 'NewItem' => '0',
+ 'PopItem' => '0',
+ 'HotItem' => '0',
+ 'Status' => 2,
+ 'Type' => 1,
+ 'ParentId' => array('cat_0' => 'CategoryId'),
+ 'AutomaticFilename' => '0',
+ 'EditorsPick' => '0',
+ 'Template' => '#default_design#',
+ ),
+ 'update_hash' => array(
+ 'FormId' => array('base_item' => array('prefix' => 'form.second', 'field' => 'FormId')),
+ 'RequireLogin' => 1,
+ 'RequireSSL' => 1,
+ 'DirectLinkEnabled' => 1,
+ 'OverridePageCacheKey' => 1,
+ 'EnablePageCache' => 1,
+ 'Protected' => 1,
+ 'IsMenu' => 1,
+ 'UseMenuIconUrl' => 1,
+ 'UseExternalUrl' => 1,
+ 'NewItem' => 1,
+ 'PopItem' => 1,
+ 'HotItem' => 1,
+ 'Status' => 1,
+ 'Type' => 1,
+ 'ParentId' => array('cat_1' => 'CategoryId'),
+ 'AutomaticFilename' => 1,
+ 'EditorsPick' => 1,
+ 'Priority' => '-2',
+ 'Template' => '#inherit#',
+ ),
+ ),
+ 'Submission log' => array(
+ 'prefix' => 'submission-log',
+ 'create_hash' => array(
+ 'FromEmail' => 'service@in-portal.org',
+ 'ToEmail' => 'admin@in-portal.org',
+ 'Subject' => 'UnknownOptionTest',
+ 'Message' => 'UnknownOptionTest',
+ 'ReplyStatus' => 1,
+ 'SentStatus' => 1,
+ ),
+ 'update_hash' => array(
+ 'ReplyStatus' => '0',
+ 'SentStatus' => '0',
+ ),
+ ),
+ 'System event subscriptions' => array(
+ 'prefix' => 'system-event-subscription',
+ 'create_hash' => array(
+ 'EmailTemplateId' => array('self' => 0),
+ 'SubscriberEmeil' => 'service@in-portal.org',
+ 'UserId' => 'root',
+ 'IncludeSublevels' => '0',
+ ),
+ 'update_hash' => array(
+ 'EmailTemplateId' => array('self' => 1),
+ 'IncludeSublevels' => 1,
+ ),
+ ),
+ 'System log' => array(
+ 'prefix' => 'system-log',
+ 'create_hash' => array(
+ 'LogLevel' => kLogger::LL_ALERT,
+ 'LogType' => kLogger::LT_PHP,
+ 'LogRequestSource' => 1,
+ 'LogInterface' => kLogger::LI_FRONT,
+ 'LogCodeFragmentsRotated' => 1,
+ 'LogNotificationStatus' => kLogger::LNS_DISABLED,
+ ),
+ 'update_hash' => array(
+ 'LogLevel' => kLogger::LL_CRITICAL,
+ 'LogType' => kLogger::LT_DATABASE,
+ 'LogRequestSource' => 2,
+ 'LogInterface' => kLogger::LI_ADMIN,
+ 'LogCodeFragmentsRotated' => '0',
+ 'LogNotificationStatus' => kLogger::LNS_PENDING,
+ ),
+ ),
+ 'Themes' => array(
+ 'prefix' => 'theme',
+ 'create_hash' => array(
+ 'Name' => 'UnknownOptionTest',
+ 'Enabled' => '0',
+ 'PrimaryTheme' => 1,
+ 'LanguagePackInstalled' => 1,
+ ),
+ 'update_hash' => array(
+ 'Enabled' => 1,
+ 'PrimaryTheme' => '0',
+ 'LanguagePackInstalled' => '0',
+ ),
+ ),
+ 'Thesaurus' => array(
+ 'prefix' => 'thesaurus',
+ 'create_hash' => array(
+ 'SearchTerm' => 'UnknownOptionTest',
+ 'ThesaurusTerm' => 'UnknownOptionTest',
+ 'ThesaurusType' => '0',
+ ),
+ 'update_hash' => array(
+ 'ThesaurusTerm' => 'UnknownOptionTest2',
+ ),
+ ),
+ 'Users' => array(
+ 'prefix' => 'u',
+ 'create_hash' => array(
+ 'Password' => 'uuerretrty',
+ 'VerifyPassword' => 'uuerretrty',
+ 'Password_plain' => 'uuerretrty',
+ 'VerifyPassword_plain' => 'uuerretrty',
+ 'PasswordHashingMethod' => PasswordHashingMethod::MD5,
+ 'State' => 'IL',
+ 'Country' => 'USA',
+ 'Status' => 1,
+ 'FrontLanguage' => 1,
+ 'AdminLanguage' => 1,
+ 'DisplayToPublic' => 'FirstName',
+ 'UserType' => '0',
+ 'PrimaryGroupId' => 13,
+ 'OldStyleLogin' => 1,
+ 'EmailVerified' => '0',
+ 'Email' => 'test@erik.dallas.intechnic.com'
+ ),
+ 'update_hash' => array(
+ 'PasswordHashingMethod' => PasswordHashingMethod::PHPPASS,
+ 'State' => 'DC',
+ 'Country' => 'USA',
+ 'Status' => 2,
+ 'FrontLanguage' => 2,
+ 'AdminLanguage' => 2,
+ 'DisplayToPublic' => 'Email',
+ 'UserType' => 1,
+ 'PrimaryGroupId' => 11,
+ 'OldStyleLogin' => '0',
+ 'EmailVerified' => 1,
+ ),
+ ),
+ );
+ }
+
+}
Index: core/tests/Unit/kernel/utility/formatters/options_formatterTest.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/core/tests/Unit/kernel/utility/formatters/options_formatterTest.php b/core/tests/Unit/kernel/utility/formatters/options_formatterTest.php
new file mode 100644
--- /dev/null (date 1754906940871)
+++ b/core/tests/Unit/kernel/utility/formatters/options_formatterTest.php (date 1754906940871)
@@ -0,0 +1,139 @@
+<?php
+
+/**
+ * The class name must match the file name for Phabricator-invoked PHPUnit to run this test.
+ *
+ * TODO: Once "options_formatter.php" file is renamed we can rename this class/filename as well.
+ */
+class options_formatterTest extends AbstractTestCase // phpcs:ignore Squiz.Classes.ValidClassName.NotCamelCaps
+{
+
+ /**
+ * Fixture of the kDBItem class.
+ *
+ * @var kDBItem
+ */
+ protected $dbItemFixture;
+
+ /**
+ * @before
+ */
+ protected function setUpTest()
+ {
+ $db_item = new kDBItem();
+ $db_item->Init('stop-word', ''); // Existing unit used for the "ValidatorClass" unit config option to work.
+ $db_item->SetFieldOptions(
+ 'SampleField',
+ array(
+ 'options' => array(1 => 'la_ADP', 2 => 'la_AED', 3 => 'la_AFA', 4 => 'la_ALL'),
+ )
+ );
+
+ $this->dbItemFixture = $db_item;
+ }
+
+ public function testParseEmptyValue()
+ {
+ $option_formatter = new kOptionsFormatter();
+ $actual = $option_formatter->Parse('', 'SampleField', $this->dbItemFixture);
+
+ $this->assertEmpty($this->dbItemFixture->GetErrorPseudo('SampleField'), 'No validation errors');
+ $this->assertNull($actual);
+ }
+
+ /**
+ * @dataProvider usePhrasesDataProvider
+ */
+ public function testParseKnownOptionByValue($use_phrases)
+ {
+ $option_formatter = new kOptionsFormatter();
+ $this->dbItemFixture->SetFieldOption('SampleField', 'use_phrases', $use_phrases);
+
+ $option_title = $use_phrases ? 'UAE Dirham' : 'la_AED';
+ $actual = $option_formatter->Parse($option_title, 'SampleField', $this->dbItemFixture);
+
+ $this->assertEmpty($this->dbItemFixture->GetErrorPseudo('SampleField'), 'No validation errors');
+ $this->assertSame(2, $actual);
+ }
+
+ public function testParseKnownOptionByKey()
+ {
+ $option_formatter = new kOptionsFormatter();
+ $actual = $option_formatter->Parse(2, 'SampleField', $this->dbItemFixture);
+
+ $this->assertEmpty($this->dbItemFixture->GetErrorPseudo('SampleField'), 'No validation errors');
+ $this->assertSame(2, $actual);
+ }
+
+ public function testParseUnknownOption()
+ {
+ $option_formatter = new kOptionsFormatter();
+ $option_title_in = 'option5';
+ $actual = $option_formatter->Parse($option_title_in, 'SampleField', $this->dbItemFixture);
+
+ $this->assertEquals('unknown_option', $this->dbItemFixture->GetErrorPseudo('SampleField'));
+ $this->assertEquals('Option "option5" is unknown', $this->dbItemFixture->GetErrorMsg('SampleField'));
+ $this->assertSame($option_title_in, $actual, 'Given value returned as-as');
+ }
+
+ /**
+ * @dataProvider usePhrasesDataProvider
+ */
+ public function testParseKnownOptionsByKey($use_phrases)
+ {
+ $option_formatter = new kOptionsFormatter();
+ $this->dbItemFixture->SetFieldOption('SampleField', 'use_phrases', $use_phrases);
+
+ $option_titles = $use_phrases ? '|Leck|UAE Dirham|' : '|la_ALL|la_AED|';
+ $actual = $option_formatter->Parse($option_titles, 'SampleField', $this->dbItemFixture);
+
+ $this->assertEmpty($this->dbItemFixture->GetErrorPseudo('SampleField'), 'No validation errors');
+ $this->assertSame('|4|2|', $actual);
+ }
+
+ public function testParseUnknownOptions()
+ {
+ $option_formatter = new kOptionsFormatter();
+ $option_titles_in = '|la_ALL|missing|la_AED|missing 2|';
+ $actual = $option_formatter->Parse($option_titles_in, 'SampleField', $this->dbItemFixture);
+
+ $this->assertSame('unknown_option', $this->dbItemFixture->GetErrorPseudo('SampleField'));
+ $this->assertSame('Option "missing" is unknown', $this->dbItemFixture->GetErrorMsg('SampleField'));
+ $this->assertSame($option_titles_in, $actual, 'Given value returned as-as');
+ }
+
+ /**
+ * @dataProvider usePhrasesDataProvider
+ */
+ public function testParseKnownOptionsByKeyWithCommaSeparator($use_phrases)
+ {
+ $option_formatter = new kOptionsFormatter();
+ $this->dbItemFixture->SetFieldOption('SampleField', 'use_phrases', $use_phrases);
+
+ $option_titles = $use_phrases ? 'Leck, UAE Dirham' : 'la_ALL, la_AED';
+ $actual = $option_formatter->Parse($option_titles, 'SampleField', $this->dbItemFixture);
+
+ $this->assertEmpty($this->dbItemFixture->GetErrorPseudo('SampleField'), 'No validation errors');
+ $this->assertSame('|4|2|', $actual);
+ }
+
+ public function testParseUnknownOptionsWithCommaSeparator()
+ {
+ $option_formatter = new kOptionsFormatter();
+ $option_titles_in = 'la_ALL, missing, la_AED, missing 2';
+ $actual = $option_formatter->Parse($option_titles_in, 'SampleField', $this->dbItemFixture);
+
+ $this->assertSame('unknown_option', $this->dbItemFixture->GetErrorPseudo('SampleField'));
+ $this->assertSame('Option "missing" is unknown', $this->dbItemFixture->GetErrorMsg('SampleField'));
+ $this->assertSame($option_titles_in, $actual, 'Given value returned as-as');
+ }
+
+ public static function usePhrasesDataProvider()
+ {
+ return array(
+ 'not using phrases' => array(false),
+ 'using phrases' => array(true),
+ );
+ }
+
+}
Index: modules/custom/tests/Functional/CustomUnknownOptionTest.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/modules/custom/tests/Functional/CustomUnknownOptionTest.php b/modules/custom/tests/Functional/CustomUnknownOptionTest.php
new file mode 100644
--- /dev/null (date 1754909833801)
+++ b/modules/custom/tests/Functional/CustomUnknownOptionTest.php (date 1754909833801)
@@ -0,0 +1,41 @@
+<?php
+
+
+class CustomUnknownOptionTest extends AbstractUnknownOptionTestCase
+{
+
+ /**
+ * Object changes to compensate test environment incompatibilities
+ *
+ * @param kDBItem $object Object.
+ *
+ * @return void
+ */
+ protected function prepareObjectForTest(kDBItem $object)
+ {
+ if ( $object->Prefix === 'widget' ) {
+ $object->setRequired('Image', false);
+ }
+ }
+
+ public function createAndUpdateItemDataProvider()
+ {
+ return array(
+ 'Widgets' => array(
+ 'prefix' => 'widget',
+ 'create_hash' => array(
+ 'Title' => 'UnknownOptionTest',
+ 'Type' => 2,
+ 'Status' => 1,
+ 'Good' => 1,
+ ),
+ 'update_hash' => array(
+ 'Type' => 1,
+ 'Status' => 2,
+ 'Good' => '0',
+ ),
+ ),
+ );
+ }
+
+}
Index: modules/in-bulletin/tests/Functional/InBulletinUnknownOptionTest.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/modules/in-bulletin/tests/Functional/InBulletinUnknownOptionTest.php b/modules/in-bulletin/tests/Functional/InBulletinUnknownOptionTest.php
new file mode 100644
--- /dev/null (date 1754906941806)
+++ b/modules/in-bulletin/tests/Functional/InBulletinUnknownOptionTest.php (date 1754906941806)
@@ -0,0 +1,145 @@
+<?php
+
+
+class InBulletinUnknownOptionTest extends AbstractUnknownOptionTestCase
+{
+
+ /**
+ * @beforeClass
+ */
+ public static function setUpTestBeforeClass()
+ {
+ parent::setUpTestBeforeClass();
+
+ $application =& kApplication::Instance();
+
+ self::$baseItems['u.logged'] = $application->recallObject(
+ 'u.logged',
+ null,
+ array('skip_autoload' => true)
+ );
+ self::$baseItems['u.logged']->Clear();
+ self::$baseItems['u.logged']->SetDBField('FirstName', 'Intechnic');
+ self::$baseItems['u.logged']->SetDBField('LastName', 'Tester');
+ self::$baseItems['u.logged']->SetDBField('Password', 'UnknownOptionTest');
+ self::$baseItems['u.logged']->SetDBField('VerifyPassword', 'UnknownOptionTest');
+ self::$baseItems['u.logged']->SetDBField('Password_plain', 'UnknownOptionTest');
+ self::$baseItems['u.logged']->SetDBField('VerifyPassword_plain', 'UnknownOptionTest');
+ self::$baseItems['u.logged']->SetDBField('Email', 'in-bulletin-test@in-portal.org');
+ self::createBaseItem('u.logged', 'base user');
+
+ $application->StoreVar('admin', 1);
+ $application->SetVar('m_cat_id', self::$categories[0]->GetID());
+ $application->StoreVar('user_id', self::$baseItems['u.logged']->GetID());
+ }
+
+ /**
+ * Object changes to compensate test environment incompatibilities
+ *
+ * @param kDBItem $object Object.
+ *
+ * @return void
+ */
+ protected function prepareObjectForTest(kDBItem $object)
+ {
+ if ( $object->Prefix === 'emoticon' ) {
+ $object->setRequired('EmotionImage', false);
+ }
+ }
+
+ public function createAndUpdateItemDataProvider()
+ {
+ return array(
+ 'Emoticons' => array(
+ 'prefix' => 'emoticon',
+ 'create_hash' => array(
+ 'Name' => 'UnknownOptionTest',
+ 'KeyStroke' => 'AA',
+ 'Enabled' => '0',
+ ),
+ 'update_hash' => array(
+ 'IsPopular' => '0',
+ 'Enabled' => 1,
+ ),
+ ),
+ 'Poll answers' => array(
+ 'prefix' => 'poll-answer',
+ 'create_hash' => array(
+ 'l1_Answer' => 'UnknownOptionTest',
+ 'Status' => '0',
+ ),
+ 'update_hash' => array(
+ 'Status' => 1,
+ ),
+ ),
+ 'Poll comments' => array(
+ 'prefix' => 'poll-comment',
+ 'create_hash' => array(
+ 'CreatedById' => array('base_item' => array('prefix' => 'u.logged', 'field' => 'Email')),
+ 'CommentBody' => 'UnknownOptionTest',
+ 'Status' => 2,
+ ),
+ 'update_hash' => array(
+ 'Status' => 1,
+ ),
+ ),
+ 'Polls' => array(
+ 'prefix' => 'poll',
+ 'create_hash' => array(
+ 'Name' => 'UnknownOptionTest',
+ 'l1_Question' => 'UnknownOptionTest',
+ 'RequireLogin' => 1,
+ 'AllowComments' => '0',
+ 'AllowMultipleVotings' => '0',
+ 'Status' => '0',
+ ),
+ 'update_hash' => array(
+ 'RequireLogin' => '0',
+ 'AllowComments' => 1,
+ 'AllowMultipleVotings' => 1,
+ 'Status' => 1,
+ ),
+ ),
+ 'Private messages' => array(
+ 'prefix' => 'private-message',
+ 'create_hash' => array(
+ 'FromId' => array('base_item' => array('prefix' => 'u.logged', 'field' => 'Email')),
+ 'ToId' => array('base_item' => array('prefix' => 'u.logged', 'field' => 'Email')),
+ 'Body' => 'UnknownOptionTest',
+ 'FolderId' => 1,
+ 'Status' => 1,
+ ),
+ 'update_hash' => array(
+ 'FolderId' => '0',
+ 'Status' => '0',
+ ),
+ ),
+ 'Topics' => array(
+ 'prefix' => 'bb',
+ 'create_hash' => array(
+ 'TopicText' => 'UnknownOptionTest',
+ 'PostingText' => 'UnknownOptionTest',
+ 'OwnerId' => 'root',
+ 'CategoryId' => array('cat_0' => 'CategoryId'),
+ 'NotifyOwnerOnChanges' => 1,
+ 'EditorsPick' => 1,
+ 'Status' => 1,
+ 'TopicType' => '0',
+ 'NewItem' => 1,
+ 'PopItem' => 1,
+ 'HotItem' => 1,
+ ),
+ 'update_hash' => array(
+ 'NotifyOwnerOnChanges' => '0',
+ 'EditorsPick' => '0',
+ 'Status' => 2,
+ 'TopicType' => 1,
+ 'NewItem' => 2,
+ 'PopItem' => 2,
+ 'HotItem' => 2,
+ ),
+ ),
+ );
+ }
+
+}
Index: modules/in-commerce/tests/Functional/InCommerceUnknownOptionTest.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/modules/in-commerce/tests/Functional/InCommerceUnknownOptionTest.php b/modules/in-commerce/tests/Functional/InCommerceUnknownOptionTest.php
new file mode 100644
--- /dev/null (date 1754906942123)
+++ b/modules/in-commerce/tests/Functional/InCommerceUnknownOptionTest.php (date 1754906942123)
@@ -0,0 +1,692 @@
+<?php
+
+
+class InCommerceUnknownOptionTest extends AbstractUnknownOptionTestCase
+{
+
+ /**
+ * @beforeClass
+ */
+ public static function setUpTestBeforeClass()
+ {
+ parent::setUpTestBeforeClass();
+
+ $application =& kApplication::Instance();
+
+ self::$baseItems['u.logged'] = $application->recallObject(
+ 'u.logged',
+ null,
+ array('skip_autoload' => true)
+ );
+ self::$baseItems['u.logged']->Clear();
+ self::$baseItems['u.logged']->SetDBField('FirstName', 'Intechnic');
+ self::$baseItems['u.logged']->SetDBField('LastName', 'Tester');
+ self::$baseItems['u.logged']->SetDBField('Password', 'UnknownOptionTest');
+ self::$baseItems['u.logged']->SetDBField('VerifyPassword', 'UnknownOptionTest');
+ self::$baseItems['u.logged']->SetDBField('Password_plain', 'UnknownOptionTest');
+ self::$baseItems['u.logged']->SetDBField('VerifyPassword_plain', 'UnknownOptionTest');
+ self::$baseItems['u.logged']->SetDBField('Email', 'in-commerce-test@in-portal.org');
+ self::createBaseItem('u.logged', 'first base user');
+
+ $application->StoreVar('admin', 1);
+ $application->StoreVar('user_id', self::$baseItems['u.logged']->GetID());
+
+ self::$baseItems['u.second'] = $application->recallObject(
+ 'u.second',
+ null,
+ array('skip_autoload' => true)
+ );
+ self::$baseItems['u.second']->Clear();
+ self::$baseItems['u.second']->SetDBField('FirstName', 'Intechnic');
+ self::$baseItems['u.second']->SetDBField('LastName', 'Developer');
+ self::$baseItems['u.second']->SetDBField('Password', 'UnknownOptionTest2');
+ self::$baseItems['u.second']->SetDBField('VerifyPassword', 'UnknownOptionTest2');
+ self::$baseItems['u.second']->SetDBField('Password_plain', 'UnknownOptionTest2');
+ self::$baseItems['u.second']->SetDBField('VerifyPassword_plain', 'UnknownOptionTest2');
+ self::$baseItems['u.second']->SetDBField('Email', 'dev@in-portal.org');
+ self::createBaseItem('u.second', 'second base user');
+
+ self::$baseItems['u.third'] = $application->recallObject(
+ 'u.third',
+ null,
+ array('skip_autoload' => true)
+ );
+ self::$baseItems['u.third']->Clear();
+ self::$baseItems['u.third']->SetDBField('FirstName', 'Intechnic');
+ self::$baseItems['u.third']->SetDBField('LastName', 'Affiliate');
+ self::$baseItems['u.third']->SetDBField('Password', 'UnknownOptionTest3');
+ self::$baseItems['u.third']->SetDBField('VerifyPassword', 'UnknownOptionTest3');
+ self::$baseItems['u.third']->SetDBField('Password_plain', 'UnknownOptionTest3');
+ self::$baseItems['u.third']->SetDBField('VerifyPassword_plain', 'UnknownOptionTest3');
+ self::$baseItems['u.third']->SetDBField('Email', 'affiliate@in-portal.org');
+ self::createBaseItem('u.third', 'third base user');
+
+ self::$baseItems['apt.first'] = $application->recallObject(
+ 'apt.first',
+ null,
+ array('skip_autoload' => true)
+ );
+ self::$baseItems['apt.first']->Clear();
+ self::$baseItems['apt.first']->SetDBField('Status', 1);
+ self::$baseItems['apt.first']->SetDBField('Name', 'UnknownOptionsTestBase');
+ self::createBaseItem('apt.first', 'first base affiliate payment type');
+
+ self::$baseItems['apt.second'] = $application->recallObject(
+ 'apt.second',
+ null,
+ array('skip_autoload' => true)
+ );
+ self::$baseItems['apt.second']->Clear();
+ self::$baseItems['apt.second']->SetDBField('Status', 1);
+ self::$baseItems['apt.second']->SetDBField('Name', 'UnknownOptionsTestBase2');
+ self::createBaseItem('apt.second', 'second base affiliate payment type');
+
+ self::$baseItems['ap.first'] = $application->recallObject(
+ 'ap.first',
+ null,
+ array('skip_autoload' => true)
+ );
+ self::$baseItems['ap.first']->Clear();
+ self::$baseItems['ap.first']->SetDBField('Name', 'UnknownOptionsTestBase');
+ self::$baseItems['ap.first']->SetDBField('Enabled', 1);
+ self::createBaseItem('ap.first', 'first base affiliate plan');
+
+ self::$baseItems['ap.second'] = $application->recallObject(
+ 'ap.second',
+ null,
+ array('skip_autoload' => true)
+ );
+ self::$baseItems['ap.second']->Clear();
+ self::$baseItems['ap.second']->SetDBField('Name', 'UnknownOptionsTestBase2');
+ self::$baseItems['ap.second']->SetDBField('Enabled', 1);
+ self::createBaseItem('ap.second', 'second base affiliate plan');
+
+ self::$baseItems['affil.first'] = $application->recallObject(
+ 'affil',
+ null,
+ array('skip_autoload' => true)
+ );
+ self::$baseItems['affil.first']->Clear();
+ self::$baseItems['affil.first']->SetDBField('PortalUserId', self::$baseItems['u.logged']->GetID());
+ self::$baseItems['affil.first']->SetDBField('Status', 1);
+ self::$baseItems['affil.first']->SetDBField('SSN', 'UnknownOptionsTestBase');
+ self::$baseItems['affil.first']->SetDBField('PaymentTypeId', self::$baseItems['apt.first']->GetID());
+ self::$baseItems['affil.first']->SetDBField('AffiliatePlanId', self::$baseItems['ap.first']->GetID());
+ self::createBaseItem('affil.first', 'first base affiliate');
+
+ self::$baseItems['affil.second'] = $application->recallObject(
+ 'affil.second',
+ null,
+ array('skip_autoload' => true)
+ );
+ self::$baseItems['affil.second']->Clear();
+ self::$baseItems['affil.second']->SetDBField('PortalUserId', self::$baseItems['u.second']->GetID());
+ self::$baseItems['affil.second']->SetDBField('Status', 1);
+ self::$baseItems['affil.second']->SetDBField('SSN', 'UnknownOptionsTestBase');
+ self::$baseItems['affil.second']->SetDBField('PaymentTypeId', self::$baseItems['apt.first']->GetID());
+ self::$baseItems['affil.second']->SetDBField('AffiliatePlanId', self::$baseItems['ap.first']->GetID());
+ self::createBaseItem('affil.second', 'second base affiliate');
+
+ self::$baseItems['coup'] = $application->recallObject(
+ 'coup',
+ null,
+ array('skip_autoload' => true)
+ );
+ self::$baseItems['coup']->Clear();
+ self::$baseItems['coup']->SetDBField('Name', 'UnknownOptionsTestBase');
+ self::$baseItems['coup']->SetDBField('Code', 'UnknownOptionsTestBase');
+ self::createBaseItem('coup', 'base coupon');
+
+ self::$baseItems['g.first'] = $application->recallObject(
+ 'g.first',
+ null,
+ array('skip_autoload' => true)
+ );
+ self::$baseItems['g.first']->Clear();
+ self::$baseItems['g.first']->SetDBField('Name', 'UnknownOptionsTestFirst');
+ self::createBaseItem('g.first', 'first base group');
+
+ self::$baseItems['g.second'] = $application->recallObject(
+ 'g.second',
+ null,
+ array('skip_autoload' => true)
+ );
+ self::$baseItems['g.second']->Clear();
+ self::$baseItems['g.second']->SetDBField('Name', 'UnknownOptionsTestSecond');
+ self::createBaseItem('g.second', 'second base group');
+
+ self::$baseItems['d'] = $application->recallObject(
+ 'd',
+ null,
+ array('skip_autoload' => true)
+ );
+ self::$baseItems['d']->Clear();
+ self::$baseItems['d']->SetDBField('Name', 'UnknownOptionsTestBase');
+ self::$baseItems['d']->SetDBField('GroupId', self::$baseItems['g.first']->GetID());
+ self::createBaseItem('d', 'base discount');
+
+ self::$baseItems['manuf.base'] = $application->recallObject(
+ 'manuf.base',
+ null,
+ array('skip_autoload' => true)
+ );
+ self::$baseItems['manuf.base']->Clear();
+ self::$baseItems['manuf.base']->SetDBField('Name', 'UnknownOptionsTestBase');
+ self::createBaseItem('manuf.base', 'base manufacturer');
+
+ self::$baseItems['p'] = $application->recallObject(
+ 'p',
+ null,
+ array('skip_autoload' => true)
+ );
+ self::$baseItems['p']->Clear();
+ self::$baseItems['p']->SetDBField('l1_Name', 'UnknownOptionsTestBase');
+ self::$baseItems['p']->SetDBField('SKU', 'UnknownOptionsTestBase');
+ self::createBaseItem('p', 'base product');
+
+ self::$baseItems['p-rev'] = $application->recallObject(
+ 'p-rev',
+ null,
+ array('skip_autoload' => true)
+ );
+ self::$baseItems['p-rev']->Clear();
+ self::$baseItems['p-rev']->SetDBField('CreatedById', self::$baseItems['u.logged']->GetID());
+ self::$baseItems['p-rev']->SetDBField('ReviewText', 'UnknownOptionsTestBase');
+ self::$baseItems['p-rev']->SetDBField('ItemId', self::$baseItems['p']->GetDBField('ResourceId'));
+ self::$baseItems['p-rev']->SetDBField('Rating', 3);
+ self::$baseItems['p-rev']->SetDBField('Status', 2);
+ self::createBaseItem('p-rev', 'base product review');
+
+ self::$baseItems['s'] = $application->recallObject(
+ 's',
+ null,
+ array('skip_autoload' => true)
+ );
+ self::$baseItems['s']->Clear();
+ self::$baseItems['s']->SetDBField('Code', 'UnknownOptionsTestBase');
+ self::$baseItems['s']->SetDBField('Name', 'UnknownOptionsTestBase');
+ self::$baseItems['s']->SetDBField('SpeedCode', 'UnknownOptionsTestBase');
+ self::createBaseItem('s', 'base shipping type');
+
+ self::$baseItems['ord.base'] = $application->recallObject(
+ 'ord.base',
+ null,
+ array('skip_autoload' => true)
+ );
+ self::$baseItems['ord.base']->Clear();
+ self::$baseItems['ord.base']->SetDBField('Number', '234567');
+ self::$baseItems['ord.base']->SetDBField('SubNumber', '00');
+ self::$baseItems['ord.base']->SetDBField('PortalUserId', self::$baseItems['u.logged']->GetID());
+ self::createBaseItem('ord.base', 'base order');
+ }
+
+ /**
+ * Object changes to compensate test environment incompatibilities
+ *
+ * @param kDBItem $object Object.
+ *
+ * @return void
+ */
+ protected function prepareObjectForTest(kDBItem $object)
+ {
+ if ( $object->Prefix == 'file' ) {
+ $object->setRequired('RealPath', false);
+ }
+ }
+
+ public function createAndUpdateItemDataProvider()
+ {
+ return array(
+ 'Manufacturers' => array(
+ 'prefix' => 'manuf',
+ 'create_hash' => array(
+ 'Name' => 'UnknownOptionTest',
+ 'IsPopular' => 1,
+ 'State' => 'Illinois',
+ 'Country' => 'USA',
+ ),
+ 'update_hash' => array(
+ 'IsPopular' => '0',
+ 'State' => '',
+ 'Country' => '',
+ ),
+ ),
+ 'User Addresses' => array(
+ 'prefix' => 'addr',
+ 'create_hash' => array(
+ 'To' => 'Intechnic Tester',
+ 'Phone' => '0123456789',
+ 'Address1' => 'UnknownOptionsTest',
+ 'City' => 'UnknownOptionsTest',
+ 'Zip' => '60061',
+ 'State' => 'IL',
+ 'Country' => 'USA',
+ 'LastUsedAsBilling' => 1,
+ 'LastUsedAsShipping' => 1,
+ 'IsProfileAddress' => 1,
+ ),
+ 'update_hash' => array(
+ 'State' => '',
+ 'Country' => 'ITA',
+ 'LastUsedAsBilling' => '0',
+ 'LastUsedAsShipping' => '0',
+ 'IsProfileAddress' => '0',
+ ),
+ ),
+ 'Affiliate payment types' => array(
+ 'prefix' => 'apt',
+ 'create_hash' => array(
+ 'Name' => 'UnknownOptionsTest',
+ 'Status' => 1,
+ 'IsPrimary' => 1,
+ ),
+ 'update_hash' => array(
+ 'Status' => '0',
+ 'IsPrimary' => '0',
+ ),
+ ),
+ 'Affiliate payments' => array(
+ 'prefix' => 'apayments.first',
+ 'create_hash' => array(
+ 'Name' => 'UnknownOptionsTest',
+ 'AffiliateId' => array('base_item' => array('prefix' => 'u.logged', 'field' => 'Email')),
+ 'PaymentTypeId' => array(
+ 'base_item' => array('prefix' => 'apt.first', 'field' => 'PaymentTypeId'),
+ ),
+ ),
+ 'update_hash' => array(
+ 'AffiliateId' => array('base_item' => array('prefix' => 'u.second', 'field' => 'Email')),
+ 'PaymentTypeId' => array(
+ 'base_item' => array('prefix' => 'apt.second', 'field' => 'PaymentTypeId'),
+ ),
+ ),
+ ),
+ 'Affiliate plans' => array(
+ 'prefix' => 'ap',
+ 'create_hash' => array(
+ 'Name' => 'UnknownOptionsTest',
+ 'PlanType' => 2,
+ 'ResetInterval' => 2628000,
+ 'PaymentType' => 1,
+ 'Enabled' => 1,
+ 'IsPrimary' => 1,
+ ),
+ 'update_hash' => array(
+ 'PlanType' => 1,
+ 'ResetInterval' => 7884000,
+ 'PaymentType' => '0',
+ 'Enabled' => '0',
+ 'IsPrimary' => '0',
+ ),
+ ),
+ 'Affiliates' => array(
+ 'prefix' => 'affil.test',
+ 'create_hash' => array(
+ 'PortalUserId' => array('base_item' => array('prefix' => 'u.third', 'field' => 'Email')),
+ 'SSN' => 'UnknownOptionsTest',
+ 'AffiliatePlanId' => array(
+ 'base_item' => array('prefix' => 'ap.first', 'field' => 'AffiliatePlanId'),
+ ),
+ 'Status' => 1,
+ 'PaymentTypeId' => array(
+ 'base_item' => array('prefix' => 'apt.first', 'field' => 'PaymentTypeId'),
+ ),
+ ),
+ 'update_hash' => array(
+ 'AffiliatePlanId' => array(
+ 'base_item' => array('prefix' => 'ap.second', 'field' => 'AffiliatePlanId'),
+ ),
+ 'Status' => 2,
+ 'PaymentTypeId' => array(
+ 'base_item' => array('prefix' => 'apt.second', 'field' => 'PaymentTypeId'),
+ ),
+ ),
+ ),
+ 'Coupons' => array(
+ 'prefix' => 'coup.test',
+ 'create_hash' => array(
+ 'Name' => 'UnknownOptionsTest',
+ 'Code' => 'UnknownOptionsTest',
+ 'Status' => 2,
+ 'Type' => 2,
+ ),
+ 'update_hash' => array(
+ 'Status' => 1,
+ 'Type' => 1,
+ ),
+ ),
+ 'Coupon items' => array(
+ 'prefix' => 'coupi',
+ 'create_hash' => array(
+ 'CouponId' => array('base_item' => array('prefix' => 'coup', 'field' => 'CouponId')),
+ 'ItemResourceId' => array('cat_0' => 'ResourceId'),
+ 'ItemType' => 2,
+ ),
+ 'update_hash' => array(
+ 'ItemResourceId' => null,
+ 'ItemType' => '0',
+ ),
+ ),
+ 'Currencies' => array(
+ 'prefix' => 'curr',
+ 'create_hash' => array(
+ 'ISO' => 'BTC',
+ 'Name' => 'Bitcoin',
+ 'Symbol' => 'B',
+ 'SymbolPosition' => '0',
+ 'Status' => 0,
+ 'IsPrimary' => 1,
+ ),
+ 'update_hash' => array(
+ 'SymbolPosition' => 1,
+ 'Status' => 1,
+ 'IsPrimary' => '0',
+ ),
+ ),
+ 'Discounts' => array(
+ 'prefix' => 'd',
+ 'create_hash' => array(
+ 'Name' => 'UnknownOptionsTest',
+ 'Status' => 1,
+ 'GroupId' => array('base_item' => array('prefix' => 'g.first', 'field' => 'Name')),
+ 'Type' => 2,
+ ),
+ 'update_hash' => array(
+ 'Status' => 2,
+ 'GroupId' => array('base_item' => array('prefix' => 'g.second', 'field' => 'Name')),
+ 'Type' => 1,
+ ),
+ ),
+ 'Discount items' => array(
+ 'prefix' => 'di',
+ 'create_hash' => array(
+ 'DiscountId' => array('base_item' => array('prefix' => 'd', 'field' => 'DiscountId')),
+ 'ItemResourceId' => array('cat_0' => 'ResourceId'),
+ 'ItemType' => 2,
+ ),
+ 'update_hash' => array(
+ 'ItemResourceId' => null,
+ 'ItemType' => '0',
+ ),
+ ),
+ 'Products' => array(
+ 'prefix' => 'p.test',
+ 'create_hash' => array(
+ 'l1_Name' => 'UnknownOptionsTest',
+ 'SKU' => 'UnknownOptionsTest',
+ 'AutomaticFilename' => '0',
+ 'ManufacturerId' => array(
+ 'base_item' => array('prefix' => 'manuf.base', 'field' => 'ManufacturerId'),
+ ),
+ 'Status' => 2,
+ 'BackOrder' => 1,
+ 'NewItem' => 1,
+ 'HotItem' => 1,
+ 'PopItem' => 1,
+ 'EditorsPick' => '0',
+ 'Featured' => 1,
+ 'OnSale' => 1,
+ 'Type' => PRODUCT_TYPE_DOWNLOADABLE,
+ 'InventoryStatus' => 1,
+ 'AccessGroupId' => array('base_item' => array('prefix' => 'g.first', 'field' => 'GroupId')),
+ 'AccessDurationType' => 7,
+ 'OptionsSelectionMode' => 1,
+ 'IsRecurringBilling' => 1,
+ 'ShippingMode' => 1,
+ ),
+ 'update_hash' => array(
+ 'AutomaticFilename' => 1,
+ 'ManufacturerId' => '',
+ 'Status' => 1,
+ 'BackOrder' => 2,
+ 'NewItem' => 2,
+ 'HotItem' => 2,
+ 'PopItem' => 2,
+ 'EditorsPick' => 1,
+ 'Featured' => '0',
+ 'OnSale' => '0',
+ 'Type' => PRODUCT_TYPE_TANGIBLE,
+ 'InventoryStatus' => 2,
+ 'AccessGroupId' => '',
+ 'AccessDurationType' => '',
+ 'OptionsSelectionMode' => '0',
+ 'IsRecurringBilling' => '0',
+ 'ShippingMode' => '0',
+ ),
+ ),
+ 'Files' => array(
+ 'prefix' => 'file',
+ 'create_hash' => array(
+ 'FileName' => 'UnknownOptionsTest',
+ 'FilePath' => 'UnknownOptionsTest.txt',
+ 'Status' => 0,
+ ),
+ 'update_hash' => array(
+ 'Status' => 1,
+ ),
+ ),
+ 'Reviews' => array(
+ 'prefix' => 'rev',
+ 'create_hash' => array(
+ 'CreatedById' => array('base_item' => array('prefix' => 'u.logged', 'field' => 'Email')),
+ 'ReviewText' => 'UnknownOptionTest',
+ 'ItemId' => array('base_item' => array('prefix' => 'p', 'field' => 'ResourceId')),
+ 'Rating' => 3,
+ 'Status' => 2,
+ ),
+ 'update_hash' => array(
+ 'Rating' => 5,
+ ),
+ ),
+ 'Spam reports' => array(
+ 'prefix' => 'spam-report',
+ 'create_hash' => array(
+ 'MessageText' => 'UnknownOptionTest',
+ 'ItemPrefix' => 'p-rev',
+ 'ItemId' => array('base_item' => array('prefix' => 'p-rev', 'field' => 'ReviewId')),
+ ),
+ 'update_hash' => array(
+ 'ItemPrefix' => '',
+ ),
+ ),
+ 'Gift certificates' => array(
+ 'prefix' => 'gc',
+ 'create_hash' => array(
+ 'Purchaser' => 'UnknownOptionTest',
+ 'Recipient' => 'UnknownOptionTest',
+ 'RecipientEmail' => 'recipient@in-portal.org',
+ 'RecipientFirstname' => 'Recipient',
+ 'RecipientLastname' => 'Recipient',
+ 'RecipientAddress1' => 'Address',
+ 'RecipientCity' => 'City',
+ 'RecipientState' => 'Illinois',
+ 'RecipientZipcode' => '60061',
+ 'RecipientCountry' => 'USA',
+ 'Code' => 'CODE',
+ 'Amount' => '12',
+ 'Status' => 1,
+ 'SendVia' => 1,
+ ),
+ 'update_hash' => array(
+ 'Status' => 2,
+ 'SendVia' => '0',
+ 'RecipientCountry' => 'AFG',
+ 'RecipientState' => '',
+ ),
+ ),
+ 'Orders' => array(
+ 'prefix' => 'ord.test',
+ 'create_hash' => array(
+ 'Number' => '123456',
+ 'SubNumber' => '00',
+ 'Status' => 1,
+ 'OnHold' => 1,
+ 'PortalUserId' => array('base_item' => array('prefix' => 'u.logged', 'field' => 'Email')),
+ 'BillingState' => 'Illinois',
+ 'BillingCountry' => 'USA',
+ 'PaymentType' => 'Credit Card',
+ 'PaymentCardType' => '2',
+ 'ShippingState' => 'Illinois',
+ 'ShippingCountry' => 'USA',
+ 'ShippingType' => array('base_item' => array('prefix' => 's', 'field' => 'ShippingID')),
+ 'ShippingOption' => 1,
+ 'ShippingGroupOption' => 1,
+ 'TransactionStatus' => 1,
+ 'IsRecurringBilling' => 1,
+ 'ChargeOnNextApprove' => 1,
+ ),
+ 'update_hash' => array(
+ 'Status' => 3,
+ 'OnHold' => '0',
+ 'BillingState' => '',
+ 'BillingCountry' => 'AFG',
+ 'PaymentType' => '',
+ 'PaymentCardType' => '',
+ 'ShippingState' => '',
+ 'ShippingCountry' => '',
+ 'ShippingType' => '',
+ 'ShippingOption' => '0',
+ 'ShippingGroupOption' => '0',
+ 'TransactionStatus' => 2,
+ 'IsRecurringBilling' => '0',
+ 'ChargeOnNextApprove' => '0',
+ ),
+ ),
+ 'Order items' => array(
+ 'prefix' => 'orditems.base',
+ 'create_hash' => array(
+ 'OrderId' => array('base_item' => array('prefix' => 'ord.base', 'field' => 'OrderId')),
+ 'ProductId' => array('base_item' => array('prefix' => 'p', 'field' => 'ProductId')),
+ 'ReturnType' => 2,
+ ),
+ 'update_hash' => array(
+ 'ReturnType' => '',
+ ),
+ ),
+ 'Payment types' => array(
+ 'prefix' => 'ord',
+ 'create_hash' => array(
+ 'Name' => 'UnknownOptionTest',
+ 'Status' => 1,
+ 'IsPrimary' => 1,
+ 'BuiltIn' => 1,
+ 'GatewayId' => 1,
+ 'PlacedOrdersEdit' => 1,
+ ),
+ 'update_hash' => array(
+ 'Status' => '0',
+ 'IsPrimary' => '0',
+ 'BuiltIn' => '0',
+ 'GatewayId' => '0',
+ 'PlacedOrdersEdit' => '0',
+ ),
+ ),
+ 'Product prices' => array(
+ 'prefix' => 'pr',
+ 'create_hash' => array(
+ 'ProductId' => array('base_item' => array('prefix' => 'p', 'field' => 'ProductId')),
+ 'Negotiated' => 1,
+ 'AccessUnit' => 2,
+ 'IsPrimary' => 1,
+ ),
+ 'update_hash' => array(
+ 'Negotiated' => '0',
+ 'AccessUnit' => '',
+ 'IsPrimary' => '0',
+ ),
+ ),
+ 'Product option combinations' => array(
+ 'prefix' => 'poc',
+ 'create_hash' => array(
+ 'ProductId' => array('base_item' => array('prefix' => 'p', 'field' => 'ProductId')),
+ 'Combination' => unserialize('a:2:{i:2;s:3:"Red";i:1;s:2:"36";}'),
+ 'Price' => '0',
+ 'PriceType' => 2,
+ 'WeightType' => 2,
+ 'Availability' => '0',
+ ),
+ 'update_hash' => array(
+ 'PriceType' => 3,
+ 'WeightType' => 3,
+ 'Availability' => 1,
+ ),
+ ),
+ 'Product options' => array(
+ 'prefix' => 'po',
+ 'create_hash' => array(
+ 'ProductId' => array('base_item' => array('prefix' => 'p', 'field' => 'ProductId')),
+ 'Name' => 'UnknownOptionTest',
+ 'OptionType' => 1,
+ 'Required' => '0',
+ 'Listable' => 1,
+ ),
+ 'update_hash' => array(
+ 'OptionType' => 3,
+ 'Required' => 1,
+ 'Listable' => '0',
+ ),
+ ),
+ 'Shipping types' => array(
+ 'prefix' => 's.test',
+ 'create_hash' => array(
+ 'Code' => 'UnknownOptionsTest',
+ 'Name' => 'UnknownOptionTest',
+ 'SpeedCode' => 'UnknownOptionTest',
+ 'LocationFrom' => 3,
+ 'Type' => 2,
+ 'Status' => '0',
+ 'IsFreePromoShipping' => 1,
+ 'InsuranceType' => 1,
+
+ ),
+ 'update_hash' => array(
+ 'LocationFrom' => 4,
+ 'Type' => 1,
+ 'Status' => 1,
+ 'IsFreePromoShipping' => '0',
+ 'InsuranceType' => 2,
+ ),
+ ),
+ 'Shipping quote engines' => array(
+ 'prefix' => 'sqe',
+ 'create_hash' => array(
+ 'ClassName' => 'USPS',
+ 'Status' => 1,
+
+ ),
+ 'update_hash' => array(
+ 'Status' => '0',
+ ),
+ ),
+ 'Taxes' => array(
+ 'prefix' => 'tax',
+ 'create_hash' => array(
+ 'Name' => 'UnknownOptionsTest',
+ 'Type' => 2,
+ 'ApplyToShipping' => 1,
+ 'ApplyToProcessing' => 1,
+
+ ),
+ 'update_hash' => array(
+ 'Type' => 1,
+ 'ApplyToShipping' => '0',
+ 'ApplyToProcessing' => '0',
+ ),
+ ),
+ 'Shipping Zones' => array(
+ 'prefix' => 'z',
+ 'create_hash' => array(
+ 'Name' => 'UnknownOptionsTest',
+ 'Type' => 2,
+ 'CODallowed' => '0',
+
+ ),
+ 'update_hash' => array(
+ 'Type' => 1,
+ 'CODallowed' => 1,
+ ),
+ ),
+ );
+ }
+
+}
Index: modules/in-link/tests/Functional/InLinkUnknownOptionTest.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/modules/in-link/tests/Functional/InLinkUnknownOptionTest.php b/modules/in-link/tests/Functional/InLinkUnknownOptionTest.php
new file mode 100644
--- /dev/null (date 1754906942594)
+++ b/modules/in-link/tests/Functional/InLinkUnknownOptionTest.php (date 1754906942594)
@@ -0,0 +1,134 @@
+<?php
+
+
+class InLinkUnknownOptionTest extends AbstractUnknownOptionTestCase
+{
+
+ /**
+ * @before
+ */
+ public static function setUpTestBeforeClass()
+ {
+ parent::setUpTestBeforeClass();
+
+ $application =& kApplication::Instance();
+
+ self::$baseItems['lst.first'] = $application->recallObject(
+ 'lst.first',
+ null,
+ array('skip_autoload' => true)
+ );
+ self::$baseItems['lst.first']->Clear();
+ self::$baseItems['lst.first']->SetDBField('Name', 'UnknownOptionTestBase');
+ self::createBaseItem('lst.first', 'base listing type');
+
+ self::$baseItems['l.first'] = $application->recallObject(
+ 'l.first',
+ null,
+ array('skip_autoload' => true)
+ );
+ self::$baseItems['l.first']->Clear();
+ self::$baseItems['l.first']->SetDBField('l1_Name', 'UnknownOptionTestBase');
+ self::$baseItems['l.first']->SetDBField('Url', 'https://www.in-portal.org/');
+ self::$baseItems['l.first']->SetDBField('CreatedById', USER_ROOT);
+ self::createBaseItem('l.first', 'base link');
+
+ $application->StoreVar('admin', 1);
+ $application->SetVar('m_cat_id', self::$categories[0]->GetID());
+ }
+
+ public function createAndUpdateItemDataProvider()
+ {
+ return array(
+ 'Link validations' => array(
+ 'prefix' => 'link-validation',
+ 'create_hash' => array(
+ 'ValidationCode' => 400,
+ 'ValidationStatus' => 1,
+ ),
+ 'update_hash' => array(
+ 'ValidationCode' => 403,
+ 'ValidationStatus' => '0',
+ ),
+ ),
+ 'Links' => array(
+ 'prefix' => 'l',
+ 'create_hash' => array(
+ 'l1_Name' => 'UnknownOptionTest',
+ 'Url' => 'https://www.in-portal.org/',
+ 'CreatedById' => 'root',
+ 'AutomaticFilename' => '0',
+ 'Status' => 1,
+ 'EditorsPick' => 1,
+ 'HotItem' => 1,
+ 'PopItem' => 1,
+ 'NewItem' => 1,
+ 'ReciprocalLinkFound' => 1,
+ ),
+ 'update_hash' => array(
+ 'AutomaticFilename' => 1,
+ 'Status' => 2,
+ 'EditorsPick' => '0',
+ 'HotItem' => 2,
+ 'PopItem' => 2,
+ 'NewItem' => 2,
+ 'ReciprocalLinkFound' => '0',
+ ),
+ ),
+ 'Listing types' => array(
+ 'prefix' => 'lst',
+ 'create_hash' => array(
+ 'Name' => 'UnknownOptionTest',
+ 'DurationType' => 3,
+ 'OnPurchaseEdPick' => 1,
+ 'OnPurchaseStatus' => 1,
+ 'OnPurchaseNew' => 1,
+ 'OnPurchasePop' => 1,
+ 'OnPurchaseHot' => 1,
+ 'OnPurchasePriorityAction' => 1,
+ 'OnExpireEdPick' => 1,
+ 'OnExpireNew' => 1,
+ 'OnExpirePop' => 1,
+ 'OnExpireHot' => 1,
+ 'OnExpirePriorityAction' => 1,
+ 'OnExpireStatus' => 1,
+ 'EnableBuying' => '0',
+ 'Recurring' => 1,
+ ),
+ 'update_hash' => array(
+ 'ShopCartName' => 'UnknownOptionTest',
+ 'DurationType' => '',
+ 'OnPurchaseEdPick' => 3,
+ 'OnPurchaseStatus' => 3,
+ 'OnPurchaseNew' => 3,
+ 'OnPurchasePop' => 3,
+ 'OnPurchaseHot' => 3,
+ 'OnPurchasePriorityAction' => 3,
+ 'OnExpireEdPick' => 3,
+ 'OnExpireNew' => 3,
+ 'OnExpirePop' => 3,
+ 'OnExpireHot' => 3,
+ 'OnExpirePriorityAction' => 3,
+ 'OnExpireStatus' => 3,
+ 'EnableBuying' => 1,
+ 'Recurring' => '0',
+ ),
+ ),
+ 'Listings' => array(
+ 'prefix' => 'ls',
+ 'create_hash' => array(
+ 'ListingTypeId' => array('base_item' => array('prefix' => 'lst.first', 'field' => 'Name')),
+ 'ItemResourceId' => array('base_item' => array('prefix' => 'l.first', 'field' => 'ResourceId')),
+ 'Status' => 1,
+ 'PendingRenewal' => 1,
+ ),
+ 'update_hash' => array(
+ 'ListingTypeId' => '',
+ 'Status' => 2,
+ 'PendingRenewal' => '0',
+ ),
+ ),
+ );
+ }
+
+}
Index: modules/in-news/tests/Functional/InNewsUnknownOptionTest.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/modules/in-news/tests/Functional/InNewsUnknownOptionTest.php b/modules/in-news/tests/Functional/InNewsUnknownOptionTest.php
new file mode 100644
--- /dev/null (date 1754906942659)
+++ b/modules/in-news/tests/Functional/InNewsUnknownOptionTest.php (date 1754906942659)
@@ -0,0 +1,43 @@
+<?php
+
+
+class InNewsUnknownOptionTest extends AbstractUnknownOptionTestCase
+{
+
+ public function createAndUpdateItemDataProvider()
+ {
+ return array(
+ 'Articles' => array(
+ 'prefix' => 'n',
+ 'create_hash' => array(
+ 'Title' => 'UnknownOptionTest',
+ 'Body' => 'UnknownOptionTest',
+ 'CategoryId' => array('cat_0' => 'CategoryId'),
+ 'CreatedById' => 'root',
+ 'AutomaticFilename' => '0',
+ 'Status' => 1,
+ 'EditorsPick' => 1,
+ 'LeadStory' => 1,
+ 'LeadCatStory' => 1,
+ 'HotItem' => 1,
+ 'PopItem' => 1,
+ 'NewItem' => 1,
+ 'Archived' => 1,
+ ),
+ 'update_hash' => array(
+ 'CategoryId' => '',
+ 'AutomaticFilename' => 1,
+ 'Status' => 2,
+ 'EditorsPick' => '0',
+ 'LeadStory' => '0',
+ 'LeadCatStory' => '0',
+ 'HotItem' => 2,
+ 'PopItem' => 2,
+ 'NewItem' => 2,
+ 'Archived' => '',
+ ),
+ ),
+ );
+ }
+
+}
Index: .arcconfig
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/.arcconfig b/.arcconfig
--- a/.arcconfig (revision 16830)
+++ b/.arcconfig (date 1754906942718)
@@ -1,5 +1,8 @@
{
"project.name": "in-portal",
"repository.callsign": "INP",
- "phabricator.uri": "https://qa.in-portal.org/"
+ "phabricator.uri": "https://qa.in-portal.org/",
+ "unit.engine": "PhpunitTestEngine",
+ "phpunit_config": "tools/build/inc/phpunit.xml",
+ "unit.phpunit.binary": "vendor/bin/phpunit"
}
Event Timeline
Log In to Comment