From 3112d63fd0d52308944881cd189a5aacc98d0dac Mon Sep 17 00:00:00 2001 From: John Mertic Date: Fri, 20 Jul 2012 12:55:45 -0400 Subject: [PATCH] Release 6.5.1 --- ModuleInstall/ModuleInstaller.php | 153 +++- .../PackageManager/PackageManager.php | 24 +- .../PackageManager/PackageManagerDisplay.php | 11 +- .../PackageManager/tpls/PackageForm.tpl | 7 +- Zend/Oauth/Provider.php | 2 +- cache/include/javascript/sugar_field_grp.js | 17 +- cache/include/javascript/sugar_grp1.js | 22 +- cache/include/javascript/sugar_grp1_jquery.js | 2 +- cache/include/javascript/sugar_grp_emails.js | 17 +- cache/include/javascript/sugar_grp_jsolait.js | 3 +- .../include/javascript/sugar_grp_quickcomp.js | 14 +- data/BeanFactory.php | 18 +- data/Link2.php | 3 +- .../EmailAddressRelationship.php | 15 + data/Relationships/M2MRelationship.php | 21 + data/Relationships/One2MBeanRelationship.php | 36 +- data/Relationships/One2MRelationship.php | 33 +- data/Relationships/SugarRelationship.php | 25 + data/SugarBean.php | 90 ++- download.php | 8 +- files.md5 | 527 ++++++------- include/EditView/EditView2.php | 4 + include/EditView/SubpanelQuickCreate.php | 55 +- include/ListView/ListView.php | 30 +- include/ListView/ListViewData.php | 3 + include/ListView/ListViewDisplay.php | 6 +- include/ListView/ListViewPagination.tpl | 4 +- include/MVC/SugarApplication.php | 5 +- include/MVC/View/SugarView.php | 8 +- include/MVC/View/views/view.detail.php | 2 +- include/MVC/View/views/view.edit.php | 2 +- include/MVC/View/views/view.list.php | 13 +- include/MVC/View/views/view.popup.php | 10 +- include/Popups/tpls/PopupGeneric.tpl | 2 +- include/SearchForm/SearchForm.php | 4 +- include/SearchForm/SearchForm2.php | 19 +- .../plugins/function.sugar_action_menu.php | 42 +- .../Smarty/plugins/function.sugar_menu.php | 2 +- .../plugins/function.sugar_number_format.php | 4 +- .../Smarty/plugins/function.sugar_phone.php | 2 +- include/SubPanel/SubPanel.php | 1 - include/SubPanel/SubPanelDefinitions.php | 55 +- include/SubPanel/SubPanelTiles.js | 3 +- include/SubPanel/SubPanelTiles.php | 12 +- include/SugarCharts/Jit/js/sugarCharts.js | 12 +- include/SugarCharts/SugarChart.php | 3 +- .../Fields/Datetime/SugarFieldDatetime.php | 13 +- .../Fields/Datetimecombo/Datetimecombo.js | 17 +- .../Datetimecombo/SugarFieldDatetimecombo.php | 54 +- include/SugarFields/Fields/Link/EditView.tpl | 6 +- .../SugarFields/Fields/Parent/SearchView.tpl | 2 - .../Fields/Relate/SugarFieldRelate.php | 2 +- include/SugarFolders/SugarFolders.php | 6 +- .../SugarObjects/templates/file/vardefs.php | 3 +- .../SugarObjects/templates/issue/vardefs.php | 1 + .../person/metadata/subpanels/default.php | 1 + include/SugarTheme/SugarTheme.php | 8 +- include/Sugar_Smarty.php | 18 +- include/clean.php | 7 +- .../connectors/utils/ConnectorHtmlHelper.php | 168 +++++ .../utils/ConnectorHtmlHelperFactory.php | 65 ++ include/connectors/utils/ConnectorUtils.php | 113 +-- include/database/DBManager.php | 27 +- include/database/MssqlManager.php | 32 +- include/database/MysqlManager.php | 5 +- include/generic/LayoutManager.php | 12 + include/generic/Save2.php | 63 +- include/generic/SugarWidgets/SugarWidget.php | 10 + .../SugarWidgets/SugarWidgetFielddate.php | 14 + .../SugarWidgets/SugarWidgetFielddatetime.php | 6 +- .../SugarWidgets/SugarWidgetFieldenum.php | 20 +- .../SugarWidgetFieldmultienum.php | 41 +- .../SugarWidgets/SugarWidgetFieldrelate.php | 10 +- .../SugarWidgets/SugarWidgetReportField.php | 2 +- .../SugarWidgetSubPanelDetailViewLink.php | 4 + .../SugarWidgetSubPanelRemoveButton.php | 5 +- ...garWidgetSubPanelTopArchiveEmailButton.php | 4 +- .../SugarWidgetSubPanelTopButton.php | 38 +- ...garWidgetSubPanelTopComposeEmailButton.php | 6 + ...ubPanelTopCreateCampaignLogEntryButton.php | 29 +- .../SugarWidgetSubPanelTopSelectButton.php | 28 +- ...rWidgetSubPanelTopSelectContactsButton.php | 5 - ...ugarWidgetSubPanelTopSelectUsersButton.php | 5 - include/globalControlLinks.php | 1 + include/javascript/ajaxUI.js | 4 +- include/javascript/jquery/jquery.sugarMenu.js | 2 +- include/javascript/jsclass_async.js | 3 +- include/javascript/quickCompose.js | 2 +- include/javascript/sugar_3.js | 14 +- include/language/en_us.lang.php | 9 +- include/modules.php | 1 - include/php-sql-parser.php | 2 +- include/upload_file.php | 68 ++ include/utils.php | 92 ++- include/utils/autoloader.php | 2 +- include/utils/file_utils.php | 11 + include/utils/security_utils.php | 2 +- include/utils/sugar_file_utils.php | 10 +- install/confirmSettings.php | 26 +- install/install_utils.php | 10 + install/language/en_us.lang.php | 1 + json_server.php | 6 +- jssource/JSGroupings.php | 1 - .../include/SubPanel/SubPanelTiles.js | 8 +- .../include/SugarCharts/Jit/js/sugarCharts.js | 33 + .../Fields/Datetimecombo/Datetimecombo.js | 68 +- .../src_files/include/javascript/ajaxUI.js | 7 + .../include/javascript/jsclass_async.js | 8 +- .../include/javascript/quickCompose.js | 1 + .../src_files/include/javascript/sugar_3.js | 32 +- jssource/src_files/modules/Calendar/Cal.js | 6 +- .../modules/Meetings/duration_dependency.js | 115 +-- metadata/audit_templateMetaData.php | 2 +- modules/ACL/ACLController.php | 6 +- modules/ACLActions/ACLAction.php | 17 +- modules/Accounts/Account.php | 11 +- modules/Accounts/metadata/subpaneldefs.php | 1 + modules/Accounts/vardefs.php | 7 - modules/Activities/Popup_picker.php | 7 +- modules/Administration/Diagnostic.php | 4 + modules/Administration/DiagnosticDelete.php | 4 + modules/Administration/DiagnosticDownload.php | 4 + modules/Administration/DiagnosticRun.php | 4 + modules/Administration/DisplayWarnings.php | 11 + modules/Administration/SugarSpriteBuilder.php | 4 +- .../Administration/language/en_us.lang.php | 12 +- .../metadata/adminpaneldefs.php | 10 +- modules/Administration/views/view.backups.php | 4 + modules/Calendar/Cal.js | 6 +- modules/Calendar/CalendarGrid.php | 16 +- modules/Calls/Call.php | 20 +- modules/Calls/CallFormBase.php | 5 +- modules/CampaignLog/language/en_us.lang.php | 3 + modules/CampaignLog/vardefs.php | 63 +- modules/Campaigns/Campaign.php | 5 + modules/Campaigns/WebToLeadCapture.php | 5 + modules/Campaigns/WebToLeadDownloadForm.html | 21 +- modules/Campaigns/WebToLeadFormSave.php | 53 +- modules/Campaigns/WizardHome.php | 5 +- modules/Campaigns/WizardMarketing.html | 2 +- modules/Campaigns/language/en_us.lang.php | 1 + modules/Campaigns/metadata/detailviewdefs.php | 2 +- modules/Campaigns/utils.php | 8 +- modules/Campaigns/views/view.detail.php | 4 +- modules/Cases/Case.php | 2 +- .../MyPipelineBySalesStageDashlet.php | 20 +- modules/Configurator/Configurator.php | 12 +- modules/Configurator/Forms.php | 6 + modules/Configurator/LogView.php | 16 +- modules/Configurator/language/en_us.lang.php | 4 +- modules/Configurator/tpls/EditView.tpl | 20 +- modules/Configurator/tpls/adminwizard.tpl | 22 +- .../sources/ext/rest/linkedin/config.php | 2 - .../ext/rest/linkedin/language/en_us.lang.php | 2 +- modules/Contacts/AcceptDecline.php | 26 +- modules/Contacts/Contact.php | 3 - modules/Contacts/ContactFormBase.php | 78 +- modules/Contacts/Popup_picker.php | 101 +-- modules/Contacts/metadata/quickcreatedefs.php | 2 + modules/Contacts/tpls/QuickCreate.tpl | 4 +- modules/Contacts/vardefs.php | 2 +- modules/Contacts/views/view.edit.php | 4 + modules/Currencies/Currency.php | 10 +- .../templates/Fields/Forms/enum.tpl | 6 +- .../templates/Fields/TemplateField.php | 1 + modules/EAPM/controller.php | 3 + modules/EmailMan/EmailMan.php | 10 +- modules/EmailMan/tpls/config.tpl | 22 +- modules/EmailTemplates/AttachFiles.php | 25 +- modules/EmailTemplates/EmailTemplate.php | 101 ++- .../EmailTemplates/EmailTemplateFormBase.php | 8 +- .../PopupDocumentsCampaignTemplate.html | 2 +- .../PopupDocumentsCampaignTemplate.php | 4 +- modules/Emails/Delete.php | 2 +- modules/Emails/Email.php | 88 ++- modules/Emails/EmailUI.php | 30 +- modules/Emails/EmailUIAjax.php | 29 +- modules/Emails/javascript/EmailUI.js | 26 +- modules/Emails/javascript/EmailUICompose.js | 4 +- modules/Emails/javascript/complexLayout.js | 6 +- .../Emails/javascript/composeEmailTemplate.js | 2 +- modules/Employees/Employee.php | 24 + .../Dashlets/ChartsDashlet/ChartsDashlet.php | 8 +- .../iFrameDashlet/iFrameDashlet.meta.php | 5 +- .../Dashlets/iFrameDashlet/iFrameDashlet.php | 12 +- modules/Home/UnifiedSearchAdvanced.php | 9 +- modules/Home/index.php | 16 +- modules/Home/views/view.list.php | 18 + modules/Import/ImportCacheFiles.php | 2 +- modules/Import/Importer.php | 22 +- modules/Import/views/view.confirm.php | 10 +- modules/Import/views/view.last.php | 11 +- modules/Import/views/view.step3.php | 8 +- modules/InboundEmail/EditView.php | 4 +- modules/InboundEmail/InboundEmail.php | 43 +- modules/Leads/tpls/ConvertLead.tpl | 9 +- modules/Leads/tpls/ConvertLeadFooter.tpl | 5 +- modules/Leads/tpls/ConvertLeadHeader.tpl | 33 +- modules/Leads/tpls/QuickCreate.tpl | 4 +- modules/Leads/vardefs.php | 2 + modules/Leads/views/view.convertlead.php | 54 +- modules/MailMerge/Step3.php | 101 +-- modules/MailMerge/Step4.php | 10 +- modules/MailMerge/index.php | 2 +- modules/MailMerge/merge_query.php | 99 +++ .../MyMeetingsDashlet/MyMeetingsDashlet.php | 18 +- modules/Meetings/Meeting.php | 14 +- modules/Meetings/MeetingFormBase.php | 4 +- modules/Meetings/duration_dependency.js | 27 +- modules/Meetings/metadata/detailviewdefs.php | 2 +- modules/Meetings/metadata/editviewdefs.php | 3 +- modules/Meetings/metadata/quickcreatedefs.php | 2 +- modules/Meetings/vardefs.php | 7 +- modules/MergeRecords/Step1.html | 2 +- modules/MergeRecords/Step2.php | 4 +- modules/MergeRecords/Step3.html | 4 +- modules/ModuleBuilder/MB/MBModule.php | 2 +- .../ModuleBuilder/Module/DropDownBrowser.php | 14 + .../ModuleBuilder/javascript/SimpleList.js | 2 +- .../ModuleBuilder/parsers/StandardField.php | 15 + .../parsers/views/DashletMetaDataParser.php | 2 +- modules/ModuleBuilder/tpls/editProperty.tpl | 2 +- .../ModuleBuilder/views/view.modulefields.php | 16 + modules/ProjectTask/ProjectTask.php | 222 +++++- modules/Prospects/tpls/QuickCreate.tpl | 4 +- modules/Schedulers/Scheduler.php | 13 +- modules/Schedulers/_AddJobsHere.php | 21 + modules/Schedulers/language/en_us.lang.php | 2 + modules/SchedulersJobs/vardefs.php | 10 +- modules/SugarFeed/tpls/AdminSettings.tpl | 6 +- modules/Tasks/Task.php | 3 +- modules/UpgradeWizard/language/en_us.lang.php | 2 +- modules/UpgradeWizard/silentUpgrade.php | 7 + .../UpgradeWizard/silentUpgrade_dce_step1.php | 6 + .../UpgradeWizard/silentUpgrade_dce_step2.php | 6 + modules/UpgradeWizard/silentUpgrade_step1.php | 6 + modules/UpgradeWizard/silentUpgrade_step2.php | 7 + modules/UpgradeWizard/systemCheck.php | 1 + modules/UpgradeWizard/uw_utils.php | 33 +- modules/Users/Authenticate.php | 11 +- modules/Users/GeneratePassword.php | 192 ++--- modules/Users/LoggedOut.php | 53 ++ modules/Users/LoggedOut.tpl | 55 ++ modules/Users/Login.php | 14 +- modules/Users/Logout.php | 6 +- modules/Users/Save.php | 64 +- modules/Users/User.php | 2 +- modules/Users/UserViewHelper.php | 12 +- .../AuthenticationController.php | 22 +- .../SAMLAuthenticate/SAMLAuthenticate.php | 23 +- .../SAMLAuthenticate/SAMLAuthenticateUser.php | 137 +++- .../authentication/SAMLAuthenticate/index.php | 8 +- .../lib/xmlseclibs/xmlseclibs.php | 20 +- .../SAMLAuthenticate/settings.php | 34 +- .../SugarAuthenticate/SugarAuthenticate.php | 9 +- modules/Users/language/en_us.lang.php | 3 + modules/Users/tpls/EditViewFooter.tpl | 4 +- modules/vCals/vCal.php | 8 +- service/core/SugarWebServiceImpl.php | 6 + service/example/example.html | 2 +- service/v4/SugarWebServiceImplv4.php | 3 + soap/SoapPortalHelper.php | 2 +- soap/SoapPortalUsers.php | 12 +- soap/SoapSugarUsers.php | 24 +- sugar_version.php | 8 +- tests/PHPUnit/File/Iterator/Autoload.php | 75 -- tests/PHPUnit/File/Iterator/Facade.php | 157 ---- tests/PHPUnit/PHP/CodeCoverage/Autoload.php | 97 --- tests/PHPUnit/PHP/CodeCoverage/Exception.php | 60 -- .../PHP/CodeCoverage/Report/Factory.php | 274 ------- .../PHP/CodeCoverage/Report/HTML/Renderer.php | 239 ------ .../Report/HTML/Renderer/Dashboard.php | 236 ------ .../Report/HTML/Renderer/Directory.php | 141 ---- .../Report/HTML/Renderer/File.php | 634 ---------------- .../HTML/Renderer/Template/close12_1.gif | Bin 85 -> 0 bytes .../HTML/Renderer/Template/container-min.js | 19 - .../HTML/Renderer/Template/container.css | 324 -------- .../Renderer/Template/dashboard.html.dist | 115 --- .../Renderer/Template/directory.html.dist | 71 -- .../HTML/Renderer/Template/directory.png | Bin 581 -> 0 bytes .../Template/directory_item.html.dist | 25 - .../HTML/Renderer/Template/file.html.dist | 120 --- .../Report/HTML/Renderer/Template/file.png | Bin 333 -> 0 bytes .../Renderer/Template/file_item.html.dist | 26 - .../Renderer/Template/file_no_yui.html.dist | 79 -- .../Report/HTML/Renderer/Template/glass.png | Bin 167 -> 0 bytes .../HTML/Renderer/Template/highcharts.js | 170 ----- .../HTML/Renderer/Template/jquery.min.js | 4 - .../Renderer/Template/method_item.html.dist | 19 - .../Report/HTML/Renderer/Template/style.css | 500 ------------- .../HTML/Renderer/Template/yahoo-dom-event.js | 14 - .../Report/HTML/Renderer/Template/yui_item.js | 5 - .../PHPUnit/PHP/CodeCoverage/Report/Node.php | 332 --------- .../CodeCoverage/Report/Node/Directory.php | 513 ------------- .../PHP/CodeCoverage/Report/Node/File.php | 694 ------------------ .../PHP/CodeCoverage/Report/Node/Iterator.php | 149 ---- tests/PHPUnit/PHP/CodeCoverage/Report/PHP.php | 75 -- .../PHPUnit/PHP/CodeCoverage/Report/Text.php | 286 -------- tests/PHPUnit/PHP/Timer/Autoload.php | 75 -- tests/PHPUnit/PHP/Token/Stream/Autoload.php | 232 ------ .../PHPUnit/PHPUnit/Framework/Comparator.php | 98 --- .../PHPUnit/Framework/Comparator/Array.php | 178 ----- .../Framework/Comparator/DOMDocument.php | 115 --- .../PHPUnit/Framework/Comparator/Double.php | 102 --- .../Framework/Comparator/Exception.php | 93 --- .../Framework/Comparator/MockObject.php | 87 --- .../PHPUnit/Framework/Comparator/Numeric.php | 117 --- .../PHPUnit/Framework/Comparator/Object.php | 146 ---- .../PHPUnit/Framework/Comparator/Resource.php | 98 --- .../PHPUnit/Framework/Comparator/Scalar.php | 137 ---- .../Framework/Comparator/SplObjectStorage.php | 115 --- .../PHPUnit/Framework/Comparator/Type.php | 106 --- .../PHPUnit/Framework/ComparatorFactory.php | 156 ---- .../Framework/Constraint/Composite.php | 115 --- .../PHPUnit/Framework/Constraint/Count.php | 129 ---- .../PHPUnit/Framework/Constraint/SameSize.php | 74 -- .../PHPUnit/Framework/Error/Deprecated.php | 66 -- .../PHPUnit/Framework/MockObject/Autoload.php | 111 --- .../MockObject/Generator/trait_class.tpl.dist | 4 - .../Framework/MockObject/Stub/ReturnSelf.php | 76 -- .../MockObject/Stub/ReturnValueMap.php | 87 --- .../PHPUnit/PHPUnit/Framework/OutputError.php | 61 -- tests/PHPUnit/PHPUnit/Util/String.php | 119 --- tests/SugarTestHelper.php | 353 +++++++++ tests/data/Bug52133Test.php | 109 +++ tests/data/Bug53223Test.php | 203 +++++ tests/data/Bug53963Test.php | 84 +++ tests/data/GetLinkedBeansTest.php | 8 + tests/data/Relationships/Bug52544Test.php | 73 ++ tests/data/SugarBeanTest.php | 27 + .../MVC/Controller/SugarControllerTest.php | 2 +- .../MVC/View/views/ViewNoAccessTest.php | 12 +- .../include/MVC/View/views/ViewVcardTest.php | 13 +- tests/include/SerializeEvilTest.php | 1 + .../Smarty/plugins/FunctionSugarHelpTest.php | 8 +- tests/include/database/Bug52783Test.php | 109 +++ tests/include/database/Bug53002Test.php | 66 ++ tests/include/database/DBManagerTest.php | 21 +- tests/include/utils/Bug33284_Test.php | 6 +- tests/include/utils/CleanDirNameTest.php | 54 ++ tests/metadata/Bug51105Test.php | 68 ++ .../Administration/SugarSpriteBuilderTest.php | 4 + .../modules/Configurator/ConfiguratorTest.php | 2 +- tests/modules/DynamicFields/Bug51427Test.php | 254 +++++++ .../templates/Fields/Bug52610Test.php | 81 ++ .../Emails/BugNullAssignedUserIdTest.php | 95 +++ tests/modules/InboundEmail/Bug43554Test.php | 27 +- tests/modules/Leads/Bug44522Test.php | 5 +- tests/modules/Leads/ConvertLeadTests.php | 74 +- tests/modules/MassUpdate/Bug51596Test.php | 108 +-- tests/modules/ModuleBuilder/Bug52063Test.php | 4 +- .../modules/ModuleBuilder/MB/Bug40299Test.php | 65 ++ tests/modules/Project/Bug37123Test.php | 14 +- tests/modules/Reports/Bug36246Test.php | 2 +- .../SchedulersJobs/SchedulersJobsTest.php | 40 + tests/modules/UpgradeWizard/Bug46028Test.php | 5 + .../SAMLAuthenticate/Bug49069Test.php | 11 +- .../SAMLAuthenticate/Bug49959Test.php | 190 +++++ .../SAMLAuthenticate/Bug50936Test.php | 11 +- tests/service/Bug42683Test.php | 27 +- tests/service/Bug51723Test.php | 135 ++++ tests/soap/Bug41392Test.php | 2 +- tests/soap/Bug43339Test.php | 165 +++++ themes/Sugar5/css/style.css | 43 +- 364 files changed, 6271 insertions(+), 9972 deletions(-) create mode 100644 include/connectors/utils/ConnectorHtmlHelper.php create mode 100644 include/connectors/utils/ConnectorHtmlHelperFactory.php create mode 100644 modules/MailMerge/merge_query.php create mode 100644 modules/Users/LoggedOut.php create mode 100644 modules/Users/LoggedOut.tpl delete mode 100755 tests/PHPUnit/File/Iterator/Autoload.php delete mode 100755 tests/PHPUnit/File/Iterator/Facade.php delete mode 100755 tests/PHPUnit/PHP/CodeCoverage/Autoload.php delete mode 100755 tests/PHPUnit/PHP/CodeCoverage/Exception.php delete mode 100755 tests/PHPUnit/PHP/CodeCoverage/Report/Factory.php delete mode 100755 tests/PHPUnit/PHP/CodeCoverage/Report/HTML/Renderer.php delete mode 100755 tests/PHPUnit/PHP/CodeCoverage/Report/HTML/Renderer/Dashboard.php delete mode 100755 tests/PHPUnit/PHP/CodeCoverage/Report/HTML/Renderer/Directory.php delete mode 100755 tests/PHPUnit/PHP/CodeCoverage/Report/HTML/Renderer/File.php delete mode 100755 tests/PHPUnit/PHP/CodeCoverage/Report/HTML/Renderer/Template/close12_1.gif delete mode 100755 tests/PHPUnit/PHP/CodeCoverage/Report/HTML/Renderer/Template/container-min.js delete mode 100755 tests/PHPUnit/PHP/CodeCoverage/Report/HTML/Renderer/Template/container.css delete mode 100755 tests/PHPUnit/PHP/CodeCoverage/Report/HTML/Renderer/Template/dashboard.html.dist delete mode 100755 tests/PHPUnit/PHP/CodeCoverage/Report/HTML/Renderer/Template/directory.html.dist delete mode 100755 tests/PHPUnit/PHP/CodeCoverage/Report/HTML/Renderer/Template/directory.png delete mode 100755 tests/PHPUnit/PHP/CodeCoverage/Report/HTML/Renderer/Template/directory_item.html.dist delete mode 100755 tests/PHPUnit/PHP/CodeCoverage/Report/HTML/Renderer/Template/file.html.dist delete mode 100755 tests/PHPUnit/PHP/CodeCoverage/Report/HTML/Renderer/Template/file.png delete mode 100755 tests/PHPUnit/PHP/CodeCoverage/Report/HTML/Renderer/Template/file_item.html.dist delete mode 100755 tests/PHPUnit/PHP/CodeCoverage/Report/HTML/Renderer/Template/file_no_yui.html.dist delete mode 100755 tests/PHPUnit/PHP/CodeCoverage/Report/HTML/Renderer/Template/glass.png delete mode 100755 tests/PHPUnit/PHP/CodeCoverage/Report/HTML/Renderer/Template/highcharts.js delete mode 100755 tests/PHPUnit/PHP/CodeCoverage/Report/HTML/Renderer/Template/jquery.min.js delete mode 100755 tests/PHPUnit/PHP/CodeCoverage/Report/HTML/Renderer/Template/method_item.html.dist delete mode 100755 tests/PHPUnit/PHP/CodeCoverage/Report/HTML/Renderer/Template/style.css delete mode 100755 tests/PHPUnit/PHP/CodeCoverage/Report/HTML/Renderer/Template/yahoo-dom-event.js delete mode 100755 tests/PHPUnit/PHP/CodeCoverage/Report/HTML/Renderer/Template/yui_item.js delete mode 100755 tests/PHPUnit/PHP/CodeCoverage/Report/Node.php delete mode 100755 tests/PHPUnit/PHP/CodeCoverage/Report/Node/Directory.php delete mode 100755 tests/PHPUnit/PHP/CodeCoverage/Report/Node/File.php delete mode 100755 tests/PHPUnit/PHP/CodeCoverage/Report/Node/Iterator.php delete mode 100755 tests/PHPUnit/PHP/CodeCoverage/Report/PHP.php delete mode 100755 tests/PHPUnit/PHP/CodeCoverage/Report/Text.php delete mode 100755 tests/PHPUnit/PHP/Timer/Autoload.php delete mode 100755 tests/PHPUnit/PHP/Token/Stream/Autoload.php delete mode 100755 tests/PHPUnit/PHPUnit/Framework/Comparator.php delete mode 100755 tests/PHPUnit/PHPUnit/Framework/Comparator/Array.php delete mode 100755 tests/PHPUnit/PHPUnit/Framework/Comparator/DOMDocument.php delete mode 100755 tests/PHPUnit/PHPUnit/Framework/Comparator/Double.php delete mode 100755 tests/PHPUnit/PHPUnit/Framework/Comparator/Exception.php delete mode 100755 tests/PHPUnit/PHPUnit/Framework/Comparator/MockObject.php delete mode 100755 tests/PHPUnit/PHPUnit/Framework/Comparator/Numeric.php delete mode 100755 tests/PHPUnit/PHPUnit/Framework/Comparator/Object.php delete mode 100755 tests/PHPUnit/PHPUnit/Framework/Comparator/Resource.php delete mode 100755 tests/PHPUnit/PHPUnit/Framework/Comparator/Scalar.php delete mode 100755 tests/PHPUnit/PHPUnit/Framework/Comparator/SplObjectStorage.php delete mode 100755 tests/PHPUnit/PHPUnit/Framework/Comparator/Type.php delete mode 100755 tests/PHPUnit/PHPUnit/Framework/ComparatorFactory.php delete mode 100755 tests/PHPUnit/PHPUnit/Framework/Constraint/Composite.php delete mode 100755 tests/PHPUnit/PHPUnit/Framework/Constraint/Count.php delete mode 100755 tests/PHPUnit/PHPUnit/Framework/Constraint/SameSize.php delete mode 100755 tests/PHPUnit/PHPUnit/Framework/Error/Deprecated.php delete mode 100755 tests/PHPUnit/PHPUnit/Framework/MockObject/Autoload.php delete mode 100755 tests/PHPUnit/PHPUnit/Framework/MockObject/Generator/trait_class.tpl.dist delete mode 100755 tests/PHPUnit/PHPUnit/Framework/MockObject/Stub/ReturnSelf.php delete mode 100755 tests/PHPUnit/PHPUnit/Framework/MockObject/Stub/ReturnValueMap.php delete mode 100755 tests/PHPUnit/PHPUnit/Framework/OutputError.php delete mode 100755 tests/PHPUnit/PHPUnit/Util/String.php create mode 100755 tests/data/Bug52133Test.php create mode 100755 tests/data/Bug53223Test.php create mode 100755 tests/data/Bug53963Test.php create mode 100755 tests/data/Relationships/Bug52544Test.php create mode 100755 tests/include/database/Bug52783Test.php create mode 100755 tests/include/database/Bug53002Test.php create mode 100755 tests/include/utils/CleanDirNameTest.php create mode 100755 tests/metadata/Bug51105Test.php create mode 100755 tests/modules/DynamicFields/Bug51427Test.php create mode 100755 tests/modules/DynamicFields/templates/Fields/Bug52610Test.php create mode 100755 tests/modules/Emails/BugNullAssignedUserIdTest.php create mode 100755 tests/modules/ModuleBuilder/MB/Bug40299Test.php create mode 100755 tests/modules/Users/authentication/SAMLAuthenticate/Bug49959Test.php create mode 100755 tests/service/Bug51723Test.php create mode 100755 tests/soap/Bug43339Test.php diff --git a/ModuleInstall/ModuleInstaller.php b/ModuleInstall/ModuleInstaller.php index b1ab2375..7f7fd346 100644 --- a/ModuleInstall/ModuleInstaller.php +++ b/ModuleInstall/ModuleInstaller.php @@ -534,7 +534,155 @@ class ModuleInstaller{ } } - public function install_extensions() + /** + * Method removes module from global search configurations + * + * return bool + */ + public function uninstall_global_search() + { + if (empty($this->installdefs['beans'])) + { + return true; + } + + if (is_file('custom/modules/unified_search_modules_display.php') == false) + { + return true; + } + + $user = new User(); + $users = get_user_array(); + $unified_search_modules_display = array(); + require('custom/modules/unified_search_modules_display.php'); + + foreach($this->installdefs['beans'] as $beanDefs) + { + if (array_key_exists($beanDefs['module'], $unified_search_modules_display) == false) + { + continue; + } + unset($unified_search_modules_display[$beanDefs['module']]); + foreach($users as $userId => $userName) + { + if (empty($userId)) + { + continue; + } + $user->retrieve($userId); + $prefs = $user->getPreference('globalSearch', 'search'); + if (array_key_exists($beanDefs['module'], $prefs) == false) + { + continue; + } + unset($prefs[$beanDefs['module']]); + $user->setPreference('globalSearch', $prefs, 0, 'search'); + $user->savePreferencesToDB(); + } + } + + if (write_array_to_file("unified_search_modules_display", $unified_search_modules_display, 'custom/modules/unified_search_modules_display.php') == false) + { + global $app_strings; + $msg = string_format($app_strings['ERR_FILE_WRITE'], array('custom/modules/unified_search_modules_display.php')); + $GLOBALS['log']->error($msg); + throw new Exception($msg); + return false; + } + return true; + } + + /** + * Method enables module in global search configurations by disabled_module_visible key + * + * return bool + */ + public function enable_global_search() + { + if (empty($this->installdefs['beans'])) + { + return true; + } + + if (is_file('custom/modules/unified_search_modules_display.php') == false) + { + return true; + } + + $unified_search_modules_display = array(); + require('custom/modules/unified_search_modules_display.php'); + + foreach($this->installdefs['beans'] as $beanDefs) + { + if (array_key_exists($beanDefs['module'], $unified_search_modules_display) == false) + { + continue; + } + if (isset($unified_search_modules_display[$beanDefs['module']]['disabled_module_visible']) == false) + { + continue; + } + $unified_search_modules_display[$beanDefs['module']]['visible'] = $unified_search_modules_display[$beanDefs['module']]['disabled_module_visible']; + unset($unified_search_modules_display[$beanDefs['module']]['disabled_module_visible']); + } + + if (write_array_to_file("unified_search_modules_display", $unified_search_modules_display, 'custom/modules/unified_search_modules_display.php') == false) + { + global $app_strings; + $msg = string_format($app_strings['ERR_FILE_WRITE'], array('custom/modules/unified_search_modules_display.php')); + $GLOBALS['log']->error($msg); + throw new Exception($msg); + return false; + } + return true; + } + + /** + * Method disables module in global search configurations by disabled_module_visible key + * + * return bool + */ + public function disable_global_search() + { + if (empty($this->installdefs['beans'])) + { + return true; + } + + if (is_file('custom/modules/unified_search_modules_display.php') == false) + { + return true; + } + + $unified_search_modules_display = array(); + require('custom/modules/unified_search_modules_display.php'); + + foreach($this->installdefs['beans'] as $beanDefs) + { + if (array_key_exists($beanDefs['module'], $unified_search_modules_display) == false) + { + continue; + } + if (isset($unified_search_modules_display[$beanDefs['module']]['visible']) == false) + { + continue; + } + $unified_search_modules_display[$beanDefs['module']]['disabled_module_visible'] = $unified_search_modules_display[$beanDefs['module']]['visible']; + $unified_search_modules_display[$beanDefs['module']]['visible'] = false; + } + + if (write_array_to_file("unified_search_modules_display", $unified_search_modules_display, 'custom/modules/unified_search_modules_display.php') == false) + { + global $app_strings; + $msg = string_format($app_strings['ERR_FILE_WRITE'], array('custom/modules/unified_search_modules_display.php')); + $GLOBALS['log']->error($msg); + throw new Exception($msg); + return false; + } + return true; + } + + public function install_extensions() { foreach($this->extensions as $extname => $ext) { $install = "install_$extname"; @@ -1328,6 +1476,7 @@ class ModuleInstaller{ 'uninstall_connectors', 'uninstall_layoutfields', 'uninstall_extensions', + 'uninstall_global_search', 'disable_manifest_logichooks', 'post_uninstall', ); @@ -1883,6 +2032,7 @@ private function dir_file_count($path){ 'enable_dashlets', 'enable_relationships', 'enable_extensions', + 'enable_global_search', 'enable_manifest_logichooks', 'reset_opcodes', ); @@ -1952,6 +2102,7 @@ private function dir_file_count($path){ 'disable_dashlets', 'disable_relationships', 'disable_extensions', + 'disable_global_search', 'disable_manifest_logichooks', 'reset_opcodes', ); diff --git a/ModuleInstall/PackageManager/PackageManager.php b/ModuleInstall/PackageManager/PackageManager.php index 9316f5b3..186a15b6 100644 --- a/ModuleInstall/PackageManager/PackageManager.php +++ b/ModuleInstall/PackageManager/PackageManager.php @@ -569,21 +569,25 @@ class PackageManager{ $uh->id_name = $name; $found = $uh->checkForExisting($uh); if($found != null){ - global $sugar_config; global $mod_strings; global $current_language; $base_upgrade_dir = $this->upload_dir.'/upgrades'; $base_tmp_upgrade_dir = "$base_upgrade_dir/temp"; - if(!isset($GLOBALS['mi_remove_tables']))$GLOBALS['mi_remove_tables'] = true; - $unzip_dir = mk_temp_dir( $base_tmp_upgrade_dir ); - unzip($found->filename, $unzip_dir ); - $mi = new ModuleInstaller(); - $mi->silent = true; - $mi->uninstall( "$unzip_dir"); - $found->delete(); - unlink(remove_file_extension( $found->filename ) . '-manifest.php'); - unlink($found->filename); + if(is_file($found->filename)){ + if(!isset($GLOBALS['mi_remove_tables']))$GLOBALS['mi_remove_tables'] = true; + $unzip_dir = mk_temp_dir( $base_tmp_upgrade_dir ); + unzip($found->filename, $unzip_dir ); + $mi = new ModuleInstaller(); + $mi->silent = true; + $mi->uninstall( "$unzip_dir"); + $found->delete(); + unlink(remove_file_extension( $found->filename ) . '-manifest.php'); + unlink($found->filename); + }else{ + //file(s_ have been deleted or are not found in the directory, allow database delete to happen but no need to change filesystem + $found->delete(); + } } } diff --git a/ModuleInstall/PackageManager/PackageManagerDisplay.php b/ModuleInstall/PackageManager/PackageManagerDisplay.php index 85241420..e9072fd5 100644 --- a/ModuleInstall/PackageManager/PackageManagerDisplay.php +++ b/ModuleInstall/PackageManager/PackageManagerDisplay.php @@ -62,6 +62,7 @@ class PackageManagerDisplay{ global $sugar_version, $sugar_config; $app_strings = return_application_language($current_language); $ss = new Sugar_Smarty(); + $ss->assign('APP_STRINGS', $app_strings); $ss->assign('FORM_1_PLACE_HOLDER', $form1); $ss->assign('form_action', $form_action); $ss->assign('hidden_fields', $hidden_fields); @@ -116,7 +117,14 @@ class PackageManagerDisplay{ $ss->assign('MOD', $mod_strings); $ss->assign('module_load', 'true'); - $ss->assign('scripts', PackageManagerDisplay::getDisplayScript($install)); + if (UploadStream::getSuhosinStatus() == false) + { + $ss->assign('ERR_SUHOSIN', true); + } + else + { + $ss->assign('scripts', PackageManagerDisplay::getDisplayScript($install)); + } $show_login = false; //hiding install from sugar $ss->assign('MODULE_SELECTOR', PackageManagerDisplay::buildGridOutput($tree, $mod_strings, $isAlive, $show_login)); $ss->assign('FORM_2_PLACE_HOLDER', $form2); @@ -608,4 +616,3 @@ class PackageManagerDisplay{ } } } -?> diff --git a/ModuleInstall/PackageManager/tpls/PackageForm.tpl b/ModuleInstall/PackageManager/tpls/PackageForm.tpl index fac4b8da..96a913d0 100644 --- a/ModuleInstall/PackageManager/tpls/PackageForm.tpl +++ b/ModuleInstall/PackageManager/tpls/PackageForm.tpl @@ -35,6 +35,9 @@ ********************************************************************************/ *} +{if $ERR_SUHOSIN == true} +{$APP_STRINGS.ERR_SUHOSIN} +{else} {$scripts} {$TREEHEADER} {literal} @@ -101,6 +104,4 @@ pre { {/literal} {/if} - - - +{/if} diff --git a/Zend/Oauth/Provider.php b/Zend/Oauth/Provider.php index 9105d8bf..220db809 100644 --- a/Zend/Oauth/Provider.php +++ b/Zend/Oauth/Provider.php @@ -256,7 +256,7 @@ class Zend_Oauth_Provider if(empty($_SERVER['SERVER_PORT']) || empty($_SERVER['HTTP_HOST']) || empty($_SERVER['REQUEST_URI'])) { return Zend_Uri_Http::fromString("http://localhost/"); } - if($_SERVER['SERVER_PORT'] == 443 || (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on')) { + if($_SERVER['SERVER_PORT'] == 443 || (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') || (!empty($_SERVER['HTTP_HTTPS']) && $_SERVER['HTTP_HTTPS'] == 'on')) { $proto = 'https'; } return Zend_Uri_Http::fromString("$proto://{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"); diff --git a/cache/include/javascript/sugar_field_grp.js b/cache/include/javascript/sugar_field_grp.js index 5a9ee496..a37a25a8 100644 --- a/cache/include/javascript/sugar_field_grp.js +++ b/cache/include/javascript/sugar_field_grp.js @@ -51,10 +51,10 @@ function Datetimecombo(datetime,field,timeformat,tabindex,showCheckbox,checked,a this.fieldname=field;if(datetime!='') {parts=datetime.split(' ');this.hrs=parseInt(parts[1].substring(0,2),10);this.mins=parseInt(parts[1].substring(3,5),10);} this.timeformat=timeformat;this.tabindex=tabindex==null||isNaN(tabindex)?1:tabindex;this.timeseparator=this.timeformat.substring(2,3);this.has12Hours=/^11/.test(this.timeformat);this.hasMeridiem=/am|pm/i.test(this.timeformat);if(this.hasMeridiem){this.pm=/pm/.test(this.timeformat);} -this.meridiem=this.hasMeridiem?trim(this.datetime.substring(16)):'';this.datetime=this.datetime.substr(0,10);this.showCheckbox=showCheckbox;this.checked=parseInt(checked);document.getElementById(this.fieldname+'_date').value=this.datetime;if(this.mins>0&&this.mins<15){this.mins=15;}else if(this.mins>15&&this.mins<30){this.mins=30;}else if(this.mins>30&&this.mins<45){this.mins=45;}else if(this.mins>45){this.hrs+=1;this.mins=0;if(this.hasMeridiem&&this.hrs==12){if(this.meridiem=="pm"||this.meridiem=="am"){if(this.meridiem=="pm"){this.meridiem="am";}else{this.meridiem="pm";}}else{if(this.meridiem=="PM"){this.meridiem="AM";}else{this.meridiem="PM";}}} +this.meridiem=this.hasMeridiem?trim(this.datetime.substring(16)):'';this.datetime=this.datetime.substr(0,10);this.showCheckbox=showCheckbox;this.checked=parseInt(checked);YAHOO.util.Selector.query('input#'+this.fieldname+'_date')[0].value=this.datetime;if(this.mins>0&&this.mins<15){this.mins=15;}else if(this.mins>15&&this.mins<30){this.mins=30;}else if(this.mins>30&&this.mins<45){this.mins=45;}else if(this.mins>45){this.hrs+=1;this.mins=0;if(this.hasMeridiem&&this.hrs==12){if(this.meridiem=="pm"||this.meridiem=="am"){if(this.meridiem=="pm"){this.meridiem="am";}else{this.meridiem="pm";}}else{if(this.meridiem=="PM"){this.meridiem="AM";}else{this.meridiem="PM";}}} if(this.hasMeridiem&&this.hrs>12){this.hrs=this.hrs-12;}}} -Datetimecombo.prototype.jsscript=function(callback){text='\nfunction update_'+this.fieldname+'(calendar) {';text+='\nd = document.getElementById("'+this.fieldname+'_date").value;';text+='\nh = document.getElementById("'+this.fieldname+'_hours").value;';text+='\nm = document.getElementById("'+this.fieldname+'_minutes").value;';text+='\nnewdate = d + " " + h + "'+this.timeseparator+'" + m;';if(this.hasMeridiem){text+='\nif(typeof document.getElementById("'+this.fieldname+'_meridiem") != "undefined") {';text+='\n newdate += document.getElementById("'+this.fieldname+'_meridiem").value;';text+='\n}';} -text+='\nif(trim(newdate) =="'+this.timeseparator+'") newdate="";';text+='\ndocument.getElementById("'+this.fieldname+'").value = newdate;';text+='\n'+callback;text+='\n}';return text;} +Datetimecombo.prototype.jsscript=function(callback){text='\nfunction update_'+this.fieldname+'(calendar) {';text+='\nd = YAHOO.util.Selector.query("input#'+this.fieldname+'_date")[0].value;';text+='\nh = YAHOO.util.Selector.query("select#'+this.fieldname+'_hours")[0].value;';text+='\nm = YAHOO.util.Selector.query("select#'+this.fieldname+'_minutes")[0].value;';text+='\nnewdate = d + " " + h + "'+this.timeseparator+'" + m;';if(this.hasMeridiem){text+='\nif(typeof YAHOO.util.Selector.query("select#'+this.fieldname+'_meridiem")[0] != "undefined") {';text+='\n newdate += YAHOO.util.Selector.query("select#'+this.fieldname+'_meridiem")[0].value;';text+='\n}';} +text+='\nif(trim(newdate) =="'+this.timeseparator+'") newdate="";';text+='\nYAHOO.util.Selector.query("select#'+this.fieldname+'")[0].value = newdate;';text+='\n'+callback;text+='\n}';return text;} Datetimecombo.prototype.html=function(callback){var text=' ';text+=this.timeseparator;text+='\n ';} if(this.showCheckbox){text+='\n';} text+='';return text;};Datetimecombo.prototype.update=function(updateListeners){if(typeof(updateListeners)=="undefined") -updateListeners=true;var d=window.document.getElementById(this.fieldname+'_date');var h=window.document.getElementById(this.fieldname+'_hours');var m=window.document.getElementById(this.fieldname+'_minutes');var mer=document.getElementById(this.fieldname+"_meridiem");if(d.value==""){h.selectedIndex=0;m.selectedIndex=0;if(mer)mer.selectedIndex=0;}else{if(this.allowEmptyHM){if(h.selectedIndex==0)h.selectedIndex=12;if(m.selectedIndex==0)m.selectedIndex=1;if(mer&&(mer.selectedIndex==0))mer.selectedIndex=1;}} -var newdate=d.value+' '+h.value+this.timeseparator+m.value;if(this.hasMeridiem){ampm=document.getElementById(this.fieldname+"_meridiem").value;newdate+=ampm;} +updateListeners=true;var d=YAHOO.util.Selector.query('input#'+this.fieldname+'_date')[0];var h=YAHOO.util.Selector.query('select#'+this.fieldname+'_hours')[0];var m=YAHOO.util.Selector.query('select#'+this.fieldname+'_minutes')[0];var mer=YAHOO.util.Selector.query('select#'+this.fieldname+"_meridiem")[0];if(d.value==""){h.selectedIndex=0;m.selectedIndex=0;if(mer)mer.selectedIndex=0;}else{if(this.allowEmptyHM){if(h.selectedIndex==0)h.selectedIndex=12;if(m.selectedIndex==0)m.selectedIndex=1;if(mer&&(mer.selectedIndex==0))mer.selectedIndex=1;}} +var newdate=d.value+' '+h.value+this.timeseparator+m.value;if(this.hasMeridiem){ampm=YAHOO.util.Selector.query('select#'+this.fieldname+"_meridiem")[0].value;newdate+=ampm;} if(trim(newdate)==""+this.timeseparator+""){newdate='';} -document.getElementById(this.fieldname).value=newdate;if(updateListeners) -SUGAR.util.callOnChangeListers(this.fieldname);if(this.showCheckbox){flag=this.fieldname+'_flag';date=this.fieldname+'_date';hours=this.fieldname+'_hours';mins=this.fieldname+'_minutes';if(document.getElementById(flag).checked){document.getElementById(flag).value=1;document.getElementById(this.fieldname).value='';document.getElementById(date).disabled=true;document.getElementById(hours).disabled=true;document.getElementById(mins).disabled=true;}else{document.getElementById(flag).value=0;document.getElementById(date).disabled=false;document.getElementById(hours).disabled=false;document.getElementById(mins).disabled=false;}}};/* End of File include/SugarFields/Fields/Datetimecombo/Datetimecombo.js */ +YAHOO.util.Selector.query('input#'+this.fieldname)[0].value=newdate;if(updateListeners) +SUGAR.util.callOnChangeListers(this.fieldname);if(this.showCheckbox){flag=this.fieldname+'_flag';date=this.fieldname+'_date';hours=this.fieldname+'_hours';mins=this.fieldname+'_minutes';if(YAHOO.util.Selector.query('input#'+flag)[0].checked) +{YAHOO.util.Selector.query('input#'+flag)[0].value=1;YAHOO.util.Selector.query('input#'+this.fieldname)[0].value='';YAHOO.util.Selector.query('input#'+date)[0].disabled=true;YAHOO.util.Selector.query('select#'+hours)[0].disabled=true;YAHOO.util.Selector.query('select#'+mins)[0].disabled=true;} +else +{YAHOO.util.Selector.query('input#'+flag)[0].value=0;YAHOO.util.Selector.query('input#'+date)[0].disabled=false;YAHOO.util.Selector.query('select#'+hours)[0].disabled=false;YAHOO.util.Selector.query('select#'+mins)[0].disabled=false;}}};/* End of File include/SugarFields/Fields/Datetimecombo/Datetimecombo.js */ diff --git a/cache/include/javascript/sugar_grp1.js b/cache/include/javascript/sugar_grp1.js index f5f933cc..acc40550 100644 --- a/cache/include/javascript/sugar_grp1.js +++ b/cache/include/javascript/sugar_grp1.js @@ -191,7 +191,7 @@ else if(document.documentElement&&document.documentElement.scrollTop) {nwX=document.documentElement.scrollLeft;seX=document.documentElement.clientWidth;nwY=document.documentElement.scrollTop;seY=document.documentElement.clientHeight;} else if(document.body) {nwX=document.body.scrollLeft;seX=document.body.clientWidth;nwY=document.body.scrollTop;seY=document.body.clientHeight;} -var inView=true;for(var wp=0;wp=nwX&&elementCoor.y>=nwY&&elementCoor.x<=seX&&elementCoor.y<=seY)){inView=false;scrollToTop=elementCoor.y-75;scrollToLeft=elementCoor.x-75;} +var inView=true;for(var wp=0;wp=nwX&&elementCoor.y>=nwY&&elementCoor.x<=seX+nwX&&elementCoor.y<=seY+nwY)){inView=false;scrollToTop=elementCoor.y-75;scrollToLeft=elementCoor.x-75;} else{break;}} if(!inView)window.scrollTo(scrollToLeft,scrollToTop);return false;} disableOnUnloadEditView(form);return true;} @@ -479,6 +479,7 @@ selectedIndex=nodeCount;}} document.getElementById('orderBySelect').selectedIndex=selectedIndex;};SUGAR.tabChooser.movementCallback(document.getElementById('display_tabs_td').getElementsByTagName('select')[0]);if(document.search_form.orderBy) document.search_form.orderBy.options.value=SUGAR.savedViews.selectedOrderBy;if(SUGAR.savedViews.selectedSortOrder=='DESC')document.getElementById('sort_order_desc_radio').checked=true;else document.getElementById('sort_order_asc_radio').checked=true;}};}();SUGAR.searchForm=function(){var url;return{searchFormSelect:function(view,previousView){var module=view.split('|')[0];var theView=view.split('|')[1];var handleDisplay=function(){document.search_form.searchFormTab.value=theView;patt=module+"(.*)SearchForm$";divId=document.search_form.getElementsByTagName('div');for(i=0;i0){optionList[0].selected="selected";} +for(var ii=0;ii3&&elem.name.substring(elem.name.length-3)=='_id')||((elem.name.length>9)&&(elem.name.substring(elem.name.length-9)=='_id_basic'))||(elem.name.length>12&&elem.name.substring(elem.name.length-12)=='_id_advanced')||(elem.name.length>2&&elem.name.substring(elem.name.length-2)=='_c')||((elem.name.length>8)&&(elem.name.substring(elem.name.length-8)=='_c_basic'))||(elem.name.length>11&&elem.name.substring(elem.name.length-11)=='_c_advanced')) {elem.value='';}}} @@ -563,11 +565,11 @@ popupCount=1;window.document.popup_request_data=popup_request_data;window.docume popupCount++;if(hide_clear_button){URL+='&hide_clear_button=true';} windowFeatures='width='+width +',height='+height -+',resizable=1,scrollbars=1';if(popup_mode==''&&popup_mode=='undefined'){popup_mode='single';} -URL+='&mode='+popup_mode;if(create==''&&create=='undefined'){create='false';} -URL+='&create='+create;if(metadata!=''&&metadata!='undefined'){URL+='&metadata='+metadata;} ++',resizable=1,scrollbars=1';if(popup_mode==''||popup_mode==undefined){popup_mode='single';} +URL+='&mode='+popup_mode;if(create==''||create==undefined){create='false';} +URL+='&create='+create;if(metadata!=''&&metadata!=undefined){URL+='&metadata='+metadata;} if(popup_request_data.jsonObject){var request_data=popup_request_data.jsonObject;}else{var request_data=popup_request_data;} -var field_to_name_array_url='';if(request_data&&request_data.field_to_name_array!='undefined'){for(var key in request_data.field_to_name_array){if(key.toLowerCase()!='id'){field_to_name_array_url+='&field_to_name[]='+encodeURIComponent(key.toLowerCase());}}} +var field_to_name_array_url='';if(request_data&&request_data.field_to_name_array!=undefined){for(var key in request_data.field_to_name_array){if(key.toLowerCase()!='id'){field_to_name_array_url+='&field_to_name[]='+encodeURIComponent(key.toLowerCase());}}} if(field_to_name_array_url){URL+=field_to_name_array_url;} win=SUGAR.util.openWindow(URL,windowName,windowFeatures);if(window.focus) {win.focus();} @@ -682,7 +684,9 @@ else{SUGAR.ajaxUI.showLoadingPanel();ui.lastCall=YAHOO.util.Connect.asyncRequest SA.cleanGlobals();var form=YAHOO.util.Dom.get(formname)||document.forms[formname];if(SA.canAjaxLoadModule(form.module.value)&&typeof(YAHOO.util.Selector.query("input[type=file]",form)[0])=="undefined"&&/action=ajaxui/.exec(window.location)) {var string=con.setForm(form);var baseUrl="index.php?action=ajaxui#ajaxUILoc=";SA.lastURL="";if(string.length>200) {SUGAR.ajaxUI.showLoadingPanel();form.onsubmit=function(){return true;};form.submit();}else{con.resetFormState();window.location=baseUrl+encodeURIComponent("index.php?"+string);} -return true;}else{form.submit();return false;}},cleanGlobals:function() +return true;}else{if(typeof(YAHOO.util.Selector.query("input[type=submit]",form)[0])!="undefined"&&YAHOO.util.Selector.query("input[type=submit]",form)[0].value=="Save") +{ajaxStatus.showStatus(SUGAR.language.get('app_strings','LBL_SAVING'));} +form.submit();return false;}},cleanGlobals:function() {sqs_objects={};QSProcessedFieldsArray={};collection={};if(SUGAR.EmailAddressWidget){SUGAR.EmailAddressWidget.instances={};SUGAR.EmailAddressWidget.count={};} YAHOO.util.Event.removeListener(window,'resize');if(typeof(dialog)!='undefined'&&typeof(dialog.destroy)=='function'){dialog.destroy();delete dialog;}},firstLoad:function() {var url=YAHOO.util.History.getBookmarkedState('ajaxUILoc');var aRegex=/action=([^&#]*)/.exec(window.location);var action=aRegex?aRegex[1]:false;var mRegex=/module=([^&#]*)/.exec(window.location);var module=mRegex?mRegex[1]:false;if(module!="ModuleBuilder") @@ -850,7 +854,7 @@ var theme=SUGAR.themes.theme_name;var idx=0;if(!SE.composeLayout.composeTemplate SE.composeLayout.composeTemplate=new YAHOO.SUGAR.Template(SE.templates['compose']);var panel_modal=dce_mode?false:true,panel_width='880px',panel_constrain=dce_mode?false:true,panel_height=dce_mode?'auto':'400px',panel_shadow=dce_mode?false:true,panel_draggable=dce_mode?false:true,panel_resize=dce_mode?false:true,panel_close=dce_mode?false:true;SQ.parentPanel=new YAHOO.widget.Panel("container1",{modal:panel_modal,visible:true,constraintoviewport:panel_constrain,width:panel_width,height:panel_height,shadow:panel_shadow,draggable:panel_draggable,resize:panel_resize,close:panel_close});if(!dce_mode){SQ.parentPanel.setHeader(SUGAR.language.get('app_strings','LBL_EMAIL_QUICK_COMPOSE'));} SQ.parentPanel.setBody("");var composePanel=SE.composeLayout.getQuickComposeLayout(SQ.parentPanel,this.options);if(!dce_mode){var resize=new YAHOO.util.Resize('container1',{handles:['br'],autoRatio:false,minWidth:400,minHeight:350,status:false});resize.on('resize',function(args){var panelHeight=args.height;this.cfg.setProperty("height",panelHeight+"px");var layout=SE.composeLayout[SE.composeLayout.currentInstanceId];layout.set("height",panelHeight-50);layout.resize(true);SE.composeLayout.resizeEditor(SE.composeLayout.currentInstanceId);},SQ.parentPanel,true);}else{SUGAR.util.doWhen("typeof SE.composeLayout[SE.composeLayout.currentInstanceId] != 'undefined'",function(){var panelHeight=400;SQ.parentPanel.cfg.setProperty("height",panelHeight+"px");var layout=SE.composeLayout[SE.composeLayout.currentInstanceId];layout.set("height",panelHeight);layout.resize(true);SE.composeLayout.resizeEditor(SE.composeLayout.currentInstanceId);});} YAHOO.util.Dom.setStyle("container1","z-index",1);if(!SQ.tinyLoaded) -{tinymce.dom.Event.domLoaded=true;tinyMCE.init({convert_urls:false,theme_advanced_toolbar_align:tinyConfig.theme_advanced_toolbar_align,width:tinyConfig.width,theme:tinyConfig.theme,theme_advanced_toolbar_location:tinyConfig.theme_advanced_toolbar_location,theme_advanced_buttons1:tinyConfig.theme_advanced_buttons1,theme_advanced_buttons2:tinyConfig.theme_advanced_buttons2,theme_advanced_buttons3:tinyConfig.theme_advanced_buttons3,plugins:tinyConfig.plugins,elements:tinyConfig.elements,language:tinyConfig.language,extended_valid_elements:tinyConfig.extended_valid_elements,mode:tinyConfig.mode,strict_loading_mode:true});SQ.tinyLoaded=true;} +{tinymce.dom.Event.domLoaded=true;tinyMCE.init({convert_urls:false,theme_advanced_toolbar_align:tinyConfig.theme_advanced_toolbar_align,valid_children:tinyConfig.valid_children,width:tinyConfig.width,theme:tinyConfig.theme,theme_advanced_toolbar_location:tinyConfig.theme_advanced_toolbar_location,theme_advanced_buttons1:tinyConfig.theme_advanced_buttons1,theme_advanced_buttons2:tinyConfig.theme_advanced_buttons2,theme_advanced_buttons3:tinyConfig.theme_advanced_buttons3,plugins:tinyConfig.plugins,elements:tinyConfig.elements,language:tinyConfig.language,extended_valid_elements:tinyConfig.extended_valid_elements,mode:tinyConfig.mode,strict_loading_mode:true});SQ.tinyLoaded=true;} SQ.parentPanel.show();SUGAR.email2.composeLayout.forceCloseCompose=function(o){SUGAR.quickCompose.parentPanel.hide();} if(!dce_mode){SQ.parentPanel.center();}},init:function(o){if(typeof o.menu_id!='undefined'){this.dceMenuPanel=o.menu_id;}else{this.dceMenuPanel=null;} loadingMessgPanl=new YAHOO.widget.SimpleDialog('loading',{width:'200px',close:true,modal:true,visible:true,fixedcenter:true,constraintoviewport:true,draggable:false});loadingMessgPanl.setHeader(SUGAR.language.get('app_strings','LBL_EMAIL_PERFORMING_TASK'));loadingMessgPanl.setBody(SUGAR.language.get('app_strings','LBL_EMAIL_ONE_MOMENT'));loadingMessgPanl.render(document.body);loadingMessgPanl.show();if(!SUGAR.quickCompose.resourcesLoaded) @@ -861,8 +865,6 @@ this.initUI(o);},loadResources:function(o) if(typeof YAHOO=="undefined"||!YAHOO){var YAHOO={};}YAHOO.namespace=function(){var b=arguments,g=null,e,c,f;for(e=0;e":">",'"':""","'":"'","/":"/","`":"`"},d=["toString","valueOf"],e={isArray:function(j){return a.toString.apply(j)===c;},isBoolean:function(j){return typeof j==="boolean";},isFunction:function(j){return(typeof j==="function")||a.toString.apply(j)===h;},isNull:function(j){return j===null;},isNumber:function(j){return typeof j==="number"&&isFinite(j);},isObject:function(j){return(j&&(typeof j==="object"||f.isFunction(j)))||false;},isString:function(j){return typeof j==="string";},isUndefined:function(j){return typeof j==="undefined";},_IEEnumFix:(YAHOO.env.ua.ie)?function(l,k){var j,n,m;for(j=0;j"'\/`]/g,function(k){return g[k];});},extend:function(m,n,l){if(!n||!m){throw new Error("extend failed, please check that "+"all dependencies are included.");}var k=function(){},j;k.prototype=n.prototype;m.prototype=new k();m.prototype.constructor=m;m.superclass=n.prototype;if(n.prototype.constructor==a.constructor){n.prototype.constructor=n;}if(l){for(j in l){if(f.hasOwnProperty(l,j)){m.prototype[j]=l[j];}}f._IEEnumFix(m.prototype,l);}},augmentObject:function(n,m){if(!m||!n){throw new Error("Absorb failed, verify dependencies.");}var j=arguments,l,o,k=j[2];if(k&&k!==true){for(l=2;l0)?f.dump(j[l],p-1):t);}else{r.push(j[l]);}r.push(q);}if(r.length>1){r.pop();}r.push("]");}else{r.push("{");for(l in j){if(f.hasOwnProperty(j,l)){r.push(l+m);if(f.isObject(j[l])){r.push((p>0)?f.dump(j[l],p-1):t);}else{r.push(j[l]);}r.push(q);}}if(r.length>1){r.pop();}r.push("}");}return r.join("");},substitute:function(x,y,E,l){var D,C,B,G,t,u,F=[],p,z=x.length,A="dump",r=" ",q="{",m="}",n,w;for(;;){D=x.lastIndexOf(q,z);if(D<0){break;}C=x.indexOf(m,D);if(D+1>C){break;}p=x.substring(D+1,C);G=p;u=null;B=G.indexOf(r);if(B>-1){u=G.substring(B+1);G=G.substring(0,B);}t=y[G];if(E){t=E(G,t,u);}if(f.isObject(t)){if(f.isArray(t)){t=f.dump(t,parseInt(u,10));}else{u=u||"";n=u.indexOf(A);if(n>-1){u=u.substring(4);}w=t.toString();if(w===i||n>-1){t=f.dump(t,parseInt(u,10));}else{t=w;}}}else{if(!f.isString(t)&&!f.isNumber(t)){t="~-"+F.length+"-~";F[F.length]=p;}}x=x.substring(0,D)+t+x.substring(C+1);if(l===false){z=D-1;}}for(D=F.length-1;D>=0;D=D-1){x=x.replace(new RegExp("~-"+D+"-~"),"{"+F[D]+"}","g");}return x;},trim:function(j){try{return j.replace(/^\s+|\s+$/g,"");}catch(k){return j;}},merge:function(){var n={},k=arguments,j=k.length,m;for(m=0;m=420){z.addEventListener("load",function(){YAHOO.log(x+" DOM2 onload "+u,"info","Get");F(x,u);});}else{t=m[x];if(t.varName){v=YAHOO.util.Get.POLL_FREQ;YAHOO.log("Polling for "+t.varName[0]);t.maxattempts=YAHOO.util.Get.TIMEOUT/v;t.attempts=0;t._cache=t.varName[0].split(".");t.timer=s.later(v,t,function(w){I=this._cache;A=I.length;J=this.win;for(C=0;Cthis.maxattempts){y="Over retry limit, giving up";t.timer.cancel();q(x,y);}else{YAHOO.log(I[C]+" failed, retrying");}return;}}YAHOO.log("Safari poll complete");t.timer.cancel();F(x,u);},null,true);}else{s.later(YAHOO.util.Get.POLL_FREQ,null,F,[x,u]);}}}}else{z.onload=function(){YAHOO.log(x+" onload "+u,"info","Get");F(x,u);};}}};q=function(w,v){YAHOO.log("get failure: "+v,"warn","Get");var u=m[w],t;if(u.onFailure){t=u.scope||u.win;u.onFailure.call(t,a(u,v));}};d=function(z){if(m[z]){var t=m[z],u=t.nodes,x=u.length,C=t.win.document,A=C.getElementsByTagName("head")[0],v,y,w,B;if(t.insertBefore){v=b(t.insertBefore,z);if(v){A=v.parentNode;}}for(y=0;y=m.rollup);if(roll){break;}}}}}else{for(j=0;j=m.rollup);if(roll){break;}}}}}if(roll){r[i]=true;rolled=true;this.getRequires(m);}}}if(!rolled){break;}}},_reduce:function(){var i,j,s,m,r=this.required;for(i in r){if(i in this.loaded){delete r[i];}else{var skinDef=this.parseSkin(i);if(skinDef){if(!skinDef.module){var skin_pre=this.SKIN_PREFIX+skinDef.skin;for(j in r){if(lang.hasOwnProperty(r,j)){m=this.moduleInfo[j];var ext=m&&m.ext;if(!ext&&j!==i&&j.indexOf(skin_pre)>-1){delete r[j];}}}}}else{m=this.moduleInfo[i];s=m&&m.supersedes;if(s){for(j=0;j-1){return true;}if(after&&YUI.ArrayUtil.indexOf(after,bb)>-1){return true;}if(checkOptional&&optional&&YUI.ArrayUtil.indexOf(optional,bb)>-1){return true;}var ss=info[bb]&&info[bb].supersedes;if(ss){for(ii=0;iistartLen){YAHOO.util.Get.script(self._filter(js),{data:self._loading,onSuccess:callback,onFailure:self._onFailure,onTimeout:self._onTimeout,insertBefore:self.insertBefore,charset:self.charset,timeout:self.timeout,scope:self});}else{this.loadNext();}};if(css.length>startLen){YAHOO.util.Get.css(this._filter(css),{data:this._loading,onSuccess:loadScript,onFailure:this._onFailure,onTimeout:this._onTimeout,insertBefore:this.insertBefore,charset:this.charset,timeout:this.timeout,scope:self});}else{loadScript();}return;}else{this.loadNext(this._loading);}},insert:function(o,type){this.calculate(o);this._loading=true;this.loadType=type;if(this.combine){return this._combine();}if(!type){var self=this;this._internalCallback=function(){self._internalCallback=null;self.insert(null,"js");};this.insert(null,"css");return;}this.loadNext();},sandbox:function(o,type){var self=this,success=function(o){var idx=o.argument[0],name=o.argument[2];self._scriptText[idx]=o.responseText;if(self.onProgress){self.onProgress.call(self.scope,{name:name,scriptText:o.responseText,xhrResponse:o,data:self.data});}self._loadCount++;if(self._loadCount>=self._stopCount){var v=self.varName||"YAHOO";var t="(function() {\n";var b="\nreturn "+v+";\n})();";var ref=eval(t+self._scriptText.join("\n")+b);self._pushEvents(ref);if(ref){self.onSuccess.call(self.scope,{reference:ref,data:self.data});}else{self._onFailure.call(self.varName+" reference failure");}}},failure=function(o){self.onFailure.call(self.scope,{msg:"XHR failure",xhrResponse:o,data:self.data});};self._config(o);if(!self.onSuccess){throw new Error("You must supply an onSuccess handler for your sandbox");}self._sandbox=true;if(!type||type!=="js"){self._internalCallback=function(){self._internalCallback=null;self.sandbox(null,"js");};self.insert(null,"css");return;}if(!util.Connect){var ld=new YAHOO.util.YUILoader();ld.insert({base:self.base,filter:self.filter,require:"connection",insertBefore:self.insertBefore,charset:self.charset,onSuccess:function(){self.sandbox(null,"js");},scope:self},"js");return;}self._scriptText=[];self._loadCount=0;self._stopCount=self.sorted.length;self._xhr=[];self.calculate();var s=self.sorted,l=s.length,i,m,url;for(i=0;i - / *
  • - * or - element contains submenu + * - element contains submenu * ", - "footer": "" - }, diff --git a/tests/PHPUnit/PHP/CodeCoverage/Report/Node.php b/tests/PHPUnit/PHP/CodeCoverage/Report/Node.php deleted file mode 100755 index 83964894..00000000 --- a/tests/PHPUnit/PHP/CodeCoverage/Report/Node.php +++ /dev/null @@ -1,332 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @category PHP - * @package CodeCoverage - * @author Sebastian Bergmann - * @copyright 2009-2011 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://github.com/sebastianbergmann/php-code-coverage - * @since File available since Release 1.1.0 - */ - -/** - * Base class for nodes in the code coverage information tree. - * - * @category PHP - * @package CodeCoverage - * @author Sebastian Bergmann - * @copyright 2009-2011 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 1.1.1 - * @link http://github.com/sebastianbergmann/php-code-coverage - * @since Class available since Release 1.1.0 - */ -abstract class PHP_CodeCoverage_Report_Node implements Countable -{ - /** - * @var string - */ - protected $name; - - /** - * @var string - */ - protected $path; - - /** - * @var array - */ - protected $pathArray; - - /** - * @var PHP_CodeCoverage_Report_Node - */ - protected $parent; - - /** - * @var string - */ - protected $id; - - /** - * Constructor. - * - * @param string $name - * @param PHP_CodeCoverage_Report_Node $parent - */ - public function __construct($name, PHP_CodeCoverage_Report_Node $parent = NULL) - { - if (substr($name, -1) == '/') { - $name = substr($name, 0, -1); - } - - $this->name = $name; - $this->parent = $parent; - } - - /** - * @return string - */ - public function getName() - { - return $this->name; - } - - /** - * @return string - */ - public function getId() - { - if ($this->id === NULL) { - $parent = $this->getParent(); - - if ($parent === NULL) { - $this->id = 'index'; - } else { - $parentId = $parent->getId(); - - if ($parentId == 'index') { - $this->id = $this->name; - } else { - $this->id = $parentId . '_' . $this->name; - } - } - } - - return $this->id; - } - - /** - * @return string - */ - public function getPath() - { - if ($this->path === NULL) { - if ($this->parent === NULL) { - $this->path = $this->name; - } else { - $this->path = $this->parent->getPath() . '/' . $this->name; - } - } - - return $this->path; - } - - /** - * @return array - */ - public function getPathAsArray() - { - if ($this->pathArray === NULL) { - if ($this->parent === NULL) { - $this->pathArray = array(); - } else { - $this->pathArray = $this->parent->getPathAsArray(); - } - - $this->pathArray[] = $this; - } - - return $this->pathArray; - } - - /** - * @return PHP_CodeCoverage_Report_Node - */ - public function getParent() - { - return $this->parent; - } - - /** - * Returns the percentage of classes that has been tested. - * - * @param boolean $asString - * @return integer - */ - public function getTestedClassesPercent($asString = TRUE) - { - return PHP_CodeCoverage_Util::percent( - $this->getNumTestedClasses(), - $this->getNumClasses(), - $asString - ); - } - - /** - * Returns the percentage of traits that has been tested. - * - * @param boolean $asString - * @return integer - */ - public function getTestedTraitsPercent($asString = TRUE) - { - return PHP_CodeCoverage_Util::percent( - $this->getNumTestedTraits(), - $this->getNumTraits(), - $asString - ); - } - - /** - * Returns the percentage of methods that has been tested. - * - * @param boolean $asString - * @return integer - */ - public function getTestedMethodsPercent($asString = TRUE) - { - return PHP_CodeCoverage_Util::percent( - $this->getNumTestedMethods(), - $this->getNumMethods(), - $asString - ); - } - - /** - * Returns the percentage of executed lines. - * - * @param boolean $asString - * @return integer - */ - public function getLineExecutedPercent($asString = TRUE) - { - return PHP_CodeCoverage_Util::percent( - $this->getNumExecutedLines(), - $this->getNumExecutableLines(), - $asString - ); - } - - /** - * Returns the classes of this node. - * - * @return array - */ - abstract public function getClasses(); - - /** - * Returns the traits of this node. - * - * @return array - */ - abstract public function getTraits(); - - /** - * Returns the functions of this node. - * - * @return array - */ - abstract public function getFunctions(); - - /** - * Returns the LOC/CLOC/NCLOC of this node. - * - * @return array - */ - abstract public function getLinesOfCode(); - - /** - * Returns the number of executable lines. - * - * @return integer - */ - abstract public function getNumExecutableLines(); - - /** - * Returns the number of executed lines. - * - * @return integer - */ - abstract public function getNumExecutedLines(); - - /** - * Returns the number of classes. - * - * @return integer - */ - abstract public function getNumClasses(); - - /** - * Returns the number of tested classes. - * - * @return integer - */ - abstract public function getNumTestedClasses(); - - /** - * Returns the number of traits. - * - * @return integer - */ - abstract public function getNumTraits(); - - /** - * Returns the number of tested traits. - * - * @return integer - */ - abstract public function getNumTestedTraits(); - - /** - * Returns the number of methods. - * - * @return integer - */ - abstract public function getNumMethods(); - - /** - * Returns the number of tested methods. - * - * @return integer - */ - abstract public function getNumTestedMethods(); - - /** - * Returns the number of functions. - * - * @return integer - */ - abstract public function getNumFunctions(); - - /** - * Returns the number of tested functions. - * - * @return integer - */ - abstract public function getNumTestedFunctions(); -} diff --git a/tests/PHPUnit/PHP/CodeCoverage/Report/Node/Directory.php b/tests/PHPUnit/PHP/CodeCoverage/Report/Node/Directory.php deleted file mode 100755 index 2b577f92..00000000 --- a/tests/PHPUnit/PHP/CodeCoverage/Report/Node/Directory.php +++ /dev/null @@ -1,513 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @category PHP - * @package CodeCoverage - * @author Sebastian Bergmann - * @copyright 2009-2011 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://github.com/sebastianbergmann/php-code-coverage - * @since File available since Release 1.1.0 - */ - -/** - * Represents a directory in the code coverage information tree. - * - * @category PHP - * @package CodeCoverage - * @author Sebastian Bergmann - * @copyright 2009-2011 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 1.1.1 - * @link http://github.com/sebastianbergmann/php-code-coverage - * @since Class available since Release 1.1.0 - */ -class PHP_CodeCoverage_Report_Node_Directory extends PHP_CodeCoverage_Report_Node implements IteratorAggregate -{ - /** - * @var PHP_CodeCoverage_Report_Node[] - */ - protected $children = array(); - - /** - * @var PHP_CodeCoverage_Report_Node_Directory[] - */ - protected $directories = array(); - - /** - * @var PHP_CodeCoverage_Report_Node_File[] - */ - protected $files = array(); - - /** - * @var array - */ - protected $classes; - - /** - * @var array - */ - protected $traits; - - /** - * @var array - */ - protected $functions; - - /** - * @var array - */ - protected $linesOfCode = NULL; - - /** - * @var integer - */ - protected $numFiles = -1; - - /** - * @var integer - */ - protected $numExecutableLines = -1; - - /** - * @var integer - */ - protected $numExecutedLines = -1; - - /** - * @var integer - */ - protected $numClasses = -1; - - /** - * @var integer - */ - protected $numTestedClasses = -1; - - /** - * @var integer - */ - protected $numTraits = -1; - - /** - * @var integer - */ - protected $numTestedTraits = -1; - - /** - * @var integer - */ - protected $numMethods = -1; - - /** - * @var integer - */ - protected $numTestedMethods = -1; - - /** - * @var integer - */ - protected $numFunctions = -1; - - /** - * @var integer - */ - protected $numTestedFunctions = -1; - - /** - * Returns the number of files in/under this node. - * - * @return integer - */ - public function count() - { - if ($this->numFiles == -1) { - $this->numFiles = 0; - - foreach ($this->children as $child) { - $this->numFiles += count($child); - } - } - - return $this->numFiles; - } - - /** - * Returns an iterator for this node. - * - * @return RecursiveIteratorIterator - */ - public function getIterator() - { - return new RecursiveIteratorIterator( - new PHP_CodeCoverage_Report_Node_Iterator($this), - RecursiveIteratorIterator::SELF_FIRST - ); - } - - /** - * Adds a new directory. - * - * @param string $name - * @return PHP_CodeCoverage_Report_Node_Directory - */ - public function addDirectory($name) - { - $directory = new PHP_CodeCoverage_Report_Node_Directory($name, $this); - - $this->children[] = $directory; - $this->directories[] = &$this->children[count($this->children) - 1]; - - return $directory; - } - - /** - * Adds a new file. - * - * @param string $name - * @param array $coverageData - * @param array $testData - * @param boolean $cacheTokens - * @return PHP_CodeCoverage_Report_Node_File - * @throws PHP_CodeCoverage_Exception - */ - public function addFile($name, array $coverageData, array $testData, $cacheTokens) - { - $file = new PHP_CodeCoverage_Report_Node_File( - $name, $this, $coverageData, $testData, $cacheTokens - ); - - $this->children[] = $file; - $this->files[] = &$this->children[count($this->children) - 1]; - - $this->numExecutableLines = -1; - $this->numExecutedLines = -1; - - return $file; - } - - /** - * Returns the directories in this directory. - * - * @return array - */ - public function getDirectories() - { - return $this->directories; - } - - /** - * Returns the files in this directory. - * - * @return array - */ - public function getFiles() - { - return $this->files; - } - - /** - * Returns the child nodes of this node. - * - * @return array - */ - public function getChildNodes() - { - return $this->children; - } - - /** - * Returns the classes of this node. - * - * @return array - */ - public function getClasses() - { - if ($this->classes === NULL) { - $this->classes = array(); - - foreach ($this->children as $child) { - $this->classes = array_merge( - $this->classes, $child->getClasses() - ); - } - } - - return $this->classes; - } - - /** - * Returns the traits of this node. - * - * @return array - */ - public function getTraits() - { - if ($this->traits === NULL) { - $this->traits = array(); - - foreach ($this->children as $child) { - $this->traits = array_merge( - $this->traits, $child->getTraits() - ); - } - } - - return $this->traits; - } - - /** - * Returns the functions of this node. - * - * @return array - */ - public function getFunctions() - { - if ($this->functions === NULL) { - $this->functions = array(); - - foreach ($this->children as $child) { - $this->functions = array_merge( - $this->functions, $child->getFunctions() - ); - } - } - - return $this->functions; - } - - /** - * Returns the LOC/CLOC/NCLOC of this node. - * - * @return array - */ - public function getLinesOfCode() - { - if ($this->linesOfCode === NULL) { - $this->linesOfCode = array('loc' => 0, 'cloc' => 0, 'ncloc' => 0); - - foreach ($this->children as $child) { - $linesOfCode = $child->getLinesOfCode(); - - $this->linesOfCode['loc'] += $linesOfCode['loc']; - $this->linesOfCode['cloc'] += $linesOfCode['cloc']; - $this->linesOfCode['ncloc'] += $linesOfCode['ncloc']; - } - } - - return $this->linesOfCode; - } - - /** - * Returns the number of executable lines. - * - * @return integer - */ - public function getNumExecutableLines() - { - if ($this->numExecutableLines == -1) { - $this->numExecutableLines = 0; - - foreach ($this->children as $child) { - $this->numExecutableLines += $child->getNumExecutableLines(); - } - } - - return $this->numExecutableLines; - } - - /** - * Returns the number of executed lines. - * - * @return integer - */ - public function getNumExecutedLines() - { - if ($this->numExecutedLines == -1) { - $this->numExecutedLines = 0; - - foreach ($this->children as $child) { - $this->numExecutedLines += $child->getNumExecutedLines(); - } - } - - return $this->numExecutedLines; - } - - /** - * Returns the number of classes. - * - * @return integer - */ - public function getNumClasses() - { - if ($this->numClasses == -1) { - $this->numClasses = 0; - - foreach ($this->children as $child) { - $this->numClasses += $child->getNumClasses(); - } - } - - return $this->numClasses; - } - - /** - * Returns the number of tested classes. - * - * @return integer - */ - public function getNumTestedClasses() - { - if ($this->numTestedClasses == -1) { - $this->numTestedClasses = 0; - - foreach ($this->children as $child) { - $this->numTestedClasses += $child->getNumTestedClasses(); - } - } - - return $this->numTestedClasses; - } - - /** - * Returns the number of traits. - * - * @return integer - */ - public function getNumTraits() - { - if ($this->numTraits == -1) { - $this->numTraits = 0; - - foreach ($this->children as $child) { - $this->numTraits += $child->getNumTraits(); - } - } - - return $this->numTraits; - } - - /** - * Returns the number of tested traits. - * - * @return integer - */ - public function getNumTestedTraits() - { - if ($this->numTestedTraits == -1) { - $this->numTestedTraits = 0; - - foreach ($this->children as $child) { - $this->numTestedTraits += $child->getNumTestedTraits(); - } - } - - return $this->numTestedTraits; - } - - /** - * Returns the number of methods. - * - * @return integer - */ - public function getNumMethods() - { - if ($this->numMethods == -1) { - $this->numMethods = 0; - - foreach ($this->children as $child) { - $this->numMethods += $child->getNumMethods(); - } - } - - return $this->numMethods; - } - - /** - * Returns the number of tested methods. - * - * @return integer - */ - public function getNumTestedMethods() - { - if ($this->numTestedMethods == -1) { - $this->numTestedMethods = 0; - - foreach ($this->children as $child) { - $this->numTestedMethods += $child->getNumTestedMethods(); - } - } - - return $this->numTestedMethods; - } - - /** - * Returns the number of functions. - * - * @return integer - */ - public function getNumFunctions() - { - if ($this->numFunctions == -1) { - $this->numFunctions = 0; - - foreach ($this->children as $child) { - $this->numFunctions += $child->getNumFunctions(); - } - } - - return $this->numFunctions; - } - - /** - * Returns the number of tested functions. - * - * @return integer - */ - public function getNumTestedFunctions() - { - if ($this->numTestedFunctions == -1) { - $this->numTestedFunctions = 0; - - foreach ($this->children as $child) { - $this->numTestedFunctions += $child->getNumTestedFunctions(); - } - } - - return $this->numTestedFunctions; - } -} diff --git a/tests/PHPUnit/PHP/CodeCoverage/Report/Node/File.php b/tests/PHPUnit/PHP/CodeCoverage/Report/Node/File.php deleted file mode 100755 index dd5172ee..00000000 --- a/tests/PHPUnit/PHP/CodeCoverage/Report/Node/File.php +++ /dev/null @@ -1,694 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @category PHP - * @package CodeCoverage - * @author Sebastian Bergmann - * @copyright 2009-2011 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://github.com/sebastianbergmann/php-code-coverage - * @since File available since Release 1.1.0 - */ - -/** - * Represents a file in the code coverage information tree. - * - * @category PHP - * @package CodeCoverage - * @author Sebastian Bergmann - * @copyright 2009-2011 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 1.1.1 - * @link http://github.com/sebastianbergmann/php-code-coverage - * @since Class available since Release 1.1.0 - */ -class PHP_CodeCoverage_Report_Node_File extends PHP_CodeCoverage_Report_Node -{ - /** - * @var array - */ - protected $coverageData; - - /** - * @var array - */ - protected $testData; - - /** - * @var array - */ - protected $ignoredLines; - - /** - * @var integer - */ - protected $numExecutableLines = 0; - - /** - * @var integer - */ - protected $numExecutedLines = 0; - - /** - * @var array - */ - protected $classes = array(); - - /** - * @var array - */ - protected $traits = array(); - - /** - * @var array - */ - protected $functions = array(); - - /** - * @var array - */ - protected $linesOfCode = array(); - - /** - * @var integer - */ - protected $numTestedTraits = 0; - - /** - * @var integer - */ - protected $numTestedClasses = 0; - - /** - * @var integer - */ - protected $numMethods = NULL; - - /** - * @var integer - */ - protected $numTestedMethods = NULL; - - /** - * @var integer - */ - protected $numTestedFunctions = NULL; - - /** - * @var array - */ - protected $startLines = array(); - - /** - * @var array - */ - protected $endLines = array(); - - /** - * @var boolean - */ - protected $cacheTokens; - - /** - * Constructor. - * - * @param string $name - * @param PHP_CodeCoverage_Report_Node $parent - * @param array $coverageData - * @param array $testData - * @param boolean $cacheTokens - */ - public function __construct($name, PHP_CodeCoverage_Report_Node $parent, array $coverageData, array $testData, $cacheTokens) - { - if (!is_bool($cacheTokens)) { - throw new InvalidArgumentException; - } - - parent::__construct($name, $parent); - - $this->coverageData = $coverageData; - $this->testData = $testData; - $this->ignoredLines = PHP_CodeCoverage_Util::getLinesToBeIgnored( - $this->getPath(), $cacheTokens - ); - $this->cacheTokens = $cacheTokens; - - $this->calculateStatistics(); - } - - /** - * Returns the number of files in/under this node. - * - * @return integer - */ - public function count() - { - return 1; - } - - /** - * Returns the code coverage data of this node. - * - * @return array - */ - public function getCoverageData() - { - return $this->coverageData; - } - - /** - * Returns the test data of this node. - * - * @return array - */ - public function getTestData() - { - return $this->testData; - } - - /** - * @return array - */ - public function getIgnoredLines() - { - return $this->ignoredLines; - } - - /** - * Returns the classes of this node. - * - * @return array - */ - public function getClasses() - { - return $this->classes; - } - - /** - * Returns the traits of this node. - * - * @return array - */ - public function getTraits() - { - return $this->traits; - } - - /** - * Returns the functions of this node. - * - * @return array - */ - public function getFunctions() - { - return $this->functions; - } - - /** - * Returns the LOC/CLOC/NCLOC of this node. - * - * @return array - */ - public function getLinesOfCode() - { - return $this->linesOfCode; - } - - /** - * Returns the number of executable lines. - * - * @return integer - */ - public function getNumExecutableLines() - { - return $this->numExecutableLines; - } - - /** - * Returns the number of executed lines. - * - * @return integer - */ - public function getNumExecutedLines() - { - return $this->numExecutedLines; - } - - /** - * Returns the number of classes. - * - * @return integer - */ - public function getNumClasses() - { - return count($this->classes); - } - - /** - * Returns the number of tested classes. - * - * @return integer - */ - public function getNumTestedClasses() - { - return $this->numTestedClasses; - } - - /** - * Returns the number of traits. - * - * @return integer - */ - public function getNumTraits() - { - return count($this->traits); - } - - /** - * Returns the number of tested traits. - * - * @return integer - */ - public function getNumTestedTraits() - { - return $this->numTestedTraits; - } - - /** - * Returns the number of methods. - * - * @return integer - */ - public function getNumMethods() - { - if ($this->numMethods === NULL) { - $this->numMethods = 0; - - foreach ($this->classes as $class) { - foreach ($class['methods'] as $method) { - if ($method['executableLines'] > 0) { - $this->numMethods++; - } - } - } - - foreach ($this->traits as $trait) { - foreach ($trait['methods'] as $method) { - if ($method['executableLines'] > 0) { - $this->numMethods++; - } - } - } - } - - return $this->numMethods; - } - - /** - * Returns the number of tested methods. - * - * @return integer - */ - public function getNumTestedMethods() - { - if ($this->numTestedMethods === NULL) { - $this->numTestedMethods = 0; - - foreach ($this->classes as $class) { - foreach ($class['methods'] as $method) { - if ($method['executableLines'] > 0 && - $method['coverage'] == 100) { - $this->numTestedMethods++; - } - } - } - - foreach ($this->traits as $trait) { - foreach ($trait['methods'] as $method) { - if ($method['executableLines'] > 0 && - $method['coverage'] == 100) { - $this->numTestedMethods++; - } - } - } - } - - return $this->numTestedMethods; - } - - /** - * Returns the number of functions. - * - * @return integer - */ - public function getNumFunctions() - { - return count($this->functions); - } - - /** - * Returns the number of tested functions. - * - * @return integer - */ - public function getNumTestedFunctions() - { - if ($this->numTestedFunctions === NULL) { - $this->numTestedFunctions = 0; - - foreach ($this->functions as $function) { - if ($function['executableLines'] > 0 && - $function['coverage'] == 100) { - $this->numTestedFunctions++; - } - } - } - - return $this->numTestedFunctions; - } - - /** - * Calculates coverage statistics for the file. - */ - protected function calculateStatistics() - { - if ($this->cacheTokens) { - $tokens = PHP_Token_Stream_CachingFactory::get($this->getPath()); - } else { - $tokens = new PHP_Token_Stream($this->getPath()); - } - - $this->processClasses($tokens); - $this->processTraits($tokens); - $this->processFunctions($tokens); - $this->linesOfCode = $tokens->getLinesOfCode(); - unset($tokens); - - for ($lineNumber = 1; $lineNumber <= $this->linesOfCode['loc']; $lineNumber++) { - if (isset($this->startLines[$lineNumber])) { - // Start line of a class. - if (isset($this->startLines[$lineNumber]['className'])) { - $currentClass = &$this->startLines[$lineNumber]; - } - - // Start line of a trait. - else if (isset($this->startLines[$lineNumber]['traitName'])) { - $currentTrait = &$this->startLines[$lineNumber]; - } - - // Start line of a method. - else if (isset($this->startLines[$lineNumber]['methodName'])) { - $currentMethod = &$this->startLines[$lineNumber]; - } - - // Start line of a function. - else if (isset($this->startLines[$lineNumber]['functionName'])) { - $currentFunction = &$this->startLines[$lineNumber]; - } - } - - if (!isset($this->ignoredLines[$lineNumber]) && - isset($this->coverageData[$lineNumber]) && - $this->coverageData[$lineNumber] !== NULL) { - if (isset($currentClass)) { - $currentClass['executableLines']++; - } - - if (isset($currentTrait)) { - $currentTrait['executableLines']++; - } - - if (isset($currentMethod)) { - $currentMethod['executableLines']++; - } - - if (isset($currentFunction)) { - $currentFunction['executableLines']++; - } - - $this->numExecutableLines++; - - if (count($this->coverageData[$lineNumber]) > 0 || - isset($this->ignoredLines[$lineNumber])) { - if (isset($currentClass)) { - $currentClass['executedLines']++; - } - - if (isset($currentTrait)) { - $currentTrait['executedLines']++; - } - - if (isset($currentMethod)) { - $currentMethod['executedLines']++; - } - - if (isset($currentFunction)) { - $currentFunction['executedLines']++; - } - - $this->numExecutedLines++; - } - } - - if (isset($this->endLines[$lineNumber])) { - // End line of a class. - if (isset($this->endLines[$lineNumber]['className'])) { - unset($currentClass); - } - - // End line of a trait. - else if (isset($this->endLines[$lineNumber]['traitName'])) { - unset($currentTrait); - } - - // End line of a method. - else if (isset($this->endLines[$lineNumber]['methodName'])) { - unset($currentMethod); - } - - // End line of a function. - else if (isset($this->endLines[$lineNumber]['functionName'])) { - unset($currentFunction); - } - } - } - - foreach ($this->traits as $traitName => &$trait) { - foreach ($trait['methods'] as &$method) { - if ($method['executableLines'] > 0) { - $method['coverage'] = ($method['executedLines'] / - $method['executableLines']) * 100; - } else { - $method['coverage'] = 100; - } - - $method['crap'] = PHP_CodeCoverage_Util::crap( - $method['ccn'], $method['coverage'] - ); - - $trait['ccn'] += $method['ccn']; - } - - if ($trait['executableLines'] > 0) { - $trait['coverage'] = ($trait['executedLines'] / - $trait['executableLines']) * 100; - } else { - $trait['coverage'] = 100; - } - - if ($trait['coverage'] == 100) { - $this->numTestedClasses++; - } - - $trait['crap'] = PHP_CodeCoverage_Util::crap( - $trait['ccn'], $trait['coverage'] - ); - } - - foreach ($this->classes as $className => &$class) { - foreach ($class['methods'] as &$method) { - if ($method['executableLines'] > 0) { - $method['coverage'] = ($method['executedLines'] / - $method['executableLines']) * 100; - } else { - $method['coverage'] = 100; - } - - $method['crap'] = PHP_CodeCoverage_Util::crap( - $method['ccn'], $method['coverage'] - ); - - $class['ccn'] += $method['ccn']; - } - - if ($class['executableLines'] > 0) { - $class['coverage'] = ($class['executedLines'] / - $class['executableLines']) * 100; - } else { - $class['coverage'] = 100; - } - - if ($class['coverage'] == 100) { - $this->numTestedClasses++; - } - - $class['crap'] = PHP_CodeCoverage_Util::crap( - $class['ccn'], $class['coverage'] - ); - } - } - - /** - * @param PHP_Token_Stream $tokens - */ - protected function processClasses(PHP_Token_Stream $tokens) - { - $classes = $tokens->getClasses(); - unset($tokens); - - $link = $this->getId() . '.html#'; - - foreach ($classes as $className => $class) { - $this->classes[$className] = array( - 'className' => $className, - 'methods' => array(), - 'startLine' => $class['startLine'], - 'executableLines' => 0, - 'executedLines' => 0, - 'ccn' => 0, - 'coverage' => 0, - 'crap' => 0, - 'package' => $class['package'], - 'link' => $link . $class['startLine'] - ); - - $this->startLines[$class['startLine']] = &$this->classes[$className]; - $this->endLines[$class['endLine']] = &$this->classes[$className]; - - foreach ($class['methods'] as $methodName => $method) { - $this->classes[$className]['methods'][$methodName] = array( - 'methodName' => $methodName, - 'signature' => $method['signature'], - 'startLine' => $method['startLine'], - 'endLine' => $method['endLine'], - 'executableLines' => 0, - 'executedLines' => 0, - 'ccn' => $method['ccn'], - 'coverage' => 0, - 'crap' => 0, - 'link' => $link . $method['startLine'] - ); - - $this->startLines[$method['startLine']] = &$this->classes[$className]['methods'][$methodName]; - $this->endLines[$method['endLine']] = &$this->classes[$className]['methods'][$methodName]; - } - } - } - - /** - * @param PHP_Token_Stream $tokens - */ - protected function processTraits(PHP_Token_Stream $tokens) - { - $traits = $tokens->getTraits(); - unset($tokens); - - $link = $this->getId() . '.html#'; - - foreach ($traits as $traitName => $trait) { - $this->traits[$traitName] = array( - 'traitName' => $traitName, - 'methods' => array(), - 'startLine' => $trait['startLine'], - 'executableLines' => 0, - 'executedLines' => 0, - 'ccn' => 0, - 'coverage' => 0, - 'crap' => 0, - 'package' => $trait['package'], - 'link' => $link . $trait['startLine'] - ); - - $this->startLines[$trait['startLine']] = &$this->traits[$traitName]; - $this->endLines[$trait['endLine']] = &$this->traits[$traitName]; - - foreach ($trait['methods'] as $methodName => $method) { - $this->traits[$traitName]['methods'][$methodName] = array( - 'methodName' => $methodName, - 'signature' => $method['signature'], - 'startLine' => $method['startLine'], - 'executableLines' => 0, - 'executedLines' => 0, - 'ccn' => $method['ccn'], - 'coverage' => 0, - 'crap' => 0, - 'link' => $link . $method['startLine'] - ); - - $this->startLines[$method['startLine']] = &$this->traits[$traitName]['methods'][$methodName]; - $this->endLines[$method['endLine']] = &$this->traits[$traitName]['methods'][$methodName]; - } - } - } - - /** - * @param PHP_Token_Stream $tokens - */ - protected function processFunctions(PHP_Token_Stream $tokens) - { - $functions = $tokens->getFunctions(); - unset($tokens); - - $link = $this->getId() . '.html#'; - - foreach ($functions as $functionName => $function) { - $this->functions[$functionName] = array( - 'functionName' => $functionName, - 'signature' => $function['signature'], - 'startLine' => $function['startLine'], - 'executableLines' => 0, - 'executedLines' => 0, - 'ccn' => $function['ccn'], - 'coverage' => 0, - 'crap' => 0, - 'link' => $link . $function['startLine'] - ); - - $this->startLines[$function['startLine']] = &$this->functions[$functionName]; - $this->endLines[$function['endLine']] = &$this->functions[$functionName]; - } - } -} diff --git a/tests/PHPUnit/PHP/CodeCoverage/Report/Node/Iterator.php b/tests/PHPUnit/PHP/CodeCoverage/Report/Node/Iterator.php deleted file mode 100755 index e3e764bc..00000000 --- a/tests/PHPUnit/PHP/CodeCoverage/Report/Node/Iterator.php +++ /dev/null @@ -1,149 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @category PHP - * @package CodeCoverage - * @author Sebastian Bergmann - * @copyright 2009-2011 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://github.com/sebastianbergmann/php-code-coverage - * @since File available since Release 1.1.0 - */ - -/** - * Recursive iterator for PHP_CodeCoverage_Report_Node object graphs. - * - * @category PHP - * @package CodeCoverage - * @author Sebastian Bergmann - * @copyright 2009-2011 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 1.1.1 - * @link http://github.com/sebastianbergmann/php-code-coverage - * @since Class available since Release 1.1.0 - */ -class PHP_CodeCoverage_Report_Node_Iterator implements RecursiveIterator -{ - /** - * @var integer - */ - protected $position; - - /** - * @var PHP_CodeCoverage_Report_Node[] - */ - protected $nodes; - - /** - * Constructor. - * - * @param PHP_CodeCoverage_Report_Node_Directory $node - */ - public function __construct(PHP_CodeCoverage_Report_Node_Directory $node) - { - $this->nodes = $node->getChildNodes(); - } - - /** - * Rewinds the Iterator to the first element. - * - */ - public function rewind() - { - $this->position = 0; - } - - /** - * Checks if there is a current element after calls to rewind() or next(). - * - * @return boolean - */ - public function valid() - { - return $this->position < count($this->nodes); - } - - /** - * Returns the key of the current element. - * - * @return integer - */ - public function key() - { - return $this->position; - } - - /** - * Returns the current element. - * - * @return PHPUnit_Framework_Test - */ - public function current() - { - return $this->valid() ? $this->nodes[$this->position] : NULL; - } - - /** - * Moves forward to next element. - * - */ - public function next() - { - $this->position++; - } - - /** - * Returns the sub iterator for the current element. - * - * @return PHP_CodeCoverage_Report_Node_Iterator - */ - public function getChildren() - { - return new PHP_CodeCoverage_Report_Node_Iterator( - $this->nodes[$this->position] - ); - } - - /** - * Checks whether the current element has children. - * - * @return boolean - */ - public function hasChildren() - { - return $this->nodes[$this->position] instanceof PHP_CodeCoverage_Report_Node_Directory; - } -} diff --git a/tests/PHPUnit/PHP/CodeCoverage/Report/PHP.php b/tests/PHPUnit/PHP/CodeCoverage/Report/PHP.php deleted file mode 100755 index aeab1d40..00000000 --- a/tests/PHPUnit/PHP/CodeCoverage/Report/PHP.php +++ /dev/null @@ -1,75 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @category PHP - * @package CodeCoverage - * @author Sebastian Bergmann - * @copyright 2009-2011 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://github.com/sebastianbergmann/php-code-coverage - * @since File available since Release 1.1.0 - */ - -/** - * Uses serialize() to write a PHP_CodeCoverage object to a file. - * - * @category PHP - * @package CodeCoverage - * @author Sebastian Bergmann - * @copyright 2009-2011 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 1.1.1 - * @link http://github.com/sebastianbergmann/php-code-coverage - * @since Class available since Release 1.1.0 - */ -class PHP_CodeCoverage_Report_PHP -{ - /** - * @param PHP_CodeCoverage $coverage - * @param string $target - * @return string - */ - public function process(PHP_CodeCoverage $coverage, $target = NULL) - { - $coverage = serialize($coverage); - - if ($target !== NULL) { - return file_put_contents($target, $coverage); - } else { - return $coverage; - } - } -} diff --git a/tests/PHPUnit/PHP/CodeCoverage/Report/Text.php b/tests/PHPUnit/PHP/CodeCoverage/Report/Text.php deleted file mode 100755 index beafc52e..00000000 --- a/tests/PHPUnit/PHP/CodeCoverage/Report/Text.php +++ /dev/null @@ -1,286 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @category PHP - * @package CodeCoverage - * @author Sebastian Bergmann - * @copyright 2009-2011 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://github.com/sebastianbergmann/php-code-coverage - * @since File available since Release 1.1.0 - */ - -/** - * Generates human readable output from an PHP_CodeCoverage object. - * - * The output gets put into a text file our written to the CLI. - * - * @category PHP - * @package CodeCoverage - * @author Sebastian Bergmann - * @copyright 2009-2011 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 1.1.1 - * @link http://github.com/sebastianbergmann/php-code-coverage - * @since Class available since Release 1.1.0 - */ -class PHP_CodeCoverage_Report_Text -{ - protected $outputStream; - protected $title; - protected $lowUpperBound; - protected $highLowerBound; - protected $showUncoveredFiles; - - protected $colors = array( - 'green' => "\x1b[30;42m", - 'yellow' => "\x1b[30;43m", - 'red' => "\x1b[37;41m", - 'header' => "\x1b[47;40m", - 'reset' => "\x1b[0m", - 'eol' => "\x1b[2K", - ); - - public function __construct(PHPUnit_Util_Printer $outputStream, $title, $lowUpperBound, $highLowerBound, $showUncoveredFiles) - { - $this->outputStream = $outputStream; - $this->title = $title; - $this->lowUpperBound = $lowUpperBound; - $this->highLowerBound = $highLowerBound; - $this->showUncoveredFiles = $showUncoveredFiles; - } - - /** - * @param PHP_CodeCoverage $coverage - * @param string $target - * @param string $name - * @return string - */ - public function process(PHP_CodeCoverage $coverage, $showColors = FALSE) - { - $output = ''; - $packages = array(); - $report = $coverage->getReport(); - unset($coverage); - - $colors = array( - 'header' => '', - 'classes' => '', - 'methods' => '', - 'lines' => '', - 'reset' => '', - 'eol' => '' - ); - - if ($showColors) { - $colors['classes'] = $this->getCoverageColor( - $report->getNumTestedClasses(), - $report->getNumClasses() - ); - $colors['methods'] = $this->getCoverageColor( - $report->getNumTestedMethods(), - $report->getNumMethods() - ); - $colors['lines'] = $this->getCoverageColor( - $report->getNumExecutedLines(), - $report->getNumExecutableLines() - ); - $colors['reset'] = $this->colors['reset']; - $colors['header'] = $this->colors['header']; - $colors['eol'] = $this->colors['eol']; - } - - $output .= PHP_EOL . PHP_EOL . - $colors['header'] . 'Code Coverage Report '; - - if ($this->title) { - $output .= 'for "' . $this->title . '"'; - } - - $output .= PHP_EOL . - date(' Y-m-d H:i:s', $_SERVER['REQUEST_TIME']) . - PHP_EOL; - - $output .= PHP_EOL . ' Summary: ' . PHP_EOL . $colors['reset'] - . $colors['classes'] . $colors['eol'] . ' Classes: ' . PHP_CodeCoverage_Util::percent($report->getNumTestedClasses(), $report->getNumClasses(), TRUE) - . ' (' . $report->getNumTestedClasses() . '/' . $report->getNumClasses() . ')' . PHP_EOL . $colors ['eol'] - . $colors['methods'] . $colors['eol'] . ' Methods: ' . PHP_CodeCoverage_Util::percent($report->getNumTestedMethods(), $report->getNumMethods(), TRUE) - . ' (' . $report->getNumTestedMethods() . '/' . $report->getNumMethods() . ')' . PHP_EOL . $colors ['eol'] - . $colors['lines'] . $colors['eol'] . ' Lines: ' . PHP_CodeCoverage_Util::percent($report->getNumExecutedLines(), $report->getNumExecutableLines(), TRUE) - . ' (' . $report->getNumExecutedLines() . '/' . $report->getNumExecutableLines() . ')' . PHP_EOL . $colors['reset'] . $colors ['eol']; - - $classCoverage = array(); - - foreach ($report as $item) { - if (!$item instanceof PHP_CodeCoverage_Report_Node_File) { - continue; - } - - $classes = array_merge($item->getClasses(), $item->getTraits()); - $coverage = $item->getCoverageData(); - $lines = array(); - $ignoredLines = $item->getIgnoredLines(); - - foreach ($classes as $className => $class) { - $classStatements = 0; - $coveredClassStatements = 0; - $coveredMethods = 0; - - foreach ($class['methods'] as $methodName => $method) { - $methodCount = 0; - $methodLines = 0; - $methodLinesCovered = 0; - - for ($i = $method['startLine']; - $i <= $method['endLine']; - $i++) { - if (isset($ignoredLines[$i])) { - continue; - } - - $add = TRUE; - $count = 0; - - if (isset($coverage[$i])) { - if ($coverage[$i] !== NULL) { - $classStatements++; - $methodLines++; - } else { - $add = FALSE; - } - - $count = count($coverage[$i]); - - if ($count > 0) { - $coveredClassStatements++; - $methodLinesCovered++; - } - } else { - $add = FALSE; - } - - $methodCount = max($methodCount, $count); - - if ($add) { - $lines[$i] = array( - 'count' => $count, 'type' => 'stmt' - ); - } - } - - if ($methodCount > 0) { - $coveredMethods++; - } - - } - - if (!empty($class['package']['namespace'])) { - $namespace = '\\' . $class['package']['namespace'] . '::'; - } - - else if (!empty($class['package']['fullPackage'])) { - $namespace = '@' . $class['package']['fullPackage'] . '::'; - } - - else { - $namespace = ''; - } - - $classCoverage[$namespace . $className] = array( - 'namespace' => $namespace, - 'className ' => $className, - 'methodsCovered' => $coveredMethods, - 'methodCount' => count($class['methods']), - 'statementsCovered' => $coveredClassStatements, - 'statementCount' => $classStatements, - ); - } - } - - ksort($classCoverage); - - $methodColor = ''; - $linesColor = ''; - $resetColor = ''; - - foreach ($classCoverage as $fullQualifiedPath => $classInfo) { - if ($classInfo['statementsCovered'] != 0 || - $this->showUncoveredFiles) { - - if ($showColors) { - $methodColor = $this->getCoverageColor($classInfo['methodsCovered'], $classInfo['methodCount']); - $linesColor = $this->getCoverageColor($classInfo['statementsCovered'], $classInfo['statementCount']); - $resetColor = $colors['reset']; - } - - $output .= PHP_EOL . $fullQualifiedPath . PHP_EOL - . ' ' . $methodColor . 'Methods: ' . $this->printCoverageCounts($classInfo['methodsCovered'], $classInfo['methodCount'], 2) . $resetColor . ' ' - . ' ' . $linesColor . 'Lines: ' . $this->printCoverageCounts($classInfo['statementsCovered'], $classInfo['statementCount'], 3) . $resetColor - ; - } - } - - $this->outputStream->write($output); - } - - protected function getCoverageColor($numberOfCoveredElements, $totalNumberOfElements) - { - $coverage = PHP_CodeCoverage_Util::percent( - $numberOfCoveredElements, $totalNumberOfElements - ); - - if ($coverage > $this->highLowerBound) { - return $this->colors['green']; - } - - else if ($coverage > $this->lowUpperBound) { - return $this->colors['yellow']; - } - - return $this->colors['red']; - } - - protected function printCoverageCounts($numberOfCoveredElements, $totalNumberOfElements, $presicion) - { - $format = '%' . $presicion . 's'; - - return PHP_CodeCoverage_Util::percent( - $numberOfCoveredElements, $totalNumberOfElements, TRUE, TRUE - ) . - ' (' . sprintf($format, $numberOfCoveredElements) . '/' . - sprintf($format, $totalNumberOfElements) . ')'; - } -} diff --git a/tests/PHPUnit/PHP/Timer/Autoload.php b/tests/PHPUnit/PHP/Timer/Autoload.php deleted file mode 100755 index 0e085b69..00000000 --- a/tests/PHPUnit/PHP/Timer/Autoload.php +++ /dev/null @@ -1,75 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHP - * @subpackage Timer - * @author Sebastian Bergmann - * @copyright 2010-2011 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://github.com/sebastianbergmann/php-timer - * @since File available since Release 1.1.0 - */ - -function php_timer_autoload($class = NULL) { - static $classes = NULL; - static $path = NULL; - - if ($classes === NULL) { - $classes = array( - 'php_timer' => '/Timer.php' - ); - - $path = dirname(dirname(__FILE__)); - } - - if ($class === NULL) { - $result = array(__FILE__); - - foreach ($classes as $file) { - $result[] = $path . $file; - } - - return $result; - } - - $cn = strtolower($class); - - if (isset($classes[$cn])) { - require $path . $classes[$cn]; - } -} - -spl_autoload_register('php_timer_autoload'); diff --git a/tests/PHPUnit/PHP/Token/Stream/Autoload.php b/tests/PHPUnit/PHP/Token/Stream/Autoload.php deleted file mode 100755 index ec0558d4..00000000 --- a/tests/PHPUnit/PHP/Token/Stream/Autoload.php +++ /dev/null @@ -1,232 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHP_TokenStream - * @author Sebastian Bergmann - * @copyright 2009-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://github.com/sebastianbergmann/php-token-stream/tree - * @since File available since Release 1.1.0 - */ - -function php_tokenstream_autoload($class = NULL) -{ - static $classes = NULL; - static $path = NULL;; - - if ($classes === NULL) { - $classes = array( - 'php_token' => '/Token.php', - 'php_token_abstract' => '/Token.php', - 'php_token_ampersand' => '/Token.php', - 'php_token_and_equal' => '/Token.php', - 'php_token_array' => '/Token.php', - 'php_token_array_cast' => '/Token.php', - 'php_token_as' => '/Token.php', - 'php_token_at' => '/Token.php', - 'php_token_backtick' => '/Token.php', - 'php_token_bad_character' => '/Token.php', - 'php_token_bool_cast' => '/Token.php', - 'php_token_boolean_and' => '/Token.php', - 'php_token_boolean_or' => '/Token.php', - 'php_token_break' => '/Token.php', - 'php_token_caret' => '/Token.php', - 'php_token_case' => '/Token.php', - 'php_token_catch' => '/Token.php', - 'php_token_character' => '/Token.php', - 'php_token_class' => '/Token.php', - 'php_token_class_c' => '/Token.php', - 'php_token_clone' => '/Token.php', - 'php_token_close_bracket' => '/Token.php', - 'php_token_close_curly' => '/Token.php', - 'php_token_close_square' => '/Token.php', - 'php_token_close_tag' => '/Token.php', - 'php_token_colon' => '/Token.php', - 'php_token_comma' => '/Token.php', - 'php_token_comment' => '/Token.php', - 'php_token_concat_equal' => '/Token.php', - 'php_token_const' => '/Token.php', - 'php_token_constant_encapsed_string' => '/Token.php', - 'php_token_continue' => '/Token.php', - 'php_token_curly_open' => '/Token.php', - 'php_token_dec' => '/Token.php', - 'php_token_declare' => '/Token.php', - 'php_token_default' => '/Token.php', - 'php_token_dir' => '/Token.php', - 'php_token_div' => '/Token.php', - 'php_token_div_equal' => '/Token.php', - 'php_token_dnumber' => '/Token.php', - 'php_token_do' => '/Token.php', - 'php_token_doc_comment' => '/Token.php', - 'php_token_dollar' => '/Token.php', - 'php_token_dollar_open_curly_braces' => '/Token.php', - 'php_token_dot' => '/Token.php', - 'php_token_double_arrow' => '/Token.php', - 'php_token_double_cast' => '/Token.php', - 'php_token_double_colon' => '/Token.php', - 'php_token_double_quotes' => '/Token.php', - 'php_token_echo' => '/Token.php', - 'php_token_else' => '/Token.php', - 'php_token_elseif' => '/Token.php', - 'php_token_empty' => '/Token.php', - 'php_token_encapsed_and_whitespace' => '/Token.php', - 'php_token_end_heredoc' => '/Token.php', - 'php_token_enddeclare' => '/Token.php', - 'php_token_endfor' => '/Token.php', - 'php_token_endforeach' => '/Token.php', - 'php_token_endif' => '/Token.php', - 'php_token_endswitch' => '/Token.php', - 'php_token_endwhile' => '/Token.php', - 'php_token_equal' => '/Token.php', - 'php_token_eval' => '/Token.php', - 'php_token_exclamation_mark' => '/Token.php', - 'php_token_exit' => '/Token.php', - 'php_token_extends' => '/Token.php', - 'php_token_file' => '/Token.php', - 'php_token_final' => '/Token.php', - 'php_token_for' => '/Token.php', - 'php_token_foreach' => '/Token.php', - 'php_token_func_c' => '/Token.php', - 'php_token_function' => '/Token.php', - 'php_token_global' => '/Token.php', - 'php_token_goto' => '/Token.php', - 'php_token_gt' => '/Token.php', - 'php_token_halt_compiler' => '/Token.php', - 'php_token_if' => '/Token.php', - 'php_token_implements' => '/Token.php', - 'php_token_inc' => '/Token.php', - 'php_token_include' => '/Token.php', - 'php_token_include_once' => '/Token.php', - 'php_token_includes' => '/Token.php', - 'php_token_inline_html' => '/Token.php', - 'php_token_instanceof' => '/Token.php', - 'php_token_int_cast' => '/Token.php', - 'php_token_interface' => '/Token.php', - 'php_token_is_equal' => '/Token.php', - 'php_token_is_greater_or_equal' => '/Token.php', - 'php_token_is_identical' => '/Token.php', - 'php_token_is_not_equal' => '/Token.php', - 'php_token_is_not_identical' => '/Token.php', - 'php_token_is_smaller_or_equal' => '/Token.php', - 'php_token_isset' => '/Token.php', - 'php_token_line' => '/Token.php', - 'php_token_list' => '/Token.php', - 'php_token_lnumber' => '/Token.php', - 'php_token_logical_and' => '/Token.php', - 'php_token_logical_or' => '/Token.php', - 'php_token_logical_xor' => '/Token.php', - 'php_token_lt' => '/Token.php', - 'php_token_method_c' => '/Token.php', - 'php_token_minus' => '/Token.php', - 'php_token_minus_equal' => '/Token.php', - 'php_token_mod_equal' => '/Token.php', - 'php_token_mul_equal' => '/Token.php', - 'php_token_mult' => '/Token.php', - 'php_token_namespace' => '/Token.php', - 'php_token_new' => '/Token.php', - 'php_token_ns_c' => '/Token.php', - 'php_token_ns_separator' => '/Token.php', - 'php_token_num_string' => '/Token.php', - 'php_token_object_cast' => '/Token.php', - 'php_token_object_operator' => '/Token.php', - 'php_token_open_bracket' => '/Token.php', - 'php_token_open_curly' => '/Token.php', - 'php_token_open_square' => '/Token.php', - 'php_token_open_tag' => '/Token.php', - 'php_token_open_tag_with_echo' => '/Token.php', - 'php_token_or_equal' => '/Token.php', - 'php_token_paamayim_nekudotayim' => '/Token.php', - 'php_token_percent' => '/Token.php', - 'php_token_pipe' => '/Token.php', - 'php_token_plus' => '/Token.php', - 'php_token_plus_equal' => '/Token.php', - 'php_token_print' => '/Token.php', - 'php_token_private' => '/Token.php', - 'php_token_protected' => '/Token.php', - 'php_token_public' => '/Token.php', - 'php_token_question_mark' => '/Token.php', - 'php_token_require' => '/Token.php', - 'php_token_require_once' => '/Token.php', - 'php_token_return' => '/Token.php', - 'php_token_semicolon' => '/Token.php', - 'php_token_sl' => '/Token.php', - 'php_token_sl_equal' => '/Token.php', - 'php_token_sr' => '/Token.php', - 'php_token_sr_equal' => '/Token.php', - 'php_token_start_heredoc' => '/Token.php', - 'php_token_static' => '/Token.php', - 'php_token_stream' => '/Token/Stream.php', - 'php_token_stream_cachingfactory' => '/Token/Stream/CachingFactory.php', - 'php_token_string' => '/Token.php', - 'php_token_string_cast' => '/Token.php', - 'php_token_string_varname' => '/Token.php', - 'php_token_switch' => '/Token.php', - 'php_token_throw' => '/Token.php', - 'php_token_tilde' => '/Token.php', - 'php_token_trait' => '/Token.php', - 'php_token_try' => '/Token.php', - 'php_token_unset' => '/Token.php', - 'php_token_unset_cast' => '/Token.php', - 'php_token_use' => '/Token.php', - 'php_token_var' => '/Token.php', - 'php_token_variable' => '/Token.php', - 'php_token_while' => '/Token.php', - 'php_token_whitespace' => '/Token.php', - 'php_token_xor_equal' => '/Token.php', - 'php_tokenwithscope' => '/Token.php' - ); - - $path = dirname(dirname(dirname(__FILE__))); - } - - if ($class === NULL) { - $result = array(__FILE__); - - foreach ($classes as $file) { - $result[] = $path . $file; - } - - return $result; - } - - $cn = strtolower($class); - - if (isset($classes[$cn])) { - require $path . $classes[$cn]; - } -} - -spl_autoload_register('php_tokenstream_autoload'); diff --git a/tests/PHPUnit/PHPUnit/Framework/Comparator.php b/tests/PHPUnit/PHPUnit/Framework/Comparator.php deleted file mode 100755 index 723d432e..00000000 --- a/tests/PHPUnit/PHPUnit/Framework/Comparator.php +++ /dev/null @@ -1,98 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Framework - * @author Bernhard Schussek - * @copyright 2002-2011 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.6.0 - */ - -/** - * Abstract base class for comparators which compare values for equality. - * - * @package PHPUnit - * @subpackage Framework - * @author Bernhard Schussek - * @copyright 2002-2011 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.6.3 - * @link http://www.phpunit.de/ - * @since Class available since Release 3.6.0 - */ -abstract class PHPUnit_Framework_Comparator -{ - /** - * @var PHPUnit_Framework_ComparatorFactory - */ - protected $factory; - - /** - * @param PHPUnit_Framework_ComparatorFactory $factory - */ - public function setFactory(PHPUnit_Framework_ComparatorFactory $factory) - { - $this->factory = $factory; - } - - /** - * Returns whether the comparator can compare two values. - * - * @param mixed $expected The first value to compare - * @param mixed $actual The second value to compare - * @return boolean - */ - abstract public function accepts($expected, $actual); - - /** - * Asserts that two values are equal. - * - * @param mixed $expected The first value to compare - * @param mixed $actual The second value to compare - * @param float $delta The allowed numerical distance between two values to - * consider them equal - * @param bool $canonicalize If set to TRUE, arrays are sorted before - * comparison - * @param bool $ignoreCase If set to TRUE, upper- and lowercasing is - * ignored when comparing string values - * @throws PHPUnit_Framework_ComparisonFailure Thrown when the comparison - * fails. Contains information about the - * specific errors that lead to the failure. - */ - abstract public function assertEquals($expected, $actual, $delta = 0, $canonicalize = FALSE, $ignoreCase = FALSE); -} diff --git a/tests/PHPUnit/PHPUnit/Framework/Comparator/Array.php b/tests/PHPUnit/PHPUnit/Framework/Comparator/Array.php deleted file mode 100755 index b9c05215..00000000 --- a/tests/PHPUnit/PHPUnit/Framework/Comparator/Array.php +++ /dev/null @@ -1,178 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Framework - * @author Bernhard Schussek - * @copyright 2002-2011 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.6.0 - */ - -/** - * Compares arrays for equality. - * - * @package PHPUnit - * @subpackage Framework_Comparator - * @author Bernhard Schussek - * @copyright 2002-2011 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.6.3 - * @link http://www.phpunit.de/ - * @since Class available since Release 3.6.0 - */ -class PHPUnit_Framework_Comparator_Array extends PHPUnit_Framework_Comparator -{ - /** - * Returns whether the comparator can compare two values. - * - * @param mixed $expected The first value to compare - * @param mixed $actual The second value to compare - * @return boolean - */ - public function accepts($expected, $actual) - { - return is_array($expected) && is_array($actual); - } - - /** - * Asserts that two values are equal. - * - * @param mixed $expected The first value to compare - * @param mixed $actual The second value to compare - * @param float $delta The allowed numerical distance between two values to - * consider them equal - * @param bool $canonicalize If set to TRUE, arrays are sorted before - * comparison - * @param bool $ignoreCase If set to TRUE, upper- and lowercasing is - * ignored when comparing string values - * @throws PHPUnit_Framework_ComparisonFailure Thrown when the comparison - * fails. Contains information about the - * specific errors that lead to the failure. - */ - public function assertEquals($expected, $actual, $delta = 0, $canonicalize = FALSE, $ignoreCase = FALSE, array &$processed = array()) - { - if ($canonicalize) { - sort($expected); - sort($actual); - } - - $remaining = $actual; - $expString = $actString = "Array (\n"; - $equal = TRUE; - - foreach ($expected as $key => $value) { - unset($remaining[$key]); - - if (!array_key_exists($key, $actual)) { - $expString .= sprintf( - " %s => %s\n", - - PHPUnit_Util_Type::export($key), - PHPUnit_Util_Type::shortenedExport($value) - ); - $equal = FALSE; - continue; - } - - try { - $this->factory->getComparatorFor($value, $actual[$key])->assertEquals($value, $actual[$key], $delta, $canonicalize, $ignoreCase, $processed); - $expString .= sprintf( - " %s => %s\n", - - PHPUnit_Util_Type::export($key), - PHPUnit_Util_Type::shortenedExport($value) - ); - $actString .= sprintf( - " %s => %s\n", - - PHPUnit_Util_Type::export($key), - PHPUnit_Util_Type::shortenedExport($actual[$key]) - ); - } - - catch (PHPUnit_Framework_ComparisonFailure $e) { - $expString .= sprintf( - " %s => %s\n", - - PHPUnit_Util_Type::export($key), - $e->getExpectedAsString() - ? $this->indent($e->getExpectedAsString()) - : PHPUnit_Util_Type::shortenedExport($e->getExpected()) - ); - $actString .= sprintf( - " %s => %s\n", - - PHPUnit_Util_Type::export($key), - $e->getActualAsString() - ? $this->indent($e->getActualAsString()) - : PHPUnit_Util_Type::shortenedExport($e->getActual()) - ); - $equal = FALSE; - } - } - - foreach ($remaining as $key => $value) { - $actString .= sprintf( - " %s => %s\n", - - PHPUnit_Util_Type::export($key), - PHPUnit_Util_Type::shortenedExport($value) - ); - $equal = FALSE; - } - - $expString .= ')'; - $actString .= ')'; - - if (!$equal) { - throw new PHPUnit_Framework_ComparisonFailure( - $expected, - $actual, - $expString, - $actString, - FALSE, - 'Failed asserting that two arrays are equal.' - ); - } - } - - protected function indent($lines) - { - return trim(str_replace("\n", "\n ", $lines)); - } -} diff --git a/tests/PHPUnit/PHPUnit/Framework/Comparator/DOMDocument.php b/tests/PHPUnit/PHPUnit/Framework/Comparator/DOMDocument.php deleted file mode 100755 index 327c4fd4..00000000 --- a/tests/PHPUnit/PHPUnit/Framework/Comparator/DOMDocument.php +++ /dev/null @@ -1,115 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Framework - * @author Bernhard Schussek - * @copyright 2002-2011 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.6.0 - */ - -/** - * Compares DOMDocument instances for equality. - * - * @package PHPUnit - * @subpackage Framework_Comparator - * @author Bernhard Schussek - * @copyright 2002-2011 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.6.3 - * @link http://www.phpunit.de/ - * @since Class available since Release 3.6.0 - */ -class PHPUnit_Framework_Comparator_DOMDocument extends PHPUnit_Framework_Comparator_Object -{ - /** - * Returns whether the comparator can compare two values. - * - * @param mixed $expected The first value to compare - * @param mixed $actual The second value to compare - * @return boolean - */ - public function accepts($expected, $actual) - { - return $expected instanceof DOMDocument && $actual instanceof DOMDocument; - } - - /** - * Asserts that two values are equal. - * - * @param mixed $expected The first value to compare - * @param mixed $actual The second value to compare - * @param float $delta The allowed numerical distance between two values to - * consider them equal - * @param bool $canonicalize If set to TRUE, arrays are sorted before - * comparison - * @param bool $ignoreCase If set to TRUE, upper- and lowercasing is - * ignored when comparing string values - * @throws PHPUnit_Framework_ComparisonFailure Thrown when the comparison - * fails. Contains information about the - * specific errors that lead to the failure. - */ - public function assertEquals($expected, $actual, $delta = 0, $canonicalize = FALSE, $ignoreCase = FALSE) - { - if ($expected->C14N() !== $actual->C14N()) { - throw new PHPUnit_Framework_ComparisonFailure( - $expected, - $actual, - $this->domToText($expected), - $this->domToText($actual), - FALSE, - 'Failed asserting that two DOM documents are equal.' - ); - } - } - - /** - * Returns the normalized, whitespace-cleaned, and indented textual - * representation of a DOMDocument. - * - * @param DOMDocument $document - * @return string - */ - protected function domToText(DOMDocument $document) - { - $document->formatOutput = TRUE; - $document->normalizeDocument(); - - return $document->saveXML(); - } -} diff --git a/tests/PHPUnit/PHPUnit/Framework/Comparator/Double.php b/tests/PHPUnit/PHPUnit/Framework/Comparator/Double.php deleted file mode 100755 index 47292fd3..00000000 --- a/tests/PHPUnit/PHPUnit/Framework/Comparator/Double.php +++ /dev/null @@ -1,102 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Framework - * @author Bernhard Schussek - * @copyright 2002-2011 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.6.0 - */ - -/** - * Compares doubles for equality. - * - * @package PHPUnit - * @subpackage Framework_Comparator - * @author Bernhard Schussek - * @copyright 2002-2011 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.6.3 - * @link http://www.phpunit.de/ - * @since Class available since Release 3.6.0 - */ -class PHPUnit_Framework_Comparator_Double extends PHPUnit_Framework_Comparator_Numeric -{ - /** - * Smallest value available in PHP. - * - * @var float - */ - const EPSILON = 0.0000000001; - - /** - * Returns whether the comparator can compare two values. - * - * @param mixed $expected The first value to compare - * @param mixed $actual The second value to compare - * @return boolean - */ - public function accepts($expected, $actual) - { - return (is_double($expected) || is_double($actual)) && is_numeric($expected) && is_numeric($actual); - } - - /** - * Asserts that two values are equal. - * - * @param mixed $expected The first value to compare - * @param mixed $actual The second value to compare - * @param float $delta The allowed numerical distance between two values to - * consider them equal - * @param bool $canonicalize If set to TRUE, arrays are sorted before - * comparison - * @param bool $ignoreCase If set to TRUE, upper- and lowercasing is - * ignored when comparing string values - * @throws PHPUnit_Framework_ComparisonFailure Thrown when the comparison - * fails. Contains information about the - * specific errors that lead to the failure. - */ - public function assertEquals($expected, $actual, $delta = 0, $canonicalize = FALSE, $ignoreCase = FALSE) - { - if ($delta == 0) { - $delta = self::EPSILON; - } - - parent::assertEquals($expected, $actual, $delta, $canonicalize, $ignoreCase); - } -} diff --git a/tests/PHPUnit/PHPUnit/Framework/Comparator/Exception.php b/tests/PHPUnit/PHPUnit/Framework/Comparator/Exception.php deleted file mode 100755 index e020ea4c..00000000 --- a/tests/PHPUnit/PHPUnit/Framework/Comparator/Exception.php +++ /dev/null @@ -1,93 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Framework - * @author Bernhard Schussek - * @copyright 2002-2011 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.6.0 - */ - -/** - * Compares Exception instances for equality. - * - * @package PHPUnit - * @subpackage Framework_Comparator - * @author Bernhard Schussek - * @copyright 2002-2011 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.6.3 - * @link http://www.phpunit.de/ - * @since Class available since Release 3.6.0 - */ -class PHPUnit_Framework_Comparator_Exception extends PHPUnit_Framework_Comparator_Object -{ - /** - * Returns whether the comparator can compare two values. - * - * @param mixed $expected The first value to compare - * @param mixed $actual The second value to compare - * @return boolean - */ - public function accepts($expected, $actual) - { - return $expected instanceof Exception && $actual instanceof Exception; - } - - /** - * Converts an object to an array containing all of its private, protected - * and public properties. - * - * @param object $object - * @return array - */ - protected function toArray($object) - { - $array = parent::toArray($object); - - unset( - $array['file'], - $array['line'], - $array['trace'], - $array['string'], // some internal property of Exception - $array['xdebug_message'] // some internal property added by XDebug - ); - - return $array; - } -} diff --git a/tests/PHPUnit/PHPUnit/Framework/Comparator/MockObject.php b/tests/PHPUnit/PHPUnit/Framework/Comparator/MockObject.php deleted file mode 100755 index 71f5b817..00000000 --- a/tests/PHPUnit/PHPUnit/Framework/Comparator/MockObject.php +++ /dev/null @@ -1,87 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Framework - * @author Bernhard Schussek - * @copyright 2002-2011 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.6.0 - */ - -/** - * Compares PHPUnit_Framework_MockObject_MockObject instances for equality. - * - * @package PHPUnit - * @subpackage Framework_Comparator - * @author Bernhard Schussek - * @copyright 2002-2011 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.6.3 - * @link http://www.phpunit.de/ - * @since Class available since Release 3.6.0 - */ -class PHPUnit_Framework_Comparator_MockObject extends PHPUnit_Framework_Comparator_Object -{ - /** - * Returns whether the comparator can compare two values. - * - * @param mixed $expected The first value to compare - * @param mixed $actual The second value to compare - * @return boolean - */ - public function accepts($expected, $actual) - { - return $expected instanceof PHPUnit_Framework_MockObject_MockObject && $actual instanceof PHPUnit_Framework_MockObject_MockObject; - } - - /** - * Converts an object to an array containing all of its private, protected - * and public properties. - * - * @param object $object - * @return array - */ - protected function toArray($object) - { - $array = parent::toArray($object); - - unset($array['invocationMocker']); - - return $array; - } -} diff --git a/tests/PHPUnit/PHPUnit/Framework/Comparator/Numeric.php b/tests/PHPUnit/PHPUnit/Framework/Comparator/Numeric.php deleted file mode 100755 index 4b6cd289..00000000 --- a/tests/PHPUnit/PHPUnit/Framework/Comparator/Numeric.php +++ /dev/null @@ -1,117 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Framework - * @author Bernhard Schussek - * @copyright 2002-2011 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.6.0 - */ - -/** - * Compares numerical values for equality. - * - * @package PHPUnit - * @subpackage Framework_Comparator - * @author Bernhard Schussek - * @author Alexander - * @copyright 2002-2011 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.6.3 - * @link http://www.phpunit.de/ - * @since Class available since Release 3.6.0 - */ -class PHPUnit_Framework_Comparator_Numeric extends PHPUnit_Framework_Comparator_Scalar -{ - /** - * Returns whether the comparator can compare two values. - * - * @param mixed $expected The first value to compare - * @param mixed $actual The second value to compare - * @return boolean - */ - public function accepts($expected, $actual) - { - // all numerical values, but not if one of them is a double - return is_numeric($expected) && is_numeric($actual) && !(is_double($expected) || is_double($actual)); - } - - /** - * Asserts that two values are equal. - * - * @param mixed $expected The first value to compare - * @param mixed $actual The second value to compare - * @param float $delta The allowed numerical distance between two values to - * consider them equal - * @param bool $canonicalize If set to TRUE, arrays are sorted before - * comparison - * @param bool $ignoreCase If set to TRUE, upper- and lowercasing is - * ignored when comparing string values - * @throws PHPUnit_Framework_ComparisonFailure Thrown when the comparison - * fails. Contains information about the - * specific errors that lead to the failure. - */ - public function assertEquals($expected, $actual, $delta = 0, $canonicalize = FALSE, $ignoreCase = FALSE) - { - if (is_infinite($actual) && is_infinite($expected)) { - return; - } - - if (is_nan($actual) && is_nan($expected)) { - return; - } - - if ((is_infinite($actual) XOR is_infinite($expected)) || - (is_nan($actual) XOR is_nan($expected)) || - abs($actual - $expected) > $delta) { - throw new PHPUnit_Framework_ComparisonFailure( - $expected, - $actual, - '', - '', - FALSE, - sprintf( - 'Failed asserting that %s matches expected %s.', - - PHPUnit_Util_Type::export($actual), - PHPUnit_Util_Type::export($expected) - ) - ); - } - } -} diff --git a/tests/PHPUnit/PHPUnit/Framework/Comparator/Object.php b/tests/PHPUnit/PHPUnit/Framework/Comparator/Object.php deleted file mode 100755 index de6d76ab..00000000 --- a/tests/PHPUnit/PHPUnit/Framework/Comparator/Object.php +++ /dev/null @@ -1,146 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Framework - * @author Bernhard Schussek - * @copyright 2002-2011 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.6.0 - */ - -/** - * Compares objects for equality. - * - * @package PHPUnit - * @subpackage Framework_Comparator - * @author Bernhard Schussek - * @copyright 2002-2011 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.6.3 - * @link http://www.phpunit.de/ - * @since Class available since Release 3.6.0 - */ -class PHPUnit_Framework_Comparator_Object extends PHPUnit_Framework_Comparator_Array -{ - /** - * Returns whether the comparator can compare two values. - * - * @param mixed $expected The first value to compare - * @param mixed $actual The second value to compare - * @return boolean - */ - public function accepts($expected, $actual) - { - return is_object($expected) && is_object($actual); - } - - /** - * Asserts that two values are equal. - * - * @param mixed $expected The first value to compare - * @param mixed $actual The second value to compare - * @param float $delta The allowed numerical distance between two values to - * consider them equal - * @param bool $canonicalize If set to TRUE, arrays are sorted before - * comparison - * @param bool $ignoreCase If set to TRUE, upper- and lowercasing is - * ignored when comparing string values - * @throws PHPUnit_Framework_ComparisonFailure Thrown when the comparison - * fails. Contains information about the - * specific errors that lead to the failure. - */ - public function assertEquals($expected, $actual, $delta = 0, $canonicalize = FALSE, $ignoreCase = FALSE, array &$processed = array()) - { - if (get_class($actual) !== get_class($expected)) { - throw new PHPUnit_Framework_ComparisonFailure( - $expected, - $actual, - PHPUnit_Util_Type::export($expected), - PHPUnit_Util_Type::export($actual), - FALSE, - sprintf( - '%s is not instance of expected class "%s".', - - PHPUnit_Util_Type::export($actual), - get_class($expected) - ) - ); - } - - // don't compare twice to allow for cyclic dependencies - if (in_array(array($actual, $expected), $processed, TRUE) || - in_array(array($expected, $actual), $processed, TRUE)) { - return; - } - - $processed[] = array($actual, $expected); - - // don't compare objects if they are identical - // this helps to avoid the error "maximum function nesting level reached" - // CAUTION: this conditional clause is not tested - if ($actual !== $expected) { - try { - parent::assertEquals($this->toArray($expected), $this->toArray($actual), $delta, $canonicalize, $ignoreCase, $processed); - } - - catch (PHPUnit_Framework_ComparisonFailure $e) { - throw new PHPUnit_Framework_ComparisonFailure( - $expected, - $actual, - // replace "Array" with "MyClass object" - substr_replace($e->getExpectedAsString(), get_class($expected).' Object', 0, 5), - substr_replace($e->getActualAsString(), get_class($actual).' Object', 0, 5), - FALSE, - 'Failed asserting that two objects are equal.' - ); - } - } - } - - /** - * Converts an object to an array containing all of its private, protected - * and public properties. - * - * @param object $object - * @return array - */ - protected function toArray($object) - { - return PHPUnit_Util_Type::toArray($object); - } -} diff --git a/tests/PHPUnit/PHPUnit/Framework/Comparator/Resource.php b/tests/PHPUnit/PHPUnit/Framework/Comparator/Resource.php deleted file mode 100755 index 81c651c1..00000000 --- a/tests/PHPUnit/PHPUnit/Framework/Comparator/Resource.php +++ /dev/null @@ -1,98 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Framework - * @author Bernhard Schussek - * @copyright 2002-2011 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.6.0 - */ - -/** - * Compares resources for equality. - * - * @package PHPUnit - * @subpackage Framework_Comparator - * @author Bernhard Schussek - * @copyright 2002-2011 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.6.3 - * @link http://www.phpunit.de/ - * @since Class available since Release 3.6.0 - */ -class PHPUnit_Framework_Comparator_Resource extends PHPUnit_Framework_Comparator -{ - /** - * Returns whether the comparator can compare two values. - * - * @param mixed $expected The first value to compare - * @param mixed $actual The second value to compare - * @return boolean - */ - public function accepts($expected, $actual) - { - return is_resource($expected) && is_resource($actual); - } - - /** - * Asserts that two values are equal. - * - * @param mixed $expected The first value to compare - * @param mixed $actual The second value to compare - * @param float $delta The allowed numerical distance between two values to - * consider them equal - * @param bool $canonicalize If set to TRUE, arrays are sorted before - * comparison - * @param bool $ignoreCase If set to TRUE, upper- and lowercasing is - * ignored when comparing string values - * @throws PHPUnit_Framework_ComparisonFailure Thrown when the comparison - * fails. Contains information about the - * specific errors that lead to the failure. - */ - public function assertEquals($expected, $actual, $delta = 0, $canonicalize = FALSE, $ignoreCase = FALSE) - { - if ($actual != $expected) { - throw new PHPUnit_Framework_ComparisonFailure( - $expected, - $actual, - PHPUnit_Util_Type::export($expected), - PHPUnit_Util_Type::export($actual) - ); - } - } -} diff --git a/tests/PHPUnit/PHPUnit/Framework/Comparator/Scalar.php b/tests/PHPUnit/PHPUnit/Framework/Comparator/Scalar.php deleted file mode 100755 index a7d6fe72..00000000 --- a/tests/PHPUnit/PHPUnit/Framework/Comparator/Scalar.php +++ /dev/null @@ -1,137 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Framework - * @author Bernhard Schussek - * @copyright 2002-2011 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.6.0 - */ - -/** - * Compares scalar or NULL values for equality. - * - * @package PHPUnit - * @subpackage Framework_Comparator - * @author Bernhard Schussek - * @copyright 2002-2011 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.6.3 - * @link http://www.phpunit.de/ - * @since Class available since Release 3.6.0 - */ -class PHPUnit_Framework_Comparator_Scalar extends PHPUnit_Framework_Comparator -{ - /** - * Returns whether the comparator can compare two values. - * - * @param mixed $expected The first value to compare - * @param mixed $actual The second value to compare - * @return boolean - * @since Method available since Release 3.6.0 - */ - public function accepts($expected, $actual) - { - return ((is_scalar($expected) XOR NULL === $expected) && - (is_scalar($actual) XOR NULL === $actual)) - // allow comparison between strings and objects featuring __toString() - || (is_string($expected) && is_object($actual) && method_exists($actual, '__toString')) - || (is_object($expected) && method_exists($expected, '__toString') && is_string($actual)); - } - - /** - * Asserts that two values are equal. - * - * @param mixed $expected The first value to compare - * @param mixed $actual The second value to compare - * @param float $delta The allowed numerical distance between two values to - * consider them equal - * @param bool $canonicalize If set to TRUE, arrays are sorted before - * comparison - * @param bool $ignoreCase If set to TRUE, upper- and lowercasing is - * ignored when comparing string values - * @throws PHPUnit_Framework_ComparisonFailure Thrown when the comparison - * fails. Contains information about the - * specific errors that lead to the failure. - */ - public function assertEquals($expected, $actual, $delta = 0, $canonicalize = FALSE, $ignoreCase = FALSE) - { - $expectedToCompare = $expected; - $actualToCompare = $actual; - - // always compare as strings to avoid strange behaviour - // otherwise 0 == 'Foobar' - if (is_string($expected) || is_string($actual)) { - $expectedToCompare = (string)$expectedToCompare; - $actualToCompare = (string)$actualToCompare; - - if ($ignoreCase) { - $expectedToCompare = strtolower($expectedToCompare); - $actualToCompare = strtolower($actualToCompare); - } - } - - if ($expectedToCompare != $actualToCompare) { - if (is_string($expected) && is_string($actual)) { - throw new PHPUnit_Framework_ComparisonFailure( - $expected, - $actual, - PHPUnit_Util_Type::export($expected), - PHPUnit_Util_Type::export($actual), - FALSE, - 'Failed asserting that two strings are equal.' - ); - } - - throw new PHPUnit_Framework_ComparisonFailure( - $expected, - $actual, - // no diff is required - '', - '', - FALSE, - sprintf( - 'Failed asserting that %s matches expected %s.', - - PHPUnit_Util_Type::export($actual), - PHPUnit_Util_Type::export($expected) - ) - ); - } - } -} diff --git a/tests/PHPUnit/PHPUnit/Framework/Comparator/SplObjectStorage.php b/tests/PHPUnit/PHPUnit/Framework/Comparator/SplObjectStorage.php deleted file mode 100755 index d0ed4d3f..00000000 --- a/tests/PHPUnit/PHPUnit/Framework/Comparator/SplObjectStorage.php +++ /dev/null @@ -1,115 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Framework - * @author Bernhard Schussek - * @copyright 2002-2011 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.6.0 - */ - -/** - * Compares SplObjectStorage instances for equality. - * - * @package PHPUnit - * @subpackage Framework_Comparator - * @author Bernhard Schussek - * @copyright 2002-2011 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.6.3 - * @link http://www.phpunit.de/ - * @since Class available since Release 3.6.0 - */ -class PHPUnit_Framework_Comparator_SplObjectStorage extends PHPUnit_Framework_Comparator -{ - /** - * Returns whether the comparator can compare two values. - * - * @param mixed $expected The first value to compare - * @param mixed $actual The second value to compare - * @return boolean - */ - public function accepts($expected, $actual) - { - return $expected instanceof SplObjectStorage && $actual instanceof SplObjectStorage; - } - - /** - * Asserts that two values are equal. - * - * @param mixed $expected The first value to compare - * @param mixed $actual The second value to compare - * @param float $delta The allowed numerical distance between two values to - * consider them equal - * @param bool $canonicalize If set to TRUE, arrays are sorted before - * comparison - * @param bool $ignoreCase If set to TRUE, upper- and lowercasing is - * ignored when comparing string values - * @throws PHPUnit_Framework_ComparisonFailure Thrown when the comparison - * fails. Contains information about the - * specific errors that lead to the failure. - */ - public function assertEquals($expected, $actual, $delta = 0, $canonicalize = FALSE, $ignoreCase = FALSE) - { - foreach ($actual as $object) { - if (!$expected->contains($object)) { - throw new PHPUnit_Framework_ComparisonFailure( - $expected, - $actual, - PHPUnit_Util_Type::export($expected), - PHPUnit_Util_Type::export($actual), - FALSE, - 'Failed asserting that two objects are equal.' - ); - } - } - - foreach ($expected as $object) { - if (!$actual->contains($object)) { - throw new PHPUnit_Framework_ComparisonFailure( - $expected, - $actual, - PHPUnit_Util_Type::export($expected), - PHPUnit_Util_Type::export($actual), - FALSE, - 'Failed asserting that two objects are equal.' - ); - } - } - } -} diff --git a/tests/PHPUnit/PHPUnit/Framework/Comparator/Type.php b/tests/PHPUnit/PHPUnit/Framework/Comparator/Type.php deleted file mode 100755 index e361e7c4..00000000 --- a/tests/PHPUnit/PHPUnit/Framework/Comparator/Type.php +++ /dev/null @@ -1,106 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Framework - * @author Bernhard Schussek - * @copyright 2002-2011 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.6.0 - */ - -/** - * Compares values for type equality. - * - * @package PHPUnit - * @subpackage Framework_Comparator - * @author Bernhard Schussek - * @copyright 2002-2011 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.6.3 - * @link http://www.phpunit.de/ - * @since Class available since Release 3.6.0 - */ -class PHPUnit_Framework_Comparator_Type extends PHPUnit_Framework_Comparator -{ - /** - * Returns whether the comparator can compare two values. - * - * @param mixed $expected The first value to compare - * @param mixed $actual The second value to compare - * @return boolean - */ - public function accepts($expected, $actual) - { - return TRUE; - } - - /** - * Asserts that two values are equal. - * - * @param mixed $expected The first value to compare - * @param mixed $actual The second value to compare - * @param float $delta The allowed numerical distance between two values to - * consider them equal - * @param bool $canonicalize If set to TRUE, arrays are sorted before - * comparison - * @param bool $ignoreCase If set to TRUE, upper- and lowercasing is - * ignored when comparing string values - * @throws PHPUnit_Framework_ComparisonFailure Thrown when the comparison - * fails. Contains information about the - * specific errors that lead to the failure. - */ - public function assertEquals($expected, $actual, $delta = 0, $canonicalize = FALSE, $ignoreCase = FALSE) - { - if (gettype($expected) != gettype($actual)) { - throw new PHPUnit_Framework_ComparisonFailure( - $expected, - $actual, - // we don't need a diff - '', - '', - FALSE, - sprintf( - '%s does not match expected type "%s".', - - PHPUnit_Util_Type::shortenedExport($actual), - gettype($expected) - ) - ); - } - } -} diff --git a/tests/PHPUnit/PHPUnit/Framework/ComparatorFactory.php b/tests/PHPUnit/PHPUnit/Framework/ComparatorFactory.php deleted file mode 100755 index 624794b4..00000000 --- a/tests/PHPUnit/PHPUnit/Framework/ComparatorFactory.php +++ /dev/null @@ -1,156 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Framework - * @author Bernhard Schussek - * @copyright 2002-2011 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.6.0 - */ - -/** - * Factory for comparators which compare values for equality. - * - * @package PHPUnit - * @subpackage Framework - * @author Bernhard Schussek - * @copyright 2002-2011 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.6.3 - * @link http://www.phpunit.de/ - * @since Class available since Release 3.6.0 - */ -class PHPUnit_Framework_ComparatorFactory -{ - /** - * @var array - */ - protected $comparators = array(); - - /** - * @var PHPUnit_Framework_ComparatorFactory - */ - private static $defaultInstance = NULL; - - /** - * Constructs a new factory. - */ - public function __construct() - { - $this->register(new PHPUnit_Framework_Comparator_Type); - $this->register(new PHPUnit_Framework_Comparator_Scalar); - $this->register(new PHPUnit_Framework_Comparator_Numeric); - $this->register(new PHPUnit_Framework_Comparator_Double); - $this->register(new PHPUnit_Framework_Comparator_Array); - $this->register(new PHPUnit_Framework_Comparator_Resource); - $this->register(new PHPUnit_Framework_Comparator_Object); - $this->register(new PHPUnit_Framework_Comparator_Exception); - $this->register(new PHPUnit_Framework_Comparator_SplObjectStorage); - $this->register(new PHPUnit_Framework_Comparator_DOMDocument); - $this->register(new PHPUnit_Framework_Comparator_MockObject); - } - - /** - * Returns the default instance. - * - * @return PHPUnit_Framework_ComparatorFactory - */ - public static function getDefaultInstance() - { - if (self::$defaultInstance === NULL) { - self::$defaultInstance = new PHPUnit_Framework_ComparatorFactory; - } - - return self::$defaultInstance; - } - - /** - * Returns the correct comparator for comparing two values. - * - * @param mixed $expected The first value to compare - * @param mixed $actual The second value to compare - * @return PHPUnit_Framework_Comparator - */ - public function getComparatorFor($expected, $actual) - { - foreach ($this->comparators as $comparator) { - if ($comparator->accepts($expected, $actual)) { - return $comparator; - } - } - - throw new InvalidArgumentException( - sprintf( - 'No comparator is registered for comparing the types "%s" and "%s"', - gettype($expected), gettype($actual) - ) - ); - } - - /** - * Registers a new comparator. - * - * This comparator will be returned by getInstance() if its accept() method - * returns TRUE for the compared values. It has higher priority than the - * existing comparators, meaning that its accept() method will be tested - * before those of the other comparators. - * - * @param PHPUnit_Framework_Comparator $comparator The registered comparator - */ - public function register(PHPUnit_Framework_Comparator $comparator) - { - array_unshift($this->comparators, $comparator); - $comparator->setFactory($this); - } - - /** - * Unregisters a comparator. - * - * This comparator will no longer be returned by getInstance(). - * - * @param PHPUnit_Framework_Comparator $comparator The unregistered comparator - */ - public function unregister(PHPUnit_Framework_Comparator $comparator) - { - foreach ($this->comparators as $key => $_comparator) { - if ($comparator === $_comparator) { - unset($this->comparators[$key]); - } - } - } -} diff --git a/tests/PHPUnit/PHPUnit/Framework/Constraint/Composite.php b/tests/PHPUnit/PHPUnit/Framework/Constraint/Composite.php deleted file mode 100755 index e59b48a1..00000000 --- a/tests/PHPUnit/PHPUnit/Framework/Constraint/Composite.php +++ /dev/null @@ -1,115 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Framework_Constraint - * @author Bernhard Schussek - * @copyright 2002-2011 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.6.0 - */ - -/** - * - * - * @package PHPUnit - * @subpackage Framework_Constraint - * @author Bernhard Schussek - * @copyright 2002-2011 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.6.3 - * @link http://www.phpunit.de/ - * @since Class available since Release 3.6.0 - */ - -abstract class PHPUnit_Framework_Constraint_Composite extends PHPUnit_Framework_Constraint -{ - /** - * @var PHPUnit_Framework_Constraint - */ - protected $innerConstraint; - - /** - * @param PHPUnit_Framework_Constraint $innerConstraint - * @param string $attributeName - */ - public function __construct(PHPUnit_Framework_Constraint $innerConstraint) - { - $this->innerConstraint = $innerConstraint; - } - - /** - * Evaluates the constraint for parameter $other - * - * If $returnResult is set to FALSE (the default), an exception is thrown - * in case of a failure. NULL is returned otherwise. - * - * If $returnResult is TRUE, the result of the evaluation is returned as - * a boolean value instead: TRUE in case of success, FALSE in case of a - * failure. - * - * @param mixed $other Value or object to evaluate. - * @param string $description Additional information about the test - * @param bool $returnResult Whether to return a result or throw an exception - * @return mixed - * @throws PHPUnit_Framework_ExpectationFailedException - */ - public function evaluate($other, $description = '', $returnResult = FALSE) - { - try { - return $this->innerConstraint->evaluate( - $other, - $description, - $returnResult - ); - } - - catch (PHPUnit_Framework_ExpectationFailedException $e) { - $this->fail($other, $description); - } - } - - /** - * Counts the number of constraint elements. - * - * @return integer - */ - public function count() - { - return count($this->innerConstraint); - } -} diff --git a/tests/PHPUnit/PHPUnit/Framework/Constraint/Count.php b/tests/PHPUnit/PHPUnit/Framework/Constraint/Count.php deleted file mode 100755 index a21eff81..00000000 --- a/tests/PHPUnit/PHPUnit/Framework/Constraint/Count.php +++ /dev/null @@ -1,129 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Framework_Constraint - * @author Sebastian Bergmann - * @author Bernhard Schussek - * @copyright 2002-2011 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.6.0 - */ - -/** - * - * - * @package PHPUnit - * @subpackage Framework_Constraint - * @author Sebastian Bergmann - * @author Bernhard Schussek - * @copyright 2002-2011 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.6.3 - * @link http://www.phpunit.de/ - * @since Class available since Release 3.6.0 - */ -class PHPUnit_Framework_Constraint_Count extends PHPUnit_Framework_Constraint -{ - /** - * @var integer - */ - protected $expectedCount = 0; - - /** - * @param integer $expected - */ - public function __construct($expected) - { - $this->expectedCount = $expected; - } - - /** - * Evaluates the constraint for parameter $other. Returns TRUE if the - * constraint is met, FALSE otherwise. - * - * @param mixed $other - * @return boolean - */ - protected function matches($other) - { - return $this->expectedCount === $this->getCountOf($other); - } - - /** - * @param mixed $other - * @return boolean - */ - protected function getCountOf($other) - { - if ($other instanceof Countable || is_array($other)) { - return count($other); - } - - else if ($other instanceof Iterator) { - return iterator_count($other); - } - } - - - /** - * Returns the description of the failure - * - * The beginning of failure messages is "Failed asserting that" in most - * cases. This method should return the second part of that sentence. - * - * @param mixed $other Evaluated value or object. - * @return string - */ - protected function failureDescription($other) - { - return sprintf( - 'actual size %d matches expected size %d', - - $this->getCountOf($other), - $this->expectedCount - ); - } - - /** - * @return string - */ - public function toString() - { - return 'count matches '; - } -} diff --git a/tests/PHPUnit/PHPUnit/Framework/Constraint/SameSize.php b/tests/PHPUnit/PHPUnit/Framework/Constraint/SameSize.php deleted file mode 100755 index db2e25c6..00000000 --- a/tests/PHPUnit/PHPUnit/Framework/Constraint/SameSize.php +++ /dev/null @@ -1,74 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Framework_Constraint - * @author Sebastian Bergmann - * @author Bernhard Schussek - * @copyright 2002-2011 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.6.0 - */ - -/** - * - * - * @package PHPUnit - * @subpackage Framework_Constraint - * @author Sebastian Bergmann - * @author Bernhard Schussek - * @copyright 2002-2011 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.6.3 - * @link http://www.phpunit.de/ - * @since Class available since Release 3.6.0 - */ -class PHPUnit_Framework_Constraint_SameSize extends PHPUnit_Framework_Constraint_Count -{ - /** - * @var integer - */ - protected $expectedCount; - - /** - * @param integer $expected - */ - public function __construct($expected) - { - $this->expectedCount = $this->getCountOf($expected); - } -} diff --git a/tests/PHPUnit/PHPUnit/Framework/Error/Deprecated.php b/tests/PHPUnit/PHPUnit/Framework/Error/Deprecated.php deleted file mode 100755 index ed6c2ca4..00000000 --- a/tests/PHPUnit/PHPUnit/Framework/Error/Deprecated.php +++ /dev/null @@ -1,66 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Framework_Error - * @author Sebastian Bergmann - * @copyright 2002-2011 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.3.0 - */ - -/** - * Wrapper for PHP deprecated errors. - * You can disable deprecated-to-exception conversion by setting - * - * - * PHPUnit_Framework_Error_Deprecated::$enabled = FALSE; - * - * - * @package PHPUnit - * @subpackage Framework_Error - * @author Sebastian Bergmann - * @copyright 2002-2011 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.6.3 - * @link http://www.phpunit.de/ - * @since Class available since Release 3.3.0 - */ -class PHPUnit_Framework_Error_Deprecated extends PHPUnit_Framework_Error -{ - public static $enabled = TRUE; -} diff --git a/tests/PHPUnit/PHPUnit/Framework/MockObject/Autoload.php b/tests/PHPUnit/PHPUnit/Framework/MockObject/Autoload.php deleted file mode 100755 index 64de1299..00000000 --- a/tests/PHPUnit/PHPUnit/Framework/MockObject/Autoload.php +++ /dev/null @@ -1,111 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit_MockObject - * @author Sebastian Bergmann - * @copyright 2002-2011 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://github.com/sebastianbergmann/phpunit-mock-objects - * @since File available since Release 1.1.0 - */ - -function phpunit_mockobject_autoload($class = NULL) { - static $classes = NULL; - static $path = NULL; - - if ($classes === NULL) { - $classes = array( - 'phpunit_framework_mockobject_builder_identity' => '/Framework/MockObject/Builder/Identity.php', - 'phpunit_framework_mockobject_builder_invocationmocker' => '/Framework/MockObject/Builder/InvocationMocker.php', - 'phpunit_framework_mockobject_builder_match' => '/Framework/MockObject/Builder/Match.php', - 'phpunit_framework_mockobject_builder_methodnamematch' => '/Framework/MockObject/Builder/MethodNameMatch.php', - 'phpunit_framework_mockobject_builder_namespace' => '/Framework/MockObject/Builder/Namespace.php', - 'phpunit_framework_mockobject_builder_parametersmatch' => '/Framework/MockObject/Builder/ParametersMatch.php', - 'phpunit_framework_mockobject_builder_stub' => '/Framework/MockObject/Builder/Stub.php', - 'phpunit_framework_mockobject_generator' => '/Framework/MockObject/Generator.php', - 'phpunit_framework_mockobject_invocation' => '/Framework/MockObject/Invocation.php', - 'phpunit_framework_mockobject_invocation_object' => '/Framework/MockObject/Invocation/Object.php', - 'phpunit_framework_mockobject_invocation_static' => '/Framework/MockObject/Invocation/Static.php', - 'phpunit_framework_mockobject_invocationmocker' => '/Framework/MockObject/InvocationMocker.php', - 'phpunit_framework_mockobject_invokable' => '/Framework/MockObject/Invokable.php', - 'phpunit_framework_mockobject_matcher' => '/Framework/MockObject/Matcher.php', - 'phpunit_framework_mockobject_matcher_anyinvokedcount' => '/Framework/MockObject/Matcher/AnyInvokedCount.php', - 'phpunit_framework_mockobject_matcher_anyparameters' => '/Framework/MockObject/Matcher/AnyParameters.php', - 'phpunit_framework_mockobject_matcher_invocation' => '/Framework/MockObject/Matcher/Invocation.php', - 'phpunit_framework_mockobject_matcher_invokedatindex' => '/Framework/MockObject/Matcher/InvokedAtIndex.php', - 'phpunit_framework_mockobject_matcher_invokedatleastonce' => '/Framework/MockObject/Matcher/InvokedAtLeastOnce.php', - 'phpunit_framework_mockobject_matcher_invokedcount' => '/Framework/MockObject/Matcher/InvokedCount.php', - 'phpunit_framework_mockobject_matcher_invokedrecorder' => '/Framework/MockObject/Matcher/InvokedRecorder.php', - 'phpunit_framework_mockobject_matcher_methodname' => '/Framework/MockObject/Matcher/MethodName.php', - 'phpunit_framework_mockobject_matcher_parameters' => '/Framework/MockObject/Matcher/Parameters.php', - 'phpunit_framework_mockobject_matcher_statelessinvocation' => '/Framework/MockObject/Matcher/StatelessInvocation.php', - 'phpunit_framework_mockobject_mockbuilder' => '/Framework/MockObject/MockBuilder.php', - 'phpunit_framework_mockobject_mockobject' => '/Framework/MockObject/MockObject.php', - 'phpunit_framework_mockobject_stub' => '/Framework/MockObject/Stub.php', - 'phpunit_framework_mockobject_stub_consecutivecalls' => '/Framework/MockObject/Stub/ConsecutiveCalls.php', - 'phpunit_framework_mockobject_stub_exception' => '/Framework/MockObject/Stub/Exception.php', - 'phpunit_framework_mockobject_stub_matchercollection' => '/Framework/MockObject/Stub/MatcherCollection.php', - 'phpunit_framework_mockobject_stub_return' => '/Framework/MockObject/Stub/Return.php', - 'phpunit_framework_mockobject_stub_returnargument' => '/Framework/MockObject/Stub/ReturnArgument.php', - 'phpunit_framework_mockobject_stub_returncallback' => '/Framework/MockObject/Stub/ReturnCallback.php', - 'phpunit_framework_mockobject_stub_returnself' => '/Framework/MockObject/Stub/ReturnSelf.php', - 'phpunit_framework_mockobject_stub_returnvaluemap' => '/Framework/MockObject/Stub/ReturnValueMap.php', - 'phpunit_framework_mockobject_verifiable' => '/Framework/MockObject/Verifiable.php' - ); - - $path = dirname(dirname(dirname(__FILE__))); - } - - if ($class === NULL) { - $result = array(__FILE__); - - foreach ($classes as $file) { - $result[] = $path . $file; - } - - return $result; - } - - $cn = strtolower($class); - - if (isset($classes[$cn])) { - $file = $path . $classes[$cn]; - - require $file; - } -} - -spl_autoload_register('phpunit_mockobject_autoload'); diff --git a/tests/PHPUnit/PHPUnit/Framework/MockObject/Generator/trait_class.tpl.dist b/tests/PHPUnit/PHPUnit/Framework/MockObject/Generator/trait_class.tpl.dist deleted file mode 100755 index 48b4bbf2..00000000 --- a/tests/PHPUnit/PHPUnit/Framework/MockObject/Generator/trait_class.tpl.dist +++ /dev/null @@ -1,4 +0,0 @@ -class {class_name} -{ - use {trait_name}; -} diff --git a/tests/PHPUnit/PHPUnit/Framework/MockObject/Stub/ReturnSelf.php b/tests/PHPUnit/PHPUnit/Framework/MockObject/Stub/ReturnSelf.php deleted file mode 100755 index 9c5c1dcd..00000000 --- a/tests/PHPUnit/PHPUnit/Framework/MockObject/Stub/ReturnSelf.php +++ /dev/null @@ -1,76 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit_MockObject - * @author Sebastian Bergmann - * @author Kris Wallsmith - * @copyright 2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://github.com/sebastianbergmann/phpunit-mock-objects - * @since File available since Release 1.1.0 - */ - -/** - * Stubs a method by returning the current object. - * - * @package PHPUnit_MockObject - * @author Sebastian Bergmann - * @author Kris Wallsmith - * @copyright 2010-2011 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 1.1.0 - * @link http://github.com/sebastianbergmann/phpunit-mock-objects - * @since Class available since Release 1.1.0 - */ -class PHPUnit_Framework_MockObject_Stub_ReturnSelf implements PHPUnit_Framework_MockObject_Stub -{ - public function invoke(PHPUnit_Framework_MockObject_Invocation $invocation) - { - if (!$invocation instanceof PHPUnit_Framework_MockObject_Invocation_Object) { - throw new PHPUnit_Framework_Exception( - 'The current object can only be returned when mocking an ' . - 'object, not a static class.' - ); - } - - return $invocation->object; - } - - public function toString() - { - return 'return the current object'; - } -} diff --git a/tests/PHPUnit/PHPUnit/Framework/MockObject/Stub/ReturnValueMap.php b/tests/PHPUnit/PHPUnit/Framework/MockObject/Stub/ReturnValueMap.php deleted file mode 100755 index 99324ea6..00000000 --- a/tests/PHPUnit/PHPUnit/Framework/MockObject/Stub/ReturnValueMap.php +++ /dev/null @@ -1,87 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit_MockObject - * @author Sebastian Bergmann - * @copyright 2010-2011 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://github.com/sebastianbergmann/phpunit-mock-objects - * @since File available since Release 1.1.0 - */ - -/** - * Stubs a method by returning a value from a map. - * - * @package PHPUnit_MockObject - * @author Sebastian Bergmann - * @copyright 2010-2011 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 1.1.0 - * @link http://github.com/sebastianbergmann/phpunit-mock-objects - * @since Class available since Release 1.1.0 - */ -class PHPUnit_Framework_MockObject_Stub_ReturnValueMap implements PHPUnit_Framework_MockObject_Stub -{ - protected $valueMap; - - public function __construct(array $valueMap) - { - $this->valueMap = $valueMap; - } - - public function invoke(PHPUnit_Framework_MockObject_Invocation $invocation) - { - $parameterCount = count($invocation->parameters); - - foreach ($this->valueMap as $map) { - if (!is_array($map) || $parameterCount != count($map) - 1) { - continue; - } - - $return = array_pop($map); - if ($invocation->parameters === $map) { - return $return; - } - } - - return NULL; - } - - public function toString() - { - return 'return value from a map'; - } -} diff --git a/tests/PHPUnit/PHPUnit/Framework/OutputError.php b/tests/PHPUnit/PHPUnit/Framework/OutputError.php deleted file mode 100755 index 8203bfe2..00000000 --- a/tests/PHPUnit/PHPUnit/Framework/OutputError.php +++ /dev/null @@ -1,61 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Framework - * @author Sebastian Bergmann - * @copyright 2002-2011 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.6.0 - */ - -/** - * Extension to PHPUnit_Framework_AssertionFailedError to mark the special - * case of a test that printed output. - * - * @package PHPUnit - * @subpackage Framework - * @author Sebastian Bergmann - * @copyright 2002-2011 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.6.3 - * @link http://www.phpunit.de/ - * @since Class available since Release 3.6.0 - */ -class PHPUnit_Framework_OutputError extends PHPUnit_Framework_AssertionFailedError -{ -} diff --git a/tests/PHPUnit/PHPUnit/Util/String.php b/tests/PHPUnit/PHPUnit/Util/String.php deleted file mode 100755 index c93594a4..00000000 --- a/tests/PHPUnit/PHPUnit/Util/String.php +++ /dev/null @@ -1,119 +0,0 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit - * @subpackage Util - * @author Sebastian Bergmann - * @copyright 2002-2011 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://www.phpunit.de/ - * @since File available since Release 3.6.0 - */ - -/** - * String helpers. - * - * @package PHPUnit - * @subpackage Util - * @author Sebastian Bergmann - * @copyright 2002-2011 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 3.6.3 - * @link http://www.phpunit.de/ - * @since Class available since Release 3.6.0 - */ -class PHPUnit_Util_String -{ - /** - * Converts a string to UTF-8 encoding. - * - * @param string $string - * @return string - */ - public static function convertToUtf8($string) - { - if (!self::isUtf8($string)) { - if (function_exists('mb_convert_encoding')) { - $string = mb_convert_encoding($string, 'UTF-8'); - } else { - $string = utf8_encode($string); - } - } - - return $string; - } - - /** - * Checks a string for UTF-8 encoding. - * - * @param string $string - * @return boolean - */ - protected static function isUtf8($string) - { - $length = strlen($string); - - for ($i = 0; $i < $length; $i++) { - if (ord($string[$i]) < 0x80) { - $n = 0; - } - - else if ((ord($string[$i]) & 0xE0) == 0xC0) { - $n = 1; - } - - else if ((ord($string[$i]) & 0xF0) == 0xE0) { - $n = 2; - } - - else if ((ord($string[$i]) & 0xF0) == 0xF0) { - $n = 3; - } - - else { - return FALSE; - } - - for ($j = 0; $j < $n; $j++) { - if ((++$i == $length) || ((ord($string[$i]) & 0xC0) != 0x80)) { - return FALSE; - } - } - } - - return TRUE; - } -} diff --git a/tests/SugarTestHelper.php b/tests/SugarTestHelper.php index e725490a..9078b7f6 100755 --- a/tests/SugarTestHelper.php +++ b/tests/SugarTestHelper.php @@ -266,3 +266,356 @@ class SugarMockLogger return count($this->messages); } } + +/** + * Own exception for SugarTestHelper class + * + * @author mgusev@sugarcrm.com + */ +class SugarTestHelperException extends PHPUnit_Framework_Exception +{ + +} + +/** + * Helper for initialization of global variables of SugarCRM + * + * @author mgusev@sugarcrm.com + */ +class SugarTestHelper +{ + /** + * @var array array of registered vars. It allows helper to unregister them on tearDown + */ + protected static $registeredVars = array(); + + /** + * @var array array of global vars. They are storing on init one time and restoring in global scope each tearDown + */ + protected static $initVars = array( + 'GLOBALS' => array() + ); + + /** + * @var array of system preference of SugarCRM as theme etc. They are storing on init one time and restoring each tearDown + */ + protected static $systemVars = array(); + + /** + * @var bool is SugarTestHelper inited or not. Just to skip initialization on the second and others call of init method + */ + protected static $isInited = false; + + /** + * All methods are static because of it we disable constructor + */ + private function __construct() + { + } + + /** + * All methods are static because of it we disable clone + */ + private function __clone() + { + } + + /** + * Initialization of main variables of SugarCRM in global scope + * + * @static + */ + public static function init() + { + if (self::$isInited == true) + { + return true; + } + + // initialization & backup of sugar_config + self::$initVars['GLOBALS']['sugar_config'] = null; + if ($GLOBALS['sugar_config']) + { + self::$initVars['GLOBALS']['sugar_config'] = $GLOBALS['sugar_config']; + } + if (self::$initVars['GLOBALS']['sugar_config'] == false) + { + global $sugar_config; + if (is_file('config.php')) + { + require_once('config.php'); + } + if (is_file('config_override.php')) + { + require_once('config_override.php'); + } + self::$initVars['GLOBALS']['sugar_config'] = $GLOBALS['sugar_config']; + } + + // backup of current_language + self::$initVars['GLOBALS']['current_language'] = 'en_us'; + if (isset($sugar_config['current_language'])) + { + self::$initVars['GLOBALS']['current_language'] = $sugar_config['current_language']; + } + if (isset($GLOBALS['current_language'])) + { + self::$initVars['GLOBALS']['current_language'] = $GLOBALS['current_language']; + } + $GLOBALS['current_language'] = self::$initVars['GLOBALS']['current_language']; + + // backup of reload_vardefs + self::$initVars['GLOBALS']['reload_vardefs'] = null; + if (isset($GLOBALS['reload_vardefs'])) + { + self::$initVars['GLOBALS']['reload_vardefs'] = $GLOBALS['reload_vardefs']; + } + + // backup of locale + self::$initVars['GLOBALS']['locale'] = null; + if (isset($GLOBALS['locale'])) + { + self::$initVars['GLOBALS']['locale'] = $GLOBALS['locale']; + } + if (self::$initVars['GLOBALS']['locale'] == false) + { + self::$initVars['GLOBALS']['locale'] = new Localization(); + } + + // backup of service_object + self::$initVars['GLOBALS']['service_object'] = null; + if (isset($GLOBALS['service_object'])) + { + self::$initVars['GLOBALS']['service_object'] = $GLOBALS['service_object']; + } + + // backup of SugarThemeRegistry + self::$systemVars['SugarThemeRegistry'] = SugarThemeRegistry::current(); + + self::$isInited = true; + } + + /** + * Checking is there helper for variable or not + * + * @static + * @param string $varName name of global variable of SugarCRM + * @return bool is there helper for a variable or not + * @throws SugarTestHelperException fired when there is no implementation of helper for a variable + */ + protected static function checkHelper($varName) + { + if (method_exists(__CLASS__, 'setUp_' . $varName) == false) + { + throw new SugarTestHelperException('setUp for $' . $varName . ' is not implemented. ' . __CLASS__ . '::setUp_' . $varName); + } + } + + /** + * Entry point for setup of global variable + * + * @static + * @param string $varName name of global variable of SugarCRM + * @param array $params some parameters for helper. For example for $mod_strings or $current_user + * @return bool is variable setuped or not + */ + public static function setUp($varName, $params = array()) + { + self::init(); + self::checkHelper($varName); + return call_user_func(__CLASS__ . '::setUp_' . $varName, $params); + } + + /** + * Clean up all registered variables and restore $initVars and $systemVars + * @static + * @return bool status of tearDown + */ + public static function tearDown() + { + self::init(); + foreach(self::$registeredVars as $varName => $isCalled) + { + if ($isCalled) + { + unset(self::$registeredVars[$varName]); + if (method_exists(__CLASS__, 'tearDown_' . $varName)) + { + call_user_func(__CLASS__ . '::tearDown_' . $varName, array()); + } + elseif (isset($GLOBALS[$varName])) + { + unset($GLOBALS[$varName]); + } + } + } + + // Restoring of system variables + foreach(self::$initVars as $scope => $vars) + { + foreach ($vars as $name => $value) + { + $GLOBALS[$scope][$name] = $value; + } + } + + // Restoring of theme + SugarThemeRegistry::set(self::$systemVars['SugarThemeRegistry']->dirName); + + return true; + } + + /** + * Registration of $current_user in global scope + * + * @static + * @param array $params parameters for SugarTestUserUtilities::createAnonymousUser method + * @return bool is variable setuped or not + */ + protected static function setUp_current_user(array $params) + { + self::$registeredVars['current_user'] = true; + $GLOBALS['current_user'] = call_user_func_array('SugarTestUserUtilities::createAnonymousUser', $params); + return true; + } + + /** + * Removal of $current_user from global scope + * + * @static + * @return bool is variable removed or not + */ + protected static function tearDown_current_user() + { + SugarTestUserUtilities::removeAllCreatedAnonymousUsers(); + unset($GLOBALS['current_user']); + return true; + } + + /** + * Registration of $beanList in global scope + * + * @static + * @return bool is variable setuped or not + */ + protected static function setUp_beanList() + { + self::$registeredVars['beanList'] = true; + global $beanList; + require('include/modules.php'); + return true; + } + + /** + * Registration of $beanFiles in global scope + * + * @static + * @return bool is variable setuped or not + */ + protected static function setUp_beanFiles() + { + self::$registeredVars['beanFiles'] = true; + global $beanFiles; + require('include/modules.php'); + return true; + } + + /** + * Registration of $moduleList in global scope + * + * @static + * @return bool is variable setuped or not + */ + protected static function setUp_moduleList() + { + self::$registeredVars['moduleList'] = true; + self::setUp_app_list_strings(); + $GLOBALS['moduleList'] = $GLOBALS['app_list_strings']['moduleList']; + return true; + } + + /** + * Registration of $modListHeader in global scope + * + * @static + * @return bool is variable setuped or not + */ + protected static function setUp_modListHeader() + { + self::$registeredVars['modListHeader'] = true; + if (isset($GLOBALS['current_user']) == false) + { + self::setUp_current_user(array( + true, + 1 + )); + } + $GLOBALS['modListHeader'] = query_module_access_list($GLOBALS['current_user']); + return true; + } + + /** + * Registration of $app_strings in global scope + * + * @static + * @return bool is variable setuped or not + */ + protected static function setUp_app_strings() + { + self::$registeredVars['app_strings'] = true; + $GLOBALS['app_strings'] = return_application_language($GLOBALS['current_language']); + return true; + } + + /** + * Registration of $app_list_strings in global scope + * + * @static + * @return bool is variable setuped or not + */ + protected static function setUp_app_list_strings() + { + self::$registeredVars['app_list_strings'] = true; + $GLOBALS['app_list_strings'] = return_app_list_strings_language($GLOBALS['current_language']); + return true; + } + + /** + * Registration of $timedate in global scope + * + * @static + * @return bool is variable setuped or not + */ + protected static function setUp_timedate() + { + self::$registeredVars['timedate'] = true; + $GLOBALS['timedate'] = TimeDate::getInstance(); + return true; + } + + /** + * Removal of $timedate from global scope + * + * @static + * @return bool is variable removed or not + */ + protected static function tearDown_timedate() + { + $GLOBALS['timedate']->clearCache(); + return true; + } + + /** + * Registration of $mod_strings in global scope + * + * @static + * @param array $params parameters for return_module_language function + * @return bool is variable setuped or not + */ + protected static function setUp_mod_strings(array $params) + { + self::$registeredVars['mod_strings'] = true; + $GLOBALS['mod_strings'] = return_module_language($GLOBALS['current_language'], $params[0]); + return true; + } +} diff --git a/tests/data/Bug52133Test.php b/tests/data/Bug52133Test.php new file mode 100755 index 00000000..1699907e --- /dev/null +++ b/tests/data/Bug52133Test.php @@ -0,0 +1,109 @@ +bean = new Account(); + Bug52113TestHook::$count = 0; + LogicHook::refreshHooks(); + } + + public function tearDown() + { + if(!empty($this->hook)) { + call_user_func_array('remove_logic_hook', $this->hook); + } + } + + /** + * @ticket 52113 + */ + public function testCallLogicHookLoop() + { + $this->hook = array('Accounts', 'test_event', Array(1, 'Test hook', __FILE__, 'Bug52113TestHook', 'count')); + call_user_func_array('check_logic_hook_file', $this->hook); + for($i=0;$i<50;$i++) { + $this->bean->call_custom_logic("test_event"); + } + $this->assertEquals(50, Bug52113TestHook::$count); + } + + /** + * @ticket 52113 + */ + public function testCallLogicHookRecursive() + { + $this->hook = array('Accounts', 'test_event', Array(1, 'Test hook', __FILE__, 'Bug52113TestHook', 'recurse')); + call_user_func_array('check_logic_hook_file', $this->hook); + for($i=0;$i<20;$i++) { + $this->bean->call_custom_logic("test_event"); + } + $this->assertEquals(220, Bug52113TestHook::$count); + } +} + +class Bug52113TestHook +{ + static public $count = 0; + public function count() + { + self::$count++; + } + + public function recurse($bean, $event) + { + $this->count(); + $bean->call_custom_logic($event); + } +} diff --git a/tests/data/Bug53223Test.php b/tests/data/Bug53223Test.php new file mode 100755 index 00000000..9df97d11 --- /dev/null +++ b/tests/data/Bug53223Test.php @@ -0,0 +1,203 @@ +relationships = new DeployedRelationships($lhs_module); + $definition = array( + 'lhs_module' => $lhs_module, + 'relationship_type' => $relationship_type, + 'rhs_module' => $rhs_module, + 'lhs_label' => $lhs_module, + 'rhs_label' => $rhs_module, + 'rhs_subpanel' => 'default' + ); + $this->relationship = RelationshipFactory::newRelationship($definition); + $this->relationships->add($this->relationship); + $this->relationships->save(); + $this->relationships->build(); + LanguageManager::clearLanguageCache($lhs_module); + + // Updating $dictionary by created relation + global $dictionary; + $moduleInstaller = new ModuleInstaller(); + $moduleInstaller->silent = true; + $moduleInstaller->rebuild_tabledictionary(); + require 'modules/TableDictionary.php'; + + // Updating vardefs + VardefManager::$linkFields = array(); + VardefManager::clearVardef(); + VardefManager::refreshVardefs($lhs_module, BeanFactory::getObjectName($lhs_module)); + if ( $lhs_module != $rhs_module ) + { + VardefManager::refreshVardefs($rhs_module, BeanFactory::getObjectName($rhs_module)); + } + SugarRelationshipFactory::rebuildCache(); + } + + private function deleteRelationship($lhs_module, $rhs_module = null, $rel_name = null) + { + $rhs_module = $rhs_module == null ? $lhs_module : $rhs_module; + + $this->relationships = new DeployedRelationships($lhs_module); + $this->relationships->delete($rel_name !== null ? $rel_name : $this->relationship->getName()); + $this->relationships->save(); + SugarRelationshipFactory::deleteCache(); + LanguageManager::clearLanguageCache($lhs_module); + if ( $lhs_module != $rhs_module ) + { + LanguageManager::clearLanguageCache($rhs_module); + } + } + + public function setUp() + { + $this->markTestIncomplete("This test is not yet complete. Artem is working on it"); + $beanList = array(); + $beanFiles = array(); + require('include/modules.php'); + $GLOBALS['beanList'] = $beanList; + $GLOBALS['beanFiles'] = $beanFiles; + + $GLOBALS['current_user'] = SugarTestUserUtilities::createAnonymousUser(); + $GLOBALS['current_user']->is_admin = 1; + + $GLOBALS['app_strings'] = return_application_language($GLOBALS['current_language']); + $GLOBALS['app_list_strings'] = return_app_list_strings_language($GLOBALS['current_language']); + + $this->createRelationship('Accounts'); + $this->parentAccount = SugarTestAccountUtilities::createAccount(); + } + + public function tearDown() + { + $this->deleteRelationship('Accounts'); + + SugarTestUserUtilities::removeAllCreatedAnonymousUsers(); + unset($GLOBALS['current_user']); + + unset($GLOBALS['beanFiles'], $GLOBALS['beanList']); + unset($GLOBALS['app_strings'], $GLOBALS['app_list_strings'], $GLOBALS['mod_strings']); + + SugarTestUserUtilities::removeAllCreatedAnonymousUsers(); + SugarTestAccountUtilities::removeAllCreatedAccounts(); + + unset($this->parentAccount); + } + + /** + * @group 53223 + */ + public function testOneToManyRelationshipModule2Modult() + { + $_REQUEST['relate_id'] = $this->parentAccount->id; + $_REQUEST['relate_to'] = $this->relationship->getName(); + + // create new account + $objAccount = new Account(); + $objAccount->name = "AccountBug53223".$_REQUEST['relate_to'].time(); + $objAccount->save(); + SugarTestAccountUtilities::setCreatedAccount(array($objAccount->id)); + + // Retrieve new data + $this->parentAccount->retrieve($this->parentAccount->id); + $objAccount->retrieve($objAccount->id); + $this->parentAccount->load_relationship($this->relationship->getName()); + $objAccount->load_relationship($this->relationship->getName()); + + // Getting data of subpanel of parent bean + $_REQUEST['module'] = 'Accounts'; + $_REQUEST['action'] = 'DetailView'; + $_REQUEST['record'] = $this->parentAccount->id; + $_SERVER['REQUEST_METHOD'] = 'GET'; + unset($GLOBALS['focus']); + + $subpanels = new SubPanelDefinitions($this->parentAccount, 'Accounts'); + $subpanelDef = $subpanels->load_subpanel($this->relationship->getName().'accounts_ida'); + $subpanel = new SubPanel('Accounts', $this->parentAccount->id, 'default', $subpanelDef); + $subpanel->setTemplateFile('include/SubPanel/SubPanelDynamic.html'); + $subpanel->display(); + $actual = $this->getActualOutput(); + $this->assertContains($objAccount->name, $actual, 'Account name is not displayed in subpanel of parent account'); + + ob_clean(); + + // Getting data of subpanel of child bean + $_REQUEST['module'] = 'Accounts'; + $_REQUEST['action'] = 'DetailView'; + $_REQUEST['record'] = $objAccount->id; + $_SERVER['REQUEST_METHOD'] = 'GET'; + unset($GLOBALS['focus']); + + $subpanels = new SubPanelDefinitions($objAccount, 'Accounts'); + $subpanelDef = $subpanels->load_subpanel($this->relationship->getName().'accounts_ida'); + $subpanel = new SubPanel('Accounts', $objAccount->id, 'default', $subpanelDef); + $subpanel->setTemplateFile('include/SubPanel/SubPanelDynamic.html'); + $subpanel->display(); + $actual = $this->getActualOutput(); + $this->assertNotContains($this->parentAccount->name, $actual, 'Parent account name is displayed in subpanel of child aaccount'); + } +} \ No newline at end of file diff --git a/tests/data/Bug53963Test.php b/tests/data/Bug53963Test.php new file mode 100755 index 00000000..14f404c8 --- /dev/null +++ b/tests/data/Bug53963Test.php @@ -0,0 +1,84 @@ +db = $GLOBALS['db']; + $this->bean = new SugarBean(); + $this->bean->table_name = 'Bug53963Test'; + $this->audit_table_name = $this->bean->get_audit_table_name(); + $this->cleanUpAuditTable(); + } + + public function tearDown() + { + $this->cleanUpAuditTable(); + } + + public function testAuditTablePrimaryKeyCreation() + { + function findPK($previous, $index){ + return $previous || ($index['type'] == 'primary'); + } + $this->bean->create_audit_table(); + $indices = $this->db->get_indices($this->audit_table_name); + $this->assertNotEmpty($indices, "Audit table indices are missing!"); + $this->assertTrue(array_reduce($indices, 'findPK'), "Audit table is missing a primary key index"); + } + + private function cleanUpAuditTable() + { + if ($this->db->tableExists($this->audit_table_name)) { + $this->db->dropTableName($this->audit_table_name); + } + } + +} diff --git a/tests/data/GetLinkedBeansTest.php b/tests/data/GetLinkedBeansTest.php index 6117e679..e1f05326 100755 --- a/tests/data/GetLinkedBeansTest.php +++ b/tests/data/GetLinkedBeansTest.php @@ -47,6 +47,12 @@ class GetLinkedBeansTest extends Sugar_PHPUnit_Framework_TestCase $GLOBALS['current_user']->setPreference('timezone', "America/Los_Angeles"); $GLOBALS['current_user']->setPreference('datef', "m/d/Y"); $GLOBALS['current_user']->setPreference('timef', "h.iA"); + + $beanList = array(); + $beanFiles = array(); + require('include/modules.php'); + $GLOBALS['beanList'] = $beanList; + $GLOBALS['beanFiles'] = $beanFiles; } public function tearDown() @@ -61,6 +67,8 @@ class GetLinkedBeansTest extends Sugar_PHPUnit_Framework_TestCase if (is_file($file)) unlink($file); } + + unset($GLOBALS['beanFiles'], $GLOBALS['beanList']); } public function testGetLinkedBeans() diff --git a/tests/data/Relationships/Bug52544Test.php b/tests/data/Relationships/Bug52544Test.php new file mode 100755 index 00000000..221d697d --- /dev/null +++ b/tests/data/Relationships/Bug52544Test.php @@ -0,0 +1,73 @@ +user1 = SugarTestUserUtilities::createAnonymousUser(); + $user2 = SugarTestUserUtilities::createAnonymousUser(); + $user2->reports_to_id = $this->user1->id; + $user2->save(); + $user3 = SugarTestUserUtilities::createAnonymousUser(); + $user3->reports_to_id = $this->user1->id; + $user3->save(); + } + + public function tearDown() + { + SugarTestUserUtilities::removeAllCreatedAnonymousUsers(); + } + + public function testGetSubpanelQueryReturnsArray() + { + // Load up the relationship + if ( ! $this->user1->load_relationship('reportees') ) { + // The relationship did not load, I'm guessing it doesn't exist + $this->fail('Could not find a relationship named: reportees'); + } + $linkQueryParts = $this->user1->reportees->getSubpanelQuery(array('return_as_array'=>true)); + + $this->assertTrue(is_array($linkQueryParts)); + } + +} \ No newline at end of file diff --git a/tests/data/SugarBeanTest.php b/tests/data/SugarBeanTest.php index 79f414ea..36438159 100755 --- a/tests/data/SugarBeanTest.php +++ b/tests/data/SugarBeanTest.php @@ -91,6 +91,33 @@ class SugarBeanTest extends Sugar_PHPUnit_Framework_TestCase $this->assertNotContains("select * from config", $bean->db->lastQuery); } + + + + /** + * Test to make sure that when a bean is cloned it removes all loaded relationships so they can be recreated on + * the cloned copy if they are called. + * + * @group 51630 + * @return void + */ + public function testCloneBeanDoesntKeepRelationship() + { + $account = SugarTestAccountUtilities::createAccount(); + + $account->load_relationship('contacts'); + + // lets make sure the relationship is loaded + $this->assertTrue(isset($account->contacts)); + + $clone_account = clone $account; + + // lets make sure that the relationship is not on the cloned record + $this->assertFalse(isset($clone_account->contacts)); + + SugarTestAccountUtilities::removeAllCreatedAccounts(); + } + } // Using Mssql here because mysql needs real connection for quoting diff --git a/tests/include/MVC/Controller/SugarControllerTest.php b/tests/include/MVC/Controller/SugarControllerTest.php index ddf7707b..a869a711 100755 --- a/tests/include/MVC/Controller/SugarControllerTest.php +++ b/tests/include/MVC/Controller/SugarControllerTest.php @@ -37,7 +37,7 @@ require_once 'include/MVC/Controller/SugarController.php'; -class SugarControllerTest extends Sugar_PHPUnit_Framework_TestCase +class SugarControllerTest extends Sugar_PHPUnit_Framework_OutputTestCase { public function setUp() { diff --git a/tests/include/MVC/View/views/ViewNoAccessTest.php b/tests/include/MVC/View/views/ViewNoAccessTest.php index d374fd13..496221a0 100755 --- a/tests/include/MVC/View/views/ViewNoAccessTest.php +++ b/tests/include/MVC/View/views/ViewNoAccessTest.php @@ -37,7 +37,7 @@ require_once('include/MVC/View/views/view.noaccess.php'); -class ViewNoAccessTest extends Sugar_PHPUnit_Framework_TestCase +class ViewNoAccessTest extends Sugar_PHPUnit_Framework_OutputTestCase { public function testConstructor() { @@ -49,15 +49,7 @@ class ViewNoAccessTest extends Sugar_PHPUnit_Framework_TestCase public function testDisplay() { $view = new ViewNoaccess; - - ob_start(); $view->display(); - $output = ob_get_contents(); - ob_end_clean(); - - $this->assertEquals( - '

    Warning: You do not have permission to access this module.

    ', - $output - ); + $this->expectedString('

    Warning: You do not have permission to access this module.

    '); } } \ No newline at end of file diff --git a/tests/include/MVC/View/views/ViewVcardTest.php b/tests/include/MVC/View/views/ViewVcardTest.php index 1a2c5789..377ce2bf 100755 --- a/tests/include/MVC/View/views/ViewVcardTest.php +++ b/tests/include/MVC/View/views/ViewVcardTest.php @@ -37,7 +37,7 @@ require_once('include/MVC/View/views/view.vcard.php'); -class ViewVcardTest extends Sugar_PHPUnit_Framework_TestCase +class ViewVcardTest extends Sugar_PHPUnit_Framework_OutputTestCase { public function setUp() { @@ -69,17 +69,8 @@ class ViewVcardTest extends Sugar_PHPUnit_Framework_TestCase $view = new ViewVcard; $view->bean = SugarTestContactUtilities::createContact(); $view->module = 'Contacts'; - - ob_start(); $view->display(); - $output = ob_get_contents(); - ob_end_clean(); - SugarTestContactUtilities::removeAllCreatedContacts(); - - $this->assertContains( - 'BEGIN:VCARD', - $output - ); + $this->expectOutputRegex('/BEGIN\:VCARD/'); } } \ No newline at end of file diff --git a/tests/include/SerializeEvilTest.php b/tests/include/SerializeEvilTest.php index 5240506d..6f48d138 100755 --- a/tests/include/SerializeEvilTest.php +++ b/tests/include/SerializeEvilTest.php @@ -35,6 +35,7 @@ ********************************************************************************/ +require_once("include/Sugarpdf/sugarpdf_config.php"); require_once 'include/tcpdf/tcpdf.php'; require_once 'include/SugarCache/SugarCacheFile.php'; require_once 'modules/Import/sources/ImportFile.php'; diff --git a/tests/include/Smarty/plugins/FunctionSugarHelpTest.php b/tests/include/Smarty/plugins/FunctionSugarHelpTest.php index 17c74daf..07228f80 100755 --- a/tests/include/Smarty/plugins/FunctionSugarHelpTest.php +++ b/tests/include/Smarty/plugins/FunctionSugarHelpTest.php @@ -42,9 +42,15 @@ class FunctionSugarHelpTest extends Sugar_PHPUnit_Framework_TestCase { public function setUp() { + SugarTestHelper::setUp('app_strings'); $this->_smarty = new Sugar_Smarty; } - + + public function tearDown() + { + SugarTestHelper::tearDown(); + } + public function providerSpecialCharactersHandledInTextParameter() { return array( diff --git a/tests/include/database/Bug52783Test.php b/tests/include/database/Bug52783Test.php new file mode 100755 index 00000000..d5a81155 --- /dev/null +++ b/tests/include/database/Bug52783Test.php @@ -0,0 +1,109 @@ +_db = new MssqlManager(); + } + + public function tearDown() + { + } + + /** + * Test if returnOrderBy() inside limitQuery() method returns a valid MSSQL ordering column for use in OVER() + * @dataProvider orderProvider + */ + public function testReturnOrderBy($sql, $expected) + { + $expected = strtolower($expected); + $result = strtolower($this->_db->limitQuery($sql, 21, 20, false, '', false)); + $this->assertContains($expected, $result); + } + + public function orderProvider() + { + return array( + 0 => array( + "SELECT contacts.id , LTRIM(RTRIM(ISNULL(contacts.first_name,'')+' '+ISNULL(contacts.last_name,''))) as name, contacts.first_name , contacts.last_name , contacts.salutation , accounts.name account_name, jtl0.account_id account_id, contacts.title , contacts.phone_work , LTRIM(RTRIM(ISNULL(jt1.first_name,'')+' '+ISNULL(jt1.last_name,''))) assigned_user_name , jt1.created_by assigned_user_name_owner , 'Users' assigned_user_name_mod, contacts.date_entered , contacts.assigned_user_id , sfav.id is_favorite FROM contacts LEFT JOIN accounts_contacts jtl0 ON contacts.id=jtl0.contact_id AND jtl0.deleted=0 + LEFT JOIN accounts accounts ON accounts.id=jtl0.account_id AND accounts.deleted=0 + AND accounts.deleted=0 LEFT JOIN users jt1 ON contacts.assigned_user_id=jt1.id AND jt1.deleted=0 + AND jt1.deleted=0 LEFT JOIN sugarfavorites sfav ON sfav.module ='Contacts' AND sfav.record_id=contacts.id AND sfav.created_by='1' AND sfav.deleted=0 where contacts.deleted=0 ORDER BY name", + + "LTRIM(RTRIM(ISNULL(contacts.first_name,'')+' '+ISNULL(contacts.last_name,'')))" + ), + 1 => array( + "SELECT contacts.id , LTRIM(RTRIM(ISNULL(contacts.first_name,'')+' '+ISNULL(contacts.last_name,''))) as name, contacts.first_name , contacts.last_name , contacts.salutation , accounts.name account_name, jtl0.account_id account_id, contacts.title , contacts.phone_work , LTRIM(RTRIM(ISNULL(jt1.first_name,'')+' '+ISNULL(jt1.last_name,''))) assigned_user_name , jt1.created_by assigned_user_name_owner , 'Users' assigned_user_name_mod, contacts.date_entered , contacts.assigned_user_id , sfav.id is_favorite FROM contacts LEFT JOIN accounts_contacts jtl0 ON contacts.id=jtl0.contact_id AND jtl0.deleted=0 + LEFT JOIN accounts accounts ON accounts.id=jtl0.account_id AND accounts.deleted=0 + AND accounts.deleted=0 LEFT JOIN users jt1 ON contacts.assigned_user_id=jt1.id AND jt1.deleted=0 + AND jt1.deleted=0 LEFT JOIN sugarfavorites sfav ON sfav.module ='Contacts' AND sfav.record_id=contacts.id AND sfav.created_by='1' AND sfav.deleted=0 where contacts.deleted=0 ORDER BY name ASC", + + "LTRIM(RTRIM(ISNULL(contacts.first_name,'')+' '+ISNULL(contacts.last_name,'')))" + ), + 2 => array( + "SELECT contacts.id , LTRIM(RTRIM(ISNULL(contacts.first_name,'')+' '+ISNULL(contacts.last_name,''))) as name, contacts.first_name , contacts.last_name , contacts.salutation , accounts.name account_name, jtl0.account_id account_id, contacts.title , contacts.phone_work , LTRIM(RTRIM(ISNULL(jt1.first_name,'')+' '+ISNULL(jt1.last_name,''))) assigned_user_name , jt1.created_by assigned_user_name_owner , 'Users' assigned_user_name_mod, contacts.date_entered , contacts.assigned_user_id , sfav.id is_favorite FROM contacts LEFT JOIN accounts_contacts jtl0 ON contacts.id=jtl0.contact_id AND jtl0.deleted=0 + LEFT JOIN accounts accounts ON accounts.id=jtl0.account_id AND accounts.deleted=0 + AND accounts.deleted=0 LEFT JOIN users jt1 ON contacts.assigned_user_id=jt1.id AND jt1.deleted=0 + AND jt1.deleted=0 LEFT JOIN sugarfavorites sfav ON sfav.module ='Contacts' AND sfav.record_id=contacts.id AND sfav.created_by='1' AND sfav.deleted=0 where contacts.deleted=0 ORDER BY contacts.name ASC", + + "contacts.name" + ), + 3 => array( + "SELECT contacts.id , ISNULL(contacts.last_name,''))) as name, contacts.first_name , contacts.last_name , contacts.salutation , accounts.name account_name, jtl0.account_id account_id, contacts.title , contacts.phone_work , LTRIM(RTRIM(ISNULL(jt1.first_name,'')+' '+ISNULL(jt1.last_name,''))) assigned_user_name , jt1.created_by assigned_user_name_owner , 'Users' assigned_user_name_mod, contacts.date_entered , contacts.assigned_user_id , sfav.id is_favorite FROM contacts LEFT JOIN accounts_contacts jtl0 ON contacts.id=jtl0.contact_id AND jtl0.deleted=0 + LEFT JOIN accounts accounts ON accounts.id=jtl0.account_id AND accounts.deleted=0 + AND accounts.deleted=0 LEFT JOIN users jt1 ON contacts.assigned_user_id=jt1.id AND jt1.deleted=0 + AND jt1.deleted=0 LEFT JOIN sugarfavorites sfav ON sfav.module ='Contacts' AND sfav.record_id=contacts.id AND sfav.created_by='1' AND sfav.deleted=0 where contacts.deleted=0 ORDER BY name ASC", + + "ISNULL(contacts.last_name,'')))" + ), + ); + } +} diff --git a/tests/include/database/Bug53002Test.php b/tests/include/database/Bug53002Test.php new file mode 100755 index 00000000..8dc1a4b5 --- /dev/null +++ b/tests/include/database/Bug53002Test.php @@ -0,0 +1,66 @@ +_db)){ + $this->_db = DBManagerFactory::getInstance(); + } + } + + public function tearDown() + { + } + + public function test_order_by_amount() + { + $query = "SELECT * FROM opportunities ORDER BY amount ASC"; + $this->_db->query($query); + // and make no error messages are asserted + $this->assertEmpty($this->_db->lastError(), "lastError should return false of the last legal query that is ordering by amount against opportunities"); + + $query = "SELECT * FROM opportunities ORDER BY amount_usdollar ASC"; + $this->_db->query($query); + // and make no error messages are asserted + $this->assertEmpty($this->_db->lastError(), "lastError should return false of the last legal query that is ordering by amount_usdollar against opportunities"); + } +} diff --git a/tests/include/database/DBManagerTest.php b/tests/include/database/DBManagerTest.php index e892bf9f..1cb38103 100755 --- a/tests/include/database/DBManagerTest.php +++ b/tests/include/database/DBManagerTest.php @@ -2061,7 +2061,7 @@ class DBManagerTest extends Sugar_PHPUnit_Framework_TestCase //echo "$size\n"; $this->_db->insertParams($tablename, $fielddefs, array('id' => $size, 'test' => $str, 'dummy' => $str)); - $select = "SELECT test FROM $tablename WHERE id = '$size'"; + $select = "SELECT test FROM $tablename WHERE id = '{$size}'"; $strresult = $this->_db->getOne($select); $this->assertEquals(0, mb_strpos($str, $strresult)); @@ -2092,13 +2092,14 @@ class DBManagerTest extends Sugar_PHPUnit_Framework_TestCase */ public function testDBGuidGeneration() { - $guids = array(); - $sql = "SELECT {$this->_db->getGuidSQL()} {$this->_db->getFromDummyTable()}"; - for($i = 0; $i < 1000; $i++) - { - $newguid = $this->_db->getOne($sql); - $this->assertFalse(in_array($newguid, $guids), "'$newguid' already existed in the array of GUIDs!"); - $guids []= $newguid; - } - } + + $guids = array(); + $sql = "SELECT {$this->_db->getGuidSQL()} {$this->_db->getFromDummyTable()}"; + for($i = 0; $i < 1000; $i++) + { + $newguid = $this->_db->getOne($sql); + $this->assertFalse(in_array($newguid, $guids), "'$newguid' already existed in the array of GUIDs!"); + $guids []= $newguid; + } + } } diff --git a/tests/include/utils/Bug33284_Test.php b/tests/include/utils/Bug33284_Test.php index 640f16d8..22bf445d 100755 --- a/tests/include/utils/Bug33284_Test.php +++ b/tests/include/utils/Bug33284_Test.php @@ -64,7 +64,7 @@ class Bug33284_Test extends Sugar_PHPUnit_Framework_TestCase $test_string = 'The quick brown fox jumps over lazy dogs'; $display_string = getTrackerSubstring($test_string); - $this->assertEquals(strlen($display_string), $default_length, 'Assert that the string length is equal to ' . $default_length . ' characters'); + $this->assertEquals(strlen(from_html($display_string)), $default_length, 'Assert that the string length is equal to ' . $default_length . ' characters'); } @@ -78,12 +78,12 @@ class Bug33284_Test extends Sugar_PHPUnit_Framework_TestCase $sugar_config['tracker_max_display_length'] = $default_length; $display_string = getTrackerSubstring($test_string); - $this->assertEquals(strlen($display_string), $default_length, 'Assert that the string length is equal to ' . $default_length . ' characters (default)'); + $this->assertEquals(strlen(from_html($display_string)), $default_length, 'Assert that the string length is equal to ' . $default_length . ' characters (default)'); $test_string = '早前於美國完成民族音樂學博士學位回港後在大專院校的音樂系任教123456789'; $display_string = getTrackerSubstring($test_string); - $this->assertEquals(mb_strlen($display_string, 'UTF-8'), $default_length, 'Assert that the string length is equal to ' . $default_length . ' characters (default)'); + $this->assertEquals(mb_strlen(from_html($display_string), 'UTF-8'), $default_length, 'Assert that the string length is equal to ' . $default_length . ' characters (default)'); } } diff --git a/tests/include/utils/CleanDirNameTest.php b/tests/include/utils/CleanDirNameTest.php new file mode 100755 index 00000000..c2292248 --- /dev/null +++ b/tests/include/utils/CleanDirNameTest.php @@ -0,0 +1,54 @@ +assertEquals(cleanDirName($dir), "dir"); + } +} \ No newline at end of file diff --git a/tests/metadata/Bug51105Test.php b/tests/metadata/Bug51105Test.php new file mode 100755 index 00000000..43cba67f --- /dev/null +++ b/tests/metadata/Bug51105Test.php @@ -0,0 +1,68 @@ +assertEquals($default, $sqc->ev->defs['templateMeta']['form']['headerTpl'], $error); + + // Employees has a defined headerTpl + $module = 'Employees'; + $sqc = new SubpanelQuickCreate($module, $view, true); + $this->assertEquals('modules/Users/tpls/EditViewHeader.tpl', $sqc->ev->defs['templateMeta']['form']['headerTpl'], $error); + } +} \ No newline at end of file diff --git a/tests/modules/Administration/SugarSpriteBuilderTest.php b/tests/modules/Administration/SugarSpriteBuilderTest.php index ec384e07..9898821e 100755 --- a/tests/modules/Administration/SugarSpriteBuilderTest.php +++ b/tests/modules/Administration/SugarSpriteBuilderTest.php @@ -53,6 +53,10 @@ public function setUp() $this->markTestSkipped('imagecreatetruecolor function not found. skipping test'); return; } + if (empty($GLOBALS['sugar_config']['use_sprites'])) + { + $GLOBALS['sugar_config']['use_sprites'] = null; + } $this->useSprites = $GLOBALS['sugar_config']['use_sprites']; $GLOBALS['sugar_config']['use_sprites'] = true; diff --git a/tests/modules/Configurator/ConfiguratorTest.php b/tests/modules/Configurator/ConfiguratorTest.php index 3ceae6c5..81d7fb1b 100755 --- a/tests/modules/Configurator/ConfiguratorTest.php +++ b/tests/modules/Configurator/ConfiguratorTest.php @@ -54,6 +54,6 @@ class ConfiguratorTest extends Sugar_PHPUnit_Framework_TestCase $this->assertEquals($cfg->config['admin_export_only'], false); $this->assertEquals($cfg->config['upload_dir'], 'yummy'); - unset($_POST); + $_POST = array(); } } diff --git a/tests/modules/DynamicFields/Bug51427Test.php b/tests/modules/DynamicFields/Bug51427Test.php new file mode 100755 index 00000000..085f35cd --- /dev/null +++ b/tests/modules/DynamicFields/Bug51427Test.php @@ -0,0 +1,254 @@ +old_dictionary=$dictionary; + $this->old_bean_list=$bean_list; + $this->test_standart_field = new TestStandardField(); + $this->test_standart_field->module='Accounts'; + loadBean($this->test_standart_field->module); + $this->test_field=get_widget('varchar'); + $this->test_field->name='name'; + $this->bean_name = get_valid_bean_name($this->test_standart_field->module); + } + + public function tearDown() + { + global $dictionary, $bean_list; + + $dictionary=$this->old_dictionary; + $bean_list=$this->old_bean_list; + VardefManager::clearVardef('Accounts', 'Account'); + VardefManager::refreshVardefs('Accounts', 'Account'); + } + + /** + * Test different combinations of the options + * + * @dataProvider providerUnifiedSearchOptions + */ + public function testIfUnifiedSearchEnabledByDefault(array $opt_common, array $opt_field, $assert) + { + $this->test_field->unified_search=false; + $this->setOptions($opt_common, $opt_field); + $this->test_standart_field->addFieldObject($this->test_field); + $this->assertEquals($assert,(boolean)$this->test_field->unified_search, + "\r\n" + .'Assertion error: field->unified_search should be `'.($assert ? 'true' : 'false').'` with the following vardef options:' + + ."\r\nvardef[][unified_search_default_enabled] " + .($opt_common['unified_search_default_enabled']===-1 ? 'is undefined' : ($opt_common['unified_search_default_enabled'] ? '= true' : '= false')) + + ."\r\nvardef[][unified_search] " + .($opt_common['unified_search']===-1 ? 'is undefined' : ($opt_common['unified_search'] ? '= true' : '= false')) + + ."\r\nvardef[][fields][][unified_search] " + .($opt_field['unified_search']===-1 ? 'is undefined' : ($opt_field['unified_search'] ? '= true' : '= false')) + ."\r\n" + ); + } + + public function providerUnifiedSearchOptions() + { + return array( + array( + 'options_common'=>array( + 'unified_search_default_enabled'=>1, + 'unified_search'=>1, + ), + 'options_field'=>array( + 'unified_search'=>1, + ), + 'assert'=>true, + ), + array( + 'options_common'=>array( + 'unified_search_default_enabled'=>0, + 'unified_search'=>1, + ), + 'options_field'=>array( + 'unified_search'=>1, + ), + 'assert'=>false, + ), + array( + 'options_common'=>array( + 'unified_search_default_enabled'=>0, + 'unified_search'=>0, + ), + 'options_field'=>array( + 'unified_search'=>1, + ), + 'assert'=>false, + ), + array( + 'options_common'=>array( + 'unified_search_default_enabled'=>0, + 'unified_search'=>0, + ), + 'options_field'=>array( + 'unified_search'=>0, + ), + 'assert'=>false, + ), + array( + 'options_common'=>array( + 'unified_search_default_enabled'=>0, + 'unified_search'=>1, + ), + 'options_field'=>array( + 'unified_search'=>0, + ), + 'assert'=>false, + ), + array( + 'options_common'=>array( + 'unified_search_default_enabled'=>0, + 'unified_search'=>0, + ), + 'options_field'=>array( + 'unified_search'=>1, + ), + 'assert'=>false, + ), + array( + 'options_common'=>array( + 'unified_search_default_enabled'=>1, + 'unified_search'=>1, + ), + 'options_field'=>array( + 'unified_search'=>-1, + ), + 'assert'=>true, + ), + array( + 'options_common'=>array( + 'unified_search_default_enabled'=>1, + 'unified_search'=>-1, + ), + 'options_field'=>array( + 'unified_search'=>1, + ), + 'assert'=>false, + ), + array( + 'options_common'=>array( + 'unified_search_default_enabled'=>-1, + 'unified_search'=>1, + ), + 'options_field'=>array( + 'unified_search'=>1, + ), + 'assert'=>false, + ), + ); + } + + private function setOptions(array $opt_common, array $opt_field) + { + global $dictionary; + $dictionary=$this->old_dictionary; + if(!empty($opt_common)) + { + foreach($opt_common as $k=>$v) + { + if($v===-1) + { + unset($dictionary[$this->bean_name][$k]); + } + else + { + $dictionary[$this->bean_name][$k]=$v; + } + } + } + if(!empty($opt_field)) + { + foreach($opt_field as $k=>$v) + { + if($v===-1) + { + unset($dictionary[$this->bean_name]['fields'][$this->test_field->name][$k]); + } + else + { + $dictionary[$this->bean_name]['fields'][$this->test_field->name][$k]=$v; + } + } + } + } +} + + +/* + * inherits StandardField + * some methods aren't used in the test + */ +class TestStandardField extends StandardField +{ + function writeVardefExtension() + { + } + + function loadCustomDef() + { + $this->custom_def=array(); + } +} \ No newline at end of file diff --git a/tests/modules/DynamicFields/templates/Fields/Bug52610Test.php b/tests/modules/DynamicFields/templates/Fields/Bug52610Test.php new file mode 100755 index 00000000..a517ca0f --- /dev/null +++ b/tests/modules/DynamicFields/templates/Fields/Bug52610Test.php @@ -0,0 +1,81 @@ +name = 'bug52610_c'; + $field->type = 'bool'; + $field->default = $default; + $field->default_value = ''; + $field->no_default = 1; + $query = $field->get_db_add_alter_table('bug52610_cstm'); + $this->assertNotContains(" DEFAULT ", $query, "DEFAULT part is present in query"); + } +} diff --git a/tests/modules/Emails/BugNullAssignedUserIdTest.php b/tests/modules/Emails/BugNullAssignedUserIdTest.php new file mode 100755 index 00000000..51857937 --- /dev/null +++ b/tests/modules/Emails/BugNullAssignedUserIdTest.php @@ -0,0 +1,95 @@ +old_current_user = $current_user; + } + + $this->current_user = SugarTestUserUtilities::createAnonymousUser(); + + $GLOBALS['current_user'] = $this->current_user; + $this->email = new Email(); + $this->email->email2init(); + + // Set some values for some fields so the query is actually built + $this->email->id = '1'; + $this->email->created_by = $this->current_user->id; + $this->email->date_modified = date('Y-m-d H:i:s'); + + // Specify an empty assigned user id for testing nulls + $this->email->assigned_user_id = ''; + } + + public function tearDown() + { + unset($this->email); + SugarTestUserUtilities::removeAllCreatedAnonymousUsers(); + unset($this->current_user); + + if ($this->old_current_user) { + $GLOBALS['current_user'] = $this->old_current_user; + } + } + + public function testNullAssignedUserIdConvertedToEmptyInSave() { + $query = $this->email->db->updateSQL($this->email); + $this->assertContains("assigned_user_id=''", $query, 'Assigned user id set to empty string not found'); + } + + public function testNullAssignedUserIdInSave() { + $this->email->setFieldNullable('assigned_user_id'); + $query = $this->email->db->updateSQL($this->email); + $this->email->revertFieldNullable('assigned_user_id'); + $this->assertContains('assigned_user_id=NULL', $query, 'Assigned user id set to DB NULL value not found'); + } +} +?> \ No newline at end of file diff --git a/tests/modules/InboundEmail/Bug43554Test.php b/tests/modules/InboundEmail/Bug43554Test.php index 5b1ad165..40184f5b 100755 --- a/tests/modules/InboundEmail/Bug43554Test.php +++ b/tests/modules/InboundEmail/Bug43554Test.php @@ -63,13 +63,13 @@ class Bug43554Test extends Sugar_PHPUnit_Framework_TestCase public function getUrls() { return array( - array("http://localhost:8888/sugarent/index.php?composeLayoutId=composeLayout1&fromAccount=1&module=Emails&action=EmailUIAjax&emailUIAction=sendEmail&setEditor=1", TRUE), - array("http://localhost:8888/index.php?composeLayoutId=composeLayout1&fromAccount=1&module=Emails&action=EmailUIAjax&emailUIAction=sendEmail&setEditor=1", TRUE), - array(to_html("http://localhost:8888/index.php?composeLayoutId=composeLayout1&fromAccount=1&module=Emails&action=EmailUIAjax&emailUIAction=sendEmail&setEditor=1"), TRUE), - array("/index.php?composeLayoutId=composeLayout1&fromAccount=1&module=Emails&action=EmailUIAjax&emailUIAction=sendEmail&setEditor=1", TRUE), - array("index.php?composeLayoutId=composeLayout1&fromAccount=1&module=Emails&action=EmailUIAjax&emailUIAction=sendEmail&setEditor=1", FALSE), - array("/?composeLayoutId=composeLayout1&fromAccount=1&module=Emails&action=EmailUIAjax&emailUIAction=sendEmail&setEditor=1", TRUE), - array("https://localhost/?composeLayoutId=composeLayout1&fromAccount=1&module=Emails&action=EmailUIAjax&emailUIAction=sendEmail&setEditor=1", TRUE), + array("http://localhost:8888/sugarent/index.php?composeLayoutId=composeLayout1&fromAccount=1&module=Emails&action=EmailUIAjax&emailUIAction=sendEmail&setEditor=1"), + array("http://localhost:8888/index.php?composeLayoutId=composeLayout1&fromAccount=1&module=Emails&action=EmailUIAjax&emailUIAction=sendEmail&setEditor=1"), + array(to_html("http://localhost:8888/index.php?composeLayoutId=composeLayout1&fromAccount=1&module=Emails&action=EmailUIAjax&emailUIAction=sendEmail&setEditor=1")), + array("/index.php?composeLayoutId=composeLayout1&fromAccount=1&module=Emails&action=EmailUIAjax&emailUIAction=sendEmail&setEditor=1"), + array("index.php?composeLayoutId=composeLayout1&fromAccount=1&module=Emails&action=EmailUIAjax&emailUIAction=sendEmail&setEditor=1"), + array("/?composeLayoutId=composeLayout1&fromAccount=1&module=Emails&action=EmailUIAjax&emailUIAction=sendEmail&setEditor=1"), + array("https://localhost/?composeLayoutId=composeLayout1&fromAccount=1&module=Emails&action=EmailUIAjax&emailUIAction=sendEmail&setEditor=1"), ); } @@ -77,17 +77,10 @@ class Bug43554Test extends Sugar_PHPUnit_Framework_TestCase * @dataProvider getUrls * @param string $url */ - function testEmailCleanup($url,$imgShouldBeRemoved) + function testEmailCleanup($url) { $data = "Test: "; - if($imgShouldBeRemoved) - { - $res = str_replace("", "", SugarCleaner::cleanHtml($data)); - $this->assertNotContains("assertContains("", "", SugarCleaner::cleanHtml($data)); + $this->assertNotContains("assertEquals($contact_id, $test_contact_id); - $output = ob_get_clean(); } } \ No newline at end of file diff --git a/tests/modules/Leads/ConvertLeadTests.php b/tests/modules/Leads/ConvertLeadTests.php index cc1eba20..2ec4da31 100755 --- a/tests/modules/Leads/ConvertLeadTests.php +++ b/tests/modules/Leads/ConvertLeadTests.php @@ -35,6 +35,7 @@ ********************************************************************************/ +require_once('tests/SugarTestViewConvertLeadUtilities.php'); require_once 'modules/Leads/views/view.convertlead.php'; require_once 'tests/SugarTestViewConvertLeadUtilities.php'; @@ -150,7 +151,45 @@ class ConvertLeadTests extends Sugar_PHPUnit_Framework_TestCase SugarTestLeadUtilities::removeAllCreatedLeads(); } - public function testActivityCopy() { + + public function testActivityCopyWithParent() { + // lets the run the activity copy again, only this time we pass in a parent account + $lead = SugarTestLeadUtilities::createLead(); + $contact = SugarTestContactUtilities::createContact(); + $meeting = SugarTestMeetingUtilities::createMeeting(); + $account = SugarTestAccountUtilities::createAccount(); + SugarTestMeetingUtilities::addMeetingParent($meeting->id, $lead->id); + $relation_id = SugarTestMeetingUtilities::addMeetingLeadRelation($meeting->id, $lead->id); + $_REQUEST['record'] = $lead->id; + + // refresh the meeting to include parent_id and parent_type + $meeting_id = $meeting->id; + $meeting = new Meeting(); + $meeting->retrieve($meeting_id); + + // action: copy meeting from lead to contact + $convertObj = new TestViewConvertLead(); + $convertObj->copyActivityWrapper($meeting, $contact, array('id'=>$account->id,'type'=>'Accounts')); + + + // 2a a newly created meeting with no parent info passed in, so parent id and type are empty + //parent type=Contatcs and parent_id=$contact->id + //$sql = "select id from meetings where parent_id='{$contact->id}' and parent_type= 'Contacts' and deleted=0"; + $sql = "select id, parent_id from meetings where name = '{$meeting->name}'"; + $result = $GLOBALS['db']->query($sql); + while ($row = $GLOBALS['db']->fetchByAssoc($result)){ + //skip if this is the original message + if($row['id'] == $meeting_id){ + continue; + } + + $this->assertEquals($row['parent_id'], $account->id, 'parent id of meeting should be equal to passed in account id: '.$account->id); + } + + } + + + public function testActivityCopyWithNoParent() { // init $lead = SugarTestLeadUtilities::createLead(); $contact = SugarTestContactUtilities::createContact(); @@ -173,15 +212,20 @@ class ConvertLeadTests extends Sugar_PHPUnit_Framework_TestCase $this->assertEquals('Leads', $meeting->parent_type, 'parent_type of the original meeting was changed from Leads to '.$meeting->parent_type); $this->assertEquals($lead->id, $meeting->parent_id, 'parent_id of the original meeting was changed from '.$lead->id.' to '.$meeting->parent_id); - // 2. a newly created meeting with parent type=Contatcs and parent_id=$contact->id - $sql = "select id from meetings where parent_id='{$contact->id}' and parent_type= 'Contacts' and deleted=0"; - $result = $GLOBALS['db']->query($sql); - $row = $GLOBALS['db']->fetchByAssoc($result); - $this->assertNotNull($row, 'Could not find the newly created meeting with parent_type=Contacts and parent_id='.$contact->id); + // 2. a newly created meeting with no parent info passed in, so parent id and type are empty $new_meeting_id = ''; - if ($row) { - $new_meeting_id = $row['id']; - } + $sql = "select id, parent_id from meetings where name = '{$meeting->name}'"; + $result = $GLOBALS['db']->query($sql); + while ($row = $GLOBALS['db']->fetchByAssoc($result)){ + //skip if this is the original message + if($row['id'] == $meeting_id){ + continue; + } + $new_meeting_id = $row['id']; + $this->assertEmpty($row['parent_id'],'parent id of meeting should be empty as no parent was sent in '); + } + + // 3. record should not be deleted from meetings_leads table $sql = "select id from meetings_leads where meeting_id='{$meeting->id}' and lead_id='{$lead->id}' and deleted=0"; @@ -342,18 +386,18 @@ class ConvertLeadTests extends Sugar_PHPUnit_Framework_TestCase $row = $GLOBALS['db']->fetchByAssoc($result); $this->assertFalse(empty($row), "Meeting-Contact relationship is not added."); - // 7. the parent_type of the new meeting should be Contacts + // 7. the parent_type of the new meeting should be empty $new_meeting_id = $row['meeting_id']; $sql = "select id, parent_type, parent_id from meetings where id='{$new_meeting_id}' and deleted=0"; $result = $GLOBALS['db']->query($sql); $row = $GLOBALS['db']->fetchByAssoc($result); $this->assertFalse(empty($row), "New meeting is not added for contact."); - $this->assertEquals('Contacts', $row['parent_type'], 'Parent type of the new meeting should be Contacts'); + $this->assertEmpty($row['parent_type'], 'Parent type of the new meeting should be Empty'); // 8. the parent_id of the new meeting should be contact id - $this->assertEquals($contact_id, $row['parent_id'], 'Parent id of the new meeting should be contact id.'); + $this->assertEmpty($row['parent_id'], 'Parent id of the new meeting should be empty.'); - // clean up + // clean up unset($_REQUEST['record']); $GLOBALS['db']->query("delete from meetings where parent_id='{$lead->id}' and parent_type= 'Leads'"); $GLOBALS['db']->query("delete from meetings where parent_id='{$contact_id}' and parent_type= 'Contacts'"); @@ -466,8 +510,8 @@ class TestViewConvertLead extends ViewConvertLead parent::moveActivity($activity, $bean); } - public function copyActivityWrapper($activity, $bean) { - parent::copyActivityAndRelateToBean($activity, $bean); + public function copyActivityWrapper($activity, $bean,$parent=array()) { + parent::copyActivityAndRelateToBean($activity, $bean,$parent); } public function testMeetingsUsersRelationships() diff --git a/tests/modules/MassUpdate/Bug51596Test.php b/tests/modules/MassUpdate/Bug51596Test.php index e79c8ea1..16bf8a91 100755 --- a/tests/modules/MassUpdate/Bug51596Test.php +++ b/tests/modules/MassUpdate/Bug51596Test.php @@ -41,25 +41,26 @@ class Bug51596Test extends Sugar_PHPUnit_Framework_TestCase { /** -* @var Contact -*/ + * @var Contact + */ protected $contact1, $contact2; /** -* @var Account -*/ + * @var Account + * @var Account + */ protected $account1, $account2; protected $field_name = 'bug51596test'; /** -* Sets up the fixture, for example, open a network connection. -* This method is called before a test is executed. -* -* @return void -*/ + * Sets up the fixture, for example, open a network connection. + * This method is called before a test is executed. + * + * @return void + */ public function setUp() { $this->markTestIncomplete("Disabling broken test on CI. Working with Sergei to get it fixed"); @@ -71,15 +72,15 @@ class Bug51596Test extends Sugar_PHPUnit_Framework_TestCase 'Contact' => array( 'fields' => array( $this->field_name => array ( - 'name' => $this->field_name, - 'rname' => 'name', - 'id_name' => 'account_id', + 'name' => $this->field_name, + 'rname' => 'name', + 'id_name' => 'account_id', 'join_name' => 'accounts', - 'type' => 'relate', - 'link' => 'accounts', - 'table' => 'accounts', - 'module' => 'Accounts', - 'source' => 'non-db', + 'type' => 'relate', + 'link' => 'accounts', + 'table' => 'accounts', + 'module' => 'Accounts', + 'source' => 'non-db', ), ), ), @@ -118,17 +119,17 @@ class Bug51596Test extends Sugar_PHPUnit_Framework_TestCase // will update "do_not_call" attribute of found contacts $_REQUEST['massupdate'] = 'true'; - $_REQUEST['entire'] = true; - $_REQUEST['module'] = 'Contacts'; - $_POST['do_not_call'] = 1; + $_REQUEST['entire'] = true; + $_REQUEST['module'] = 'Contacts'; + $_POST['do_not_call'] = 1; } /** -* Tears down the fixture, for example, close a network connection. -* This method is called after a test is executed. -* -* @return void -*/ + * Tears down the fixture, for example, close a network connection. + * This method is called after a test is executed. + * + * @return void + */ public function tearDown() { unset($_REQUEST['massupdate'], $_REQUEST['entire'], $_REQUEST['module'], $_POST['do_not_call']); @@ -159,11 +160,11 @@ class Bug51596Test extends Sugar_PHPUnit_Framework_TestCase } /** -* Verifies that objects are found and updated by name of custom related -* object -* -* @return void -*/ + * Verifies that objects are found and updated by name of custom related + * object + * + * @return void + */ public function testSearchAndUpdate() { $contact = new Contact(); @@ -174,7 +175,7 @@ class Bug51596Test extends Sugar_PHPUnit_Framework_TestCase // search for contacts related to Bug51596Test_Account1 (e.g. Contact1) $current_query_by_page = array ( - 'searchFormTab' => 'basic_search', + 'searchFormTab' => 'basic_search', $this->field_name . '_basic' => 'Bug51596Test_Account1', ); @@ -193,14 +194,14 @@ class Bug51596Test extends Sugar_PHPUnit_Framework_TestCase } /** -* Utility function. Registers vardef extension for specified module. -* -* @static -* @param string $module -* @param string $filename -* @param array $data -* @return void -*/ + * Utility function. Registers vardef extension for specified module. + * + * @static + * @param string $module + * @param string $filename + * @param array $data + * @return void + */ protected static function registerExtension($module, $filename, array $data) { $directory = 'custom/Extension/modules/' . $module . '/Ext/Vardefs'; @@ -224,13 +225,13 @@ HERE; } /** -* Utility function. Unregisters vardef extension for specified module. -* -* @static -* @param string $module -* @param string $filename -* @return void -*/ + * Utility function. Unregisters vardef extension for specified module. + * + * @static + * @param string $module + * @param string $filename + * @return void + */ protected static function unregisterExtension($module, $filename) { $directory = 'custom/Extension/modules/' . $module . '/Ext/Vardefs'; @@ -247,15 +248,16 @@ HERE; } /** -* Utility function. Rebuilds extensions for specified module. -* -* @static -* @param string $module -* @return void -*/ + * Utility function. Rebuilds extensions for specified module. + * + * @static + * @param string $module + * @return void + */ protected static function rebuildExtensions($module) { $rc = new RepairAndClear(); $rc->repairAndClearAll(array('rebuildExtensions'), array($module), false, false); } -} \ No newline at end of file + +} diff --git a/tests/modules/ModuleBuilder/Bug52063Test.php b/tests/modules/ModuleBuilder/Bug52063Test.php index 808cfbcd..156a64fd 100755 --- a/tests/modules/ModuleBuilder/Bug52063Test.php +++ b/tests/modules/ModuleBuilder/Bug52063Test.php @@ -134,8 +134,8 @@ class Bug52063Test extends Sugar_PHPUnit_Framework_TestCase unset($GLOBALS['beanList']); unset($GLOBALS['beanFiles']); unset($GLOBALS['app_list_strings']); - unset($_REQUEST); - + $_REQUEST = array(); + SugarCache::$isCacheReset = false; } /** diff --git a/tests/modules/ModuleBuilder/MB/Bug40299Test.php b/tests/modules/ModuleBuilder/MB/Bug40299Test.php new file mode 100755 index 00000000..cd0444c2 --- /dev/null +++ b/tests/modules/ModuleBuilder/MB/Bug40299Test.php @@ -0,0 +1,65 @@ +MBModule = new MBModule('testModule', 'custom/modulebuilder/packages/testPkg', 'testPkg', 'testPkg'); + } + + public function tearDown() + { + SugarTestUserUtilities::removeAllCreatedAnonymousUsers(); + unset($GLOBALS['current_user']); + $this->MBModule->delete(); + } + + public function testFieldExistForBasicFields() + { + $this->assertEquals(true, $this->MBModule->fieldExists('name')); + } +} \ No newline at end of file diff --git a/tests/modules/Project/Bug37123Test.php b/tests/modules/Project/Bug37123Test.php index 6cb55db7..e4426764 100755 --- a/tests/modules/Project/Bug37123Test.php +++ b/tests/modules/Project/Bug37123Test.php @@ -40,10 +40,9 @@ class Bug37123Test extends Sugar_PHPUnit_Framework_TestCase { public function setUp() { - global $current_user, $currentModule ; - global $beanList; - require('include/modules.php'); - $current_user = SugarTestUserUtilities::createAnonymousUser(); + SugarTestHelper::setUp('beanFiles'); + SugarTestHelper::setUp('beanList'); + SugarTestHelper::setUp('current_user'); $unid = uniqid(); $time = date('Y-m-d H:i:s'); @@ -97,10 +96,6 @@ class Bug37123Test extends Sugar_PHPUnit_Framework_TestCase public function tearDown() { - SugarTestUserUtilities::removeAllCreatedAnonymousUsers(); - unset($GLOBALS['current_user']); - unset($GLOBALS['mod_strings']); - $GLOBALS['db']->query("DELETE FROM contacts WHERE id= '{$this->contact->id}'"); $GLOBALS['db']->query("DELETE FROM accounts WHERE id = '{$this->account->id}'"); $GLOBALS['db']->query("DELETE FROM accounts_contacts WHERE id = '{$this->ac_id}'"); @@ -113,8 +108,9 @@ class Bug37123Test extends Sugar_PHPUnit_Framework_TestCase unset($this->ac_id); unset($GLOBALS['relate_id']); unset($GLOBALS['relate_to']); + SugarTestHelper::tearDown(); } -} \ No newline at end of file +} diff --git a/tests/modules/Reports/Bug36246Test.php b/tests/modules/Reports/Bug36246Test.php index 048a4b63..976cb0e6 100755 --- a/tests/modules/Reports/Bug36246Test.php +++ b/tests/modules/Reports/Bug36246Test.php @@ -56,4 +56,4 @@ class SugarWidgetFieldURLBug36246Mock extends SugarWidgetFieldURL { { return 'sugarcrm.com'; } -} \ No newline at end of file +} diff --git a/tests/modules/SchedulersJobs/SchedulersJobsTest.php b/tests/modules/SchedulersJobs/SchedulersJobsTest.php index 42edee11..2eb9f661 100755 --- a/tests/modules/SchedulersJobs/SchedulersJobsTest.php +++ b/tests/modules/SchedulersJobs/SchedulersJobsTest.php @@ -491,6 +491,46 @@ class SchedulersJobsTest extends Sugar_PHPUnit_Framework_TestCase $this->scheduler->retrieve($this->scheduler->id); $this->assertNotEmpty($this->scheduler->last_run, "Last run was not updated"); } + + public function testCleanupJobs() + { + $GLOBALS['current_user'] = SugarTestUserUtilities::createAnonymousUser(); + $this->scheduler = new Scheduler(false); + $this->scheduler->id = create_guid(); + $newjob = $this->createJob(array("name" => "Test Func", "status" => SchedulersJob::JOB_STATUS_DONE, + "target" => "function::testJobFunction1", "assigned_user_id" => $GLOBALS['current_user']->id, + "scheduler_id" => $this->scheduler->id)); + $oldjob = $this->createJob(array("name" => "Test Func", "status" => SchedulersJob::JOB_STATUS_DONE, + "target" => "function::testJobFunction1", "assigned_user_id" => $GLOBALS['current_user']->id, + "scheduler_id" => $this->scheduler->id, 'update_date_modified' => false, + 'date_modified' => TimeDate::getInstance()->getNow()->modify("-10 days")->asDB())); + $oldestjob = $this->createJob(array("name" => "Test Func", "status" => SchedulersJob::JOB_STATUS_DONE, + "target" => "function::testJobFunction1", "assigned_user_id" => $GLOBALS['current_user']->id, + "scheduler_id" => $this->scheduler->id, 'update_date_modified' => false, + 'date_modified' => TimeDate::getInstance()->getNow()->modify("-100 days")->asDb())); + + $this->assertNotEmpty($newjob->id); + $this->assertNotEmpty($oldjob->id); + $this->assertNotEmpty($oldestjob->id); + + $cleanjob = $this->createJob(array("name" => "Test Func", "status" => SchedulersJob::JOB_STATUS_RUNNING, + "target" => "function::cleanJobQueue", "assigned_user_id" => $GLOBALS['current_user']->id, + "scheduler_id" => $this->scheduler->id)); + $cleanjob->runJob(); + // new job should be still there + $job = new SchedulersJob(); + $job->retrieve($newjob->id); + $this->assertEquals($newjob->id, $job->id); + // old job should be deleted + $job = new SchedulersJob(); + $job->retrieve($oldjob->id); + $this->assertEmpty($job->id); + $job->retrieve($oldjob->id, true, false); + $this->assertEquals($oldjob->id, $job->id); + // oldest job should be purged + $count = $this->db->getOne("SELECT count(*) from {$job->table_name} WHERE id='{$oldestjob->id}'"); + $this->assertEquals(0, $count); + } } class TestSchedulersJob extends SchedulersJob diff --git a/tests/modules/UpgradeWizard/Bug46028Test.php b/tests/modules/UpgradeWizard/Bug46028Test.php index 60d5c53f..670ef943 100755 --- a/tests/modules/UpgradeWizard/Bug46028Test.php +++ b/tests/modules/UpgradeWizard/Bug46028Test.php @@ -53,6 +53,11 @@ var $opportunitiesSearchFields; public function setUp() { + $beanList = array(); + $beanFiles = array(); + require('include/modules.php'); + $GLOBALS['beanList'] = $beanList; + $GLOBALS['beanFiles'] = $beanFiles; if(file_exists('custom/modules/Opportunities/metadata/SearchFields.php')) { $this->customOpportunitiesSearchFields = file_get_contents('custom/modules/Opportunities/metadata/SearchFields.php'); diff --git a/tests/modules/Users/authentication/SAMLAuthenticate/Bug49069Test.php b/tests/modules/Users/authentication/SAMLAuthenticate/Bug49069Test.php index 488202ba..2d07e06b 100755 --- a/tests/modules/Users/authentication/SAMLAuthenticate/Bug49069Test.php +++ b/tests/modules/Users/authentication/SAMLAuthenticate/Bug49069Test.php @@ -88,15 +88,6 @@ class Bug49069Test extends Sugar_PHPUnit_Framework_TestCase 'Location: index.php?module=foo&action=bar&record=123', $url ); - - - $this->assertTrue(!empty($_REQUEST['user_name']), 'Assert that we automatically set a user_name in $_REQUEST'); - $this->assertEquals('onelogin', $_REQUEST['user_name']); - $this->assertTrue(!empty($_REQUEST['user_password']), 'Assert that we automatically set a user_password in $_REQUEST'); - $this->assertEquals('onelogin', $_REQUEST['user_password']); - - - } public function testDefaultUserNamePasswordSet() @@ -123,4 +114,4 @@ class Bug49069Test extends Sugar_PHPUnit_Framework_TestCase $this->assertEquals('bar', $_REQUEST['user_password']); } } -?> \ No newline at end of file +?> diff --git a/tests/modules/Users/authentication/SAMLAuthenticate/Bug49959Test.php b/tests/modules/Users/authentication/SAMLAuthenticate/Bug49959Test.php new file mode 100755 index 00000000..254f7bc9 --- /dev/null +++ b/tests/modules/Users/authentication/SAMLAuthenticate/Bug49959Test.php @@ -0,0 +1,190 @@ +user_name = self::$user_name; + $user->email1 = self::$user_email; + + self::$user_id = $user->save(); + } + + + /** + * This method is called after the last test of this test class is run. + * + * Removes shared test resources + */ + public static function tearDownAfterClass() + { + self::$user->mark_deleted(self::$user_id); + } + + /** + * Test fetching of a user to be authenticated by different fields + */ + public function testFetchUser() + { + // test fetching user by ID + $user = self::$auth->fetch_user(self::$user_id, 'id'); + $this->assertEquals(self::$user_id, $user->id); + + // test fetching user by username + $user = self::$auth->fetch_user(self::$user_name, 'user_name'); + $this->assertEquals(self::$user_id, $user->id); + + // test fetching user by email (default case) + $user = self::$auth->fetch_user(self::$user_email); + $this->assertEquals(self::$user_id, $user->id); + + // test fetching user by unsupported field + $user = self::$auth->fetch_user(self::$user_email, 'unsupported_field'); + $this->assertNull($user->id); + + // test fetching non-existing user + $user = self::$auth->fetch_user('some_wrong_key'); + $this->assertNull($user->id); + } + + /** + * Test that get_nameid() method of SamlResponse is called by default + */ + public function testDefaultNameId() + { + // create a mock of SAML response + $mock = $this->getResponse(); + $mock->expects($this->once()) + ->method('get_nameid'); + + // create a default SAML settings object + require(get_custom_file_if_exists('modules/Users/authentication/SAMLAuthenticate/settings.php')); + + // expect that get_nameid() method of response is used by default + self::$auth->get_user_id($mock, $settings); + } + + /** + * Test that custom XPath is used when specified in settings + */ + public function testCustomNameId() + { + $node_id = 'Bug49959Test'; + + // create response with custom XML + $mock2 = $this->getResponse(); + $mock2->xml = $this->getResponseXml($node_id); + + // create SAML settings object with custom name id definition + require(get_custom_file_if_exists('modules/Users/authentication/SAMLAuthenticate/settings.php')); + $settings->saml_settings['check']['user_name'] = '//root'; + + // expect that user ID is fetched from the document according to settings + $result = self::$auth->get_user_id($mock2, $settings); + $this->assertEquals($node_id, $result); + } + + /** + * Returns a mock of SamlResponse object + * + * @return SamlResponse + */ + protected function getResponse() + { + return $this->getMock('SamlResponse', array(), array(), '', false); + } + + /** + * Returns custom response XML document + * + * @param $node_id + * @return DOMDocument + */ + protected function getResponseXml($node_id) + { + $document = new DOMDocument(); + $document->loadXML('' . $node_id . ''); + $root = $document->createElement('root'); + $document->appendChild($root); + return $document; + } +} + +/** + * A SAMLAuthenticate class wrapper that makes some of its methods accessible + */ +class SAMLAuthenticateUserTest extends SAMLAuthenticateUser +{ + public function fetch_user($id, $field = null) + { + return parent::fetch_user($id, $field); + } + + public function get_user_id($samlresponse, $settings) + { + return parent::get_user_id($samlresponse, $settings); + } +} diff --git a/tests/modules/Users/authentication/SAMLAuthenticate/Bug50936Test.php b/tests/modules/Users/authentication/SAMLAuthenticate/Bug50936Test.php index e5d6a0c2..51c46b36 100755 --- a/tests/modules/Users/authentication/SAMLAuthenticate/Bug50936Test.php +++ b/tests/modules/Users/authentication/SAMLAuthenticate/Bug50936Test.php @@ -69,10 +69,10 @@ class Bug50936Test extends Sugar_PHPUnit_Framework_OutputTestCase $contents = <<create(); echo \$url; EOQ; @@ -81,8 +81,6 @@ EOQ; $contents = <<name_identifier_format = "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress"; - return \$settings; - } - ?> EOQ; @@ -149,4 +144,4 @@ EOQ; } -?> \ No newline at end of file +?> diff --git a/tests/service/Bug42683Test.php b/tests/service/Bug42683Test.php index cd6bad5e..fc7b3ff5 100755 --- a/tests/service/Bug42683Test.php +++ b/tests/service/Bug42683Test.php @@ -59,19 +59,32 @@ class Bug42683Test extends SOAPTestCase $lead = SugarTestLeadUtilities::createLead(); $this->_login(); - $result = $this->_soapClient->call( 'get_entry_list', array( 'session' => $this->_sessionId, "module_name" => 'Leads', "query" => "leads.id = '{$lead->id}'", - '', - 0, - array(), - array(array('name' => 'email_addresses', 'value' => array('id', 'email_address', 'opt_out', 'primary_address'))), - ) - ); + 'order_by' => '', + 'offset' => 0, + 'select_fields' => array( + 'name' + ), + 'link_name_to_fields_array' => array( + array( + 'name' => 'email_addresses', + 'value' => array( + 'id', + 'email_address', + 'opt_out', + 'primary_address' + ) + ) + ), + 'max_results' => 1, + 'deleted' => 0 + ) + ); $this->assertEquals('primary_address', $result['relationship_list'][0][0]['records'][0][3]['name']); diff --git a/tests/service/Bug51723Test.php b/tests/service/Bug51723Test.php new file mode 100755 index 00000000..ebe3f53b --- /dev/null +++ b/tests/service/Bug51723Test.php @@ -0,0 +1,135 @@ +markTestIncomplete("Test breaking on CI, working with dev to fix"); + $administration = new Administration(); + $administration->retrieveSettings(); + if(isset($administration->settings['portal_on'])) + { + $this->_opt = $administration->settings['portal_on']; + } + $administration->saveSetting('portal', 'on', 1); + + $this->_soapURL = $GLOBALS['sugar_config']['site_url'].'/soap.php?wsdl'; + parent::setUp(); + $this->_login(); + $GLOBALS['app_strings'] = return_application_language($GLOBALS['current_language']); + $GLOBALS['app_list_strings'] = return_app_list_strings_language($GLOBALS['current_language']); + + $this->_contact = new Contact(); + $this->_contact->last_name = "Contact #bug51723"; + $this->_contact->id = create_guid(); + $this->_contact->new_with_id = true; + $this->_contact->team_id = 1; + $this->_contact->save(); + } + + public function tearDown() + { + //$this->_contact->mark_deleted($this->_contact->id); + parent::tearDown(); + + $administration = new Administration(); + $administration->retrieveSettings(); + if($this->_opt === null) + { + if(isset($administration->settings['portal_on'])) + { + $administration->saveSetting('portal', 'on', 0); + } + } + else + { + $administration->saveSetting('portal', 'on', $this->_opt); + } + } + + /** + * Testing SOAP method get_entries for existing "portal_name" field + * @group 51723 + */ + public function testPortalNameInGetEntries() + { + $fields = array('portal_name', 'first_name', 'last_name'); + $result = $this->_soapClient->call( + 'get_entries', + array('session' => $this->_sessionId, + 'module_name' => 'Contacts', + 'ids' => array($this->_contact->id), + 'select_fields' => $fields + ) + ); + // replacement of $this->assertCount() + if(count($result['entry_list']) != 1) + { + $this->fail('Can\'t get entry list'); + } + + foreach ($result['entry_list'][0]['name_value_list'] as $key => &$value) + { + if(($index = array_search($value['name'], $fields, true)) !== false) + { + unset($fields[$index]); + } + else + { + $this->fail('Wrong field in selected fields:' . $value['name']); + } + } + if(count($fields) != 0) + { + $this->fail('Can\'t get expected values:' . implode(',', $fields)); + } + } + +} \ No newline at end of file diff --git a/tests/soap/Bug41392Test.php b/tests/soap/Bug41392Test.php index 5be8689f..d8b58fbf 100755 --- a/tests/soap/Bug41392Test.php +++ b/tests/soap/Bug41392Test.php @@ -48,7 +48,7 @@ class Bug41392Test extends SOAPTestCase { public function setUp() { - $this->_soapURL = $GLOBALS['sugar_config']['site_url'].'/soap.php?XDEBUG_SESSION_START=michael'; + $this->_soapURL = $GLOBALS['sugar_config']['site_url'].'/soap.php'; parent::setUp(); } diff --git a/tests/soap/Bug43339Test.php b/tests/soap/Bug43339Test.php new file mode 100755 index 00000000..47357f96 --- /dev/null +++ b/tests/soap/Bug43339Test.php @@ -0,0 +1,165 @@ +session['use_cookies'] = ini_get('session.use_cookies'); + $this->session['cache_limiter'] = ini_get('session.session.cache_limiter'); + ini_set('session.use_cookies', false); + ini_set('session.cache_limiter', false); + + SugarTestHelper::setUp('beanList'); + SugarTestHelper::setUp('beanFiles'); + + $_SERVER['REMOTE_ADDR'] = '0.0.0.0'; + + $this->_setupTestUser(); + + $this->_field = get_widget('varchar'); + $this->_field->id = $this->_moduleName . $this->_customFieldName; + $this->_field->name = $this->_customFieldName; + $this->_field->vanme = 'LBL_' . strtoupper($this->_customFieldName); + $this->_field->comments = NULL; + $this->_field->help = NULL; + $this->_field->custom_module = $this->_moduleName; + $this->_field->type = 'varchar'; + $this->_field->label = 'LBL_' . strtoupper($this->_customFieldName); + $this->_field->len = 255; + $this->_field->required = 0; + $this->_field->default_value = ''; + $this->_field->date_modified = '2012-03-14 02:23:23'; + $this->_field->deleted = 0; + $this->_field->audited = 0; + $this->_field->massupdate = 0; + $this->_field->duplicate_merge = 0; + $this->_field->reportable = 1; + $this->_field->importable = 'true'; + $this->_field->ext1 = NULL; + $this->_field->ext2 = NULL; + $this->_field->ext3 = NULL; + $this->_field->ext4 = NULL; + + $className = $beanList[$this->_moduleName]; + require_once($beanFiles[$className]); + $this->_module = new $className(); + + $this->_df = new DynamicField($this->_moduleName); + + $this->_df->setup($this->_module); + $this->_df->addFieldObject($this->_field); + } + + /** + * get_entries_count doesn't work with custom fields + * + * @group 43339 + */ + public function testGetEntriesCountForCustomField() + { + $api = new SugarWebServiceImplv4_1(); + $auth = $api->login(array('user_name' => self::$_user->user_name, 'password' => self::$_user->user_hash, 'version' => '.01'), 'SoapTest', array()); + $assert = $api->get_entries_count($auth['id'], $this->_moduleName, $this->_customFieldName . ' LIKE \'\'', 0); + $api->logout($auth['id']); + + $this->assertNotEquals(NULL, $assert['result_count']); + } + + /** + * Test for soap/SoapSugarUsers.php::get_entries_count() + * + * @group 43339 + */ + public function testGetEntriesCountFromBasicSoap() + { + $this->_soapURL = $GLOBALS['sugar_config']['site_url'].'/soap.php'; + parent::setUp(); + + $auth = $this->_soapClient->call('login', + array('user_auth' => + array( + 'user_name' => $this->_user->user_name, + 'password' => $this->_user->user_hash, + 'version' => '.01'), + 'application_name' => 'SoapTest', "name_value_list" => array() + ) + ); + + $params = array( + 'session' => $auth['id'], + 'module_name' => $this->_moduleName, + 'query' => $this->_customFieldName . ' LIKE \'\'', + 'deleted' => 0 + ); + $assert = $this->_soapClient->call('get_entries_count', $params); + + $this->assertNotEquals(NULL, $assert['result_count']); + } + + public function tearDown() + { + $this->_df->deleteField($this->_field); + + SugarTestHelper::tearDown(); + unset($_SERVER['REMOTE_ADDR']); + + $this->_tearDownTestUser(); + + ini_set('session.use_cookies', $this->session['use_cookies']); + ini_set('session.cache_limiter', $this->session['cache_limiter']); + } +} diff --git a/themes/Sugar5/css/style.css b/themes/Sugar5/css/style.css index 6006ff5f..37f81aaf 100644 --- a/themes/Sugar5/css/style.css +++ b/themes/Sugar5/css/style.css @@ -3670,7 +3670,7 @@ td.teamset-row, .edit tr td.teamset-row, .edit tr td table tr td.teamset-row { ul.clickMenu { list-style: none; - padding: 0px 3px 0px 0px; + padding: 0px 0px 0px 0px; margin: 0 !important; vertical-align: bottom; background-color: #ECF1F4; @@ -3686,18 +3686,22 @@ ul.clickMenu form{ ul.SugarActionMenuIESub { } -ul.clickMenu:hover { +#globalLinksModule ul.clickMenu.SugarActionMenu li a:hover, +#globalLinksModule ul.clickMenu li:hover span, +ul.SugarActionMenuIESub li a:hover, ul.clickMenu.SugarActionMenu li a:hover, ul.clickMenu.SugarActionMenu li span.subhover:hover, +ul#globalLinksSubnav li a:hover, ul#quickCreateULSubnav li a:hover, +ul.clickMenu li ul.subnav li a:hover,ul.clickMenu li ul.subnav li input:hover, ul.clickMenu.subpanel.records li ul.subnav li a:hover, ul.clickMenu ul.subnav-sub li a:hover { /*--Hover effect for subnav links--*/ + background-color: #4e8ccf; - background-image: none; - border-color: #4e8ccf; + border-color: #4e8ccf; color: #fff; } ul#globalLinksSubnav.SugarActionMenuIESub li a:hover, ul#quickCreateULSubnav.SugarActionMenuIESub li a:hover, ul.clickMenu:hover > li > span > a, ul.clickMenu:hover > li > a { - color: #fff !important; + /*color: #fff !important;*/ } -ul.clickMenu:hover > li > span { +ul.clickMenu li span.ab:hover { background-position: 6px 0px; } ul.clickMenu li, ul.SugarActionMenuIESub li { @@ -3730,7 +3734,7 @@ ul.clickMenu li.single a{ ul.clickMenu li a:hover{ text-decoration: none !important; } -ul.clickMenu li > span { /*--Drop down trigger styles--*/ +ul.clickMenu li span.ab { /*--Drop down trigger styles--*/ width: 17px; height: 16px; float: left; @@ -3738,7 +3742,7 @@ ul.clickMenu li > span { /*--Drop down trigger styles--*/ cursor: pointer; } -ul.clickMenu li > span.ab { /*--Drop down trigger styles--*/ +ul.clickMenu li span.ab { /*--Drop down trigger styles--*/ border-left: 1px #aaa solid; padding-left: 5px; } @@ -3778,25 +3782,27 @@ ul.clickMenu.subpanel.records { background-image: none; } +/* ul.clickMenu.subpanel.records:hover { background-color: #4e8ccf !important; background-image: none !important; border-color: #4e8ccf !important; } +*/ ul.clickMenu.subpanel.records li a{ color: #aaa; } -ul.clickMenu.subpanel.records:hover > li div a{ - color: #fff !important; +ul.clickMenu.subpanel.records > li div:hover a{ + color: #fff !important; } ul.clickMenu.subpanel.records li > span{ opacity: .5; height: 16px; - padding: 0 !important; - width: 15px; - background-position: right -28px; + width: 17px; + padding:0 5px 0 0 !important; + background-position: 50% -28px; } ul.clickMenu.subpanel.records:hover li > span{ @@ -3808,23 +3814,26 @@ ul.clickMenu.subpanel.records li ul.subnav li a span { width: 0px; background-image: none; } +ul.clickMenu.button li span.ab:hover { + background-position: 50% 0px; +} ul.clickMenu.button li > span { width: auto; - background-position: right -20px; + background-position: 50% -20px; padding: 3px 15px 3px 10px !important; height: auto; } ul.clickMenu.button:hover li > span { - background-position: right 0px; + } ul.clickMenu.button li > span a { padding: 0px !important; } -ul.clickMenu.button { +ul.clickMenu.button span { padding-right: 5px; } @@ -3882,7 +3891,7 @@ ul.clickMenu li ul.subnav li input { } ul.SugarActionMenuIESub li a:hover, ul.clickMenu li ul.subnav li a:hover,ul.clickMenu li ul.subnav li input:hover, ul.clickMenu.subpanel.records li ul.subnav li a:hover, ul.clickMenu ul.subnav-sub li a:hover { /*--Hover effect for subnav links--*/ -background-color: #355b7e; +background-color: #4e8ccf; color: #fff; font-weight: normal !important; font-size: 12px !important; -- 2.42.0