Overview

Packages

  • Actions
  • Codegen
  • Controls
    • Base
  • DatabaseAdapters
  • Events
  • None
  • Sessions
  • Tests

Classes

  • AbstractControl_CodeGenerator
  • AjaxTimingForm
  • BasicForm
  • BasicOrmTests
  • BBCodeParser
  • CacheTests
  • CalculatorForm
  • CalculatorWidget
  • ComplexColumn
  • DataRepeaterExample
  • Event
  • ExampleCheckColumn1
  • ExampleCheckColumn2
  • ExampleForm
  • Examples
  • ExampleService
  • ExamplesForm
  • ExampleSingleForm
  • ExpandAsArrayTests
  • HtmlJqDoc
  • InjectForm
  • JavaScriptHelper
  • JqAttributes
  • JqControlGen
  • JqDoc
  • JqIcon
  • Method
  • ModelConnectorTests
  • MyControl
  • MyQSlider_ChangeEvent
  • NavPanel
  • NestedTabForm
  • Option
  • Order
  • PaginatorForm
  • ParamsForm
  • PersistentExampleForm
  • PersonEditPanel
  • PluginEditForm
  • PluginManagerForm
  • Project
  • ProjectEditPanel
  • ProjectListForm
  • ProjectPickerListBox
  • ProjectViewPanel
  • QAbstractCacheProvider
  • QAbstractHtmlTableColumn
  • QAbstractHtmlTableDataColumn
  • QAccordion
  • QAccordion_ActivateEvent
  • QAccordion_BeforeActivateEvent
  • QAccordion_CreateEvent
  • QAccordionBase
  • QAccordionGen
  • QAction
  • QActionControl
  • QAjaxAction
  • QAjaxControlAction
  • QAjaxResponse
  • QAlertAction
  • QApplication
  • QApplicationBase
  • QArchive
  • QAutocomplete
  • QAutocomplete_ChangeEvent
  • QAutocomplete_CloseEvent
  • QAutocomplete_CodeGenerator
  • QAutocomplete_CreateEvent
  • QAutocomplete_FocusEvent
  • QAutocomplete_OpenEvent
  • QAutocomplete_ResponseEvent
  • QAutocomplete_SearchEvent
  • QAutocomplete_SelectEvent
  • QAutocomplete_SourceEvent
  • QAutocompleteBase
  • QAutocompleteBase_CodeGenerator
  • QAutocompleteGen
  • QAutocompleteListItem
  • QBackspaceKeyEvent
  • QBaseClass
  • QBlockControl
  • QBlurControlAction
  • QBlurEvent
  • QBorderCollapse
  • QBorderStyle
  • QBrowserType
  • QButton
  • QButtonBase
  • QCache
  • QCacheDeleteAction
  • QCacheDeleteAllAction
  • QCacheProviderAPC
  • QCacheProviderLocalMemory
  • QCacheProviderLocalMemoryTest
  • QCacheProviderMemcache
  • QCacheProviderNoCache
  • QCacheProviderProxy
  • QCacheSetAction
  • QCalendar
  • QCalendarType
  • QCallType
  • QCausesValidation
  • QCellClickEvent
  • QChangeEvent
  • QCheckBox
  • QCheckBox_CodeGenerator
  • QCheckBoxBase_CodeGenerator
  • QCheckBoxLegacyColumn
  • QCheckBoxList
  • QCheckBoxList_CodeGenerator
  • QCheckBoxListBase_CodeGenerator
  • QClickEvent
  • QCodeGen
  • QCodeGenBase
  • QConfirmAction
  • QContextMenuEvent
  • QControl
  • QControl_CodeGenerator
  • QControlBase
  • QControlBase_CodeGenerator
  • QControlBaseTests
  • QControlCategoryType
  • QControlGrouping
  • QControlLabel
  • QControlProxy
  • QConvertNotation
  • QConvertNotationBase
  • QCrossScripting
  • QCryptography
  • QCss
  • QCssAction
  • QCssClassAction
  • QCssTests
  • QCsvTextBox
  • QCursor
  • QDatabaseBase
  • QDatabaseCodeGen
  • QDatabaseFieldBase
  • QDatabaseFieldType
  • QDatabaseForeignKey
  • QDatabaseIndex
  • QDatabaseResultBase
  • QDatabaseRowBase
  • QDatabaseTests
  • QDataGrid
  • QDataGrid_CheckBoxColumn
  • QDataGrid_CodeGenerator
  • QDataGrid_SortEvent
  • QDataGridBase
  • QDataGridBase_CodeGenerator
  • QDataGridLegacy
  • QDataGridLegacyBase
  • QDataGridLegacyColumn
  • QDataGridLegacyRow
  • QDataGridLegacyRowStyle
  • QDataRepeater
  • QDatepicker
  • QDatepicker_BeforeShowDayEvent
  • QDatepicker_BeforeShowEvent
  • QDatepicker_CalculateWeekEvent
  • QDatepicker_ChangeMonthYearEvent
  • QDatepicker_CloseEvent
  • QDatepicker_SelectEvent
  • QDatepicker_SelectEvent2
  • QDatepickerBase
  • QDatepickerBox
  • QDatepickerBox_BeforeShowDayEvent
  • QDatepickerBox_BeforeShowEvent
  • QDatepickerBox_CalculateWeekEvent
  • QDatepickerBox_ChangeMonthYearEvent
  • QDatepickerBox_CloseEvent
  • QDatepickerBox_CodeGenerator
  • QDatepickerBox_SelectEvent
  • QDatepickerBoxBase
  • QDatepickerBoxBase_CodeGenerator
  • QDatepickerBoxGen
  • QDatepickerGen
  • QDateTime
  • QDateTimePicker
  • QDateTimePicker_CodeGenerator
  • QDateTimePickerBase_CodeGenerator
  • QDateTimePickerFormat
  • QDateTimePickerType
  • QDateTimeSpan
  • QDateTimeTests
  • QDateTimeTextBox
  • QDbBackedFormStateHandler
  • QDbBackedSessionHandler
  • QDialog
  • QDialog_BeforeCloseEvent
  • QDialog_ButtonEvent
  • QDialog_CloseEvent
  • QDialog_CreateEvent
  • QDialog_DragEvent
  • QDialog_DragStartEvent
  • QDialog_DragStopEvent
  • QDialog_FocusEvent
  • QDialog_OpenEvent
  • QDialog_ResizeEvent
  • QDialog_ResizeStartEvent
  • QDialog_ResizeStopEvent
  • QDialogBase
  • QDialogBox
  • QDialogGen
  • QDisplayStyle
  • QDoubleClickEvent
  • QDownArrowKeyEvent
  • QDragDropEvent
  • QDraggable
  • QDraggable_CreateEvent
  • QDraggable_DragEvent
  • QDraggable_StartEvent
  • QDraggable_StopEvent
  • QDraggableBase
  • QDraggableGen
  • QDroppable
  • QDroppable_ActivateEvent
  • QDroppable_CreateEvent
  • QDroppable_DeactivateEvent
  • QDroppable_DropEvent
  • QDroppable_OutEvent
  • QDroppable_OverEvent
  • QDroppableBase
  • QDroppableGen
  • QDropZoneGrouping
  • QEmailAttachment
  • QEmailMessage
  • QEmailServer
  • QEmailStringAttachment
  • QEmailTextBox
  • QEnterKeyEvent
  • QErrorAttribute
  • QEscapeKeyEvent
  • QEvent
  • QFieldset
  • QFile
  • QFileAsset
  • QFileAssetBase
  • QFileAssetDialog
  • QFileAssetType
  • QFileControl
  • QFileFormStateHandler
  • QFilterType
  • QFloatTextBox
  • QFloatTextBox_CodeGenerator
  • QFloatTextBoxBase_CodeGenerator
  • QFocusControlAction
  • QFocusEvent
  • QFocusInEvent
  • QFocusOutEvent
  • QFolder
  • QFontFamily
  • QForm
  • QFormBase
  • QFormGen
  • QFormStateHandler
  • QGridLines
  • QHideCalendarAction
  • QHideDialog
  • QHideDialogBox
  • QHListControl
  • QHListItem
  • QHorizontalAlign
  • QHtml
  • QHtmlAttributeManager
  • QHtmlAttributeManagerBase
  • QHtmlReporter
  • QHtmlTable
  • QHtmlTable_CodeGenerator
  • QHtmlTableBase
  • QHtmlTableCallableColumn
  • QHtmlTableCheckBoxColumn
  • QHtmlTableCheckBoxColumn_ClickEvent
  • QHtmlTableIndexedColumn
  • QHtmlTableLinkColumn
  • QHtmlTableNodeColumn
  • QHtmlTablePropertyColumn
  • QI18n
  • QI18nTests
  • QImageBase
  • QImageBrowser
  • QImageBrowserBase
  • QImageBrowserNav
  • QImageBrowserThumbnails
  • QImageButton
  • QImageControl
  • QImageControlBase
  • QImageFileAsset
  • QImageLabel
  • QImageLabelBase
  • QImageRollover
  • QImageType
  • QIndex
  • QInformixPdoDatabase
  • QInformixPdoDatabaseField
  • QInformixPdoDatabaseResult
  • QInformixPdoDatabaseRow
  • QInputEvent
  • QInstallationValidationResult
  • QInstallationValidator
  • QIntegerTextBox
  • QIntegerTextBox_CodeGenerator
  • QIntegerTextBoxBase_CodeGenerator
  • QJavaScriptAction
  • QJQAction
  • QJQBounceAction
  • QJqButton
  • QJqButton_CreateEvent
  • QJqButtonBase
  • QJqButtonGen
  • QJqCheckBox
  • QJqCheckBox_CreateEvent
  • QJqCheckBoxBase
  • QJqCheckBoxGen
  • QJQHideAction
  • QJQHideEffectAction
  • QJQHighlightAction
  • QJQPulsateAction
  • QJqRadioButton
  • QJqRadioButton_CreateEvent
  • QJqRadioButtonBase
  • QJqRadioButtonGen
  • QJQShakeAction
  • QJQShowAction
  • QJQShowEffectAction
  • QJQSizeAction
  • QJQToggleAction
  • QJQToggleEffectAction
  • QJQTransferAction
  • QJqUiEvent
  • QJqUiPropertyEvent
  • QJsClosure
  • QJsFunction
  • QJsNoQuoteKey
  • QJsParameterList
  • QJsPriority
  • QJsTimer
  • QJsTimerBase
  • QJsVarName
  • QKeyDownEvent
  • QKeyPressEvent
  • QKeyUpEvent
  • QLabel
  • QLabel_CodeGenerator
  • QLabelBase_CodeGenerator
  • QLexer
  • QLinkButton
  • QListBox
  • QListBox_CodeGenerator
  • QListBoxBase
  • QListBoxBase_CodeGenerator
  • QListControl
  • QListControl_CodeGenerator
  • QListControlBase_CodeGenerator
  • QListItem
  • QListItemBase
  • QListItemStyle
  • QManyToManyReference
  • QMenu
  • QMenu_BlurEvent
  • QMenu_CreateEvent
  • QMenu_FocusEvent
  • QMenu_SelectEvent
  • QMenuBase
  • QMenuGen
  • QMimeType
  • QModelConnectorArgumentType
  • QModelConnectorCreateType
  • QModelConnectorEditDlg
  • QModelConnectorOptions
  • QModelConnectorParam
  • QMouseDownEvent
  • QMouseEnterEvent
  • QMouseLeaveEvent
  • QMouseMoveEvent
  • QMouseOutEvent
  • QMouseOverEvent
  • QMouseUpEvent
  • QMultiLevelCacheProvider
  • QMySqlDatabase
  • QMySqlDatabaseField
  • QMySqlDatabaseResult
  • QMySqli5ClusterDatabase
  • QMySqli5Database
  • QMySqli5DatabaseField
  • QMySqli5DatabaseResult
  • QMySqliDatabase
  • QMySqliDatabaseField
  • QMySqliDatabaseResult
  • QMySqliDatabaseRow
  • QNoScriptAjaxAction
  • QNumericTextBox
  • QOnEvent
  • QOracleDatabase
  • QOracleDatabaseField
  • QOracleDatabaseResult
  • QOracleDatabaseRow
  • QOrderedListType
  • QOverflow
  • QPaginatedControl
  • QPaginator
  • QPaginatorBase
  • QPanel
  • QPartialQueryBuilder
  • QPdoDatabase
  • QPdoDatabaseResult
  • QPgConditionILike
  • QPgConditionJsonContains
  • QPgQ
  • QPosition
  • QPostgreSqlDatabase
  • QPostgreSqlDatabaseField
  • QPostgreSqlDatabaseResult
  • QPostgreSqlDatabaseRow
  • QPostgreSqlPdoDatabase
  • QPostgreSqlPdoDatabaseField
  • QPostgreSqlPdoDatabaseResult
  • QPostgreSqlPdoDatabaseRow
  • QProgressbar
  • QProgressbar_ChangeEvent
  • QProgressbar_CompleteEvent
  • QProgressbar_CreateEvent
  • QProgressbarBase
  • QProgressbarGen
  • QQ
  • QQAggregationClause
  • QQAliasTests
  • QQAssociationNode
  • QQAverage
  • QQClause
  • QQColumnNode
  • QQCondition
  • QQConditionAll
  • QQConditionAnd
  • QQConditionBetween
  • QQConditionComparison
  • QQConditionEqual
  • QQConditionExists
  • QQConditionGreaterOrEqual
  • QQConditionGreaterThan
  • QQConditionIn
  • QQConditionIsNotNull
  • QQConditionIsNull
  • QQConditionLessOrEqual
  • QQConditionLessThan
  • QQConditionLike
  • QQConditionLogical
  • QQConditionNone
  • QQConditionNot
  • QQConditionNotBetween
  • QQConditionNotEqual
  • QQConditionNotExists
  • QQConditionNotIn
  • QQConditionNotLike
  • QQConditionOr
  • QQCount
  • QQDistinct
  • QQExpand
  • QQExpandAsArray
  • QQExpandVirtualNode
  • QQFuncTests
  • QQFunctionNode
  • QQGroupBy
  • QQHavingClause
  • QQLimitInfo
  • QQMathNode
  • QQMathOpTests
  • QQMaximum
  • QQMinimum
  • QQNamedValue
  • QQNode
  • QQNoParentNode
  • QQOrderBy
  • QQReverseReferenceNode
  • QQSelect
  • QQSubQueryCountNode
  • QQSubQueryNode
  • QQSubQuerySqlNode
  • QQSum
  • QQTableNode
  • QQuery
  • QQueryBuilder
  • QQueryExpansion
  • QQVirtualNode
  • QRadioButton
  • QRadioButtonList
  • QRadioButtonList_CodeGenerator
  • QRadioButtonListBase_CodeGenerator
  • QRedirectAction
  • QReference
  • QRegex
  • QRegisterClickPositionAction
  • QRepeatDirection
  • QRequestMode
  • QResetTimerAction
  • QResizable
  • QResizable_CreateEvent
  • QResizable_ResizeEvent
  • QResizable_StartEvent
  • QResizable_StopEvent
  • QResizableBase
  • QResizableGen
  • QResizeHandleDirection
  • QRestServiceCodeGen
  • QReverseReference
  • QRssCategory
  • QRssFeed
  • QRssImage
  • QRssItem
  • QSampleControl
  • QSampleTranslation
  • QSelectable
  • QSelectable_CreateEvent
  • QSelectable_SelectedEvent
  • QSelectable_SelectingEvent
  • QSelectable_StartEvent
  • QSelectable_StopEvent
  • QSelectable_UnselectedEvent
  • QSelectable_UnselectingEvent
  • QSelectableBase
  • QSelectableGen
  • QSelectControlAction
  • QSelectEvent
  • QSelectionMode
  • QSelectMenu
  • QSelectMenu_ChangeEvent
  • QSelectMenu_CloseEvent
  • QSelectMenu_CreateEvent
  • QSelectMenu_FocusEvent
  • QSelectMenu_OpenEvent
  • QSelectMenu_SelectEvent
  • QSelectMenuBase
  • QSelectMenuGen
  • QServerAction
  • QServerControlAction
  • QSessionFormStateHandler
  • QSetValueAction
  • QShowCalendarAction
  • QShowDialog
  • QShowDialogBox
  • QSlider
  • QSlider_ChangeEvent
  • QSlider_CodeGenerator
  • QSlider_CreateEvent
  • QSlider_SlideEvent
  • QSlider_StartEvent
  • QSlider_StopEvent
  • QSliderBase
  • QSliderBase_CodeGenerator
  • QSliderGen
  • QSoapMethod
  • QSoapParameter
  • QSoapService
  • QSortable
  • QSortable_ActivateEvent
  • QSortable_BeforeStopEvent
  • QSortable_ChangeEvent
  • QSortable_CreateEvent
  • QSortable_DeactivateEvent
  • QSortable_OutEvent
  • QSortable_OverEvent
  • QSortable_ReceiveEvent
  • QSortable_RemoveEvent
  • QSortable_SortEvent
  • QSortable_StartEvent
  • QSortable_StopEvent
  • QSortable_UpdateEvent
  • QSortableBase
  • QSortableGen
  • QSpinner
  • QSpinner_ChangeEvent
  • QSpinner_CreateEvent
  • QSpinner_SpinEvent
  • QSpinner_StartEvent
  • QSpinner_StopEvent
  • QSpinnerBase
  • QSpinnerGen
  • QSqlColumn
  • QSqLite3PdoDatabase
  • QSqLite3PdoDatabaseField
  • QSqLite3PdoDatabaseResult
  • QSqLite3PdoDatabaseRow
  • QSqlServer2005Database
  • QSqlServer2005DatabaseField
  • QSqlServer2005DatabaseResult
  • QSqlServer2005DatabaseRow
  • QSqlServerDatabase
  • QSqlServerDatabaseField
  • QSqlServerDatabaseResult
  • QSqlServerDatabaseRow
  • QSqlTable
  • QStack
  • QStopPropagationAction
  • QString
  • QStringTest
  • QTabKeyEvent
  • QTabs
  • QTabs_ActivateEvent
  • QTabs_BeforeActivateEvent
  • QTabs_BeforeLoadEvent
  • QTabs_CreateEvent
  • QTabs_LoadEvent
  • QTabsBase
  • QTabsGen
  • QTag
  • QTagStyler
  • QTerminateAction
  • QTestControl
  • QTestForm
  • QTextAlign
  • QTextBox
  • QTextBox_CodeGenerator
  • QTextBoxBase
  • QTextBoxBase_CodeGenerator
  • QTextMode
  • QTimer
  • QTimerExpiredEvent
  • QTimerTests
  • QToggleCssClassAction
  • QToggleDisplayAction
  • QToggleEnableAction
  • QTranslationPoParser
  • QTreeNav
  • QTreeNavItem
  • QType
  • QTypeTable
  • QTypeTests
  • QUnitTestCaseBase
  • QUnorderedListStyle
  • QUpArrowKeyEvent
  • QUrlTextBox
  • QVerticalAlign
  • QVirtualAttributeColumn
  • QWaitIcon
  • QWatcher
  • QWatcherBase
  • QWatcherCache
  • QWatcherDB
  • QWatcherNone
  • QWriteBox
  • RecordsSummary
  • RefreshForm
  • SampleComposite
  • SampleForm
  • SelectableLabel
  • SelectForm
  • SpeedForm
  • TestImageBrowser
  • UrlForm

