Page MenuHomeIn-Portal Phabricator

INP-1886 - Add value-clearing support for "kDateFormatter::UpdateSubFields" method
Changes PlannedPublic

Authored by alex on Tue, Nov 19, 11:19 AM.

Details

Reviewers
erik
Test Plan

Code:

/** @var CategoriesItem $category */
$category = $application->recallObject('c', null, array('skip_autoload' => true));
$category->Clear();

// Set date from virtual.
$category->SetDBFieldsFromHash(array(
	'CreatedOn_date' => 1732023005,
	'CreatedOn_time' => 1732023005,
));
$category->UpdateFormattersMasterFields();
$test_result = $category->GetDBField('CreatedOn') == 1732023005 && $category->GetDBField('CreatedOn_date') == 1732023005 && $category->GetDBField('CreatedOn_time') == 1732023005;
echo 'Test 1: ' . ($test_result ? 'OK' : 'FAILED') . '<br/>' . PHP_EOL;

// Clear date from virtual.
$category->SetDBFieldsFromHash(array(
	'CreatedOn_date' => null,
	'CreatedOn_time' => null,
));
$category->UpdateFormattersMasterFields();
$test_result = $category->GetDBField('CreatedOn') === null && $category->GetDBField('CreatedOn_date') === null && $category->GetDBField('CreatedOn_time') === null;
echo 'Test 2: ' . ($test_result ? 'OK' : 'FAILED') . '<br/>' . PHP_EOL;

// Set date from combined.
$category->SetDBFieldsFromHash(array(
	'CreatedOn' => 1732023005,
	'CreatedOn_date' => 123,
	'CreatedOn_time' => 123,
	'CreatedOn_combined' => 1,
));
$category->UpdateFormattersMasterFields();
$test_result = $category->GetDBField('CreatedOn') == 1732023005 && $category->GetDBField('CreatedOn_date') == 123 && $category->GetDBField('CreatedOn_time') == 123;
echo 'Test 3: ' . ($test_result ? 'OK' : 'FAILED') . '<br/>' . PHP_EOL;

// Clear date from combined.
$category->SetDBFieldsFromHash(array(
	'CreatedOn' => null,
	'CreatedOn_date' => 456,
	'CreatedOn_time' => 456,
	'CreatedOn_combined' => 1,
));
$category->UpdateFormattersMasterFields();
$test_result = $category->GetDBField('CreatedOn') === null && $category->GetDBField('CreatedOn_date') == 456 && $category->GetDBField('CreatedOn_time') == 456;
echo 'Test 4: ' . ($test_result ? 'OK' : 'FAILED') . '<br/>' . PHP_EOL;

// Set date directly.
$category->SetDBFieldsFromHash(array(
	'CreatedOn' => 1732023005,
));
$category->UpdateFormattersSubFields(array('CreatedOn'));
$test_result = $category->GetDBField('CreatedOn') == 1732023005 && $category->GetDBField('CreatedOn_date') == 1732023005 && $category->GetDBField('CreatedOn_time') == 1732023005;
echo 'Test 5: ' . ($test_result ? 'OK' : 'FAILED') . '<br/>' . PHP_EOL;

// Clear date directly.
$category->SetDBFieldsFromHash(array(
	'CreatedOn' => null,
));
$category->UpdateFormattersSubFields(array('CreatedOn'));
$test_result = $category->GetDBField('CreatedOn') === null && $category->GetDBField('CreatedOn_date') === null && $category->GetDBField('CreatedOn_time') === null;
echo 'Test 6: ' . ($test_result ? 'OK' : 'FAILED') . '<br/>' . PHP_EOL;

Test Plan

  1. in the IDE replace the $application->Run(); line in the /index.php with the above-shown code and save changes
  2. open the /index.php in the Web Browser
  3. confirm, that all tests pass

Diff Detail

Repository
rINP In-Portal
Branch
/in-portal/branches/5.2.x
Lint
Lint OK
Unit
No Unit Test Coverage
Build Status
Buildable 1336
Build 1336: arc lint + arc unit

Event Timeline

alex created this revision.Tue, Nov 19, 11:19 AM
alex requested review of this revision.Tue, Nov 19, 11:19 AM
alex edited the test plan for this revision. (Show Details)Tue, Nov 19, 11:22 AM
alex added a project: Restricted Project.
alex planned changes to this revision.Thu, Nov 21, 12:56 AM

New data came in during LIVE testing: the kDBItem::UpdateFormattersSubFields is used too aggressively, which results in clearing already populated date/time virtual fields. Need to adjust code/test plan for that.