Interfaces

  • ICacheAction
  • QDataList_CodeGenerator_Interface
  • QTranslationBase

Traits

  • QDataBinder
  • QListItemManager
  • QModelTrait

Exceptions

  • QCallerException
  • QCrossScriptingException
  • QCryptographyException
  • QDatabaseExceptionBase
  • QDataBindException
  • QDateTimeNullException
  • QEmailException
  • QIndexOutOfRangeException
  • QInformixPdoDatabaseException
  • QInvalidCastException
  • QInvalidFormStateException
  • QMySqliDatabaseException
  • QOptimisticLockingException
  • QOracleDatabaseException
  • QPdoDatabaseException
  • QPoParserException
  • QPostgreSqlDatabaseException
  • QPostgreSqlPdoDatabaseException
  • QRemoteAdminDeniedException
  • QSqLite3PdoDatabaseException
  • QSqlServer2005DatabaseException
  • QSqlServerDatabaseException
  • QUndefinedMethodException
  • QUndefinedPrimaryKeyException
  • QUndefinedPropertyException

Functions

  • __database_check_error
  • __QForm_EvaluateTemplate_ObHandler
  • _b
  • _indent
  • _nl
  • _p
  • _r
  • _t
  • _tp
  • _tr
  • array_trim
  • beginsWith
  • CamelCaseFromDash
  • CastToInt
  • DataGridEvalHandleError
  • DisplayMonospacedText
  • endsWith
  • GO_BACK
  • jq_anytime_gen
  • jq_control_gen
  • jq_inc_gen
  • jq_indent
  • PrintExplainStatement
  • PrintInstructions
  • QcubedHandleCodeGenParseError
  • QcubedHandleError
  • QcubedHandleException
  • QCubedShutdown
  • QDateTimeErrorHandler
  • trimOffEnd
  • trimOffFront
  • Overview
  • Package
  • Class
  1: <?php
  2: 
  3: /**
  4:  * 
  5:  * @package Tests
  6:  */
  7: if(!class_exists('Person')){
  8:     require_once __INCLUDES__ .'/model/Person.class.php';
  9: }
 10: if(!class_exists('Project')){
 11:     require_once __INCLUDES__ .'/model/Project.class.php';
 12: }
 13: if(!class_exists('Login')){
 14:     require_once __INCLUDES__ .'/model/Login.class.php';
 15: }
 16: if(!class_exists('Milestone')){
 17:     require_once __INCLUDES__ .'/model/Milestone.class.php';
 18: }
 19: if(!class_exists('Address')){
 20:     require_once __INCLUDES__ .'/model/Address.class.php';
 21: }
 22: 
 23: if(!class_exists('QAbstractCacheProvider')){
 24:     include_once __QCUBED_CORE__ . '/framework/QCacheProviderLocalMemory.class.php';
 25: }
 26: 
 27: /**
 28:  * Cache provider like QCacheProviderLocalMemory, but with public access to the underlying array.
 29:  */
 30: class QCacheProviderLocalMemoryTest extends QCacheProviderLocalMemory {
 31:     /**
 32:      * @var array
 33:      * @access public We need it to be public to enumerate cached values.
 34:      */
 35:     public $arrLocalCache;
 36: 
 37: }
 38: 
 39: // test cases:
 40: // 1. roll back after save should leave cache empty
 41: // 2. roll back after save should leave object in a cache unchanged (object already were in a cache)
 42: // 3. commit after save should place modified object into the cache
 43: // 3a. commit after save should place modified object into the cache (object already were in a cache)
 44: // 4. commit after the object delete should leave the cache empty
 45: // 4a. commit after the object delete should leave the cache empty (cache was populated with object to be deleted before transaction begins)
 46: // 5. roll back after the object delete should leave the cache empty
 47: // 5a. roll back after the object delete should leave object in a cache unchanged (cache was populated with object to be deleted before transaction begins)
 48: //
 49: class QDatabaseTests extends QUnitTestCaseBase {
 50:     // 1. roll back after save should leave cache empty
 51:     public function testTransactionWithCacheSaveRollBack() {
 52:         Person::GetDatabase()->Caching = true;
 53:         // establish a cache object we can work with
 54:         $objCacheProvider = QApplication::$objCacheProvider;
 55:         QApplication::$objCacheProvider = new QCacheProviderLocalMemoryTest(array());
 56:         // cache is empty now
 57:         
 58:         $strPerson1_FirstName = null;
 59:         try {
 60:             Person::GetDatabase()->TransactionBegin();
 61:             // cache is substituted
 62:             $objPerson1 = Person::Load(1);
 63:             // person object is placed in the temporary cache
 64:             $strPerson1_FirstName = $objPerson1->FirstName;
 65:             $objPerson1->FirstName = "New value 1";
 66:             $objPerson1->Save();
 67:             // person object is removed from the temporary cache
 68:             
 69:             // imitate the load made by other client.
 70:             // It populates the cache with old value.
 71:             $objPerson1a = Person::Load(1);
 72:             // old person value is placed in the temporary cache
 73: 
 74:             throw new Exception("DATABASE ERROR!"); // imitate the database error in the next Save call
 75:             
 76:             Person::GetDatabase()->TransactionCommit();
 77:         } catch(Exception $ex) {
 78:             Person::GetDatabase()->TransactionRollBack();
 79:             // temporary cache is throwed out. the empty application cache is restored.
 80:         }
 81:         $this->assertEquals(0, count(QApplication::$objCacheProvider->arrLocalCache), "Object is not placed in a cache because of the transaction roll back.");
 82: 
 83:         // restore the actual cache object
 84:         QApplication::$objCacheProvider = $objCacheProvider;
 85:     }
 86:     
 87:     // 2. roll back after save should leave object in a cache unchanged (object already were in a cache)
 88:     public function testTransactionWithCacheSaveRollBack2() {
 89:         Person::GetDatabase()->Caching = true;
 90:         // establish a cache object we can work with
 91:         $objCacheProvider = QApplication::$objCacheProvider;
 92:         QApplication::$objCacheProvider = new QCacheProviderLocalMemoryTest(array());
 93:         // cache is empty now
 94:         
 95:         $objPerson1z = Person::Load(1);
 96:         // original person value is placed in a cache
 97:         $strPerson1_FirstName = $objPerson1z->FirstName;
 98:         try {
 99:             Person::GetDatabase()->TransactionBegin();
100:             // cache is substituted
101:             $objPerson1 = Person::Load(1);
102:             // person object is placed in the temporary cache
103:             $objPerson1->FirstName = "New value 1";
104:             $objPerson1->Save();
105:             // person object is removed from the temporary cache
106:             
107:             // imitate the load made by other client.
108:             // It populates the cache with old value.
109:             $objPerson1a = Person::Load(1);
110:             // old person value is placed in the temporary cache
111: 
112:             throw new Exception("DATABASE ERROR!"); // imitate the database error in the next Save call
113: 
114:             Person::GetDatabase()->TransactionCommit();
115:         } catch(Exception $ex) {
116:             Person::GetDatabase()->TransactionRollBack();
117:             // temporary cache is throwed out. the empty application cache is restored.
118:         }
119:         $this->assertEquals(1, count(QApplication::$objCacheProvider->arrLocalCache), "Object is not dropped from a cache because of the transaction roll back.");
120:         foreach (QApplication::$objCacheProvider->arrLocalCache as $objPerson) {
121:             $this->assertEquals($strPerson1_FirstName, $objPerson->FirstName, "Object is not modified in a cache because of the transaction roll back.");
122:         }
123: 
124:         // restore the actual cache object
125:         QApplication::$objCacheProvider = $objCacheProvider;
126:     }
127:     
128:     // 3. commit after save should place modified object into the cache
129:     public function testTransactionWithCacheSaveCommit() {
130:         Person::GetDatabase()->Caching = true;
131:         // establish a cache object we can work with
132:         $objCacheProvider = QApplication::$objCacheProvider;
133:         QApplication::$objCacheProvider = new QCacheProviderLocalMemoryTest(array());
134:         // cache is empty now
135:         
136:         try {
137:             Person::GetDatabase()->TransactionBegin();
138:             // cache is substituted
139:             $objPerson1 = Person::Load(1);
140:             // person object is placed in the temporary cache
141:             $objPerson1->FirstName = "New value 1";
142:             $objPerson1->Save();
143:             // person object is removed from the temporary cache
144:             
145:             Person::GetDatabase()->TransactionCommit();
146:             // new person value is placed in the database
147:         } catch(Exception $ex) {
148:             Person::GetDatabase()->TransactionRollBack();
149:         }
150:         
151:         $this->assertEquals(0, count(QApplication::$objCacheProvider->arrLocalCache), "Object is not placed in a cache after save because of the transaction commit.");
152:         
153:         // imitate the load made by other client.
154:         // It populates the cache with new value.
155:         $objPerson1a = Person::Load(1);
156:         // new person value is placed in the application cache
157:         
158:         $this->assertEquals(1, count(QApplication::$objCacheProvider->arrLocalCache), "Object is added to a cache because of the transaction commit.");
159:         foreach (QApplication::$objCacheProvider->arrLocalCache as $objPerson) {
160:             $this->assertEquals("New value 1", $objPerson->FirstName, "Object is modified in a cache because of the transaction commit.");
161:         }
162:         
163:         // Restore the original value to not break other tests
164:         $objPerson1a->FirstName = "John";
165:         $objPerson1a->Save();
166: 
167:         // restore the actual cache object
168:         QApplication::$objCacheProvider = $objCacheProvider;
169:     }
170:     
171:     // 3a. commit after save should place modified object into the cache (object already were in a cache)
172:     public function testTransactionWithCacheSaveCommit2() {
173:         Person::GetDatabase()->Caching = true;
174:         // establish a cache object we can work with
175:         $objCacheProvider = QApplication::$objCacheProvider;
176:         QApplication::$objCacheProvider = new QCacheProviderLocalMemoryTest(array());
177:         // cache is empty now
178:         
179:         $objPerson1z = Person::Load(1);
180:         // original person value is placed in a cache
181:         $strPerson1_FirstName = $objPerson1z->FirstName;
182:         try {
183:             Person::GetDatabase()->TransactionBegin();
184:             // cache is substituted
185:             $objPerson1 = Person::Load(1);
186:             // person object is placed in the temporary cache
187:             $objPerson1->FirstName = "New value 1";
188:             $objPerson1->Save();
189:             // person object is removed from the temporary cache
190:             
191:             Person::GetDatabase()->TransactionCommit();
192:             // new person value is placed in the database
193:         } catch(Exception $ex) {
194:             Person::GetDatabase()->TransactionRollBack();
195:         }
196:         
197:         $this->assertEquals(0, count(QApplication::$objCacheProvider->arrLocalCache), "Object is dropped from a cache because of the transaction commit.");
198:         
199:         // imitate the load made by other client.
200:         // It populates the cache with new value.
201:         $objPerson1a = Person::Load(1);
202:         // new person value is placed in the application cache
203:         
204:         $this->assertEquals(1, count(QApplication::$objCacheProvider->arrLocalCache), "Object is not dropped from a cache because of the transaction commit.");
205:         foreach (QApplication::$objCacheProvider->arrLocalCache as $objPerson) {
206:             $this->assertEquals("New value 1", $objPerson->FirstName, "Object is modified in a cache because of the transaction commit.");
207:         }
208:         
209:         // Restore the original value to not break other tests
210:         $objPerson1a->FirstName = "John";
211:         $objPerson1a->Save();
212: 
213:         // restore the actual cache object
214:         QApplication::$objCacheProvider = $objCacheProvider;
215:     }
216:     
217:     // 4. commit after the object delete should leave the cache empty
218:     public function testTransactionWithCacheDeleteCommit() {
219:         // create an object in the database
220:         $objPerson1z = new Person;
221:         $objPerson1z->FirstName = "test";
222:         $objPerson1z->LastName = "test";
223:         $objPerson1z->Save();
224:         
225:         Person::GetDatabase()->Caching = true;
226:         // establish a cache object we can work with
227:         $objCacheProvider = QApplication::$objCacheProvider;
228:         QApplication::$objCacheProvider = new QCacheProviderLocalMemoryTest(array());
229:         // cache is empty now
230:         
231:         try {
232:             Person::GetDatabase()->TransactionBegin();
233:             // cache is substituted
234:             $objPerson1 = Person::Load($objPerson1z->Id);
235:             // person object is placed in the temporary cache
236:             $objPerson1->Delete();
237:             // person object is removed from the temporary cache
238:             
239:             Person::GetDatabase()->TransactionCommit();
240:             // person value is removed from the database
241:         } catch(Exception $ex) {
242:             Person::GetDatabase()->TransactionRollBack();
243:         }
244:         
245:         $this->assertEquals(0, count(QApplication::$objCacheProvider->arrLocalCache), "Object is not placed in a cache after delete because of the transaction commit.");
246:         
247:         // restore the actual cache object
248:         QApplication::$objCacheProvider = $objCacheProvider;
249:     }
250:     
251:     // 4a. commit after the object delete should leave the cache empty (cache was populated with object to be deleted before transaction begins)
252:     public function testTransactionWithCacheDeleteCommit2() {
253:         Person::GetDatabase()->Caching = true;
254:         // establish a cache object we can work with
255:         $objCacheProvider = QApplication::$objCacheProvider;
256:         QApplication::$objCacheProvider = new QCacheProviderLocalMemoryTest(array());
257:         // cache is empty now
258:         
259:         // create an object in the database
260:         $objPerson1z = new Person;
261:         $objPerson1z->FirstName = "test";
262:         $objPerson1z->LastName = "test";
263:         $objPerson1z->Save();
264:         
265:         Person::Load($objPerson1z->Id);
266:         // the person object is placed in a cache
267:         $this->assertEquals(1, count(QApplication::$objCacheProvider->arrLocalCache), "Object is placed in a cache.");
268:         
269:         try {
270:             Person::GetDatabase()->TransactionBegin();
271:             // cache is substituted
272:             $objPerson1 = Person::Load($objPerson1z->Id);
273:             // person object is placed in the temporary cache
274:             $objPerson1->Delete();
275:             // person object is removed from the temporary cache
276:             
277:             Person::GetDatabase()->TransactionCommit();
278:             // person value is removed from the database
279:         } catch(Exception $ex) {
280:             Person::GetDatabase()->TransactionRollBack();
281:         }
282:         
283:         $this->assertEquals(0, count(QApplication::$objCacheProvider->arrLocalCache), "Object is removed from a cache after delete because of the transaction commit.");
284:         
285:         // restore the actual cache object
286:         QApplication::$objCacheProvider = $objCacheProvider;
287:     }
288:     
289:     // 5. roll back after the object delete should leave the cache empty
290:     public function testTransactionWithCacheDeleteRollBack() {
291:         // create an object in the database
292:         $objPerson1z = new Person;
293:         $objPerson1z->FirstName = "test";
294:         $objPerson1z->LastName = "test";
295:         $objPerson1z->Save();
296:         
297:         Person::GetDatabase()->Caching = true;
298:         // establish a cache object we can work with
299:         $objCacheProvider = QApplication::$objCacheProvider;
300:         QApplication::$objCacheProvider = new QCacheProviderLocalMemoryTest(array());
301:         // cache is empty now
302:         
303:         try {
304:             Person::GetDatabase()->TransactionBegin();
305:             // cache is substituted
306:             $objPerson1 = Person::Load($objPerson1z->Id);
307:             // person object is placed in the temporary cache
308:             $objPerson1->Delete();
309:             // person object is removed from the temporary cache
310:             
311:             throw new Exception("DATABASE ERROR!"); // imitate the database error in the next Save call
312:             
313:             Person::GetDatabase()->TransactionCommit();
314:         } catch(Exception $ex) {
315:             Person::GetDatabase()->TransactionRollBack();
316:             // actual cache leaved unchanged
317:         }
318:         
319:         $this->assertEquals(0, count(QApplication::$objCacheProvider->arrLocalCache), "Object is not placed in a cache after delete because of the transaction roll back.");
320:         
321:         // restore the actual cache object
322:         QApplication::$objCacheProvider = $objCacheProvider;
323:         
324:         // clean up
325:         $objPerson1 = Person::Load($objPerson1z->Id);
326:         // person object is placed in the temporary cache
327:         $objPerson1->Delete();
328:     }
329: 
330:     // 5a. roll back after the object delete should leave object in a cache unchanged (cache was populated with object to be deleted before transaction begins)
331:     public function testTransactionWithCacheDeleteRollBack2() {
332:         Person::GetDatabase()->Caching = true;
333:         // establish a cache object we can work with
334:         $objCacheProvider = QApplication::$objCacheProvider;
335:         QApplication::$objCacheProvider = new QCacheProviderLocalMemoryTest(array());
336:         // cache is empty now
337:         
338:         // create an object in the database
339:         $objPerson1z = new Person;
340:         $objPerson1z->FirstName = "test";
341:         $objPerson1z->LastName = "test";
342:         $objPerson1z->Save();
343:         
344:         Person::Load($objPerson1z->Id);
345:         // the person object is placed in a cache
346:         $this->assertEquals(1, count(QApplication::$objCacheProvider->arrLocalCache), "Object is placed in a cache.");
347:         
348:         try {
349:             Person::GetDatabase()->TransactionBegin();
350:             // cache is substituted
351:             $objPerson1 = Person::Load($objPerson1z->Id);
352:             // person object is placed in the temporary cache
353:             $objPerson1->Delete();
354:             // person object is removed from the temporary cache
355:             
356:             throw new Exception("DATABASE ERROR!"); // imitate the database error in the next Save call
357:             
358:             Person::GetDatabase()->TransactionCommit();
359:         } catch(Exception $ex) {
360:             Person::GetDatabase()->TransactionRollBack();
361:             // actual cache leaved unchanged
362:         }
363:         
364:         $this->assertEquals(1, count(QApplication::$objCacheProvider->arrLocalCache), "Object is NOT removed from a cache after delete because of the transaction roll back.");
365:         
366:         // restore the actual cache object
367:         QApplication::$objCacheProvider = $objCacheProvider;
368:         
369:         // clean up
370:         $objPerson1 = Person::Load($objPerson1z->Id);
371:         // person object is placed in the temporary cache
372:         $objPerson1->Delete();
373:     }
374: }
API documentation generated by ApiGen