From 9c71e8c884c7d5b277db136897113ec96618dc63 Mon Sep 17 00:00:00 2001 From: Dillon-Brown Date: Thu, 29 Jul 2021 16:52:11 +0100 Subject: [PATCH] Squashed 'public/legacy/' changes from f058c4c306..2aaee3c558 2aaee3c558 Implement PDFEngine bf78e964fd Fix PDF_Lib constructors cfe6e2a1e0 Replace deprecated fzaninotto/faker with fakerphp/faker 7f8d18b8fb Move test namespaces into autoload-dev 1778603d07 Upgrade nesbot/carbon to v2.x 171ef65335 Update Travis config to use composer v2.x 7a4d0007af Upgrade composer-merge-plugin to v2.x 0461d8f4ba Fix PHPUnit 9 deprecations and warnings 15906ef6a5 Fix test case class not matching filename deprecation warnings b92a9dcdbd Replace abandoned leafo/scssphp with scssphp/scssphp 9a0fea7c9e Upgrade Robo to v3.x 5462b82a22 Update composer.json 77d3575052 Fix missing default config values 1d4a0e7421 Consolidate global search settings e75e0f4add Remove duplicate "Global Search" link in the adminpanel 1bfa51fa73 Implement search engine selection d5a33281e1 Deprecate UnifiedSearchAdvanced fcce848d4c Unify search engines c8c02c5398 Remove new/legacy search engine labels e34cad759d Add codeception 4.1.x dependencies to composer cc3a504997 Migrate PHPUnit schema for 9.5.x ce5a63be20 Upgrade PHPUnit to 9.5.x f52dc24e61 Remove codeception 420303758e Fix tests remove incompletes c93e654768 Fix tests deprecated asserts 4feebbab22 Fix tests define return type hints abd327d267 Update test namespaces for PSR-4/PSR-8 f464e2a829 Fix tests redundant noinspection 5b74cc4d2c Fix tests misordered assert arguments 03a83246f4 Fix tests use appropriate asserts a04c048c18 Fix tests one-time use variables 683533e2b6 Fix tests method invocations 7e44ec9583 Update PHPUnit schema 2181ad7f3d Update Travis config to remove PHP 7.2 480a87c03a Update minimum required PHP to v7.3.0 200c6deb61 Update composer.lock git-subtree-dir: public/legacy git-subtree-split: 2aaee3c5581c025abca1114276e2d20c709f2812 --- .gitignore | 2 + .travis.yml | 10 +- composer.json | 62 +- composer.lock | 5423 +++++++++-------- include/language/en_us.lang.php | 2 + include/utils.php | 90 +- .../Exceptions/PDFEngineNotFoundException.php | 52 + .../PDF/Exceptions/PDFException.php | 29 +- lib/PDF/MPDF/MPDFEngine.php | 161 + lib/PDF/PDFEngine.php | 87 + lib/PDF/PDFWrapper.php | 175 + lib/Robo/Plugin/Commands/BuildCommands.php | 12 +- .../Plugin/Commands/CodeCoverageCommands.php | 8 +- .../Commands/CodingStandardCommands.php | 5 +- .../Plugin/Commands/ElasticSearchCommands.php | 5 +- lib/Robo/Plugin/Commands/UpgradeCommands.php | 5 +- lib/Search/AOD/LuceneSearchEngine.php | 178 + lib/Search/BasicSearch/BasicSearchEngine.php | 247 + .../ElasticSearch/ElasticSearchEngine.php | 61 +- lib/Search/SearchConfigurator.php | 12 +- lib/Search/SearchEngine.php | 14 +- lib/Search/SearchModules.php | 256 +- lib/Search/SearchQuery.php | 138 +- lib/Search/SearchResults.php | 108 +- lib/Search/SearchWrapper.php | 96 +- .../SqlSearch/SimpleSqlSearchEngine.php | 47 +- lib/Search/UI/MVC/Controller.php | 30 +- lib/Search/UI/MVC/View.php | 14 +- lib/Search/UI/SearchFormController.php | 19 +- lib/Search/UI/SearchFormView.php | 47 +- lib/Search/UI/SearchResultsController.php | 73 +- lib/Search/UI/SearchThrowableHandler.php | 41 +- lib/Search/UI/templates/search.form.tpl | 87 +- modules/AOR_Reports/controller.php | 139 +- .../AOS_PDF_Templates/PDF_Lib/classes/bmp.php | 10 +- .../PDF_Lib/classes/cssmgr.php | 20 +- .../PDF_Lib/classes/directw.php | 9 +- .../PDF_Lib/classes/form.php | 2 +- .../AOS_PDF_Templates/PDF_Lib/classes/gif.php | 12 +- .../PDF_Lib/classes/grad.php | 9 +- .../PDF_Lib/classes/indic.php | 5 +- .../AOS_PDF_Templates/PDF_Lib/classes/svg.php | 20 +- .../PDF_Lib/classes/tocontents.php | 40 +- .../PDF_Lib/classes/ttfontsuni.php | 43 +- .../AOS_PDF_Templates/PDF_Lib/classes/wmf.php | 10 +- modules/AOS_PDF_Templates/PDF_Lib/mpdf.php | 2 +- .../PDF_Lib/mpdfi/fpdi_pdf_parser.php | 2 +- .../PDF_Lib/mpdfi/pdf_context.php | 2 +- .../PDF_Lib/mpdfi/pdf_parser.php | 2 +- modules/AOS_PDF_Templates/formLetterPdf.php | 72 +- modules/AOS_PDF_Templates/generatePdf.php | 46 +- modules/Administration/AODAdmin.php | 107 - modules/Administration/AODAdmin.tpl | 31 - modules/Administration/Search/Controller.php | 33 +- .../Search/ElasticSearch/Controller.php | 3 +- .../Search/ElasticSearch/View.php | 6 +- .../GlobalSearchSettings.tpl | 147 +- modules/Administration/Search/MVC/View.php | 10 +- modules/Administration/Search/View.php | 47 +- modules/Administration/Search/view.tpl | 72 +- .../Administration/language/en_us.lang.php | 8 +- .../metadata/adminpaneldefs.php | 17 - modules/Home/Search.php | 4 +- modules/Home/UnifiedSearch.php | 281 +- modules/Home/UnifiedSearchAdvanced.php | 58 +- tests/SuiteCRM/Enumerator/DatabaseDriver.php | 47 +- .../SuiteCRM/Enumerator/DesignBreakPoint.php | 49 +- tests/SuiteCRM/Enumerator/SugarObjectType.php | 53 +- tests/SuiteCRM/Test/BeanFactoryTestCase.php | 80 +- .../SuiteCRM/Test/Driver/PhpBrowserDriver.php | 45 +- tests/SuiteCRM/Test/Driver/WebDriver.php | 46 +- .../Test/SuitePHPUnitFrameworkTestCase.php | 43 +- tests/SuiteCRM/Test/TestLogger.php | 57 +- tests/_support/Helper/Acceptance.php | 61 +- .../Helper/PhpBrowserDriverHelper.php | 37 + tests/_support/InstallTester.php | 37 + tests/_support/Page/Design.php | 44 +- .../Step/Acceptance/AccountsTester.php | 54 +- .../Step/Acceptance/ModuleBuilder.php | 10 +- .../Step/Acceptance/NavigationBarTester.php | 56 +- tests/acceptance/Core/BasicModuleCest.php | 43 +- tests/acceptance/Core/CompanyModuleCest.php | 58 +- tests/acceptance/Core/FileModuleCest.php | 44 +- tests/acceptance/Core/IssueModuleCest.php | 40 +- .../Core/ModuleBuilderFieldsCest.php | 40 +- tests/acceptance/Core/PersonModuleCest.php | 40 +- tests/acceptance/Core/SaleModuleCest.php | 40 +- .../lib/Search/ElasticsearchCest.php | 118 +- tests/api/v8/ModulesCest.php | 1616 +++++ tests/phpunit.xml.dist | 57 +- .../Api/Core/Loader/CustomLoaderTest.php | 40 +- tests/unit/phpunit/ConfigTest.php | 60 + tests/unit/phpunit/configTest.php | 17 - tests/unit/phpunit/data/BeanFactoryTest.php | 128 +- tests/unit/phpunit/data/SugarBeanMock.php | 12 +- tests/unit/phpunit/data/SugarBeanTest.php | 207 +- .../MVC/Controller/ControllerFactoryTest.php | 18 - .../phpunit/include/MVC/SugarModuleTest.php | 61 - .../include/MVC/View/SugarViewTest.php | 278 - .../include/MVC/View/ViewFactoryTest.php | 71 - .../include/MVC/View/views/view.ajaxTest.php | 24 - .../MVC/View/views/view.ajaxuiTest.php | 28 - .../MVC/View/views/view.classicTest.php | 73 - .../MVC/View/views/view.detailTest.php | 66 - .../include/MVC/View/views/view.editTest.php | 72 - .../MVC/View/views/view.favoritesTest.php | 20 - .../include/MVC/View/views/view.htmlTest.php | 35 - .../MVC/View/views/view.importvcardTest.php | 42 - .../View/views/view.importvcardsaveTest.php | 33 - .../include/MVC/View/views/view.jsonTest.php | 38 - .../View/views/view.modulelistmenuTest.php | 41 - .../MVC/View/views/view.multieditTest.php | 51 - .../MVC/View/views/view.noaccessTest.php | 24 - .../include/MVC/View/views/view.quickTest.php | 49 - .../MVC/View/views/view.quickcreateTest.php | 86 - .../MVC/View/views/view.quickeditTest.php | 43 - .../MVC/View/views/view.serializedTest.php | 34 - .../MVC/View/views/view.sugarpdfTest.php | 59 - .../include/MVC/View/views/view.vcardTest.php | 35 - .../include/MVC/View/views/view.xmlTest.php | 34 - .../phpunit/include/SugarDateTimeTest.php | 77 - .../include/SugarTheme/SugarThemeTest.php | 15 - .../include/utils/activityUtilsTest.php | 33 - .../phpunit/include/utils/autoloaderTest.php | 35 - .../phpunit/include/utils/dbUtilsTest.php | 115 - .../include/utils/encryptionUtilsTest.php | 94 - .../phpunit/include/utils/fileUtilsTest.php | 528 -- .../phpunit/include/utils/layoutUtilsTest.php | 99 - .../phpunit/include/utils/mvcUtilsTest.php | 99 - .../phpunit/include/utils/phpZipUtilsTest.php | 91 - .../include/utils/progressBarUtilsTest.php | 89 - .../include/utils/sugarFileUtilsTest.php | 170 - .../phpunit/include/utils/zipUtilsTest.php | 27 - .../ErrorMessageTest.php | 22 +- .../GoogleSync/GoogleSyncMock.php | 6 +- .../GoogleSync/GoogleSyncTest.php | 423 +- .../Imap/ImapHandlerFactoryTest.php | 44 +- .../Imap/ImapTestSettingsEntryHandlerTest.php | 36 +- .../JsonApiErrorObjectTest.php} | 26 +- .../LangExceptionTest.php | 19 +- .../{include => includes}/LangTextTest.php | 49 +- .../Localization/LocalizationTest.php | 0 .../MVC/Controller/ControllerFactoryTest.php | 63 + .../MVC/Controller/SugarControllerTest.php | 150 +- .../MVC/SugarApplicationTest.php | 253 +- .../phpunit/includes/MVC/SugarModuleTest.php | 100 + .../includes/MVC/View/SugarViewTest.php | 303 + .../includes/MVC/View/ViewFactoryTest.php | 118 + .../includes/MVC/View/views/ViewAjaxTest.php | 70 + .../MVC/View/views/ViewAjaxUITest.php | 60 + .../MVC/View/views/ViewClassicTest.php | 119 + .../MVC/View/views/ViewDetailTest.php | 113 + .../includes/MVC/View/views/ViewEditTest.php | 119 + .../includes/MVC/View/views/ViewHtmlTest.php | 82 + .../MVC/View/views/ViewImportvcardTest.php | 88 + .../View/views/ViewImportvcardsaveTest.php | 60 + .../includes/MVC/View/views/ViewJsonTest.php | 60 + .../MVC/View/views/ViewListTest.php} | 107 +- .../MVC/View/views/ViewMetadataTest.php} | 119 +- .../MVC/View/views/ViewModulelistmenuTest.php | 87 + .../MVC/View/views/ViewMultieditTest.php | 97 + .../MVC/View/views/ViewNoaccessTest.php | 69 + .../MVC/View/views/ViewPopupTest.php} | 99 +- .../includes/MVC/View/views/ViewQuickTest.php | 105 + .../MVC/View/views/ViewQuickcreateTest.php | 132 + .../MVC/View/views/ViewQuickeditTest.php | 88 + .../MVC/View/views/ViewSerializedTest.php | 59 + .../MVC/View/views/ViewSugarpdfTest.php | 95 + .../includes/MVC/View/views/ViewVcardTest.php | 83 + .../includes/MVC/View/views/ViewXMLTest.php | 72 +- .../SubPanel/SubPanelTest.php | 22 +- .../phpunit/includes/SugarDateTimeTest.php | 115 + .../SugarEmailAddressTest.php | 133 +- .../SugarFolders/SugarFolderTest.php | 149 +- .../SugarLogger/LoggerManagerTest.php | 22 +- .../SugarObjects/templates/PersonTest.php | 56 +- .../includes/SugarTheme/SugarThemeTest.php | 15 + .../{include => includes}/TimeDateTest.php | 110 +- .../{include => includes}/UtilsTest.php | 97 +- .../database/DBManagerTest.php | 32 +- .../utils/LogicHookTest.php | 283 +- .../includes/utils/SugarAutoLoaderTest.php | 81 + .../includes/utils/activity_utilsTest.php | 78 + .../utils/array_utilsTest.php} | 139 +- .../phpunit/includes/utils/db_utilsTest.php | 162 + .../includes/utils/encryption_utilsTest.php | 139 + .../phpunit/includes/utils/file_utilsTest.php | 517 ++ .../includes/utils/layout_utilsTest.php | 144 + .../utils/logic_utilsTest.php} | 99 +- .../phpunit/includes/utils/mvc_utilsTest.php | 145 + .../includes/utils/php_zip_utilsTest.php | 136 + .../includes/utils/progress_bar_utilsTest.php | 135 + .../utils/security_utilsTest.php} | 97 +- .../phpunit/lib/Exception/ExceptionTest.php | 51 +- .../phpunit/lib/PDF/MPDF/MPDFEngineTest.php | 159 + tests/unit/phpunit/lib/PDF/PDFWrapperTest.php | 90 + .../Search/UI/SearchResultsControllerTest.php | 36 +- .../lib/SuiteCRM/Log/CliLoggerHandlerTest.php | 10 +- .../Commands/CodeCoverageCommandsTest.php | 21 +- .../Search/AbstractDocumentifierMock.php | 17 +- .../Search/AbstractDocumentifierTest.php | 16 +- .../SuiteCRM/Search/AbstractIndexerTest.php | 22 +- .../ElasticSearchClientBuilderTest.php | 81 +- .../ElasticSearch/ElasticSearchEngineTest.php | 77 +- .../ElasticSearchIndexerTest.php | 181 +- .../ElasticSearchInstallTest.php | 25 +- .../ElasticSearchIntegrationTest.php | 29 +- .../Search/SearchDefsDocumentifierTest.php | 4 +- .../lib/SuiteCRM/Search/SearchEngineMock.php | 40 +- .../lib/SuiteCRM/Search/SearchInstallTest.php | 6 +- .../lib/SuiteCRM/Search/SearchQueryTest.php | 60 +- .../SuiteCRM/Search/SearchTestAbstract.php | 50 +- .../lib/SuiteCRM/Search/SearchWrapperTest.php | 155 +- .../Search/TestCustomEngines/MockSearch.php | 67 +- .../lib/SuiteCRM/Utility/ArrayMapperTest.php | 2 +- .../Utility/BeanJsonSerializerTest.php | 12 +- .../BeanJsonSerializerTestData/BeanMock.php | 15 +- .../SuiteCRM/Utility/CurrentLanguageTest.php | 4 +- .../SuiteCRM/Utility/ModuleLanguageTest.php | 6 +- .../lib/SuiteCRM/Utility/PathsTest.php | 12 +- .../SuiteCRM/Utility/StringValidatorTest.php | 12 +- .../lib/SuiteCRM/Utility/SuiteLoggerTest.php | 79 +- .../modules/ACLActions/ACLActionTest.php | 58 - .../phpunit/modules/ACLRoles/ACLRoleTest.php | 73 +- .../AM_ProjectTemplatesTest.php | 20 +- .../AM_TaskTemplates/AM_TaskTemplatesTest.php | 20 +- .../modules/AOD_Index/AOD_IndexTest.php | 145 +- .../AOD_IndexEvent/AOD_IndexEventTest.php | 22 +- .../AOK_KnowledgeBaseTest.php | 20 +- .../AOK_Knowledge_Base_CategoriesTest.php | 20 +- .../AOP_Case_Events/AOP_Case_EventsTest.php | 22 +- .../AOP_Case_Updates/AOP_Case_UpdatesTest.php | 64 +- .../modules/AOR_Charts/AOR_ChartTest.php | 92 +- .../AOR_Conditions/AOR_ConditionTest.php | 28 +- .../modules/AOR_Fields/AOR_FieldTest.php | 28 +- .../modules/AOR_Reports/AOR_ReportTest.php | 131 +- .../AOR_Scheduled_ReportsTest.php | 51 +- .../AOS_Contracts/AOS_ContractsTest.php | 42 +- .../modules/AOS_Invoices/AOS_InvoicesTest.php | 30 +- .../AOS_Line_Item_GroupsTest.php | 32 +- .../AOS_PDF_TemplatesTest.php | 20 +- .../AOS_Product_CategoriesTest.php | 28 +- .../modules/AOS_Products/AOS_ProductsTest.php | 34 +- .../AOS_Products_QuotesTest.php | 36 +- .../modules/AOS_Quotes/AOS_QuotesTest.php | 30 +- .../modules/AOW_Actions/AOW_ActionTest.php | 34 +- .../AOW_Conditions/AOW_ConditionTest.php | 34 +- .../AOW_Processed/AOW_ProcessedTest.php | 28 +- .../modules/AOW_WorkFlow/AOW_WorkFlowTest.php | 144 +- .../phpunit/modules/Accounts/AccountTest.php | 118 +- .../Administration/AdministrationTest.php | 52 +- .../Administration/BaseHandlerTest.php | 4 +- .../GoogleCalendarSettingsHandlerMock.php | 20 +- .../GoogleCalendarSettingsHandlerTest.php | 26 +- .../unit/phpunit/modules/Alerts/AlertTest.php | 28 +- .../unit/phpunit/modules/Audit/AuditTest.php | 78 +- .../phpunit/modules/Audit/PopupPickerTest.php | 29 +- tests/unit/phpunit/modules/Bugs/BugTest.php | 104 +- tests/unit/phpunit/modules/Calls/CallTest.php | 150 +- .../Calls_Reschedule/Calls_RescheduleTest.php | 22 +- .../modules/CampaignLog/CampaignLogTest.php | 47 +- .../CampaignTrackers/CampaignTrackerTest.php | 34 +- .../modules/Campaigns/CampaignTest.php | 145 +- tests/unit/phpunit/modules/Cases/CaseTest.php | 244 - .../unit/phpunit/modules/Cases/aCaseTest.php | 289 + .../phpunit/modules/Contacts/ContactTest.php | 138 +- .../modules/Currencies/CurrencyTest.php | 162 +- .../DocumentRevisionTest.php | 103 +- .../modules/Documents/DocumentTest.php | 86 +- tests/unit/phpunit/modules/EAPM/EAPMTest.php | 93 +- .../EmailAddresses/EmailAddressTest.php | 27 +- .../phpunit/modules/EmailMan/EmailManTest.php | 102 +- .../EmailMarketing/EmailMarketingTest.php | 51 +- .../EmailTemplates/EmailTemplateTest.php | 167 +- .../modules/EmailText/EmailTextTest.php | 19 +- .../modules/Emails/EmailFromValidatorTest.php | 72 +- .../unit/phpunit/modules/Emails/EmailMock.php | 16 +- .../unit/phpunit/modules/Emails/EmailTest.php | 613 +- .../Emails/NonGmailSentFolderHandlerMock.php | 5 +- .../Emails/NonGmailSentFolderHandlerTest.php | 68 +- .../modules/Emails/SugarPHPMailerMock.php | 2 +- .../modules/Employees/EmployeeTest.php | 83 +- .../FP_Event_LocationsTest.php | 20 +- .../modules/FP_events/FP_eventsTest.php | 65 +- .../modules/Favorites/FavoritesTest.php | 36 +- .../unit/phpunit/modules/Groups/GroupTest.php | 26 +- .../modules/InboundEmail/InboundEmailTest.php | 1415 ++--- tests/unit/phpunit/modules/Leads/LeadTest.php | 142 +- .../phpunit/modules/Meetings/MeetingTest.php | 209 +- .../modules/MergeRecords/MergeRecordTest.php | 133 +- tests/unit/phpunit/modules/Notes/NoteTest.php | 74 +- .../modules/OAuthKeys/OAuthKeyTest.php | 34 +- .../modules/OAuthTokens/OAuthTokenTest.php | 121 +- .../modules/Opportunities/OpportunityTest.php | 152 +- .../phpunit/modules/Project/ProjectTest.php | 76 +- .../modules/ProjectTask/ProjectTaskTest.php | 125 +- .../ProspectLists/ProspectListTest.php | 114 +- .../modules/Prospects/ProspectTest.php | 70 +- .../Relationships/RelationshipTest.php | 133 +- .../phpunit/modules/Releases/ReleaseTest.php | 48 +- tests/unit/phpunit/modules/Roles/RoleTest.php | 68 +- .../modules/SavedSearch/SavedSearchTest.php | 102 +- .../modules/Schedulers/SchedulerTest.php | 129 +- .../SchedulersJobs/SchedulersJobTest.php | 151 +- .../SecurityGroups/SecurityGroupTest.php | 186 +- .../modules/SugarFeed/SugarFeedTest.php | 98 +- tests/unit/phpunit/modules/Tasks/TaskTest.php | 84 +- .../phpunit/modules/Trackers/TrackerTest.php | 50 +- .../UserPreferences/UserPreferenceTest.php | 54 +- .../Users/GoogleApiKeySaverEntryPointMock.php | 22 +- .../Users/GoogleApiKeySaverEntryPointTest.php | 24 +- .../modules/Users/SAML2AuthenticateTest.php | 51 +- tests/unit/phpunit/modules/Users/UserTest.php | 458 +- tests/unit/phpunit/modules/iCals/iCalTest.php | 10 +- .../jjwg_Address_CacheTest.php | 64 +- .../modules/jjwg_Areas/jjwg_AreasTest.php | 148 +- .../modules/jjwg_Maps/jjwg_MapsTest.php | 162 +- .../modules/jjwg_Markers/jjwg_MarkersTest.php | 103 +- tests/unit/phpunit/modules/vCals/vCalTest.php | 112 +- .../service/v4/SugarWebServiceUtilv4Test.php | 59 +- themes/SuiteP/css/Dawn/style.css | 3 +- themes/SuiteP/css/Day/style.css | 3 +- themes/SuiteP/css/Dusk/style.css | 3 +- themes/SuiteP/css/Night/style.css | 3 +- 324 files changed, 18517 insertions(+), 13877 deletions(-) create mode 100644 lib/PDF/Exceptions/PDFEngineNotFoundException.php rename modules/Administration/Search/scripts.js => lib/PDF/Exceptions/PDFException.php (85%) create mode 100644 lib/PDF/MPDF/MPDFEngine.php create mode 100644 lib/PDF/PDFEngine.php create mode 100644 lib/PDF/PDFWrapper.php create mode 100644 lib/Search/AOD/LuceneSearchEngine.php create mode 100644 lib/Search/BasicSearch/BasicSearchEngine.php delete mode 100644 modules/Administration/AODAdmin.php delete mode 100644 modules/Administration/AODAdmin.tpl rename modules/Administration/{templates => Search}/GlobalSearchSettings.tpl (50%) mode change 100755 => 100644 create mode 100644 tests/api/v8/ModulesCest.php create mode 100644 tests/unit/phpunit/ConfigTest.php delete mode 100644 tests/unit/phpunit/configTest.php delete mode 100644 tests/unit/phpunit/include/MVC/Controller/ControllerFactoryTest.php delete mode 100644 tests/unit/phpunit/include/MVC/SugarModuleTest.php delete mode 100644 tests/unit/phpunit/include/MVC/View/SugarViewTest.php delete mode 100644 tests/unit/phpunit/include/MVC/View/ViewFactoryTest.php delete mode 100644 tests/unit/phpunit/include/MVC/View/views/view.ajaxTest.php delete mode 100644 tests/unit/phpunit/include/MVC/View/views/view.ajaxuiTest.php delete mode 100644 tests/unit/phpunit/include/MVC/View/views/view.classicTest.php delete mode 100644 tests/unit/phpunit/include/MVC/View/views/view.detailTest.php delete mode 100644 tests/unit/phpunit/include/MVC/View/views/view.editTest.php delete mode 100644 tests/unit/phpunit/include/MVC/View/views/view.favoritesTest.php delete mode 100644 tests/unit/phpunit/include/MVC/View/views/view.htmlTest.php delete mode 100644 tests/unit/phpunit/include/MVC/View/views/view.importvcardTest.php delete mode 100644 tests/unit/phpunit/include/MVC/View/views/view.importvcardsaveTest.php delete mode 100644 tests/unit/phpunit/include/MVC/View/views/view.jsonTest.php delete mode 100644 tests/unit/phpunit/include/MVC/View/views/view.modulelistmenuTest.php delete mode 100644 tests/unit/phpunit/include/MVC/View/views/view.multieditTest.php delete mode 100644 tests/unit/phpunit/include/MVC/View/views/view.noaccessTest.php delete mode 100644 tests/unit/phpunit/include/MVC/View/views/view.quickTest.php delete mode 100644 tests/unit/phpunit/include/MVC/View/views/view.quickcreateTest.php delete mode 100644 tests/unit/phpunit/include/MVC/View/views/view.quickeditTest.php delete mode 100644 tests/unit/phpunit/include/MVC/View/views/view.serializedTest.php delete mode 100644 tests/unit/phpunit/include/MVC/View/views/view.sugarpdfTest.php delete mode 100644 tests/unit/phpunit/include/MVC/View/views/view.vcardTest.php delete mode 100644 tests/unit/phpunit/include/MVC/View/views/view.xmlTest.php delete mode 100644 tests/unit/phpunit/include/SugarDateTimeTest.php delete mode 100644 tests/unit/phpunit/include/SugarTheme/SugarThemeTest.php delete mode 100644 tests/unit/phpunit/include/utils/activityUtilsTest.php delete mode 100644 tests/unit/phpunit/include/utils/autoloaderTest.php delete mode 100644 tests/unit/phpunit/include/utils/dbUtilsTest.php delete mode 100644 tests/unit/phpunit/include/utils/encryptionUtilsTest.php delete mode 100644 tests/unit/phpunit/include/utils/fileUtilsTest.php delete mode 100644 tests/unit/phpunit/include/utils/layoutUtilsTest.php delete mode 100644 tests/unit/phpunit/include/utils/mvcUtilsTest.php delete mode 100644 tests/unit/phpunit/include/utils/phpZipUtilsTest.php delete mode 100644 tests/unit/phpunit/include/utils/progressBarUtilsTest.php delete mode 100644 tests/unit/phpunit/include/utils/sugarFileUtilsTest.php delete mode 100644 tests/unit/phpunit/include/utils/zipUtilsTest.php rename tests/unit/phpunit/{include => includes}/ErrorMessageTest.php (88%) rename tests/unit/phpunit/{include => includes}/GoogleSync/GoogleSyncMock.php (93%) rename tests/unit/phpunit/{include => includes}/GoogleSync/GoogleSyncTest.php (66%) rename tests/unit/phpunit/{include => includes}/Imap/ImapHandlerFactoryTest.php (82%) rename tests/unit/phpunit/{include => includes}/Imap/ImapTestSettingsEntryHandlerTest.php (77%) rename tests/unit/phpunit/{include/APIErrorObjectTest.php => includes/JsonApiErrorObjectTest.php} (90%) rename tests/unit/phpunit/{include => includes}/LangExceptionTest.php (91%) rename tests/unit/phpunit/{include => includes}/LangTextTest.php (74%) rename tests/unit/phpunit/{include => includes}/Localization/LocalizationTest.php (100%) create mode 100644 tests/unit/phpunit/includes/MVC/Controller/ControllerFactoryTest.php rename tests/unit/phpunit/{include => includes}/MVC/Controller/SugarControllerTest.php (54%) rename tests/unit/phpunit/{include => includes}/MVC/SugarApplicationTest.php (58%) create mode 100644 tests/unit/phpunit/includes/MVC/SugarModuleTest.php create mode 100644 tests/unit/phpunit/includes/MVC/View/SugarViewTest.php create mode 100644 tests/unit/phpunit/includes/MVC/View/ViewFactoryTest.php create mode 100644 tests/unit/phpunit/includes/MVC/View/views/ViewAjaxTest.php create mode 100644 tests/unit/phpunit/includes/MVC/View/views/ViewAjaxUITest.php create mode 100644 tests/unit/phpunit/includes/MVC/View/views/ViewClassicTest.php create mode 100644 tests/unit/phpunit/includes/MVC/View/views/ViewDetailTest.php create mode 100644 tests/unit/phpunit/includes/MVC/View/views/ViewEditTest.php create mode 100644 tests/unit/phpunit/includes/MVC/View/views/ViewHtmlTest.php create mode 100644 tests/unit/phpunit/includes/MVC/View/views/ViewImportvcardTest.php create mode 100644 tests/unit/phpunit/includes/MVC/View/views/ViewImportvcardsaveTest.php create mode 100644 tests/unit/phpunit/includes/MVC/View/views/ViewJsonTest.php rename tests/unit/phpunit/{include/MVC/View/views/view.listTest.php => includes/MVC/View/views/ViewListTest.php} (63%) rename tests/unit/phpunit/{include/MVC/View/views/view.metadataTest.php => includes/MVC/View/views/ViewMetadataTest.php} (51%) create mode 100644 tests/unit/phpunit/includes/MVC/View/views/ViewModulelistmenuTest.php create mode 100644 tests/unit/phpunit/includes/MVC/View/views/ViewMultieditTest.php create mode 100644 tests/unit/phpunit/includes/MVC/View/views/ViewNoaccessTest.php rename tests/unit/phpunit/{include/MVC/View/views/view.popupTest.php => includes/MVC/View/views/ViewPopupTest.php} (50%) create mode 100644 tests/unit/phpunit/includes/MVC/View/views/ViewQuickTest.php create mode 100644 tests/unit/phpunit/includes/MVC/View/views/ViewQuickcreateTest.php create mode 100644 tests/unit/phpunit/includes/MVC/View/views/ViewQuickeditTest.php create mode 100644 tests/unit/phpunit/includes/MVC/View/views/ViewSerializedTest.php create mode 100644 tests/unit/phpunit/includes/MVC/View/views/ViewSugarpdfTest.php create mode 100644 tests/unit/phpunit/includes/MVC/View/views/ViewVcardTest.php rename modules/Administration/Search/ajaxSubmit.js => tests/unit/phpunit/includes/MVC/View/views/ViewXMLTest.php (60%) rename tests/unit/phpunit/{include => includes}/SubPanel/SubPanelTest.php (86%) create mode 100644 tests/unit/phpunit/includes/SugarDateTimeTest.php rename tests/unit/phpunit/{include => includes}/SugarEmailAddress/SugarEmailAddressTest.php (96%) rename tests/unit/phpunit/{include => includes}/SugarFolders/SugarFolderTest.php (85%) rename tests/unit/phpunit/{include => includes}/SugarLogger/LoggerManagerTest.php (60%) rename tests/unit/phpunit/{include => includes}/SugarObjects/templates/PersonTest.php (65%) create mode 100644 tests/unit/phpunit/includes/SugarTheme/SugarThemeTest.php rename tests/unit/phpunit/{include => includes}/TimeDateTest.php (54%) rename tests/unit/phpunit/{include => includes}/UtilsTest.php (60%) rename tests/unit/phpunit/{include => includes}/database/DBManagerTest.php (69%) rename tests/unit/phpunit/{include => includes}/utils/LogicHookTest.php (80%) create mode 100644 tests/unit/phpunit/includes/utils/SugarAutoLoaderTest.php create mode 100644 tests/unit/phpunit/includes/utils/activity_utilsTest.php rename tests/unit/phpunit/{include/utils/arrayUtilsTest.php => includes/utils/array_utilsTest.php} (68%) create mode 100644 tests/unit/phpunit/includes/utils/db_utilsTest.php create mode 100644 tests/unit/phpunit/includes/utils/encryption_utilsTest.php create mode 100644 tests/unit/phpunit/includes/utils/file_utilsTest.php create mode 100644 tests/unit/phpunit/includes/utils/layout_utilsTest.php rename tests/unit/phpunit/{include/utils/logicUtilsTest.php => includes/utils/logic_utilsTest.php} (70%) create mode 100644 tests/unit/phpunit/includes/utils/mvc_utilsTest.php create mode 100644 tests/unit/phpunit/includes/utils/php_zip_utilsTest.php create mode 100644 tests/unit/phpunit/includes/utils/progress_bar_utilsTest.php rename tests/unit/phpunit/{include/utils/securityUtilsTest.php => includes/utils/security_utilsTest.php} (55%) create mode 100644 tests/unit/phpunit/lib/PDF/MPDF/MPDFEngineTest.php create mode 100644 tests/unit/phpunit/lib/PDF/PDFWrapperTest.php delete mode 100644 tests/unit/phpunit/modules/Cases/CaseTest.php create mode 100644 tests/unit/phpunit/modules/Cases/aCaseTest.php diff --git a/.gitignore b/.gitignore index 373989221..d23acae5a 100755 --- a/.gitignore +++ b/.gitignore @@ -16,6 +16,8 @@ custom/modules/unified_search_modules_display.php # Ignore AOD indexes modules/AOD_Index/Index/* install/status.json +# Ignore PDF Fonts +modules/AOS_PDF_Templates/PDF_Lib/ttfontdata/ # Configuration files should be ignored. /config.php /config_override.php diff --git a/.travis.yml b/.travis.yml index 5174bb732..565143c14 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,20 +4,20 @@ os: linux matrix: fast_finish: true include: - - name: "PHP 7.2 / MySQL 5.7" - php: "7.2" + - name: "PHP 7.3 / MySQL 5.7" + php: "7.3" dist: xenial - name: "PHP 7.4 / MySQL 5.7" php: "7.4" dist: xenial # Run composer validate to make sure the composer.json and composer.lock are in sync. - name: "composer validate" - php: "7.2" + php: "7.3" dist: xenial before_script: composer install script: composer validate - name: "code coverage" - php: "7.3" + php: "7.4" dist: xenial script: ./vendor/bin/codecept run install --env travis-ci-hub -f --ext DotReporter; ./vendor/bin/robo code:coverage --ci; cat codeception.dist.yml; bash <(curl -s https://codecov.io/bash) -f tests/_output/coverage.xml @@ -45,7 +45,7 @@ before_install: install: - phpenv config-add travis.php.ini - - composer self-update --1 && composer --version + - composer self-update --stable && composer --version before_script: # Set up MySQL diff --git a/composer.json b/composer.json index ceb62600b..e97143b72 100644 --- a/composer.json +++ b/composer.json @@ -4,8 +4,11 @@ "homepage": "https://suitecrm.com", "type": "project", "license": "GPL-3.0", - "authors": [], - "minimum-stability": "dev", + "authors": [ + { + "name": "SalesAgility Ltd" + } + ], "support": { "issues": "https://github.com/salesagility/SuiteCRM/issues", "wiki": "https://docs.suitecrm.com", @@ -16,7 +19,7 @@ "config": { "vendor-dir": "vendor", "platform": { - "php": "7.2.9" + "php": "7.3.0" }, "optimize-autoloader": true, "sort-packages": true, @@ -24,8 +27,10 @@ "elasticsearch/elasticsearch": "dist" } }, + "minimum-stability": "dev", + "prefer-stable": true, "require": { - "php": ">=7.2.9", + "php": ">=7.3.0", "ext-curl": "*", "ext-gd": "*", "ext-imap": "*", @@ -42,7 +47,7 @@ "league/oauth2-server": "^5.1", "league/uri": "^4.2.3", "monolog/monolog": "^1.23", - "nesbot/carbon": "^1.31", + "nesbot/carbon": "^2.0.0", "onelogin/php-saml": "3.4.1", "paragonie/random_compat": "^2.0", "phpmailer/phpmailer": "^6.0", @@ -51,13 +56,15 @@ "slim/slim": "^3.8", "smarty/smarty": "^2.6", "soundasleep/html2text": "~0.5", - "symfony/yaml": "^3.4", + "symfony/options-resolver": "^3.4", + "symfony/validator": "^3.4", + "symfony/yaml": "^5.2", "tinymce/tinymce": "^4.9.11", "tedivm/jshrink": "^1.3", "tuupola/slim-jwt-auth": "^2.0", "vlucas/phpdotenv": "^3.5", "voku/anti-xss": "^2.3", - "wikimedia/composer-merge-plugin": "^1.4", + "wikimedia/composer-merge-plugin": "^2.0", "zbateson/mail-mime-parser": "^1.1", "zf1/zend-gdata": "^1.12", "zf1/zend-loader": "^1.12", @@ -69,24 +76,22 @@ "require-dev": { "consolidation/robo": "^1.4", "browserstack/browserstack-local": "^1.1", - "codeception/codeception": "^3.0", + "codeception/codeception": "^4.1", + "codeception/module-asserts": "^1.3", + "codeception/module-filesystem": "^1.0", + "codeception/module-phpbrowser": "^1.0", + "codeception/module-rest": "^1.3", + "codeception/module-webdriver": "^1.2", + "fakerphp/faker": "^1.14", "filp/whoops": "^2.3", "flow/jsonpath": "^0.4", "friendsofphp/php-cs-fixer": "^2.15", - "fzaninotto/faker": "^1.6", "jeroendesloovere/vcard": "v1.5", - "leafo/scssphp": "^0.7.7", "mikey179/vfsstream": "1.6.*", "mockery/mockery": "^1.1.0", - "phpunit/phpunit": "^8.5" + "phpunit/phpunit": "^9.5", + "scssphp/scssphp": "^1.5" }, - "scripts": { - "post-install-cmd": [ - "rm -Rf vendor/elasticsearch/elasticsearch/tests/Elasticsearch/Tests", - "Google\\Task\\Composer::cleanup" - ] - }, - "prefer-stable": true, "autoload": { "files": [ "deprecated.php" @@ -94,9 +99,7 @@ "psr-4": { "SuiteCRM\\": [ "lib/", - "include/", - "tests/SuiteCRM/", - "tests/unit/phpunit/lib/SuiteCRM/" + "include/" ], "SuiteCRM\\Custom\\": [ "custom/lib" @@ -109,6 +112,23 @@ "Api/" ] }, + "autoload-dev": { + "psr-4": { + "SuiteCRM\\": [ + "tests/SuiteCRM/", + "tests/unit/phpunit/lib/SuiteCRM/" + ], + "SuiteCRM\\Tests\\Unit\\": [ + "tests/unit/phpunit/" + ] + } + }, + "scripts": { + "post-install-cmd": [ + "rm -Rf vendor/elasticsearch/elasticsearch/tests/Elasticsearch/Tests", + "Google\\Task\\Composer::cleanup" + ] + }, "extra": { "merge-plugin": { "include": [ diff --git a/composer.lock b/composer.lock index 7ee51080c..bcd148c25 100644 --- a/composer.lock +++ b/composer.lock @@ -4,30 +4,384 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "7e121e0f8e0b09a3d0d009bd1de01750", + "content-hash": "1c4a6880e816a40086da53a79902bfed", "packages": [ { - "name": "defuse/php-encryption", - "version": "v2.2.1", + "name": "consolidation/annotated-command", + "version": "4.2.4", "source": { "type": "git", - "url": "https://github.com/defuse/php-encryption.git", - "reference": "0f407c43b953d571421e0020ba92082ed5fb7620" + "url": "https://github.com/consolidation/annotated-command.git", + "reference": "ec297e05cb86557671c2d6cbb1bebba6c7ae2c60" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/defuse/php-encryption/zipball/0f407c43b953d571421e0020ba92082ed5fb7620", - "reference": "0f407c43b953d571421e0020ba92082ed5fb7620", + "url": "https://api.github.com/repos/consolidation/annotated-command/zipball/ec297e05cb86557671c2d6cbb1bebba6c7ae2c60", + "reference": "ec297e05cb86557671c2d6cbb1bebba6c7ae2c60", + "shasum": "" + }, + "require": { + "consolidation/output-formatters": "^4.1.1", + "php": ">=7.1.3", + "psr/log": "^1|^2", + "symfony/console": "^4.4.8|~5.1.0", + "symfony/event-dispatcher": "^4.4.8|^5", + "symfony/finder": "^4.4.8|^5" + }, + "require-dev": { + "phpunit/phpunit": ">=7.5.20", + "squizlabs/php_codesniffer": "^3", + "yoast/phpunit-polyfills": "^0.2.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "4.x-dev" + } + }, + "autoload": { + "psr-4": { + "Consolidation\\AnnotatedCommand\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Greg Anderson", + "email": "greg.1.anderson@greenknowe.org" + } + ], + "description": "Initialize Symfony Console commands from annotated command class methods.", + "time": "2020-12-10T16:56:39+00:00" + }, + { + "name": "consolidation/config", + "version": "2.0.1", + "source": { + "type": "git", + "url": "https://github.com/consolidation/config.git", + "reference": "9a2c2a7b2aea1b3525984a4378743a8b74c14e1c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/consolidation/config/zipball/9a2c2a7b2aea1b3525984a4378743a8b74c14e1c", + "reference": "9a2c2a7b2aea1b3525984a4378743a8b74c14e1c", + "shasum": "" + }, + "require": { + "dflydev/dot-access-data": "^1.1.0", + "grasmash/expander": "^1", + "php": ">=7.1.3", + "psr/log": "^1.1", + "symfony/event-dispatcher": "^4||^5" + }, + "require-dev": { + "phpunit/phpunit": ">=7.5.20", + "squizlabs/php_codesniffer": "^3", + "symfony/console": "^4||^5", + "symfony/yaml": "^4||^5", + "yoast/phpunit-polyfills": "^0.2.0" + }, + "suggest": { + "symfony/event-dispatcher": "Required to inject configuration into Command options", + "symfony/yaml": "Required to use Consolidation\\Config\\Loader\\YamlConfigLoader" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "2.x-dev" + } + }, + "autoload": { + "psr-4": { + "Consolidation\\Config\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Greg Anderson", + "email": "greg.1.anderson@greenknowe.org" + } + ], + "description": "Provide configuration services for a commandline tool.", + "time": "2020-12-06T00:03:30+00:00" + }, + { + "name": "consolidation/log", + "version": "2.0.2", + "source": { + "type": "git", + "url": "https://github.com/consolidation/log.git", + "reference": "82a2aaaa621a7b976e50a745a8d249d5085ee2b1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/consolidation/log/zipball/82a2aaaa621a7b976e50a745a8d249d5085ee2b1", + "reference": "82a2aaaa621a7b976e50a745a8d249d5085ee2b1", + "shasum": "" + }, + "require": { + "php": ">=7.1.3", + "psr/log": "^1.0", + "symfony/console": "^4|^5" + }, + "require-dev": { + "phpunit/phpunit": ">=7.5.20", + "squizlabs/php_codesniffer": "^3", + "yoast/phpunit-polyfills": "^0.2.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "2.x-dev" + } + }, + "autoload": { + "psr-4": { + "Consolidation\\Log\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Greg Anderson", + "email": "greg.1.anderson@greenknowe.org" + } + ], + "description": "Improved Psr-3 / Psr\\Log logger based on Symfony Console components.", + "time": "2020-12-10T16:26:23+00:00" + }, + { + "name": "consolidation/output-formatters", + "version": "4.1.2", + "source": { + "type": "git", + "url": "https://github.com/consolidation/output-formatters.git", + "reference": "5821e6ae076bf690058a4de6c94dce97398a69c9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/consolidation/output-formatters/zipball/5821e6ae076bf690058a4de6c94dce97398a69c9", + "reference": "5821e6ae076bf690058a4de6c94dce97398a69c9", + "shasum": "" + }, + "require": { + "dflydev/dot-access-data": "^1.1.0", + "php": ">=7.1.3", + "symfony/console": "^4|^5", + "symfony/finder": "^4|^5" + }, + "require-dev": { + "php-coveralls/php-coveralls": "^2.4.2", + "phpunit/phpunit": ">=7", + "squizlabs/php_codesniffer": "^3", + "symfony/var-dumper": "^4", + "symfony/yaml": "^4", + "yoast/phpunit-polyfills": "^0.2.0" + }, + "suggest": { + "symfony/var-dumper": "For using the var_dump formatter" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "4.x-dev" + } + }, + "autoload": { + "psr-4": { + "Consolidation\\OutputFormatters\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Greg Anderson", + "email": "greg.1.anderson@greenknowe.org" + } + ], + "description": "Format text by applying transformations provided by plug-in formatters.", + "time": "2020-12-12T19:04:59+00:00" + }, + { + "name": "consolidation/robo", + "version": "3.0.3", + "source": { + "type": "git", + "url": "https://github.com/consolidation/Robo.git", + "reference": "734620ad3f9bb457fda1a52338b42439115cf941" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/consolidation/Robo/zipball/734620ad3f9bb457fda1a52338b42439115cf941", + "reference": "734620ad3f9bb457fda1a52338b42439115cf941", + "shasum": "" + }, + "require": { + "consolidation/annotated-command": "^4.2.4", + "consolidation/config": "^1.2.1|^2.0.1", + "consolidation/log": "^1.1.1|^2.0.2", + "consolidation/output-formatters": "^4.1.2", + "consolidation/self-update": "^1.2", + "league/container": "^3.3.1", + "php": ">=7.1.3", + "symfony/console": "^4.4.19 || ^5", + "symfony/event-dispatcher": "^4.4.19 || ^5", + "symfony/filesystem": "^4.4.9 || ^5", + "symfony/finder": "^4.4.9 || ^5", + "symfony/process": "^4.4.9 || ^5", + "symfony/yaml": "^4.4 || ^5" + }, + "conflict": { + "codegyre/robo": "*" + }, + "require-dev": { + "natxet/cssmin": "3.0.4", + "patchwork/jsqueeze": "^2", + "pear/archive_tar": "^1.4.4", + "phpunit/phpunit": "^7.5.20 | ^8", + "squizlabs/php_codesniffer": "^3", + "yoast/phpunit-polyfills": "^0.2.0" + }, + "suggest": { + "natxet/cssmin": "For minifying CSS files in taskMinify", + "patchwork/jsqueeze": "For minifying JS files in taskMinify", + "pear/archive_tar": "Allows tar archives to be created and extracted in taskPack and taskExtract, respectively.", + "totten/lurkerlite": "For monitoring filesystem changes in taskWatch" + }, + "bin": [ + "robo" + ], + "type": "library", + "extra": { + "scenarios": { + "symfony4": { + "require": { + "symfony/console": "^4.4.11", + "symfony/event-dispatcher": "^4.4.11", + "symfony/filesystem": "^4.4.11", + "symfony/finder": "^4.4.11", + "symfony/process": "^4.4.11", + "phpunit/phpunit": "^6", + "nikic/php-parser": "^2" + }, + "remove": [ + "codeception/phpunit-wrapper" + ], + "config": { + "platform": { + "php": "7.1.3" + } + } + } + }, + "branch-alias": { + "dev-master": "2.x-dev", + "dev-main": "2.x-dev" + } + }, + "autoload": { + "psr-4": { + "Robo\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Davert", + "email": "davert.php@resend.cc" + } + ], + "description": "Modern task runner", + "time": "2021-02-21T19:19:43+00:00" + }, + { + "name": "consolidation/self-update", + "version": "1.2.0", + "source": { + "type": "git", + "url": "https://github.com/consolidation/self-update.git", + "reference": "dba6b2c0708f20fa3ba8008a2353b637578849b4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/consolidation/self-update/zipball/dba6b2c0708f20fa3ba8008a2353b637578849b4", + "reference": "dba6b2c0708f20fa3ba8008a2353b637578849b4", + "shasum": "" + }, + "require": { + "php": ">=5.5.0", + "symfony/console": "^2.8|^3|^4|^5", + "symfony/filesystem": "^2.5|^3|^4|^5" + }, + "bin": [ + "scripts/release" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.x-dev" + } + }, + "autoload": { + "psr-4": { + "SelfUpdate\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Alexander Menk", + "email": "menk@mestrona.net" + }, + { + "name": "Greg Anderson", + "email": "greg.1.anderson@greenknowe.org" + } + ], + "description": "Provides a self:update command for Symfony Console applications.", + "time": "2020-04-13T02:49:20+00:00" + }, + { + "name": "defuse/php-encryption", + "version": "v2.3.1", + "source": { + "type": "git", + "url": "https://github.com/defuse/php-encryption.git", + "reference": "77880488b9954b7884c25555c2a0ea9e7053f9d2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/defuse/php-encryption/zipball/77880488b9954b7884c25555c2a0ea9e7053f9d2", + "reference": "77880488b9954b7884c25555c2a0ea9e7053f9d2", "shasum": "" }, "require": { "ext-openssl": "*", "paragonie/random_compat": ">= 2", - "php": ">=5.4.0" + "php": ">=5.6.0" }, "require-dev": { - "nikic/php-parser": "^2.0|^3.0|^4.0", - "phpunit/phpunit": "^4|^5" + "phpunit/phpunit": "^4|^5|^6|^7|^8|^9" }, "bin": [ "bin/generate-defuse-key" @@ -67,7 +421,66 @@ "security", "symmetric key cryptography" ], - "time": "2018-07-24T23:27:56+00:00" + "time": "2021-04-09T23:57:26+00:00" + }, + { + "name": "dflydev/dot-access-data", + "version": "v1.1.0", + "source": { + "type": "git", + "url": "https://github.com/dflydev/dflydev-dot-access-data.git", + "reference": "3fbd874921ab2c041e899d044585a2ab9795df8a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/dflydev/dflydev-dot-access-data/zipball/3fbd874921ab2c041e899d044585a2ab9795df8a", + "reference": "3fbd874921ab2c041e899d044585a2ab9795df8a", + "shasum": "" + }, + "require": { + "php": ">=5.3.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "psr-0": { + "Dflydev\\DotAccessData": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Dragonfly Development Inc.", + "email": "info@dflydev.com", + "homepage": "http://dflydev.com" + }, + { + "name": "Beau Simensen", + "email": "beau@dflydev.com", + "homepage": "http://beausimensen.com" + }, + { + "name": "Carlos Frutos", + "email": "carlos@kiwing.it", + "homepage": "https://github.com/cfrutos" + } + ], + "description": "Given a deep data structure, access data by dot notation.", + "homepage": "https://github.com/dflydev/dflydev-dot-access-data", + "keywords": [ + "access", + "data", + "dot", + "notation" + ], + "time": "2017-01-20T21:14:22+00:00" }, { "name": "elasticsearch/elasticsearch", @@ -176,16 +589,16 @@ }, { "name": "firebase/php-jwt", - "version": "v5.2.1", + "version": "v5.3.0", "source": { "type": "git", "url": "https://github.com/firebase/php-jwt.git", - "reference": "f42c9110abe98dd6cfe9053c49bc86acc70b2d23" + "reference": "3c2d70f2e64e2922345e89f2ceae47d2463faae1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/firebase/php-jwt/zipball/f42c9110abe98dd6cfe9053c49bc86acc70b2d23", - "reference": "f42c9110abe98dd6cfe9053c49bc86acc70b2d23", + "url": "https://api.github.com/repos/firebase/php-jwt/zipball/3c2d70f2e64e2922345e89f2ceae47d2463faae1", + "reference": "3c2d70f2e64e2922345e89f2ceae47d2463faae1", "shasum": "" }, "require": { @@ -222,20 +635,20 @@ "jwt", "php" ], - "time": "2021-02-12T00:02:00+00:00" + "time": "2021-05-20T17:37:02+00:00" }, { "name": "google/apiclient", - "version": "v2.9.1", + "version": "v2.9.2", "source": { "type": "git", "url": "https://github.com/googleapis/google-api-php-client.git", - "reference": "2fb6e702aca5d68203fa737f89f6f774022494c6" + "reference": "e9ef4c26a044b8d39a46bcf296be795fe24a1849" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/googleapis/google-api-php-client/zipball/2fb6e702aca5d68203fa737f89f6f774022494c6", - "reference": "2fb6e702aca5d68203fa737f89f6f774022494c6", + "url": "https://api.github.com/repos/googleapis/google-api-php-client/zipball/e9ef4c26a044b8d39a46bcf296be795fe24a1849", + "reference": "e9ef4c26a044b8d39a46bcf296be795fe24a1849", "shasum": "" }, "require": { @@ -250,7 +663,7 @@ }, "require-dev": { "cache/filesystem-adapter": "^0.3.2|^1.1", - "composer/composer": "^1.10", + "composer/composer": "^1.10.22", "dealerdirect/phpcodesniffer-composer-installer": "^0.7", "phpcompatibility/php-compatibility": "^9.2", "phpunit/phpunit": "^5.7||^8.5.13", @@ -287,20 +700,20 @@ "keywords": [ "google" ], - "time": "2021-01-19T17:48:59+00:00" + "time": "2021-06-09T22:15:08+00:00" }, { "name": "google/apiclient-services", - "version": "v0.166.0", + "version": "v0.180.0", "source": { "type": "git", "url": "https://github.com/googleapis/google-api-php-client-services.git", - "reference": "46b71684a100f3d976e0321cf24f487b314add68" + "reference": "69b977fd15de892432f7f29ea93d57845cf26974" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/googleapis/google-api-php-client-services/zipball/46b71684a100f3d976e0321cf24f487b314add68", - "reference": "46b71684a100f3d976e0321cf24f487b314add68", + "url": "https://api.github.com/repos/googleapis/google-api-php-client-services/zipball/69b977fd15de892432f7f29ea93d57845cf26974", + "reference": "69b977fd15de892432f7f29ea93d57845cf26974", "shasum": "" }, "require": { @@ -324,20 +737,20 @@ "keywords": [ "google" ], - "time": "2021-03-22T11:26:04+00:00" + "time": "2021-06-06T11:20:02+00:00" }, { "name": "google/auth", - "version": "v1.15.0", + "version": "v1.15.1", "source": { "type": "git", "url": "https://github.com/googleapis/google-auth-library-php.git", - "reference": "b346c07de6613e26443d7b4830e5e1933b830dc4" + "reference": "4e0c9367719df9703e96f5ad613041b87742471c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/googleapis/google-auth-library-php/zipball/b346c07de6613e26443d7b4830e5e1933b830dc4", - "reference": "b346c07de6613e26443d7b4830e5e1933b830dc4", + "url": "https://api.github.com/repos/googleapis/google-auth-library-php/zipball/4e0c9367719df9703e96f5ad613041b87742471c", + "reference": "4e0c9367719df9703e96f5ad613041b87742471c", "shasum": "" }, "require": { @@ -351,7 +764,7 @@ "require-dev": { "guzzlehttp/promises": "0.1.1|^1.3", "kelvinmo/simplejwt": "^0.2.5|^0.5.1", - "phpseclib/phpseclib": "^2", + "phpseclib/phpseclib": "^2.0.31", "phpunit/phpunit": "^4.8.36|^5.7", "sebastian/comparator": ">=1.2.3", "squizlabs/php_codesniffer": "^3.5" @@ -376,7 +789,7 @@ "google", "oauth2" ], - "time": "2021-02-05T20:50:04+00:00" + "time": "2021-04-21T17:42:05+00:00" }, { "name": "google/recaptcha", @@ -426,38 +839,92 @@ "time": "2020-03-31T17:50:54+00:00" }, { - "name": "guzzlehttp/guzzle", - "version": "6.5.5", + "name": "grasmash/expander", + "version": "1.0.0", "source": { "type": "git", - "url": "https://github.com/guzzle/guzzle.git", - "reference": "9d4290de1cfd701f38099ef7e183b64b4b7b0c5e" + "url": "https://github.com/grasmash/expander.git", + "reference": "95d6037344a4be1dd5f8e0b0b2571a28c397578f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/guzzle/zipball/9d4290de1cfd701f38099ef7e183b64b4b7b0c5e", - "reference": "9d4290de1cfd701f38099ef7e183b64b4b7b0c5e", + "url": "https://api.github.com/repos/grasmash/expander/zipball/95d6037344a4be1dd5f8e0b0b2571a28c397578f", + "reference": "95d6037344a4be1dd5f8e0b0b2571a28c397578f", + "shasum": "" + }, + "require": { + "dflydev/dot-access-data": "^1.1.0", + "php": ">=5.4" + }, + "require-dev": { + "greg-1-anderson/composer-test-scenarios": "^1", + "phpunit/phpunit": "^4|^5.5.4", + "satooshi/php-coveralls": "^1.0.2|dev-master", + "squizlabs/php_codesniffer": "^2.7" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.x-dev" + } + }, + "autoload": { + "psr-4": { + "Grasmash\\Expander\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Matthew Grasmick" + } + ], + "description": "Expands internal property references in PHP arrays file.", + "time": "2017-12-21T22:14:55+00:00" + }, + { + "name": "guzzlehttp/guzzle", + "version": "7.3.0", + "source": { + "type": "git", + "url": "https://github.com/guzzle/guzzle.git", + "reference": "7008573787b430c1c1f650e3722d9bba59967628" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/guzzle/zipball/7008573787b430c1c1f650e3722d9bba59967628", + "reference": "7008573787b430c1c1f650e3722d9bba59967628", "shasum": "" }, "require": { "ext-json": "*", - "guzzlehttp/promises": "^1.0", - "guzzlehttp/psr7": "^1.6.1", - "php": ">=5.5", - "symfony/polyfill-intl-idn": "^1.17.0" + "guzzlehttp/promises": "^1.4", + "guzzlehttp/psr7": "^1.7 || ^2.0", + "php": "^7.2.5 || ^8.0", + "psr/http-client": "^1.0" + }, + "provide": { + "psr/http-client-implementation": "1.0" }, "require-dev": { + "bamarni/composer-bin-plugin": "^1.4.1", "ext-curl": "*", - "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.4 || ^7.0", + "php-http/client-integration-tests": "^3.0", + "phpunit/phpunit": "^8.5.5 || ^9.3.5", "psr/log": "^1.1" }, "suggest": { + "ext-curl": "Required for CURL handler support", + "ext-intl": "Required for Internationalized Domain Name (IDN) support", "psr/log": "Required for using the Log middleware" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "6.5-dev" + "dev-master": "7.3-dev" } }, "autoload": { @@ -477,6 +944,11 @@ "name": "Michael Dowling", "email": "mtdowling@gmail.com", "homepage": "https://github.com/mtdowling" + }, + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com", + "homepage": "https://sagikazarmark.hu" } ], "description": "Guzzle is a PHP HTTP client library", @@ -487,10 +959,30 @@ "framework", "http", "http client", + "psr-18", + "psr-7", "rest", "web service" ], - "time": "2020-06-16T21:01:06+00:00" + "funding": [ + { + "url": "https://github.com/GrahamCampbell", + "type": "github" + }, + { + "url": "https://github.com/Nyholm", + "type": "github" + }, + { + "url": "https://github.com/alexeyshockov", + "type": "github" + }, + { + "url": "https://github.com/gmponos", + "type": "github" + } + ], + "time": "2021-03-23T11:33:13+00:00" }, { "name": "guzzlehttp/promises", @@ -545,16 +1037,16 @@ }, { "name": "guzzlehttp/psr7", - "version": "1.8.1", + "version": "1.8.2", "source": { "type": "git", "url": "https://github.com/guzzle/psr7.git", - "reference": "35ea11d335fd638b5882ff1725228b3d35496ab1" + "reference": "dc960a912984efb74d0a90222870c72c87f10c91" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/psr7/zipball/35ea11d335fd638b5882ff1725228b3d35496ab1", - "reference": "35ea11d335fd638b5882ff1725228b3d35496ab1", + "url": "https://api.github.com/repos/guzzle/psr7/zipball/dc960a912984efb74d0a90222870c72c87f10c91", + "reference": "dc960a912984efb74d0a90222870c72c87f10c91", "shasum": "" }, "require": { @@ -612,7 +1104,7 @@ "uri", "url" ], - "time": "2021-03-21T16:25:00+00:00" + "time": "2021-04-26T09:17:50+00:00" }, { "name": "guzzlehttp/ringphp", @@ -903,65 +1395,6 @@ ], "time": "2020-05-27T16:41:55+00:00" }, - { - "name": "kylekatarnls/update-helper", - "version": "1.2.1", - "source": { - "type": "git", - "url": "https://github.com/kylekatarnls/update-helper.git", - "reference": "429be50660ed8a196e0798e5939760f168ec8ce9" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/kylekatarnls/update-helper/zipball/429be50660ed8a196e0798e5939760f168ec8ce9", - "reference": "429be50660ed8a196e0798e5939760f168ec8ce9", - "shasum": "" - }, - "require": { - "composer-plugin-api": "^1.1.0 || ^2.0.0", - "php": ">=5.3.0" - }, - "require-dev": { - "codeclimate/php-test-reporter": "dev-master", - "composer/composer": "2.0.x-dev || ^2.0.0-dev", - "phpunit/phpunit": ">=4.8.35 <6.0" - }, - "type": "composer-plugin", - "extra": { - "class": "UpdateHelper\\ComposerPlugin" - }, - "autoload": { - "psr-0": { - "UpdateHelper\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Kyle", - "email": "kylekatarnls@gmail.com" - } - ], - "description": "Update helper", - "funding": [ - { - "url": "https://github.com/kylekatarnls", - "type": "github" - }, - { - "url": "https://opencollective.com/Carbon", - "type": "open_collective" - }, - { - "url": "https://tidelift.com/funding/github/packagist/nesbot/carbon", - "type": "tidelift" - } - ], - "time": "2020-04-07T20:44:10+00:00" - }, { "name": "lcobucci/jwt", "version": "3.3.3", @@ -1027,6 +1460,81 @@ ], "time": "2020-08-20T13:22:28+00:00" }, + { + "name": "league/container", + "version": "3.3.5", + "source": { + "type": "git", + "url": "https://github.com/thephpleague/container.git", + "reference": "048ab87810f508dbedbcb7ae941b606eb8ee353b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/thephpleague/container/zipball/048ab87810f508dbedbcb7ae941b606eb8ee353b", + "reference": "048ab87810f508dbedbcb7ae941b606eb8ee353b", + "shasum": "" + }, + "require": { + "php": "^7.0 || ^8.0", + "psr/container": "^1.0.0 || ^2.0.0" + }, + "provide": { + "psr/container-implementation": "^1.0" + }, + "replace": { + "orno/di": "~2.0" + }, + "require-dev": { + "phpunit/phpunit": "^6.0", + "roave/security-advisories": "dev-master", + "scrutinizer/ocular": "^1.8", + "squizlabs/php_codesniffer": "^3.5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.x-dev", + "dev-3.x": "3.x-dev", + "dev-2.x": "2.x-dev", + "dev-1.x": "1.x-dev" + } + }, + "autoload": { + "psr-4": { + "League\\Container\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Phil Bennett", + "email": "philipobenito@gmail.com", + "homepage": "http://www.philipobenito.com", + "role": "Developer" + } + ], + "description": "A fast and intuitive dependency injection container.", + "homepage": "https://github.com/thephpleague/container", + "keywords": [ + "container", + "dependency", + "di", + "injection", + "league", + "provider", + "service" + ], + "funding": [ + { + "url": "https://github.com/philipobenito", + "type": "github" + } + ], + "time": "2021-03-16T09:42:56+00:00" + }, { "name": "league/event", "version": "2.2.0", @@ -1224,16 +1732,16 @@ }, { "name": "monolog/monolog", - "version": "1.26.0", + "version": "1.26.1", "source": { "type": "git", "url": "https://github.com/Seldaek/monolog.git", - "reference": "2209ddd84e7ef1256b7af205d0717fb62cfc9c33" + "reference": "c6b00f05152ae2c9b04a448f99c7590beb6042f5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Seldaek/monolog/zipball/2209ddd84e7ef1256b7af205d0717fb62cfc9c33", - "reference": "2209ddd84e7ef1256b7af205d0717fb62cfc9c33", + "url": "https://api.github.com/repos/Seldaek/monolog/zipball/c6b00f05152ae2c9b04a448f99c7590beb6042f5", + "reference": "c6b00f05152ae2c9b04a448f99c7590beb6042f5", "shasum": "" }, "require": { @@ -1302,47 +1810,61 @@ "type": "tidelift" } ], - "time": "2020-12-14T12:56:38+00:00" + "time": "2021-05-28T08:32:12+00:00" }, { "name": "nesbot/carbon", - "version": "1.39.1", + "version": "2.49.0", "source": { "type": "git", "url": "https://github.com/briannesbitt/Carbon.git", - "reference": "4be0c005164249208ce1b5ca633cd57bdd42ff33" + "reference": "93d9db91c0235c486875d22f1e08b50bdf3e6eee" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/4be0c005164249208ce1b5ca633cd57bdd42ff33", - "reference": "4be0c005164249208ce1b5ca633cd57bdd42ff33", + "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/93d9db91c0235c486875d22f1e08b50bdf3e6eee", + "reference": "93d9db91c0235c486875d22f1e08b50bdf3e6eee", "shasum": "" }, "require": { - "kylekatarnls/update-helper": "^1.1", - "php": ">=5.3.9", - "symfony/translation": "~2.6 || ~3.0 || ~4.0" + "ext-json": "*", + "php": "^7.1.8 || ^8.0", + "symfony/polyfill-mbstring": "^1.0", + "symfony/translation": "^3.4 || ^4.0 || ^5.0" }, "require-dev": { - "composer/composer": "^1.2", - "friendsofphp/php-cs-fixer": "~2", - "phpunit/phpunit": "^4.8.35 || ^5.7" + "doctrine/orm": "^2.7", + "friendsofphp/php-cs-fixer": "^2.14 || ^3.0", + "kylekatarnls/multi-tester": "^2.0", + "phpmd/phpmd": "^2.9", + "phpstan/extension-installer": "^1.0", + "phpstan/phpstan": "^0.12.54", + "phpunit/phpunit": "^7.5.20 || ^8.5.14", + "squizlabs/php_codesniffer": "^3.4" }, "bin": [ - "bin/upgrade-carbon" + "bin/carbon" ], "type": "library", "extra": { - "update-helper": "Carbon\\Upgrade", + "branch-alias": { + "dev-master": "2.x-dev", + "dev-3.x": "3.x-dev" + }, "laravel": { "providers": [ "Carbon\\Laravel\\ServiceProvider" ] + }, + "phpstan": { + "includes": [ + "extension.neon" + ] } }, "autoload": { "psr-4": { - "": "src/" + "Carbon\\": "src/Carbon/" } }, "notification-url": "https://packagist.org/downloads/", @@ -1354,16 +1876,30 @@ "name": "Brian Nesbitt", "email": "brian@nesbot.com", "homepage": "http://nesbot.com" + }, + { + "name": "kylekatarnls", + "homepage": "http://github.com/kylekatarnls" } ], - "description": "A simple API extension for DateTime.", + "description": "An API extension for DateTime that supports 281 different languages.", "homepage": "http://carbon.nesbot.com", "keywords": [ "date", "datetime", "time" ], - "time": "2019-10-14T05:51:36+00:00" + "funding": [ + { + "url": "https://opencollective.com/Carbon", + "type": "open_collective" + }, + { + "url": "https://tidelift.com/funding/github/packagist/nesbot/carbon", + "type": "tidelift" + } + ], + "time": "2021-06-02T07:31:40+00:00" }, { "name": "nikic/fast-route", @@ -1525,16 +2061,16 @@ }, { "name": "paragonie/random_compat", - "version": "v2.0.19", + "version": "v2.0.20", "source": { "type": "git", "url": "https://github.com/paragonie/random_compat.git", - "reference": "446fc9faa5c2a9ddf65eb7121c0af7e857295241" + "reference": "0f1f60250fccffeaf5dda91eea1c018aed1adc2a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/paragonie/random_compat/zipball/446fc9faa5c2a9ddf65eb7121c0af7e857295241", - "reference": "446fc9faa5c2a9ddf65eb7121c0af7e857295241", + "url": "https://api.github.com/repos/paragonie/random_compat/zipball/0f1f60250fccffeaf5dda91eea1c018aed1adc2a", + "reference": "0f1f60250fccffeaf5dda91eea1c018aed1adc2a", "shasum": "" }, "require": { @@ -1570,20 +2106,20 @@ "pseudorandom", "random" ], - "time": "2020-10-15T10:06:57+00:00" + "time": "2021-04-17T09:33:01+00:00" }, { "name": "phpmailer/phpmailer", - "version": "v6.3.0", + "version": "v6.4.1", "source": { "type": "git", "url": "https://github.com/PHPMailer/PHPMailer.git", - "reference": "4a08cf4cdd2c38d12ee2b9fa69e5d235f37a6dcb" + "reference": "9256f12d8fb0cd0500f93b19e18c356906cbed3d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPMailer/PHPMailer/zipball/4a08cf4cdd2c38d12ee2b9fa69e5d235f37a6dcb", - "reference": "4a08cf4cdd2c38d12ee2b9fa69e5d235f37a6dcb", + "url": "https://api.github.com/repos/PHPMailer/PHPMailer/zipball/9256f12d8fb0cd0500f93b19e18c356906cbed3d", + "reference": "9256f12d8fb0cd0500f93b19e18c356906cbed3d", "shasum": "" }, "require": { @@ -1601,7 +2137,7 @@ "yoast/phpunit-polyfills": "^0.2.0" }, "suggest": { - "ext-mbstring": "Needed to send email in multibyte encoding charset", + "ext-mbstring": "Needed to send email in multibyte encoding charset or decode encoded addresses", "hayageek/oauth2-yahoo": "Needed for Yahoo XOAUTH2 authentication", "league/oauth2-google": "Needed for Google XOAUTH2 authentication", "psr/log": "For optional PSR-3 debug logging", @@ -1642,7 +2178,7 @@ "type": "github" } ], - "time": "2021-02-19T15:28:08+00:00" + "time": "2021-04-29T12:25:04+00:00" }, { "name": "phpoption/phpoption", @@ -1711,16 +2247,16 @@ }, { "name": "phpseclib/phpseclib", - "version": "3.0.6", + "version": "3.0.8", "source": { "type": "git", "url": "https://github.com/phpseclib/phpseclib.git", - "reference": "906a5fafabe5e6ba51ef3dc65b2722a677908837" + "reference": "d9615a6fb970d9933866ca8b4036ec3407b020b6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/906a5fafabe5e6ba51ef3dc65b2722a677908837", - "reference": "906a5fafabe5e6ba51ef3dc65b2722a677908837", + "url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/d9615a6fb970d9933866ca8b4036ec3407b020b6", + "reference": "d9615a6fb970d9933866ca8b4036ec3407b020b6", "shasum": "" }, "require": { @@ -1814,7 +2350,7 @@ "type": "tidelift" } ], - "time": "2021-03-10T13:58:31+00:00" + "time": "2021-04-19T03:20:48+00:00" }, { "name": "pimple/pimple", @@ -1956,6 +2492,101 @@ ], "time": "2021-03-05T17:36:06+00:00" }, + { + "name": "psr/event-dispatcher", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/event-dispatcher.git", + "reference": "dbefd12671e8a14ec7f180cab83036ed26714bb0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/event-dispatcher/zipball/dbefd12671e8a14ec7f180cab83036ed26714bb0", + "reference": "dbefd12671e8a14ec7f180cab83036ed26714bb0", + "shasum": "" + }, + "require": { + "php": ">=7.2.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\EventDispatcher\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Standard interfaces for event handling.", + "keywords": [ + "events", + "psr", + "psr-14" + ], + "time": "2019-01-08T18:20:26+00:00" + }, + { + "name": "psr/http-client", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-client.git", + "reference": "2dfb5f6c5eff0e91e20e913f8c5452ed95b86621" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-client/zipball/2dfb5f6c5eff0e91e20e913f8c5452ed95b86621", + "reference": "2dfb5f6c5eff0e91e20e913f8c5452ed95b86621", + "shasum": "" + }, + "require": { + "php": "^7.0 || ^8.0", + "psr/http-message": "^1.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Client\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for HTTP clients", + "homepage": "https://github.com/php-fig/http-client", + "keywords": [ + "http", + "http-client", + "psr", + "psr-18" + ], + "time": "2020-06-29T06:28:15+00:00" + }, { "name": "psr/http-message", "version": "1.0.1", @@ -2008,16 +2639,16 @@ }, { "name": "psr/log", - "version": "1.1.3", + "version": "1.1.4", "source": { "type": "git", "url": "https://github.com/php-fig/log.git", - "reference": "0f73288fd15629204f9d42b7055f72dacbe811fc" + "reference": "d49695b909c3b7628b6289db5479a1c204601f11" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/log/zipball/0f73288fd15629204f9d42b7055f72dacbe811fc", - "reference": "0f73288fd15629204f9d42b7055f72dacbe811fc", + "url": "https://api.github.com/repos/php-fig/log/zipball/d49695b909c3b7628b6289db5479a1c204601f11", + "reference": "d49695b909c3b7628b6289db5479a1c204601f11", "shasum": "" }, "require": { @@ -2041,7 +2672,7 @@ "authors": [ { "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" + "homepage": "https://www.php-fig.org/" } ], "description": "Common interface for logging libraries", @@ -2051,7 +2682,7 @@ "psr", "psr-3" ], - "time": "2020-03-23T09:12:05+00:00" + "time": "2021-05-03T11:20:27+00:00" }, { "name": "ralouphie/getallheaders", @@ -2352,17 +2983,507 @@ "time": "2017-04-19T22:01:50+00:00" }, { - "name": "symfony/polyfill", - "version": "v1.22.1", + "name": "symfony/console", + "version": "v5.1.11", "source": { "type": "git", - "url": "https://github.com/symfony/polyfill.git", - "reference": "712c20dd05bf98da7a9ab6eace8daa937ba05d20" + "url": "https://github.com/symfony/console.git", + "reference": "d9a267b621c5082e0a6c659d73633b6fd28a8a08" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill/zipball/712c20dd05bf98da7a9ab6eace8daa937ba05d20", - "reference": "712c20dd05bf98da7a9ab6eace8daa937ba05d20", + "url": "https://api.github.com/repos/symfony/console/zipball/d9a267b621c5082e0a6c659d73633b6fd28a8a08", + "reference": "d9a267b621c5082e0a6c659d73633b6fd28a8a08", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "symfony/polyfill-mbstring": "~1.0", + "symfony/polyfill-php73": "^1.8", + "symfony/polyfill-php80": "^1.15", + "symfony/service-contracts": "^1.1|^2", + "symfony/string": "^5.1" + }, + "conflict": { + "symfony/dependency-injection": "<4.4", + "symfony/dotenv": "<5.1", + "symfony/event-dispatcher": "<4.4", + "symfony/lock": "<4.4", + "symfony/process": "<4.4" + }, + "provide": { + "psr/log-implementation": "1.0" + }, + "require-dev": { + "psr/log": "~1.0", + "symfony/config": "^4.4|^5.0", + "symfony/dependency-injection": "^4.4|^5.0", + "symfony/event-dispatcher": "^4.4|^5.0", + "symfony/lock": "^4.4|^5.0", + "symfony/process": "^4.4|^5.0", + "symfony/var-dumper": "^4.4|^5.0" + }, + "suggest": { + "psr/log": "For using the console logger", + "symfony/event-dispatcher": "", + "symfony/lock": "", + "symfony/process": "" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Console\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Eases the creation of beautiful and testable command line interfaces", + "homepage": "https://symfony.com", + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-01-27T10:01:46+00:00" + }, + { + "name": "symfony/deprecation-contracts", + "version": "v2.4.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/deprecation-contracts.git", + "reference": "5f38c8804a9e97d23e0c8d63341088cd8a22d627" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/5f38c8804a9e97d23e0c8d63341088cd8a22d627", + "reference": "5f38c8804a9e97d23e0c8d63341088cd8a22d627", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "2.4-dev" + }, + "thanks": { + "name": "symfony/contracts", + "url": "https://github.com/symfony/contracts" + } + }, + "autoload": { + "files": [ + "function.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "A generic function and convention to trigger deprecation notices", + "homepage": "https://symfony.com", + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-03-23T23:28:01+00:00" + }, + { + "name": "symfony/event-dispatcher", + "version": "v5.3.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/event-dispatcher.git", + "reference": "67a5f354afa8e2f231081b3fa11a5912f933c3ce" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/67a5f354afa8e2f231081b3fa11a5912f933c3ce", + "reference": "67a5f354afa8e2f231081b3fa11a5912f933c3ce", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "symfony/deprecation-contracts": "^2.1", + "symfony/event-dispatcher-contracts": "^2", + "symfony/polyfill-php80": "^1.15" + }, + "conflict": { + "symfony/dependency-injection": "<4.4" + }, + "provide": { + "psr/event-dispatcher-implementation": "1.0", + "symfony/event-dispatcher-implementation": "2.0" + }, + "require-dev": { + "psr/log": "~1.0", + "symfony/config": "^4.4|^5.0", + "symfony/dependency-injection": "^4.4|^5.0", + "symfony/error-handler": "^4.4|^5.0", + "symfony/expression-language": "^4.4|^5.0", + "symfony/http-foundation": "^4.4|^5.0", + "symfony/service-contracts": "^1.1|^2", + "symfony/stopwatch": "^4.4|^5.0" + }, + "suggest": { + "symfony/dependency-injection": "", + "symfony/http-kernel": "" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\EventDispatcher\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Provides tools that allow your application components to communicate with each other by dispatching events and listening to them", + "homepage": "https://symfony.com", + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-05-26T17:43:10+00:00" + }, + { + "name": "symfony/event-dispatcher-contracts", + "version": "v2.4.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/event-dispatcher-contracts.git", + "reference": "69fee1ad2332a7cbab3aca13591953da9cdb7a11" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/event-dispatcher-contracts/zipball/69fee1ad2332a7cbab3aca13591953da9cdb7a11", + "reference": "69fee1ad2332a7cbab3aca13591953da9cdb7a11", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "psr/event-dispatcher": "^1" + }, + "suggest": { + "symfony/event-dispatcher-implementation": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "2.4-dev" + }, + "thanks": { + "name": "symfony/contracts", + "url": "https://github.com/symfony/contracts" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Contracts\\EventDispatcher\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Generic abstractions related to dispatching event", + "homepage": "https://symfony.com", + "keywords": [ + "abstractions", + "contracts", + "decoupling", + "interfaces", + "interoperability", + "standards" + ], + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-03-23T23:28:01+00:00" + }, + { + "name": "symfony/filesystem", + "version": "v5.3.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/filesystem.git", + "reference": "348116319d7fb7d1faa781d26a48922428013eb2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/348116319d7fb7d1faa781d26a48922428013eb2", + "reference": "348116319d7fb7d1faa781d26a48922428013eb2", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "symfony/polyfill-ctype": "~1.8" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Filesystem\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Provides basic utilities for the filesystem", + "homepage": "https://symfony.com", + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-05-26T17:43:10+00:00" + }, + { + "name": "symfony/finder", + "version": "v5.3.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/finder.git", + "reference": "0ae3f047bed4edff6fd35b26a9a6bfdc92c953c6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/finder/zipball/0ae3f047bed4edff6fd35b26a9a6bfdc92c953c6", + "reference": "0ae3f047bed4edff6fd35b26a9a6bfdc92c953c6", + "shasum": "" + }, + "require": { + "php": ">=7.2.5" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Finder\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Finds files and directories via an intuitive fluent interface", + "homepage": "https://symfony.com", + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-05-26T12:52:38+00:00" + }, + { + "name": "symfony/options-resolver", + "version": "v3.4.47", + "source": { + "type": "git", + "url": "https://github.com/symfony/options-resolver.git", + "reference": "c7efc97a47b2ebaabc19d5b6c6b50f5c37c92744" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/options-resolver/zipball/c7efc97a47b2ebaabc19d5b6c6b50f5c37c92744", + "reference": "c7efc97a47b2ebaabc19d5b6c6b50f5c37c92744", + "shasum": "" + }, + "require": { + "php": "^5.5.9|>=7.0.8" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\OptionsResolver\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony OptionsResolver Component", + "homepage": "https://symfony.com", + "keywords": [ + "config", + "configuration", + "options" + ], + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2020-10-24T10:57:07+00:00" + }, + { + "name": "symfony/polyfill", + "version": "v1.23.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill.git", + "reference": "eb670d0f3fdacd3811d2aeb1098e7148a237a3fb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill/zipball/eb670d0f3fdacd3811d2aeb1098e7148a237a3fb", + "reference": "eb670d0f3fdacd3811d2aeb1098e7148a237a3fb", "shasum": "" }, "require": { @@ -2395,7 +3516,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.22-dev" + "dev-main": "1.23-dev" } }, "autoload": { @@ -2459,20 +3580,235 @@ "type": "tidelift" } ], - "time": "2021-02-15T12:43:29+00:00" + "time": "2021-05-27T09:34:47+00:00" }, { - "name": "symfony/translation", - "version": "v4.4.21", + "name": "symfony/process", + "version": "v5.3.0", "source": { "type": "git", - "url": "https://github.com/symfony/translation.git", - "reference": "eb8f5428cc3b40d6dffe303b195b084f1c5fbd14" + "url": "https://github.com/symfony/process.git", + "reference": "53e36cb1c160505cdaf1ef201501669c4c317191" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/translation/zipball/eb8f5428cc3b40d6dffe303b195b084f1c5fbd14", - "reference": "eb8f5428cc3b40d6dffe303b195b084f1c5fbd14", + "url": "https://api.github.com/repos/symfony/process/zipball/53e36cb1c160505cdaf1ef201501669c4c317191", + "reference": "53e36cb1c160505cdaf1ef201501669c4c317191", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "symfony/polyfill-php80": "^1.15" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Process\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Executes commands in sub-processes", + "homepage": "https://symfony.com", + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-05-26T12:52:38+00:00" + }, + { + "name": "symfony/service-contracts", + "version": "v2.4.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/service-contracts.git", + "reference": "f040a30e04b57fbcc9c6cbcf4dbaa96bd318b9bb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/service-contracts/zipball/f040a30e04b57fbcc9c6cbcf4dbaa96bd318b9bb", + "reference": "f040a30e04b57fbcc9c6cbcf4dbaa96bd318b9bb", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "psr/container": "^1.1" + }, + "suggest": { + "symfony/service-implementation": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "2.4-dev" + }, + "thanks": { + "name": "symfony/contracts", + "url": "https://github.com/symfony/contracts" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Contracts\\Service\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Generic abstractions related to writing services", + "homepage": "https://symfony.com", + "keywords": [ + "abstractions", + "contracts", + "decoupling", + "interfaces", + "interoperability", + "standards" + ], + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-04-01T10:43:52+00:00" + }, + { + "name": "symfony/string", + "version": "v5.3.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/string.git", + "reference": "a9a0f8b6aafc5d2d1c116dcccd1573a95153515b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/string/zipball/a9a0f8b6aafc5d2d1c116dcccd1573a95153515b", + "reference": "a9a0f8b6aafc5d2d1c116dcccd1573a95153515b", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "symfony/polyfill-ctype": "~1.8", + "symfony/polyfill-intl-grapheme": "~1.0", + "symfony/polyfill-intl-normalizer": "~1.0", + "symfony/polyfill-mbstring": "~1.0", + "symfony/polyfill-php80": "~1.15" + }, + "require-dev": { + "symfony/error-handler": "^4.4|^5.0", + "symfony/http-client": "^4.4|^5.0", + "symfony/translation-contracts": "^1.1|^2", + "symfony/var-exporter": "^4.4|^5.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\String\\": "" + }, + "files": [ + "Resources/functions.php" + ], + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Provides an object-oriented API to strings and deals with bytes, UTF-8 code points and grapheme clusters in a unified way", + "homepage": "https://symfony.com", + "keywords": [ + "grapheme", + "i18n", + "string", + "unicode", + "utf-8", + "utf8" + ], + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-05-26T17:43:10+00:00" + }, + { + "name": "symfony/translation", + "version": "v4.4.25", + "source": { + "type": "git", + "url": "https://github.com/symfony/translation.git", + "reference": "dfe132c5c6d89f90ce7f961742cc532e9ca16dd4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/translation/zipball/dfe132c5c6d89f90ce7f961742cc532e9ca16dd4", + "reference": "dfe132c5c6d89f90ce7f961742cc532e9ca16dd4", "shasum": "" }, "require": { @@ -2544,20 +3880,20 @@ "type": "tidelift" } ], - "time": "2021-03-23T16:25:01+00:00" + "time": "2021-05-26T17:39:37+00:00" }, { "name": "symfony/translation-contracts", - "version": "v2.3.0", + "version": "v2.4.0", "source": { "type": "git", "url": "https://github.com/symfony/translation-contracts.git", - "reference": "e2eaa60b558f26a4b0354e1bbb25636efaaad105" + "reference": "95c812666f3e91db75385749fe219c5e494c7f95" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/translation-contracts/zipball/e2eaa60b558f26a4b0354e1bbb25636efaaad105", - "reference": "e2eaa60b558f26a4b0354e1bbb25636efaaad105", + "url": "https://api.github.com/repos/symfony/translation-contracts/zipball/95c812666f3e91db75385749fe219c5e494c7f95", + "reference": "95c812666f3e91db75385749fe219c5e494c7f95", "shasum": "" }, "require": { @@ -2569,7 +3905,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.3-dev" + "dev-main": "2.4-dev" }, "thanks": { "name": "symfony/contracts", @@ -2619,35 +3955,134 @@ "type": "tidelift" } ], - "time": "2020-09-28T13:05:58+00:00" + "time": "2021-03-23T23:28:01+00:00" }, { - "name": "symfony/yaml", + "name": "symfony/validator", "version": "v3.4.47", "source": { "type": "git", - "url": "https://github.com/symfony/yaml.git", - "reference": "88289caa3c166321883f67fe5130188ebbb47094" + "url": "https://github.com/symfony/validator.git", + "reference": "d25ceea5c99022aecf37adf157c76c31fc5dcbed" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/88289caa3c166321883f67fe5130188ebbb47094", - "reference": "88289caa3c166321883f67fe5130188ebbb47094", + "url": "https://api.github.com/repos/symfony/validator/zipball/d25ceea5c99022aecf37adf157c76c31fc5dcbed", + "reference": "d25ceea5c99022aecf37adf157c76c31fc5dcbed", "shasum": "" }, "require": { "php": "^5.5.9|>=7.0.8", + "symfony/polyfill-ctype": "~1.8", + "symfony/polyfill-mbstring": "~1.0", + "symfony/translation": "~2.8|~3.0|~4.0" + }, + "conflict": { + "doctrine/lexer": "<1.0.2", + "phpunit/phpunit": "<4.8.35|<5.4.3,>=5.0", + "symfony/dependency-injection": "<3.3", + "symfony/http-kernel": "<3.3.5", + "symfony/yaml": "<3.4" + }, + "require-dev": { + "doctrine/annotations": "~1.7", + "doctrine/cache": "~1.0", + "egulias/email-validator": "^2.1.10", + "symfony/cache": "~3.1|~4.0", + "symfony/config": "~2.8|~3.0|~4.0", + "symfony/dependency-injection": "~3.3|~4.0", + "symfony/expression-language": "~2.8|~3.0|~4.0", + "symfony/http-foundation": "~2.8|~3.0|~4.0", + "symfony/http-kernel": "^3.3.5|~4.0", + "symfony/intl": "^2.8.18|^3.2.5|~4.0", + "symfony/property-access": "~2.8|~3.0|~4.0", + "symfony/var-dumper": "~3.3|~4.0", + "symfony/yaml": "~3.4|~4.0" + }, + "suggest": { + "doctrine/annotations": "For using the annotation mapping. You will also need doctrine/cache.", + "doctrine/cache": "For using the default cached annotation reader and metadata cache.", + "egulias/email-validator": "Strict (RFC compliant) email validation", + "psr/cache-implementation": "For using the metadata cache.", + "symfony/config": "", + "symfony/expression-language": "For using the Expression validator", + "symfony/http-foundation": "", + "symfony/intl": "", + "symfony/property-access": "For accessing properties within comparison constraints", + "symfony/yaml": "" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Validator\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Validator Component", + "homepage": "https://symfony.com", + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2020-10-28T05:23:51+00:00" + }, + { + "name": "symfony/yaml", + "version": "v5.3.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/yaml.git", + "reference": "3bbcf262fceb3d8f48175302e6ba0ac96e3a5a11" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/yaml/zipball/3bbcf262fceb3d8f48175302e6ba0ac96e3a5a11", + "reference": "3bbcf262fceb3d8f48175302e6ba0ac96e3a5a11", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "symfony/deprecation-contracts": "^2.1", "symfony/polyfill-ctype": "~1.8" }, "conflict": { - "symfony/console": "<3.4" + "symfony/console": "<4.4" }, "require-dev": { - "symfony/console": "~3.4|~4.0" + "symfony/console": "^4.4|^5.0" }, "suggest": { "symfony/console": "For validating YAML files using the lint command" }, + "bin": [ + "Resources/bin/yaml-lint" + ], "type": "library", "autoload": { "psr-4": { @@ -2671,7 +4106,7 @@ "homepage": "https://symfony.com/contributors" } ], - "description": "Symfony Yaml Component", + "description": "Loads and dumps YAML files", "homepage": "https://symfony.com", "funding": [ { @@ -2687,7 +4122,7 @@ "type": "tidelift" } ], - "time": "2020-10-24T10:57:07+00:00" + "time": "2021-05-26T17:43:10+00:00" }, { "name": "tedivm/jshrink", @@ -3044,38 +4479,38 @@ }, { "name": "wikimedia/composer-merge-plugin", - "version": "v1.4.1", + "version": "v2.0.1", "source": { "type": "git", "url": "https://github.com/wikimedia/composer-merge-plugin.git", - "reference": "81c6ac72a24a67383419c7eb9aa2b3437f2ab100" + "reference": "8ca2ed8ab97c8ebce6b39d9943e9909bb4f18912" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/wikimedia/composer-merge-plugin/zipball/81c6ac72a24a67383419c7eb9aa2b3437f2ab100", - "reference": "81c6ac72a24a67383419c7eb9aa2b3437f2ab100", + "url": "https://api.github.com/repos/wikimedia/composer-merge-plugin/zipball/8ca2ed8ab97c8ebce6b39d9943e9909bb4f18912", + "reference": "8ca2ed8ab97c8ebce6b39d9943e9909bb4f18912", "shasum": "" }, "require": { - "composer-plugin-api": "^1.0", - "php": ">=5.3.2" + "composer-plugin-api": "^1.1||^2.0", + "php": ">=7.2.0" }, "require-dev": { - "composer/composer": "~1.0.0", - "jakub-onderka/php-parallel-lint": "~0.8", - "phpunit/phpunit": "~4.8|~5.0", - "squizlabs/php_codesniffer": "~2.1.0" + "composer/composer": "^1.1||^2.0", + "php-parallel-lint/php-parallel-lint": "~1.1.0", + "phpunit/phpunit": "^8.5||^9.0", + "squizlabs/php_codesniffer": "~3.5.4" }, "type": "composer-plugin", "extra": { "branch-alias": { - "dev-master": "1.3.x-dev" + "dev-master": "2.x-dev" }, - "class": "Wikimedia\\Composer\\MergePlugin" + "class": "Wikimedia\\Composer\\Merge\\V2\\MergePlugin" }, "autoload": { "psr-4": { - "Wikimedia\\Composer\\": "src/" + "Wikimedia\\Composer\\Merge\\V2\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", @@ -3089,7 +4524,7 @@ } ], "description": "Composer plugin to merge multiple composer.json files", - "time": "2017-04-25T02:31:25+00:00" + "time": "2021-02-24T05:28:06+00:00" }, { "name": "zbateson/mail-mime-parser", @@ -4084,62 +5519,51 @@ }, { "name": "codeception/codeception", - "version": "3.1.2", + "version": "4.1.21", "source": { "type": "git", "url": "https://github.com/Codeception/Codeception.git", - "reference": "5ea172de7b1b2e61dcdd50d73f8368886c549fb4" + "reference": "c25f20d842a7e3fa0a8e6abf0828f102c914d419" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Codeception/Codeception/zipball/5ea172de7b1b2e61dcdd50d73f8368886c549fb4", - "reference": "5ea172de7b1b2e61dcdd50d73f8368886c549fb4", + "url": "https://api.github.com/repos/Codeception/Codeception/zipball/c25f20d842a7e3fa0a8e6abf0828f102c914d419", + "reference": "c25f20d842a7e3fa0a8e6abf0828f102c914d419", "shasum": "" }, "require": { "behat/gherkin": "^4.4.0", - "codeception/phpunit-wrapper": ">6.0.15 <6.1.0 | ^6.6.1 | ^7.7.1 | ^8.0.3", + "codeception/lib-asserts": "^1.0", + "codeception/phpunit-wrapper": ">6.0.15 <6.1.0 | ^6.6.1 | ^7.7.1 | ^8.1.1 | ^9.0", "codeception/stub": "^2.0 | ^3.0", "ext-curl": "*", "ext-json": "*", "ext-mbstring": "*", - "facebook/webdriver": "^1.6.0", - "guzzlehttp/guzzle": "^6.3.0", "guzzlehttp/psr7": "~1.4", - "hoa/console": "~3.0", - "php": ">=5.6.0 <8.0", - "symfony/browser-kit": ">=2.7 <5.0", - "symfony/console": ">=2.7 <5.0", - "symfony/css-selector": ">=2.7 <5.0", - "symfony/dom-crawler": ">=2.7 <5.0", - "symfony/event-dispatcher": ">=2.7 <5.0", - "symfony/finder": ">=2.7 <5.0", - "symfony/yaml": ">=2.7 <5.0" + "php": ">=5.6.0 <9.0", + "symfony/console": ">=2.7 <6.0", + "symfony/css-selector": ">=2.7 <6.0", + "symfony/event-dispatcher": ">=2.7 <6.0", + "symfony/finder": ">=2.7 <6.0", + "symfony/yaml": ">=2.7 <6.0" }, "require-dev": { + "codeception/module-asserts": "1.*@dev", + "codeception/module-cli": "1.*@dev", + "codeception/module-db": "1.*@dev", + "codeception/module-filesystem": "1.*@dev", + "codeception/module-phpbrowser": "1.*@dev", "codeception/specify": "~0.3", - "doctrine/annotations": "^1", - "doctrine/data-fixtures": "^1", - "doctrine/orm": "^2", - "flow/jsonpath": "~0.2", + "codeception/util-universalframework": "*@dev", "monolog/monolog": "~1.8", - "pda/pheanstalk": "~3.0", - "php-amqplib/php-amqplib": "~2.4", - "predis/predis": "^1.0", - "ramsey/uuid-doctrine": "^1.5", "squizlabs/php_codesniffer": "~2.0", - "symfony/process": ">=2.7 <5.0", - "vlucas/phpdotenv": "^3.0" + "symfony/process": ">=2.7 <6.0", + "vlucas/phpdotenv": "^2.0 | ^3.0 | ^4.0 | ^5.0" }, "suggest": { - "aws/aws-sdk-php": "For using AWS Auth in REST module and Queue module", - "codeception/phpbuiltinserver": "Start and stop PHP built-in web server for your tests", "codeception/specify": "BDD-style code blocks", "codeception/verify": "BDD-style assertions", - "flow/jsonpath": "For using JSONPath in REST module", - "league/factory-muffin": "For DataFactory module", - "league/factory-muffin-faker": "For Faker support in DataFactory module", - "phpseclib/phpseclib": "for SFTP option in FTP Module", + "hoa/console": "For interactive console functionality", "stecman/symfony-console-completion": "For BASH autocompletion", "symfony/phpunit-bridge": "For phpunit-bridge support" }, @@ -4176,31 +5600,400 @@ "functional testing", "unit testing" ], - "time": "2019-10-19T13:15:55+00:00" + "funding": [ + { + "url": "https://opencollective.com/codeception", + "type": "open_collective" + } + ], + "time": "2021-05-28T17:43:39+00:00" }, { - "name": "codeception/phpunit-wrapper", - "version": "8.1.4", + "name": "codeception/lib-asserts", + "version": "1.13.2", "source": { "type": "git", - "url": "https://github.com/Codeception/phpunit-wrapper.git", - "reference": "f41335f0b4dd17cf7bbc63e87943b3ae72a8bbc3" + "url": "https://github.com/Codeception/lib-asserts.git", + "reference": "184231d5eab66bc69afd6b9429344d80c67a33b6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Codeception/phpunit-wrapper/zipball/f41335f0b4dd17cf7bbc63e87943b3ae72a8bbc3", - "reference": "f41335f0b4dd17cf7bbc63e87943b3ae72a8bbc3", + "url": "https://api.github.com/repos/Codeception/lib-asserts/zipball/184231d5eab66bc69afd6b9429344d80c67a33b6", + "reference": "184231d5eab66bc69afd6b9429344d80c67a33b6", + "shasum": "" + }, + "require": { + "codeception/phpunit-wrapper": ">6.0.15 <6.1.0 | ^6.6.1 | ^7.7.1 | ^8.0.3 | ^9.0", + "ext-dom": "*", + "php": ">=5.6.0 <9.0" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Michael Bodnarchuk", + "email": "davert@mail.ua", + "homepage": "http://codegyre.com" + }, + { + "name": "Gintautas Miselis" + }, + { + "name": "Gustavo Nieves", + "homepage": "https://medium.com/@ganieves" + } + ], + "description": "Assertion methods used by Codeception core and Asserts module", + "homepage": "https://codeception.com/", + "keywords": [ + "codeception" + ], + "time": "2020-10-21T16:26:20+00:00" + }, + { + "name": "codeception/lib-innerbrowser", + "version": "1.5.0", + "source": { + "type": "git", + "url": "https://github.com/Codeception/lib-innerbrowser.git", + "reference": "4b0d89b37fe454e060a610a85280a87ab4f534f1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Codeception/lib-innerbrowser/zipball/4b0d89b37fe454e060a610a85280a87ab4f534f1", + "reference": "4b0d89b37fe454e060a610a85280a87ab4f534f1", + "shasum": "" + }, + "require": { + "codeception/codeception": "*@dev", + "ext-dom": "*", + "ext-json": "*", + "ext-mbstring": "*", + "php": ">=5.6.0 <9.0", + "symfony/browser-kit": ">=2.7 <6.0", + "symfony/dom-crawler": ">=2.7 <6.0" + }, + "conflict": { + "codeception/codeception": "<4.0" + }, + "require-dev": { + "codeception/util-universalframework": "dev-master" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Michael Bodnarchuk", + "email": "davert@mail.ua", + "homepage": "http://codegyre.com" + }, + { + "name": "Gintautas Miselis" + } + ], + "description": "Parent library for all Codeception framework modules and PhpBrowser", + "homepage": "https://codeception.com/", + "keywords": [ + "codeception" + ], + "time": "2021-04-23T06:18:29+00:00" + }, + { + "name": "codeception/module-asserts", + "version": "1.3.1", + "source": { + "type": "git", + "url": "https://github.com/Codeception/module-asserts.git", + "reference": "59374f2fef0cabb9e8ddb53277e85cdca74328de" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Codeception/module-asserts/zipball/59374f2fef0cabb9e8ddb53277e85cdca74328de", + "reference": "59374f2fef0cabb9e8ddb53277e85cdca74328de", + "shasum": "" + }, + "require": { + "codeception/codeception": "*@dev", + "codeception/lib-asserts": "^1.13.1", + "php": ">=5.6.0 <9.0" + }, + "conflict": { + "codeception/codeception": "<4.0" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Michael Bodnarchuk" + }, + { + "name": "Gintautas Miselis" + }, + { + "name": "Gustavo Nieves", + "homepage": "https://medium.com/@ganieves" + } + ], + "description": "Codeception module containing various assertions", + "homepage": "https://codeception.com/", + "keywords": [ + "assertions", + "asserts", + "codeception" + ], + "time": "2020-10-21T16:48:15+00:00" + }, + { + "name": "codeception/module-filesystem", + "version": "1.0.3", + "source": { + "type": "git", + "url": "https://github.com/Codeception/module-filesystem.git", + "reference": "781be167fb1557bfc9b61e0a4eac60a32c534ec1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Codeception/module-filesystem/zipball/781be167fb1557bfc9b61e0a4eac60a32c534ec1", + "reference": "781be167fb1557bfc9b61e0a4eac60a32c534ec1", + "shasum": "" + }, + "require": { + "codeception/codeception": "^4.0", + "php": ">=5.6.0 <9.0", + "symfony/finder": ">=2.7 <6.0" + }, + "conflict": { + "codeception/codeception": "<4.0" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Michael Bodnarchuk" + }, + { + "name": "Gintautas Miselis" + } + ], + "description": "Codeception module for testing local filesystem", + "homepage": "http://codeception.com/", + "keywords": [ + "codeception", + "filesystem" + ], + "time": "2020-10-24T14:46:40+00:00" + }, + { + "name": "codeception/module-phpbrowser", + "version": "1.0.2", + "source": { + "type": "git", + "url": "https://github.com/Codeception/module-phpbrowser.git", + "reference": "770a6be4160a5c0c08d100dd51bff35f6056bbf1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Codeception/module-phpbrowser/zipball/770a6be4160a5c0c08d100dd51bff35f6056bbf1", + "reference": "770a6be4160a5c0c08d100dd51bff35f6056bbf1", + "shasum": "" + }, + "require": { + "codeception/codeception": "^4.0", + "codeception/lib-innerbrowser": "^1.3", + "guzzlehttp/guzzle": "^6.3|^7.0", + "php": ">=5.6.0 <9.0" + }, + "conflict": { + "codeception/codeception": "<4.0" + }, + "require-dev": { + "codeception/module-rest": "^1.0" + }, + "suggest": { + "codeception/phpbuiltinserver": "Start and stop PHP built-in web server for your tests" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Michael Bodnarchuk" + }, + { + "name": "Gintautas Miselis" + } + ], + "description": "Codeception module for testing web application over HTTP", + "homepage": "http://codeception.com/", + "keywords": [ + "codeception", + "functional-testing", + "http" + ], + "time": "2020-10-24T15:29:28+00:00" + }, + { + "name": "codeception/module-rest", + "version": "1.3.1", + "source": { + "type": "git", + "url": "https://github.com/Codeception/module-rest.git", + "reference": "293a0103d5257b7c884ef276147a9a06914e878f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Codeception/module-rest/zipball/293a0103d5257b7c884ef276147a9a06914e878f", + "reference": "293a0103d5257b7c884ef276147a9a06914e878f", + "shasum": "" + }, + "require": { + "codeception/codeception": "^4.0", + "justinrainbow/json-schema": "~5.2.9", + "php": ">=5.6.0 <9.0", + "softcreatr/jsonpath": "^0.5 || ^0.7" + }, + "require-dev": { + "codeception/lib-innerbrowser": "^1.0", + "codeception/util-universalframework": "^1.0" + }, + "suggest": { + "aws/aws-sdk-php": "For using AWS Auth" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Gintautas Miselis" + } + ], + "description": "REST module for Codeception", + "homepage": "http://codeception.com/", + "keywords": [ + "codeception", + "rest" + ], + "time": "2021-04-23T08:12:24+00:00" + }, + { + "name": "codeception/module-webdriver", + "version": "1.2.1", + "source": { + "type": "git", + "url": "https://github.com/Codeception/module-webdriver.git", + "reference": "ebbe729c630415e8caf6b0087e457906f0c6c0c6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Codeception/module-webdriver/zipball/ebbe729c630415e8caf6b0087e457906f0c6c0c6", + "reference": "ebbe729c630415e8caf6b0087e457906f0c6c0c6", + "shasum": "" + }, + "require": { + "codeception/codeception": "^4.0", + "php": ">=5.6.0 <9.0", + "php-webdriver/webdriver": "^1.8.0" + }, + "suggest": { + "codeception/phpbuiltinserver": "Start and stop PHP built-in web server for your tests" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Michael Bodnarchuk" + }, + { + "name": "Gintautas Miselis" + }, + { + "name": "Zaahid Bateson" + } + ], + "description": "WebDriver module for Codeception", + "homepage": "http://codeception.com/", + "keywords": [ + "acceptance-testing", + "browser-testing", + "codeception" + ], + "time": "2021-04-23T17:30:57+00:00" + }, + { + "name": "codeception/phpunit-wrapper", + "version": "9.0.6", + "source": { + "type": "git", + "url": "https://github.com/Codeception/phpunit-wrapper.git", + "reference": "b0c06abb3181eedca690170f7ed0fd26a70bfacc" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Codeception/phpunit-wrapper/zipball/b0c06abb3181eedca690170f7ed0fd26a70bfacc", + "reference": "b0c06abb3181eedca690170f7ed0fd26a70bfacc", "shasum": "" }, "require": { "php": ">=7.2", - "phpunit/php-code-coverage": "^7.0", - "phpunit/phpunit": "^8.0", - "sebastian/comparator": "^3.0", - "sebastian/diff": "^3.0" + "phpunit/phpunit": "^9.0" }, "require-dev": { "codeception/specify": "*", + "consolidation/robo": "^3.0.0-alpha3", "vlucas/phpdotenv": "^3.0" }, "type": "library", @@ -4217,10 +6010,13 @@ { "name": "Davert", "email": "davert.php@resend.cc" + }, + { + "name": "Naktibalda" } ], "description": "PHPUnit classes used by Codeception", - "time": "2020-12-28T14:00:08+00:00" + "time": "2020-12-28T13:59:47+00:00" }, { "name": "codeception/stub", @@ -4254,16 +6050,16 @@ }, { "name": "composer/semver", - "version": "3.2.4", + "version": "3.2.5", "source": { "type": "git", "url": "https://github.com/composer/semver.git", - "reference": "a02fdf930a3c1c3ed3a49b5f63859c0c20e10464" + "reference": "31f3ea725711245195f62e54ffa402d8ef2fdba9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/semver/zipball/a02fdf930a3c1c3ed3a49b5f63859c0c20e10464", - "reference": "a02fdf930a3c1c3ed3a49b5f63859c0c20e10464", + "url": "https://api.github.com/repos/composer/semver/zipball/31f3ea725711245195f62e54ffa402d8ef2fdba9", + "reference": "31f3ea725711245195f62e54ffa402d8ef2fdba9", "shasum": "" }, "require": { @@ -4326,20 +6122,20 @@ "type": "tidelift" } ], - "time": "2020-11-13T08:59:24+00:00" + "time": "2021-05-24T12:41:47+00:00" }, { "name": "composer/xdebug-handler", - "version": "1.4.6", + "version": "2.0.1", "source": { "type": "git", "url": "https://github.com/composer/xdebug-handler.git", - "reference": "f27e06cd9675801df441b3656569b328e04aa37c" + "reference": "964adcdd3a28bf9ed5d9ac6450064e0d71ed7496" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/f27e06cd9675801df441b3656569b328e04aa37c", - "reference": "f27e06cd9675801df441b3656569b328e04aa37c", + "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/964adcdd3a28bf9ed5d9ac6450064e0d71ed7496", + "reference": "964adcdd3a28bf9ed5d9ac6450064e0d71ed7496", "shasum": "" }, "require": { @@ -4385,523 +6181,34 @@ "type": "tidelift" } ], - "time": "2021-03-25T17:01:18+00:00" - }, - { - "name": "consolidation/annotated-command", - "version": "4.2.4", - "source": { - "type": "git", - "url": "https://github.com/consolidation/annotated-command.git", - "reference": "ec297e05cb86557671c2d6cbb1bebba6c7ae2c60" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/consolidation/annotated-command/zipball/ec297e05cb86557671c2d6cbb1bebba6c7ae2c60", - "reference": "ec297e05cb86557671c2d6cbb1bebba6c7ae2c60", - "shasum": "" - }, - "require": { - "consolidation/output-formatters": "^4.1.1", - "php": ">=7.1.3", - "psr/log": "^1|^2", - "symfony/console": "^4.4.8|~5.1.0", - "symfony/event-dispatcher": "^4.4.8|^5", - "symfony/finder": "^4.4.8|^5" - }, - "require-dev": { - "phpunit/phpunit": ">=7.5.20", - "squizlabs/php_codesniffer": "^3", - "yoast/phpunit-polyfills": "^0.2.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "4.x-dev" - } - }, - "autoload": { - "psr-4": { - "Consolidation\\AnnotatedCommand\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Greg Anderson", - "email": "greg.1.anderson@greenknowe.org" - } - ], - "description": "Initialize Symfony Console commands from annotated command class methods.", - "time": "2020-12-10T16:56:39+00:00" - }, - { - "name": "consolidation/config", - "version": "1.2.1", - "source": { - "type": "git", - "url": "https://github.com/consolidation/config.git", - "reference": "cac1279bae7efb5c7fb2ca4c3ba4b8eb741a96c1" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/consolidation/config/zipball/cac1279bae7efb5c7fb2ca4c3ba4b8eb741a96c1", - "reference": "cac1279bae7efb5c7fb2ca4c3ba4b8eb741a96c1", - "shasum": "" - }, - "require": { - "dflydev/dot-access-data": "^1.1.0", - "grasmash/expander": "^1", - "php": ">=5.4.0" - }, - "require-dev": { - "g1a/composer-test-scenarios": "^3", - "php-coveralls/php-coveralls": "^1", - "phpunit/phpunit": "^5", - "squizlabs/php_codesniffer": "2.*", - "symfony/console": "^2.5|^3|^4", - "symfony/yaml": "^2.8.11|^3|^4" - }, - "suggest": { - "symfony/yaml": "Required to use Consolidation\\Config\\Loader\\YamlConfigLoader" - }, - "type": "library", - "extra": { - "scenarios": { - "symfony4": { - "require-dev": { - "symfony/console": "^4.0" - }, - "config": { - "platform": { - "php": "7.1.3" - } - } - }, - "symfony2": { - "require-dev": { - "symfony/console": "^2.8", - "symfony/event-dispatcher": "^2.8", - "phpunit/phpunit": "^4.8.36" - }, - "remove": [ - "php-coveralls/php-coveralls" - ], - "config": { - "platform": { - "php": "5.4.8" - } - } - } - }, - "branch-alias": { - "dev-master": "1.x-dev" - } - }, - "autoload": { - "psr-4": { - "Consolidation\\Config\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Greg Anderson", - "email": "greg.1.anderson@greenknowe.org" - } - ], - "description": "Provide configuration services for a commandline tool.", - "time": "2019-03-03T19:37:04+00:00" - }, - { - "name": "consolidation/log", - "version": "2.0.2", - "source": { - "type": "git", - "url": "https://github.com/consolidation/log.git", - "reference": "82a2aaaa621a7b976e50a745a8d249d5085ee2b1" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/consolidation/log/zipball/82a2aaaa621a7b976e50a745a8d249d5085ee2b1", - "reference": "82a2aaaa621a7b976e50a745a8d249d5085ee2b1", - "shasum": "" - }, - "require": { - "php": ">=7.1.3", - "psr/log": "^1.0", - "symfony/console": "^4|^5" - }, - "require-dev": { - "phpunit/phpunit": ">=7.5.20", - "squizlabs/php_codesniffer": "^3", - "yoast/phpunit-polyfills": "^0.2.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "2.x-dev" - } - }, - "autoload": { - "psr-4": { - "Consolidation\\Log\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Greg Anderson", - "email": "greg.1.anderson@greenknowe.org" - } - ], - "description": "Improved Psr-3 / Psr\\Log logger based on Symfony Console components.", - "time": "2020-12-10T16:26:23+00:00" - }, - { - "name": "consolidation/output-formatters", - "version": "4.1.2", - "source": { - "type": "git", - "url": "https://github.com/consolidation/output-formatters.git", - "reference": "5821e6ae076bf690058a4de6c94dce97398a69c9" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/consolidation/output-formatters/zipball/5821e6ae076bf690058a4de6c94dce97398a69c9", - "reference": "5821e6ae076bf690058a4de6c94dce97398a69c9", - "shasum": "" - }, - "require": { - "dflydev/dot-access-data": "^1.1.0", - "php": ">=7.1.3", - "symfony/console": "^4|^5", - "symfony/finder": "^4|^5" - }, - "require-dev": { - "php-coveralls/php-coveralls": "^2.4.2", - "phpunit/phpunit": ">=7", - "squizlabs/php_codesniffer": "^3", - "symfony/var-dumper": "^4", - "symfony/yaml": "^4", - "yoast/phpunit-polyfills": "^0.2.0" - }, - "suggest": { - "symfony/var-dumper": "For using the var_dump formatter" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "4.x-dev" - } - }, - "autoload": { - "psr-4": { - "Consolidation\\OutputFormatters\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Greg Anderson", - "email": "greg.1.anderson@greenknowe.org" - } - ], - "description": "Format text by applying transformations provided by plug-in formatters.", - "time": "2020-12-12T19:04:59+00:00" - }, - { - "name": "consolidation/robo", - "version": "1.4.13", - "source": { - "type": "git", - "url": "https://github.com/consolidation/Robo.git", - "reference": "fd28dcca1b935950ece26e63541fbdeeb09f7343" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/consolidation/Robo/zipball/fd28dcca1b935950ece26e63541fbdeeb09f7343", - "reference": "fd28dcca1b935950ece26e63541fbdeeb09f7343", - "shasum": "" - }, - "require": { - "consolidation/annotated-command": "^2.12.1|^4.1", - "consolidation/config": "^1.2.1", - "consolidation/log": "^1.1.1|^2", - "consolidation/output-formatters": "^3.5.1|^4.1", - "consolidation/self-update": "^1.1.5", - "grasmash/yaml-expander": "^1.4", - "league/container": "^2.4.1", - "php": ">=5.5.0", - "symfony/console": "^2.8|^3|^4", - "symfony/event-dispatcher": "^2.5|^3|^4", - "symfony/filesystem": "^2.5|^3|^4", - "symfony/finder": "^2.5|^3|^4|^5", - "symfony/process": "^2.5|^3|^4" - }, - "replace": { - "codegyre/robo": "< 1.0" - }, - "require-dev": { - "g1a/composer-test-scenarios": "^3", - "natxet/cssmin": "3.0.4", - "patchwork/jsqueeze": "^2", - "pear/archive_tar": "^1.4.4", - "php-coveralls/php-coveralls": "^1", - "phpunit/phpunit": "^5.7.27", - "squizlabs/php_codesniffer": "^3" - }, - "suggest": { - "henrikbjorn/lurker": "For monitoring filesystem changes in taskWatch", - "natxet/CssMin": "For minifying CSS files in taskMinify", - "patchwork/jsqueeze": "For minifying JS files in taskMinify", - "pear/archive_tar": "Allows tar archives to be created and extracted in taskPack and taskExtract, respectively." - }, - "bin": [ - "robo" - ], - "type": "library", - "extra": { - "scenarios": { - "finder5": { - "require": { - "symfony/finder": "^5" - }, - "config": { - "platform": { - "php": "7.2.5" - } - } - }, - "symfony4": { - "require": { - "symfony/console": "^4" - }, - "config": { - "platform": { - "php": "7.1.3" - } - } - }, - "symfony2": { - "require": { - "symfony/console": "^2.8" - }, - "require-dev": { - "phpunit/phpunit": "^4.8.36" - }, - "remove": [ - "php-coveralls/php-coveralls" - ], - "config": { - "platform": { - "php": "5.5.9" - } - }, - "scenario-options": { - "create-lockfile": "false" - } - } - }, - "branch-alias": { - "dev-master": "1.x-dev" - } - }, - "autoload": { - "psr-4": { - "Robo\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Davert", - "email": "davert.php@resend.cc" - } - ], - "description": "Modern task runner", - "time": "2020-10-11T04:51:34+00:00" - }, - { - "name": "consolidation/self-update", - "version": "1.2.0", - "source": { - "type": "git", - "url": "https://github.com/consolidation/self-update.git", - "reference": "dba6b2c0708f20fa3ba8008a2353b637578849b4" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/consolidation/self-update/zipball/dba6b2c0708f20fa3ba8008a2353b637578849b4", - "reference": "dba6b2c0708f20fa3ba8008a2353b637578849b4", - "shasum": "" - }, - "require": { - "php": ">=5.5.0", - "symfony/console": "^2.8|^3|^4|^5", - "symfony/filesystem": "^2.5|^3|^4|^5" - }, - "bin": [ - "scripts/release" - ], - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.x-dev" - } - }, - "autoload": { - "psr-4": { - "SelfUpdate\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Alexander Menk", - "email": "menk@mestrona.net" - }, - { - "name": "Greg Anderson", - "email": "greg.1.anderson@greenknowe.org" - } - ], - "description": "Provides a self:update command for Symfony Console applications.", - "time": "2020-04-13T02:49:20+00:00" - }, - { - "name": "container-interop/container-interop", - "version": "1.2.0", - "source": { - "type": "git", - "url": "https://github.com/container-interop/container-interop.git", - "reference": "79cbf1341c22ec75643d841642dd5d6acd83bdb8" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/container-interop/container-interop/zipball/79cbf1341c22ec75643d841642dd5d6acd83bdb8", - "reference": "79cbf1341c22ec75643d841642dd5d6acd83bdb8", - "shasum": "" - }, - "require": { - "psr/container": "^1.0" - }, - "type": "library", - "autoload": { - "psr-4": { - "Interop\\Container\\": "src/Interop/Container/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "Promoting the interoperability of container objects (DIC, SL, etc.)", - "homepage": "https://github.com/container-interop/container-interop", - "abandoned": "psr/container", - "time": "2017-02-14T19:40:03+00:00" - }, - { - "name": "dflydev/dot-access-data", - "version": "v1.1.0", - "source": { - "type": "git", - "url": "https://github.com/dflydev/dflydev-dot-access-data.git", - "reference": "3fbd874921ab2c041e899d044585a2ab9795df8a" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/dflydev/dflydev-dot-access-data/zipball/3fbd874921ab2c041e899d044585a2ab9795df8a", - "reference": "3fbd874921ab2c041e899d044585a2ab9795df8a", - "shasum": "" - }, - "require": { - "php": ">=5.3.2" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0-dev" - } - }, - "autoload": { - "psr-0": { - "Dflydev\\DotAccessData": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Dragonfly Development Inc.", - "email": "info@dflydev.com", - "homepage": "http://dflydev.com" - }, - { - "name": "Beau Simensen", - "email": "beau@dflydev.com", - "homepage": "http://beausimensen.com" - }, - { - "name": "Carlos Frutos", - "email": "carlos@kiwing.it", - "homepage": "https://github.com/cfrutos" - } - ], - "description": "Given a deep data structure, access data by dot notation.", - "homepage": "https://github.com/dflydev/dflydev-dot-access-data", - "keywords": [ - "access", - "data", - "dot", - "notation" - ], - "time": "2017-01-20T21:14:22+00:00" + "time": "2021-05-05T19:37:51+00:00" }, { "name": "doctrine/annotations", - "version": "1.12.1", + "version": "1.13.1", "source": { "type": "git", "url": "https://github.com/doctrine/annotations.git", - "reference": "b17c5014ef81d212ac539f07a1001832df1b6d3b" + "reference": "e6e7b7d5b45a2f2abc5460cc6396480b2b1d321f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/annotations/zipball/b17c5014ef81d212ac539f07a1001832df1b6d3b", - "reference": "b17c5014ef81d212ac539f07a1001832df1b6d3b", + "url": "https://api.github.com/repos/doctrine/annotations/zipball/e6e7b7d5b45a2f2abc5460cc6396480b2b1d321f", + "reference": "e6e7b7d5b45a2f2abc5460cc6396480b2b1d321f", "shasum": "" }, "require": { "doctrine/lexer": "1.*", "ext-tokenizer": "*", - "php": "^7.1 || ^8.0" + "php": "^7.1 || ^8.0", + "psr/cache": "^1 || ^2 || ^3" }, "require-dev": { - "doctrine/cache": "1.*", + "doctrine/cache": "^1.11 || ^2.0", "doctrine/coding-standard": "^6.0 || ^8.1", "phpstan/phpstan": "^0.12.20", - "phpunit/phpunit": "^7.5 || ^9.1.5" + "phpunit/phpunit": "^7.5 || ^8.0 || ^9.1.5", + "symfony/cache": "^4.4 || ^5.2" }, "type": "library", "autoload": { @@ -4942,7 +6249,7 @@ "docblock", "parser" ], - "time": "2021-02-21T21:00:45+00:00" + "time": "2021-05-16T18:07:53+00:00" }, { "name": "doctrine/instantiator", @@ -5086,78 +6393,82 @@ "time": "2020-05-25T17:44:05+00:00" }, { - "name": "facebook/webdriver", - "version": "1.7.1", + "name": "fakerphp/faker", + "version": "v1.14.1", "source": { "type": "git", - "url": "https://github.com/php-webdriver/php-webdriver-archive.git", - "reference": "e43de70f3c7166169d0f14a374505392734160e5" + "url": "https://github.com/FakerPHP/Faker.git", + "reference": "ed22aee8d17c7b396f74a58b1e7fefa4f90d5ef1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-webdriver/php-webdriver-archive/zipball/e43de70f3c7166169d0f14a374505392734160e5", - "reference": "e43de70f3c7166169d0f14a374505392734160e5", + "url": "https://api.github.com/repos/FakerPHP/Faker/zipball/ed22aee8d17c7b396f74a58b1e7fefa4f90d5ef1", + "reference": "ed22aee8d17c7b396f74a58b1e7fefa4f90d5ef1", "shasum": "" }, "require": { - "ext-curl": "*", - "ext-json": "*", - "ext-mbstring": "*", - "ext-zip": "*", - "php": "^5.6 || ~7.0", - "symfony/process": "^2.8 || ^3.1 || ^4.0" + "php": "^7.1 || ^8.0", + "psr/container": "^1.0", + "symfony/deprecation-contracts": "^2.2" + }, + "conflict": { + "fzaninotto/faker": "*" }, "require-dev": { - "friendsofphp/php-cs-fixer": "^2.0", - "jakub-onderka/php-parallel-lint": "^0.9.2", - "php-coveralls/php-coveralls": "^2.0", - "php-mock/php-mock-phpunit": "^1.1", - "phpunit/phpunit": "^5.7", - "sebastian/environment": "^1.3.4 || ^2.0 || ^3.0", - "squizlabs/php_codesniffer": "^2.6", - "symfony/var-dumper": "^3.3 || ^4.0" + "bamarni/composer-bin-plugin": "^1.4.1", + "ext-intl": "*", + "symfony/phpunit-bridge": "^4.4 || ^5.2" }, "suggest": { - "ext-SimpleXML": "For Firefox profile creation" + "ext-curl": "Required by Faker\\Provider\\Image to download images.", + "ext-dom": "Required by Faker\\Provider\\HtmlLorem for generating random HTML.", + "ext-iconv": "Required by Faker\\Provider\\ru_RU\\Text::realText() for generating real Russian text.", + "ext-mbstring": "Required for multibyte Unicode string functionality." }, "type": "library", "extra": { "branch-alias": { - "dev-community": "1.5-dev" + "dev-main": "v1.15-dev" } }, "autoload": { "psr-4": { - "Facebook\\WebDriver\\": "lib/" + "Faker\\": "src/Faker/" } }, "notification-url": "https://packagist.org/downloads/", "license": [ - "Apache-2.0" + "MIT" ], - "description": "A PHP client for Selenium WebDriver", - "homepage": "https://github.com/facebook/php-webdriver", + "authors": [ + { + "name": "François Zaninotto" + } + ], + "description": "Faker is a PHP library that generates fake data for you.", "keywords": [ - "facebook", - "php", - "selenium", - "webdriver" + "data", + "faker", + "fixtures" ], - "abandoned": "php-webdriver/webdriver", - "time": "2019-06-13T08:02:18+00:00" + "support": { + "issues": "https://github.com/FakerPHP/Faker/issues", + "source": "https://github.com/FakerPHP/Faker/tree/v.1.14.1" + }, + "time": "2021-03-30T06:27:33+00:00" }, { "name": "filp/whoops", - "version": "2.12.0", + "version": "2.13.0", "source": { "type": "git", "url": "https://github.com/filp/whoops.git", - "reference": "d501fd2658d55491a2295ff600ae5978eaad7403" + "reference": "2edbc73a4687d9085c8f20f398eebade844e8424" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/filp/whoops/zipball/d501fd2658d55491a2295ff600ae5978eaad7403", - "reference": "d501fd2658d55491a2295ff600ae5978eaad7403", + "url": "https://api.github.com/repos/filp/whoops/zipball/2edbc73a4687d9085c8f20f398eebade844e8424", + "reference": "2edbc73a4687d9085c8f20f398eebade844e8424", "shasum": "" }, "require": { @@ -5211,67 +6522,25 @@ "type": "github" } ], - "time": "2021-03-30T12:00:00+00:00" - }, - { - "name": "flow/jsonpath", - "version": "0.4.0", - "source": { - "type": "git", - "url": "https://github.com/FlowCommunications/JSONPath.git", - "reference": "f0222818d5c938e4ab668ab2e2c079bd51a27112" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/FlowCommunications/JSONPath/zipball/f0222818d5c938e4ab668ab2e2c079bd51a27112", - "reference": "f0222818d5c938e4ab668ab2e2c079bd51a27112", - "shasum": "" - }, - "require": { - "php": ">=5.4.0" - }, - "require-dev": { - "peekmo/jsonpath": "dev-master", - "phpunit/phpunit": "^4.0" - }, - "type": "library", - "autoload": { - "psr-0": { - "Flow\\JSONPath": "src/", - "Flow\\JSONPath\\Test": "tests/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Stephen Frank", - "email": "stephen@flowsa.com" - } - ], - "description": "JSONPath implementation for parsing, searching and flattening arrays", - "abandoned": "softcreatr/jsonpath", - "time": "2018-03-04T16:39:47+00:00" + "time": "2021-06-04T12:00:00+00:00" }, { "name": "friendsofphp/php-cs-fixer", - "version": "v2.18.4", + "version": "v2.19.0", "source": { "type": "git", "url": "https://github.com/FriendsOfPHP/PHP-CS-Fixer.git", - "reference": "06f764e3cb6d60822d8f5135205f9d32b5508a31" + "reference": "d5b8a9d852b292c2f8a035200fa6844b1f82300b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/zipball/06f764e3cb6d60822d8f5135205f9d32b5508a31", - "reference": "06f764e3cb6d60822d8f5135205f9d32b5508a31", + "url": "https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/zipball/d5b8a9d852b292c2f8a035200fa6844b1f82300b", + "reference": "d5b8a9d852b292c2f8a035200fa6844b1f82300b", "shasum": "" }, "require": { "composer/semver": "^1.4 || ^2.0 || ^3.0", - "composer/xdebug-handler": "^1.2", + "composer/xdebug-handler": "^1.2 || ^2.0", "doctrine/annotations": "^1.2", "ext-json": "*", "ext-tokenizer": "*", @@ -5314,6 +6583,11 @@ "php-cs-fixer" ], "type": "application", + "extra": { + "branch-alias": { + "dev-master": "2.19-dev" + } + }, "autoload": { "psr-4": { "PhpCsFixer\\": "src/" @@ -5353,153 +6627,7 @@ "type": "github" } ], - "time": "2021-03-20T14:52:33+00:00" - }, - { - "name": "fzaninotto/faker", - "version": "v1.9.2", - "source": { - "type": "git", - "url": "https://github.com/fzaninotto/Faker.git", - "reference": "848d8125239d7dbf8ab25cb7f054f1a630e68c2e" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/fzaninotto/Faker/zipball/848d8125239d7dbf8ab25cb7f054f1a630e68c2e", - "reference": "848d8125239d7dbf8ab25cb7f054f1a630e68c2e", - "shasum": "" - }, - "require": { - "php": "^5.3.3 || ^7.0" - }, - "require-dev": { - "ext-intl": "*", - "phpunit/phpunit": "^4.8.35 || ^5.7", - "squizlabs/php_codesniffer": "^2.9.2" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.9-dev" - } - }, - "autoload": { - "psr-4": { - "Faker\\": "src/Faker/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "François Zaninotto" - } - ], - "description": "Faker is a PHP library that generates fake data for you.", - "keywords": [ - "data", - "faker", - "fixtures" - ], - "abandoned": true, - "time": "2020-12-11T09:56:16+00:00" - }, - { - "name": "grasmash/expander", - "version": "1.0.0", - "source": { - "type": "git", - "url": "https://github.com/grasmash/expander.git", - "reference": "95d6037344a4be1dd5f8e0b0b2571a28c397578f" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/grasmash/expander/zipball/95d6037344a4be1dd5f8e0b0b2571a28c397578f", - "reference": "95d6037344a4be1dd5f8e0b0b2571a28c397578f", - "shasum": "" - }, - "require": { - "dflydev/dot-access-data": "^1.1.0", - "php": ">=5.4" - }, - "require-dev": { - "greg-1-anderson/composer-test-scenarios": "^1", - "phpunit/phpunit": "^4|^5.5.4", - "satooshi/php-coveralls": "^1.0.2|dev-master", - "squizlabs/php_codesniffer": "^2.7" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.x-dev" - } - }, - "autoload": { - "psr-4": { - "Grasmash\\Expander\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Matthew Grasmick" - } - ], - "description": "Expands internal property references in PHP arrays file.", - "time": "2017-12-21T22:14:55+00:00" - }, - { - "name": "grasmash/yaml-expander", - "version": "1.4.0", - "source": { - "type": "git", - "url": "https://github.com/grasmash/yaml-expander.git", - "reference": "3f0f6001ae707a24f4d9733958d77d92bf9693b1" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/grasmash/yaml-expander/zipball/3f0f6001ae707a24f4d9733958d77d92bf9693b1", - "reference": "3f0f6001ae707a24f4d9733958d77d92bf9693b1", - "shasum": "" - }, - "require": { - "dflydev/dot-access-data": "^1.1.0", - "php": ">=5.4", - "symfony/yaml": "^2.8.11|^3|^4" - }, - "require-dev": { - "greg-1-anderson/composer-test-scenarios": "^1", - "phpunit/phpunit": "^4.8|^5.5.4", - "satooshi/php-coveralls": "^1.0.2|dev-master", - "squizlabs/php_codesniffer": "^2.7" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.x-dev" - } - }, - "autoload": { - "psr-4": { - "Grasmash\\YamlExpander\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Matthew Grasmick" - } - ], - "description": "Expands internal property references in a yaml file.", - "time": "2017-12-16T16:06:03+00:00" + "time": "2021-05-03T21:43:24+00:00" }, { "name": "hamcrest/hamcrest-php", @@ -5548,555 +6676,6 @@ ], "time": "2020-07-09T08:09:16+00:00" }, - { - "name": "hoa/consistency", - "version": "1.17.05.02", - "source": { - "type": "git", - "url": "https://github.com/hoaproject/Consistency.git", - "reference": "fd7d0adc82410507f332516faf655b6ed22e4c2f" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/hoaproject/Consistency/zipball/fd7d0adc82410507f332516faf655b6ed22e4c2f", - "reference": "fd7d0adc82410507f332516faf655b6ed22e4c2f", - "shasum": "" - }, - "require": { - "hoa/exception": "~1.0", - "php": ">=5.5.0" - }, - "require-dev": { - "hoa/stream": "~1.0", - "hoa/test": "~2.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.x-dev" - } - }, - "autoload": { - "psr-4": { - "Hoa\\Consistency\\": "." - }, - "files": [ - "Prelude.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Ivan Enderlin", - "email": "ivan.enderlin@hoa-project.net" - }, - { - "name": "Hoa community", - "homepage": "https://hoa-project.net/" - } - ], - "description": "The Hoa\\Consistency library.", - "homepage": "https://hoa-project.net/", - "keywords": [ - "autoloader", - "callable", - "consistency", - "entity", - "flex", - "keyword", - "library" - ], - "time": "2017-05-02T12:18:12+00:00" - }, - { - "name": "hoa/console", - "version": "3.17.05.02", - "source": { - "type": "git", - "url": "https://github.com/hoaproject/Console.git", - "reference": "e231fd3ea70e6d773576ae78de0bdc1daf331a66" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/hoaproject/Console/zipball/e231fd3ea70e6d773576ae78de0bdc1daf331a66", - "reference": "e231fd3ea70e6d773576ae78de0bdc1daf331a66", - "shasum": "" - }, - "require": { - "hoa/consistency": "~1.0", - "hoa/event": "~1.0", - "hoa/exception": "~1.0", - "hoa/file": "~1.0", - "hoa/protocol": "~1.0", - "hoa/stream": "~1.0", - "hoa/ustring": "~4.0" - }, - "require-dev": { - "hoa/test": "~2.0" - }, - "suggest": { - "ext-pcntl": "To enable hoa://Event/Console/Window:resize.", - "hoa/dispatcher": "To use the console kit.", - "hoa/router": "To use the console kit." - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.x-dev" - } - }, - "autoload": { - "psr-4": { - "Hoa\\Console\\": "." - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Ivan Enderlin", - "email": "ivan.enderlin@hoa-project.net" - }, - { - "name": "Hoa community", - "homepage": "https://hoa-project.net/" - } - ], - "description": "The Hoa\\Console library.", - "homepage": "https://hoa-project.net/", - "keywords": [ - "autocompletion", - "chrome", - "cli", - "console", - "cursor", - "getoption", - "library", - "option", - "parser", - "processus", - "readline", - "terminfo", - "tput", - "window" - ], - "time": "2017-05-02T12:26:19+00:00" - }, - { - "name": "hoa/event", - "version": "1.17.01.13", - "source": { - "type": "git", - "url": "https://github.com/hoaproject/Event.git", - "reference": "6c0060dced212ffa3af0e34bb46624f990b29c54" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/hoaproject/Event/zipball/6c0060dced212ffa3af0e34bb46624f990b29c54", - "reference": "6c0060dced212ffa3af0e34bb46624f990b29c54", - "shasum": "" - }, - "require": { - "hoa/consistency": "~1.0", - "hoa/exception": "~1.0" - }, - "require-dev": { - "hoa/test": "~2.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.x-dev" - } - }, - "autoload": { - "psr-4": { - "Hoa\\Event\\": "." - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Ivan Enderlin", - "email": "ivan.enderlin@hoa-project.net" - }, - { - "name": "Hoa community", - "homepage": "https://hoa-project.net/" - } - ], - "description": "The Hoa\\Event library.", - "homepage": "https://hoa-project.net/", - "keywords": [ - "event", - "library", - "listener", - "observer" - ], - "time": "2017-01-13T15:30:50+00:00" - }, - { - "name": "hoa/exception", - "version": "1.17.01.16", - "source": { - "type": "git", - "url": "https://github.com/hoaproject/Exception.git", - "reference": "091727d46420a3d7468ef0595651488bfc3a458f" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/hoaproject/Exception/zipball/091727d46420a3d7468ef0595651488bfc3a458f", - "reference": "091727d46420a3d7468ef0595651488bfc3a458f", - "shasum": "" - }, - "require": { - "hoa/consistency": "~1.0", - "hoa/event": "~1.0" - }, - "require-dev": { - "hoa/test": "~2.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.x-dev" - } - }, - "autoload": { - "psr-4": { - "Hoa\\Exception\\": "." - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Ivan Enderlin", - "email": "ivan.enderlin@hoa-project.net" - }, - { - "name": "Hoa community", - "homepage": "https://hoa-project.net/" - } - ], - "description": "The Hoa\\Exception library.", - "homepage": "https://hoa-project.net/", - "keywords": [ - "exception", - "library" - ], - "time": "2017-01-16T07:53:27+00:00" - }, - { - "name": "hoa/file", - "version": "1.17.07.11", - "source": { - "type": "git", - "url": "https://github.com/hoaproject/File.git", - "reference": "35cb979b779bc54918d2f9a4e02ed6c7a1fa67ca" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/hoaproject/File/zipball/35cb979b779bc54918d2f9a4e02ed6c7a1fa67ca", - "reference": "35cb979b779bc54918d2f9a4e02ed6c7a1fa67ca", - "shasum": "" - }, - "require": { - "hoa/consistency": "~1.0", - "hoa/event": "~1.0", - "hoa/exception": "~1.0", - "hoa/iterator": "~2.0", - "hoa/stream": "~1.0" - }, - "require-dev": { - "hoa/test": "~2.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.x-dev" - } - }, - "autoload": { - "psr-4": { - "Hoa\\File\\": "." - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Ivan Enderlin", - "email": "ivan.enderlin@hoa-project.net" - }, - { - "name": "Hoa community", - "homepage": "https://hoa-project.net/" - } - ], - "description": "The Hoa\\File library.", - "homepage": "https://hoa-project.net/", - "keywords": [ - "Socket", - "directory", - "file", - "finder", - "library", - "link", - "temporary" - ], - "time": "2017-07-11T07:42:15+00:00" - }, - { - "name": "hoa/iterator", - "version": "2.17.01.10", - "source": { - "type": "git", - "url": "https://github.com/hoaproject/Iterator.git", - "reference": "d1120ba09cb4ccd049c86d10058ab94af245f0cc" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/hoaproject/Iterator/zipball/d1120ba09cb4ccd049c86d10058ab94af245f0cc", - "reference": "d1120ba09cb4ccd049c86d10058ab94af245f0cc", - "shasum": "" - }, - "require": { - "hoa/consistency": "~1.0", - "hoa/exception": "~1.0" - }, - "require-dev": { - "hoa/test": "~2.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.x-dev" - } - }, - "autoload": { - "psr-4": { - "Hoa\\Iterator\\": "." - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Ivan Enderlin", - "email": "ivan.enderlin@hoa-project.net" - }, - { - "name": "Hoa community", - "homepage": "https://hoa-project.net/" - } - ], - "description": "The Hoa\\Iterator library.", - "homepage": "https://hoa-project.net/", - "keywords": [ - "iterator", - "library" - ], - "time": "2017-01-10T10:34:47+00:00" - }, - { - "name": "hoa/protocol", - "version": "1.17.01.14", - "source": { - "type": "git", - "url": "https://github.com/hoaproject/Protocol.git", - "reference": "5c2cf972151c45f373230da170ea015deecf19e2" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/hoaproject/Protocol/zipball/5c2cf972151c45f373230da170ea015deecf19e2", - "reference": "5c2cf972151c45f373230da170ea015deecf19e2", - "shasum": "" - }, - "require": { - "hoa/consistency": "~1.0", - "hoa/exception": "~1.0" - }, - "require-dev": { - "hoa/test": "~2.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.x-dev" - } - }, - "autoload": { - "psr-4": { - "Hoa\\Protocol\\": "." - }, - "files": [ - "Wrapper.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Ivan Enderlin", - "email": "ivan.enderlin@hoa-project.net" - }, - { - "name": "Hoa community", - "homepage": "https://hoa-project.net/" - } - ], - "description": "The Hoa\\Protocol library.", - "homepage": "https://hoa-project.net/", - "keywords": [ - "library", - "protocol", - "resource", - "stream", - "wrapper" - ], - "time": "2017-01-14T12:26:10+00:00" - }, - { - "name": "hoa/stream", - "version": "1.17.02.21", - "source": { - "type": "git", - "url": "https://github.com/hoaproject/Stream.git", - "reference": "3293cfffca2de10525df51436adf88a559151d82" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/hoaproject/Stream/zipball/3293cfffca2de10525df51436adf88a559151d82", - "reference": "3293cfffca2de10525df51436adf88a559151d82", - "shasum": "" - }, - "require": { - "hoa/consistency": "~1.0", - "hoa/event": "~1.0", - "hoa/exception": "~1.0", - "hoa/protocol": "~1.0" - }, - "require-dev": { - "hoa/test": "~2.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.x-dev" - } - }, - "autoload": { - "psr-4": { - "Hoa\\Stream\\": "." - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Ivan Enderlin", - "email": "ivan.enderlin@hoa-project.net" - }, - { - "name": "Hoa community", - "homepage": "https://hoa-project.net/" - } - ], - "description": "The Hoa\\Stream library.", - "homepage": "https://hoa-project.net/", - "keywords": [ - "Context", - "bucket", - "composite", - "filter", - "in", - "library", - "out", - "protocol", - "stream", - "wrapper" - ], - "time": "2017-02-21T16:01:06+00:00" - }, - { - "name": "hoa/ustring", - "version": "4.17.01.16", - "source": { - "type": "git", - "url": "https://github.com/hoaproject/Ustring.git", - "reference": "e6326e2739178799b1fe3fdd92029f9517fa17a0" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/hoaproject/Ustring/zipball/e6326e2739178799b1fe3fdd92029f9517fa17a0", - "reference": "e6326e2739178799b1fe3fdd92029f9517fa17a0", - "shasum": "" - }, - "require": { - "hoa/consistency": "~1.0", - "hoa/exception": "~1.0" - }, - "require-dev": { - "hoa/test": "~2.0" - }, - "suggest": { - "ext-iconv": "ext/iconv must be present (or a third implementation) to use Hoa\\Ustring::transcode().", - "ext-intl": "To get a better Hoa\\Ustring::toAscii() and Hoa\\Ustring::compareTo()." - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "4.x-dev" - } - }, - "autoload": { - "psr-4": { - "Hoa\\Ustring\\": "." - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Ivan Enderlin", - "email": "ivan.enderlin@hoa-project.net" - }, - { - "name": "Hoa community", - "homepage": "https://hoa-project.net/" - } - ], - "description": "The Hoa\\Ustring library.", - "homepage": "https://hoa-project.net/", - "keywords": [ - "library", - "search", - "string", - "unicode" - ], - "time": "2017-01-16T07:08:25+00:00" - }, { "name": "jeroendesloovere/vcard", "version": "1.5.0", @@ -6146,132 +6725,6 @@ ], "time": "2017-06-27T11:49:49+00:00" }, - { - "name": "leafo/scssphp", - "version": "v0.7.8", - "source": { - "type": "git", - "url": "https://github.com/leafo/scssphp.git", - "reference": "a384906af3d078e98b089d7d36f6ceab8703f7ff" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/leafo/scssphp/zipball/a384906af3d078e98b089d7d36f6ceab8703f7ff", - "reference": "a384906af3d078e98b089d7d36f6ceab8703f7ff", - "shasum": "" - }, - "require": { - "php": ">=5.4.0" - }, - "require-dev": { - "phpunit/phpunit": "~4.6", - "squizlabs/php_codesniffer": "~2.5" - }, - "bin": [ - "bin/pscss" - ], - "type": "library", - "autoload": { - "psr-4": { - "Leafo\\ScssPhp\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Leaf Corcoran", - "email": "leafot@gmail.com", - "homepage": "http://leafo.net" - } - ], - "description": "scssphp is a compiler for SCSS written in PHP.", - "homepage": "http://leafo.github.io/scssphp/", - "keywords": [ - "css", - "less", - "sass", - "scss", - "stylesheet" - ], - "abandoned": "scssphp/scssphp", - "time": "2019-04-24T18:10:10+00:00" - }, - { - "name": "league/container", - "version": "2.5.0", - "source": { - "type": "git", - "url": "https://github.com/thephpleague/container.git", - "reference": "8438dc47a0674e3378bcce893a0a04d79a2c22b3" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/thephpleague/container/zipball/8438dc47a0674e3378bcce893a0a04d79a2c22b3", - "reference": "8438dc47a0674e3378bcce893a0a04d79a2c22b3", - "shasum": "" - }, - "require": { - "container-interop/container-interop": "^1.2", - "php": "^5.4 || ^7.0 || ^8.0" - }, - "provide": { - "container-interop/container-interop-implementation": "^1.2", - "psr/container-implementation": "^1.0" - }, - "replace": { - "orno/di": "~2.0" - }, - "require-dev": { - "phpunit/phpunit": "^4.8.36", - "scrutinizer/ocular": "^1.3", - "squizlabs/php_codesniffer": "^3.5" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-2.x": "2.x-dev", - "dev-1.x": "1.x-dev" - } - }, - "autoload": { - "psr-4": { - "League\\Container\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Phil Bennett", - "email": "philipobenito@gmail.com", - "homepage": "http://www.philipobenito.com", - "role": "Developer" - } - ], - "description": "A fast and intuitive dependency injection container.", - "homepage": "https://github.com/thephpleague/container", - "keywords": [ - "container", - "dependency", - "di", - "injection", - "league", - "provider", - "service" - ], - "funding": [ - { - "url": "https://github.com/philipobenito", - "type": "github" - } - ], - "time": "2021-02-22T09:20:06+00:00" - }, { "name": "mikey179/vfsstream", "version": "v1.6.8", @@ -6320,30 +6773,33 @@ }, { "name": "mockery/mockery", - "version": "1.3.4", + "version": "1.4.3", "source": { "type": "git", "url": "https://github.com/mockery/mockery.git", - "reference": "31467aeb3ca3188158613322d66df81cedd86626" + "reference": "d1339f64479af1bee0e82a0413813fe5345a54ea" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/mockery/mockery/zipball/31467aeb3ca3188158613322d66df81cedd86626", - "reference": "31467aeb3ca3188158613322d66df81cedd86626", + "url": "https://api.github.com/repos/mockery/mockery/zipball/d1339f64479af1bee0e82a0413813fe5345a54ea", + "reference": "d1339f64479af1bee0e82a0413813fe5345a54ea", "shasum": "" }, "require": { "hamcrest/hamcrest-php": "^2.0.1", "lib-pcre": ">=7.0", - "php": ">=5.6.0" + "php": "^7.3 || ^8.0" + }, + "conflict": { + "phpunit/phpunit": "<8.0" }, "require-dev": { - "phpunit/phpunit": "^5.7.10|^6.5|^7.5|^8.5|^9.3" + "phpunit/phpunit": "^8.5 || ^9.3" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.3.x-dev" + "dev-master": "1.4.x-dev" } }, "autoload": { @@ -6381,7 +6837,7 @@ "test double", "testing" ], - "time": "2021-02-24T09:51:00+00:00" + "time": "2021-02-24T09:51:49+00:00" }, { "name": "myclabs/deep-copy", @@ -6437,6 +6893,58 @@ ], "time": "2020-11-13T09:40:50+00:00" }, + { + "name": "nikic/php-parser", + "version": "v4.10.5", + "source": { + "type": "git", + "url": "https://github.com/nikic/PHP-Parser.git", + "reference": "4432ba399e47c66624bc73c8c0f811e5c109576f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/4432ba399e47c66624bc73c8c0f811e5c109576f", + "reference": "4432ba399e47c66624bc73c8c0f811e5c109576f", + "shasum": "" + }, + "require": { + "ext-tokenizer": "*", + "php": ">=7.0" + }, + "require-dev": { + "ircmaxell/php-yacc": "^0.0.7", + "phpunit/phpunit": "^6.5 || ^7.0 || ^8.0 || ^9.0" + }, + "bin": [ + "bin/php-parse" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.9-dev" + } + }, + "autoload": { + "psr-4": { + "PhpParser\\": "lib/PhpParser" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Nikita Popov" + } + ], + "description": "A PHP parser written in PHP", + "keywords": [ + "parser", + "php" + ], + "time": "2021-05-03T19:11:20+00:00" + }, { "name": "phar-io/manifest", "version": "2.0.1", @@ -6591,6 +7099,68 @@ ], "time": "2020-10-14T08:39:05+00:00" }, + { + "name": "php-webdriver/webdriver", + "version": "1.11.1", + "source": { + "type": "git", + "url": "https://github.com/php-webdriver/php-webdriver.git", + "reference": "da16e39968f8dd5cfb7d07eef91dc2b731c69880" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-webdriver/php-webdriver/zipball/da16e39968f8dd5cfb7d07eef91dc2b731c69880", + "reference": "da16e39968f8dd5cfb7d07eef91dc2b731c69880", + "shasum": "" + }, + "require": { + "ext-curl": "*", + "ext-json": "*", + "ext-zip": "*", + "php": "^5.6 || ~7.0 || ^8.0", + "symfony/polyfill-mbstring": "^1.12", + "symfony/process": "^2.8 || ^3.1 || ^4.0 || ^5.0" + }, + "replace": { + "facebook/webdriver": "*" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "^2.0", + "ondram/ci-detector": "^2.1 || ^3.5 || ^4.0", + "php-coveralls/php-coveralls": "^2.4", + "php-mock/php-mock-phpunit": "^1.1 || ^2.0", + "php-parallel-lint/php-parallel-lint": "^1.2", + "phpunit/phpunit": "^5.7 || ^7 || ^8 || ^9", + "squizlabs/php_codesniffer": "^3.5", + "symfony/var-dumper": "^3.3 || ^4.0 || ^5.0" + }, + "suggest": { + "ext-SimpleXML": "For Firefox profile creation" + }, + "type": "library", + "autoload": { + "psr-4": { + "Facebook\\WebDriver\\": "lib/" + }, + "files": [ + "lib/Exception/TimeoutException.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "A PHP client for Selenium WebDriver. Previously facebook/webdriver.", + "homepage": "https://github.com/php-webdriver/php-webdriver", + "keywords": [ + "Chromedriver", + "geckodriver", + "php", + "selenium", + "webdriver" + ], + "time": "2021-05-21T15:12:49+00:00" + }, { "name": "phpdocumentor/reflection-common", "version": "2.2.0", @@ -6802,40 +7372,44 @@ }, { "name": "phpunit/php-code-coverage", - "version": "7.0.14", + "version": "9.2.6", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "bb7c9a210c72e4709cdde67f8b7362f672f2225c" + "reference": "f6293e1b30a2354e8428e004689671b83871edde" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/bb7c9a210c72e4709cdde67f8b7362f672f2225c", - "reference": "bb7c9a210c72e4709cdde67f8b7362f672f2225c", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/f6293e1b30a2354e8428e004689671b83871edde", + "reference": "f6293e1b30a2354e8428e004689671b83871edde", "shasum": "" }, "require": { "ext-dom": "*", + "ext-libxml": "*", "ext-xmlwriter": "*", - "php": ">=7.2", - "phpunit/php-file-iterator": "^2.0.2", - "phpunit/php-text-template": "^1.2.1", - "phpunit/php-token-stream": "^3.1.1 || ^4.0", - "sebastian/code-unit-reverse-lookup": "^1.0.1", - "sebastian/environment": "^4.2.2", - "sebastian/version": "^2.0.1", - "theseer/tokenizer": "^1.1.3" + "nikic/php-parser": "^4.10.2", + "php": ">=7.3", + "phpunit/php-file-iterator": "^3.0.3", + "phpunit/php-text-template": "^2.0.2", + "sebastian/code-unit-reverse-lookup": "^2.0.2", + "sebastian/complexity": "^2.0", + "sebastian/environment": "^5.1.2", + "sebastian/lines-of-code": "^1.0.3", + "sebastian/version": "^3.0.1", + "theseer/tokenizer": "^1.2.0" }, "require-dev": { - "phpunit/phpunit": "^8.2.2" + "phpunit/phpunit": "^9.3" }, "suggest": { - "ext-xdebug": "^2.7.2" + "ext-pcov": "*", + "ext-xdebug": "*" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "7.0-dev" + "dev-master": "9.2-dev" } }, "autoload": { @@ -6867,32 +7441,32 @@ "type": "github" } ], - "time": "2020-12-02T13:39:03+00:00" + "time": "2021-03-28T07:26:59+00:00" }, { "name": "phpunit/php-file-iterator", - "version": "2.0.3", + "version": "3.0.5", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-file-iterator.git", - "reference": "4b49fb70f067272b659ef0174ff9ca40fdaa6357" + "reference": "aa4be8575f26070b100fccb67faabb28f21f66f8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/4b49fb70f067272b659ef0174ff9ca40fdaa6357", - "reference": "4b49fb70f067272b659ef0174ff9ca40fdaa6357", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/aa4be8575f26070b100fccb67faabb28f21f66f8", + "reference": "aa4be8575f26070b100fccb67faabb28f21f66f8", "shasum": "" }, "require": { - "php": ">=7.1" + "php": ">=7.3" }, "require-dev": { - "phpunit/phpunit": "^8.5" + "phpunit/phpunit": "^9.3" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0.x-dev" + "dev-master": "3.0-dev" } }, "autoload": { @@ -6923,26 +7497,93 @@ "type": "github" } ], - "time": "2020-11-30T08:25:21+00:00" + "time": "2020-09-28T05:57:25+00:00" }, { - "name": "phpunit/php-text-template", - "version": "1.2.1", + "name": "phpunit/php-invoker", + "version": "3.1.1", "source": { "type": "git", - "url": "https://github.com/sebastianbergmann/php-text-template.git", - "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686" + "url": "https://github.com/sebastianbergmann/php-invoker.git", + "reference": "5a10147d0aaf65b58940a0b72f71c9ac0423cc67" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/31f8b717e51d9a2afca6c9f046f5d69fc27c8686", - "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686", + "url": "https://api.github.com/repos/sebastianbergmann/php-invoker/zipball/5a10147d0aaf65b58940a0b72f71c9ac0423cc67", + "reference": "5a10147d0aaf65b58940a0b72f71c9ac0423cc67", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": ">=7.3" + }, + "require-dev": { + "ext-pcntl": "*", + "phpunit/phpunit": "^9.3" + }, + "suggest": { + "ext-pcntl": "*" }, "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.1-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Invoke callables with a timeout", + "homepage": "https://github.com/sebastianbergmann/php-invoker/", + "keywords": [ + "process" + ], + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-09-28T05:58:55+00:00" + }, + { + "name": "phpunit/php-text-template", + "version": "2.0.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-text-template.git", + "reference": "5da5f67fc95621df9ff4c4e5a84d6a8a2acf7c28" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/5da5f67fc95621df9ff4c4e5a84d6a8a2acf7c28", + "reference": "5da5f67fc95621df9ff4c4e5a84d6a8a2acf7c28", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, "autoload": { "classmap": [ "src/" @@ -6964,32 +7605,38 @@ "keywords": [ "template" ], - "time": "2015-06-21T13:50:34+00:00" + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-10-26T05:33:50+00:00" }, { "name": "phpunit/php-timer", - "version": "2.1.3", + "version": "5.0.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-timer.git", - "reference": "2454ae1765516d20c4ffe103d85a58a9a3bd5662" + "reference": "5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/2454ae1765516d20c4ffe103d85a58a9a3bd5662", - "reference": "2454ae1765516d20c4ffe103d85a58a9a3bd5662", + "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2", + "reference": "5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2", "shasum": "" }, "require": { - "php": ">=7.1" + "php": ">=7.3" }, "require-dev": { - "phpunit/phpunit": "^8.5" + "phpunit/phpunit": "^9.3" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.1-dev" + "dev-master": "5.0-dev" } }, "autoload": { @@ -7019,76 +7666,20 @@ "type": "github" } ], - "time": "2020-11-30T08:20:02+00:00" - }, - { - "name": "phpunit/php-token-stream", - "version": "3.1.2", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-token-stream.git", - "reference": "472b687829041c24b25f475e14c2f38a09edf1c2" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/472b687829041c24b25f475e14c2f38a09edf1c2", - "reference": "472b687829041c24b25f475e14c2f38a09edf1c2", - "shasum": "" - }, - "require": { - "ext-tokenizer": "*", - "php": ">=7.1" - }, - "require-dev": { - "phpunit/phpunit": "^7.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.1-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Wrapper around PHP's tokenizer extension.", - "homepage": "https://github.com/sebastianbergmann/php-token-stream/", - "keywords": [ - "tokenizer" - ], - "funding": [ - { - "url": "https://github.com/sebastianbergmann", - "type": "github" - } - ], - "abandoned": true, - "time": "2020-11-30T08:38:46+00:00" + "time": "2020-10-26T13:16:10+00:00" }, { "name": "phpunit/phpunit", - "version": "8.5.15", + "version": "9.5.5", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "038d4196d8e8cb405cd5e82cedfe413ad6eef9ef" + "reference": "89ff45ea9d70e35522fb6654a2ebc221158de276" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/038d4196d8e8cb405cd5e82cedfe413ad6eef9ef", - "reference": "038d4196d8e8cb405cd5e82cedfe413ad6eef9ef", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/89ff45ea9d70e35522fb6654a2ebc221158de276", + "reference": "89ff45ea9d70e35522fb6654a2ebc221158de276", "shasum": "" }, "require": { @@ -7099,32 +7690,35 @@ "ext-mbstring": "*", "ext-xml": "*", "ext-xmlwriter": "*", - "myclabs/deep-copy": "^1.10.0", + "myclabs/deep-copy": "^1.10.1", "phar-io/manifest": "^2.0.1", "phar-io/version": "^3.0.2", - "php": ">=7.2", - "phpspec/prophecy": "^1.10.3", - "phpunit/php-code-coverage": "^7.0.12", - "phpunit/php-file-iterator": "^2.0.2", - "phpunit/php-text-template": "^1.2.1", - "phpunit/php-timer": "^2.1.2", - "sebastian/comparator": "^3.0.2", - "sebastian/diff": "^3.0.2", - "sebastian/environment": "^4.2.3", - "sebastian/exporter": "^3.1.2", - "sebastian/global-state": "^3.0.0", - "sebastian/object-enumerator": "^3.0.3", - "sebastian/resource-operations": "^2.0.1", - "sebastian/type": "^1.1.3", - "sebastian/version": "^2.0.1" + "php": ">=7.3", + "phpspec/prophecy": "^1.12.1", + "phpunit/php-code-coverage": "^9.2.3", + "phpunit/php-file-iterator": "^3.0.5", + "phpunit/php-invoker": "^3.1.1", + "phpunit/php-text-template": "^2.0.3", + "phpunit/php-timer": "^5.0.2", + "sebastian/cli-parser": "^1.0.1", + "sebastian/code-unit": "^1.0.6", + "sebastian/comparator": "^4.0.5", + "sebastian/diff": "^4.0.3", + "sebastian/environment": "^5.1.3", + "sebastian/exporter": "^4.0.3", + "sebastian/global-state": "^5.0.1", + "sebastian/object-enumerator": "^4.0.3", + "sebastian/resource-operations": "^3.0.3", + "sebastian/type": "^2.3.2", + "sebastian/version": "^3.0.2" }, "require-dev": { - "ext-pdo": "*" + "ext-pdo": "*", + "phpspec/prophecy-phpunit": "^2.0.1" }, "suggest": { "ext-soap": "*", - "ext-xdebug": "*", - "phpunit/php-invoker": "^2.0.0" + "ext-xdebug": "*" }, "bin": [ "phpunit" @@ -7132,12 +7726,15 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "8.5-dev" + "dev-master": "9.5-dev" } }, "autoload": { "classmap": [ "src/" + ], + "files": [ + "src/Framework/Assert/Functions.php" ] }, "notification-url": "https://packagist.org/downloads/", @@ -7168,32 +7765,205 @@ "type": "github" } ], - "time": "2021-03-17T07:27:54+00:00" + "time": "2021-06-05T04:49:07+00:00" }, { - "name": "sebastian/code-unit-reverse-lookup", - "version": "1.0.2", + "name": "scssphp/scssphp", + "version": "v1.5.2", "source": { "type": "git", - "url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git", - "reference": "1de8cd5c010cb153fcd68b8d0f64606f523f7619" + "url": "https://github.com/scssphp/scssphp.git", + "reference": "6fe16f169f55f5e793474fb210aac0a4481619e5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/1de8cd5c010cb153fcd68b8d0f64606f523f7619", - "reference": "1de8cd5c010cb153fcd68b8d0f64606f523f7619", + "url": "https://api.github.com/repos/scssphp/scssphp/zipball/6fe16f169f55f5e793474fb210aac0a4481619e5", + "reference": "6fe16f169f55f5e793474fb210aac0a4481619e5", "shasum": "" }, "require": { - "php": ">=5.6" + "ext-ctype": "*", + "ext-json": "*", + "php": ">=5.6.0" }, "require-dev": { - "phpunit/phpunit": "^8.5" + "bamarni/composer-bin-plugin": "^1.4", + "phpunit/phpunit": "^5.7 || ^6.5 || ^7.5 || ^8.3 || ^9.4", + "sass/sass-spec": "*", + "squizlabs/php_codesniffer": "~3.5", + "symfony/phpunit-bridge": "^5.1", + "twbs/bootstrap": "~5.0", + "twbs/bootstrap4": "4.6.0", + "zurb/foundation": "~6.5" + }, + "suggest": { + "ext-iconv": "Can be used as fallback when ext-mbstring is not available", + "ext-mbstring": "For best performance, mbstring should be installed as it is faster than ext-iconv" + }, + "bin": [ + "bin/pscss" + ], + "type": "library", + "autoload": { + "psr-4": { + "ScssPhp\\ScssPhp\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Anthon Pang", + "email": "apang@softwaredevelopment.ca", + "homepage": "https://github.com/robocoder" + }, + { + "name": "Cédric Morin", + "email": "cedric@yterium.com", + "homepage": "https://github.com/Cerdic" + } + ], + "description": "scssphp is a compiler for SCSS written in PHP.", + "homepage": "http://scssphp.github.io/scssphp/", + "keywords": [ + "css", + "less", + "sass", + "scss", + "stylesheet" + ], + "time": "2021-05-18T00:05:58+00:00" + }, + { + "name": "sebastian/cli-parser", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/cli-parser.git", + "reference": "442e7c7e687e42adc03470c7b668bc4b2402c0b2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/cli-parser/zipball/442e7c7e687e42adc03470c7b668bc4b2402c0b2", + "reference": "442e7c7e687e42adc03470c7b668bc4b2402c0b2", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "1.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library for parsing CLI options", + "homepage": "https://github.com/sebastianbergmann/cli-parser", + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-09-28T06:08:49+00:00" + }, + { + "name": "sebastian/code-unit", + "version": "1.0.8", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/code-unit.git", + "reference": "1fc9f64c0927627ef78ba436c9b17d967e68e120" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/code-unit/zipball/1fc9f64c0927627ef78ba436c9b17d967e68e120", + "reference": "1fc9f64c0927627ef78ba436c9b17d967e68e120", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Collection of value objects that represent the PHP code units", + "homepage": "https://github.com/sebastianbergmann/code-unit", + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-10-26T13:08:54+00:00" + }, + { + "name": "sebastian/code-unit-reverse-lookup", + "version": "2.0.3", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git", + "reference": "ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5", + "reference": "ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" } }, "autoload": { @@ -7219,34 +7989,34 @@ "type": "github" } ], - "time": "2020-11-30T08:15:22+00:00" + "time": "2020-09-28T05:30:19+00:00" }, { "name": "sebastian/comparator", - "version": "3.0.3", + "version": "4.0.6", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "1071dfcef776a57013124ff35e1fc41ccd294758" + "reference": "55f4261989e546dc112258c7a75935a81a7ce382" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/1071dfcef776a57013124ff35e1fc41ccd294758", - "reference": "1071dfcef776a57013124ff35e1fc41ccd294758", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/55f4261989e546dc112258c7a75935a81a7ce382", + "reference": "55f4261989e546dc112258c7a75935a81a7ce382", "shasum": "" }, "require": { - "php": ">=7.1", - "sebastian/diff": "^3.0", - "sebastian/exporter": "^3.1" + "php": ">=7.3", + "sebastian/diff": "^4.0", + "sebastian/exporter": "^4.0" }, "require-dev": { - "phpunit/phpunit": "^8.5" + "phpunit/phpunit": "^9.3" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0-dev" + "dev-master": "4.0-dev" } }, "autoload": { @@ -7289,33 +8059,86 @@ "type": "github" } ], - "time": "2020-11-30T08:04:30+00:00" + "time": "2020-10-26T15:49:45+00:00" }, { - "name": "sebastian/diff", - "version": "3.0.3", + "name": "sebastian/complexity", + "version": "2.0.2", "source": { "type": "git", - "url": "https://github.com/sebastianbergmann/diff.git", - "reference": "14f72dd46eaf2f2293cbe79c93cc0bc43161a211" + "url": "https://github.com/sebastianbergmann/complexity.git", + "reference": "739b35e53379900cc9ac327b2147867b8b6efd88" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/14f72dd46eaf2f2293cbe79c93cc0bc43161a211", - "reference": "14f72dd46eaf2f2293cbe79c93cc0bc43161a211", + "url": "https://api.github.com/repos/sebastianbergmann/complexity/zipball/739b35e53379900cc9ac327b2147867b8b6efd88", + "reference": "739b35e53379900cc9ac327b2147867b8b6efd88", "shasum": "" }, "require": { - "php": ">=7.1" + "nikic/php-parser": "^4.7", + "php": ">=7.3" }, "require-dev": { - "phpunit/phpunit": "^7.5 || ^8.0", - "symfony/process": "^2 || ^3.3 || ^4" + "phpunit/phpunit": "^9.3" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0-dev" + "dev-master": "2.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library for calculating the complexity of PHP code units", + "homepage": "https://github.com/sebastianbergmann/complexity", + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-10-26T15:52:27+00:00" + }, + { + "name": "sebastian/diff", + "version": "4.0.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/diff.git", + "reference": "3461e3fccc7cfdfc2720be910d3bd73c69be590d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/3461e3fccc7cfdfc2720be910d3bd73c69be590d", + "reference": "3461e3fccc7cfdfc2720be910d3bd73c69be590d", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3", + "symfony/process": "^4.2 || ^5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0-dev" } }, "autoload": { @@ -7351,27 +8174,27 @@ "type": "github" } ], - "time": "2020-11-30T07:59:04+00:00" + "time": "2020-10-26T13:10:38+00:00" }, { "name": "sebastian/environment", - "version": "4.2.4", + "version": "5.1.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/environment.git", - "reference": "d47bbbad83711771f167c72d4e3f25f7fcc1f8b0" + "reference": "388b6ced16caa751030f6a69e588299fa09200ac" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/d47bbbad83711771f167c72d4e3f25f7fcc1f8b0", - "reference": "d47bbbad83711771f167c72d4e3f25f7fcc1f8b0", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/388b6ced16caa751030f6a69e588299fa09200ac", + "reference": "388b6ced16caa751030f6a69e588299fa09200ac", "shasum": "" }, "require": { - "php": ">=7.1" + "php": ">=7.3" }, "require-dev": { - "phpunit/phpunit": "^7.5" + "phpunit/phpunit": "^9.3" }, "suggest": { "ext-posix": "*" @@ -7379,7 +8202,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "4.2-dev" + "dev-master": "5.1-dev" } }, "autoload": { @@ -7410,34 +8233,34 @@ "type": "github" } ], - "time": "2020-11-30T07:53:42+00:00" + "time": "2020-09-28T05:52:38+00:00" }, { "name": "sebastian/exporter", - "version": "3.1.3", + "version": "4.0.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/exporter.git", - "reference": "6b853149eab67d4da22291d36f5b0631c0fd856e" + "reference": "d89cc98761b8cb5a1a235a6b703ae50d34080e65" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/6b853149eab67d4da22291d36f5b0631c0fd856e", - "reference": "6b853149eab67d4da22291d36f5b0631c0fd856e", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/d89cc98761b8cb5a1a235a6b703ae50d34080e65", + "reference": "d89cc98761b8cb5a1a235a6b703ae50d34080e65", "shasum": "" }, "require": { - "php": ">=7.0", - "sebastian/recursion-context": "^3.0" + "php": ">=7.3", + "sebastian/recursion-context": "^4.0" }, "require-dev": { "ext-mbstring": "*", - "phpunit/phpunit": "^6.0" + "phpunit/phpunit": "^9.3" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.1.x-dev" + "dev-master": "4.0-dev" } }, "autoload": { @@ -7483,30 +8306,30 @@ "type": "github" } ], - "time": "2020-11-30T07:47:53+00:00" + "time": "2020-09-28T05:24:23+00:00" }, { "name": "sebastian/global-state", - "version": "3.0.1", + "version": "5.0.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/global-state.git", - "reference": "474fb9edb7ab891665d3bfc6317f42a0a150454b" + "reference": "23bd5951f7ff26f12d4e3242864df3e08dec4e49" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/474fb9edb7ab891665d3bfc6317f42a0a150454b", - "reference": "474fb9edb7ab891665d3bfc6317f42a0a150454b", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/23bd5951f7ff26f12d4e3242864df3e08dec4e49", + "reference": "23bd5951f7ff26f12d4e3242864df3e08dec4e49", "shasum": "" }, "require": { - "php": ">=7.2", - "sebastian/object-reflector": "^1.1.1", - "sebastian/recursion-context": "^3.0" + "php": ">=7.3", + "sebastian/object-reflector": "^2.0", + "sebastian/recursion-context": "^4.0" }, "require-dev": { "ext-dom": "*", - "phpunit/phpunit": "^8.0" + "phpunit/phpunit": "^9.3" }, "suggest": { "ext-uopz": "*" @@ -7514,7 +8337,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0-dev" + "dev-master": "5.0-dev" } }, "autoload": { @@ -7543,34 +8366,87 @@ "type": "github" } ], - "time": "2020-11-30T07:43:24+00:00" + "time": "2021-06-11T13:31:12+00:00" }, { - "name": "sebastian/object-enumerator", - "version": "3.0.4", + "name": "sebastian/lines-of-code", + "version": "1.0.3", "source": { "type": "git", - "url": "https://github.com/sebastianbergmann/object-enumerator.git", - "reference": "e67f6d32ebd0c749cf9d1dbd9f226c727043cdf2" + "url": "https://github.com/sebastianbergmann/lines-of-code.git", + "reference": "c1c2e997aa3146983ed888ad08b15470a2e22ecc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/e67f6d32ebd0c749cf9d1dbd9f226c727043cdf2", - "reference": "e67f6d32ebd0c749cf9d1dbd9f226c727043cdf2", + "url": "https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/c1c2e997aa3146983ed888ad08b15470a2e22ecc", + "reference": "c1c2e997aa3146983ed888ad08b15470a2e22ecc", "shasum": "" }, "require": { - "php": ">=7.0", - "sebastian/object-reflector": "^1.1.1", - "sebastian/recursion-context": "^3.0" + "nikic/php-parser": "^4.6", + "php": ">=7.3" }, "require-dev": { - "phpunit/phpunit": "^6.0" + "phpunit/phpunit": "^9.3" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0.x-dev" + "dev-master": "1.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library for counting the lines of code in PHP source code", + "homepage": "https://github.com/sebastianbergmann/lines-of-code", + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-11-28T06:42:11+00:00" + }, + { + "name": "sebastian/object-enumerator", + "version": "4.0.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/object-enumerator.git", + "reference": "5c9eeac41b290a3712d88851518825ad78f45c71" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/5c9eeac41b290a3712d88851518825ad78f45c71", + "reference": "5c9eeac41b290a3712d88851518825ad78f45c71", + "shasum": "" + }, + "require": { + "php": ">=7.3", + "sebastian/object-reflector": "^2.0", + "sebastian/recursion-context": "^4.0" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0-dev" } }, "autoload": { @@ -7596,32 +8472,32 @@ "type": "github" } ], - "time": "2020-11-30T07:40:27+00:00" + "time": "2020-10-26T13:12:34+00:00" }, { "name": "sebastian/object-reflector", - "version": "1.1.2", + "version": "2.0.4", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/object-reflector.git", - "reference": "9b8772b9cbd456ab45d4a598d2dd1a1bced6363d" + "reference": "b4f479ebdbf63ac605d183ece17d8d7fe49c15c7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/9b8772b9cbd456ab45d4a598d2dd1a1bced6363d", - "reference": "9b8772b9cbd456ab45d4a598d2dd1a1bced6363d", + "url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/b4f479ebdbf63ac605d183ece17d8d7fe49c15c7", + "reference": "b4f479ebdbf63ac605d183ece17d8d7fe49c15c7", "shasum": "" }, "require": { - "php": ">=7.0" + "php": ">=7.3" }, "require-dev": { - "phpunit/phpunit": "^6.0" + "phpunit/phpunit": "^9.3" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.1-dev" + "dev-master": "2.0-dev" } }, "autoload": { @@ -7647,32 +8523,32 @@ "type": "github" } ], - "time": "2020-11-30T07:37:18+00:00" + "time": "2020-10-26T13:14:26+00:00" }, { "name": "sebastian/recursion-context", - "version": "3.0.1", + "version": "4.0.4", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/recursion-context.git", - "reference": "367dcba38d6e1977be014dc4b22f47a484dac7fb" + "reference": "cd9d8cf3c5804de4341c283ed787f099f5506172" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/367dcba38d6e1977be014dc4b22f47a484dac7fb", - "reference": "367dcba38d6e1977be014dc4b22f47a484dac7fb", + "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/cd9d8cf3c5804de4341c283ed787f099f5506172", + "reference": "cd9d8cf3c5804de4341c283ed787f099f5506172", "shasum": "" }, "require": { - "php": ">=7.0" + "php": ">=7.3" }, "require-dev": { - "phpunit/phpunit": "^6.0" + "phpunit/phpunit": "^9.3" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0.x-dev" + "dev-master": "4.0-dev" } }, "autoload": { @@ -7706,29 +8582,32 @@ "type": "github" } ], - "time": "2020-11-30T07:34:24+00:00" + "time": "2020-10-26T13:17:30+00:00" }, { "name": "sebastian/resource-operations", - "version": "2.0.2", + "version": "3.0.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/resource-operations.git", - "reference": "31d35ca87926450c44eae7e2611d45a7a65ea8b3" + "reference": "0f4443cb3a1d92ce809899753bc0d5d5a8dd19a8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/31d35ca87926450c44eae7e2611d45a7a65ea8b3", - "reference": "31d35ca87926450c44eae7e2611d45a7a65ea8b3", + "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/0f4443cb3a1d92ce809899753bc0d5d5a8dd19a8", + "reference": "0f4443cb3a1d92ce809899753bc0d5d5a8dd19a8", "shasum": "" }, "require": { - "php": ">=7.1" + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0-dev" + "dev-master": "3.0-dev" } }, "autoload": { @@ -7754,32 +8633,32 @@ "type": "github" } ], - "time": "2020-11-30T07:30:19+00:00" + "time": "2020-09-28T06:45:17+00:00" }, { "name": "sebastian/type", - "version": "1.1.4", + "version": "2.3.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/type.git", - "reference": "0150cfbc4495ed2df3872fb31b26781e4e077eb4" + "reference": "0d1c587401514d17e8f9258a27e23527cb1b06c1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/0150cfbc4495ed2df3872fb31b26781e4e077eb4", - "reference": "0150cfbc4495ed2df3872fb31b26781e4e077eb4", + "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/0d1c587401514d17e8f9258a27e23527cb1b06c1", + "reference": "0d1c587401514d17e8f9258a27e23527cb1b06c1", "shasum": "" }, "require": { - "php": ">=7.2" + "php": ">=7.3" }, "require-dev": { - "phpunit/phpunit": "^8.2" + "phpunit/phpunit": "^9.3" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.1-dev" + "dev-master": "2.3-dev" } }, "autoload": { @@ -7806,29 +8685,29 @@ "type": "github" } ], - "time": "2020-11-30T07:25:11+00:00" + "time": "2021-06-04T13:02:07+00:00" }, { "name": "sebastian/version", - "version": "2.0.1", + "version": "3.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/version.git", - "reference": "99732be0ddb3361e16ad77b68ba41efc8e979019" + "reference": "c6c1022351a901512170118436c764e473f6de8c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/99732be0ddb3361e16ad77b68ba41efc8e979019", - "reference": "99732be0ddb3361e16ad77b68ba41efc8e979019", + "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/c6c1022351a901512170118436c764e473f6de8c", + "reference": "c6c1022351a901512170118436c764e473f6de8c", "shasum": "" }, "require": { - "php": ">=5.6" + "php": ">=7.3" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0.x-dev" + "dev-master": "3.0-dev" } }, "autoload": { @@ -7849,31 +8728,96 @@ ], "description": "Library that helps with managing the version number of Git-hosted PHP projects", "homepage": "https://github.com/sebastianbergmann/version", - "time": "2016-10-03T07:35:21+00:00" + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-09-28T06:39:44+00:00" }, { - "name": "symfony/browser-kit", - "version": "v4.4.20", + "name": "softcreatr/jsonpath", + "version": "0.7.5", "source": { "type": "git", - "url": "https://github.com/symfony/browser-kit.git", - "reference": "cfa8d92f95294747e3abc04969efee51ed374424" + "url": "https://github.com/SoftCreatR/JSONPath.git", + "reference": "008569bf80aa3584834f7890781576bc7b65afa7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/browser-kit/zipball/cfa8d92f95294747e3abc04969efee51ed374424", - "reference": "cfa8d92f95294747e3abc04969efee51ed374424", + "url": "https://api.github.com/repos/SoftCreatR/JSONPath/zipball/008569bf80aa3584834f7890781576bc7b65afa7", + "reference": "008569bf80aa3584834f7890781576bc7b65afa7", "shasum": "" }, "require": { - "php": ">=7.1.3", - "symfony/dom-crawler": "^3.4|^4.0|^5.0" + "ext-json": "*", + "php": ">=7.1" + }, + "replace": { + "flow/jsonpath": "*" }, "require-dev": { - "symfony/css-selector": "^3.4|^4.0|^5.0", - "symfony/http-client": "^4.3|^5.0", - "symfony/mime": "^4.3|^5.0", - "symfony/process": "^3.4|^4.0|^5.0" + "phpunit/phpunit": ">=7.0", + "roave/security-advisories": "dev-master", + "squizlabs/php_codesniffer": "^3.5" + }, + "type": "library", + "autoload": { + "psr-4": { + "Flow\\JSONPath\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Stephen Frank", + "email": "stephen@flowsa.com", + "homepage": "https://prismaticbytes.com", + "role": "Developer" + }, + { + "name": "Sascha Greuel", + "email": "hello@1-2.dev", + "homepage": "http://1-2.dev", + "role": "Developer" + } + ], + "description": "JSONPath implementation for parsing, searching and flattening arrays", + "funding": [ + { + "url": "https://github.com/softcreatr", + "type": "github" + } + ], + "time": "2021-06-02T22:15:26+00:00" + }, + { + "name": "symfony/browser-kit", + "version": "v5.3.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/browser-kit.git", + "reference": "379984e25eee9811b0a25a2105e1a2b3b8d9b734" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/browser-kit/zipball/379984e25eee9811b0a25a2105e1a2b3b8d9b734", + "reference": "379984e25eee9811b0a25a2105e1a2b3b8d9b734", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "symfony/dom-crawler": "^4.4|^5.0" + }, + "require-dev": { + "symfony/css-selector": "^4.4|^5.0", + "symfony/http-client": "^4.4|^5.0", + "symfony/mime": "^4.4|^5.0", + "symfony/process": "^4.4|^5.0" }, "suggest": { "symfony/process": "" @@ -7917,110 +8861,24 @@ "type": "tidelift" } ], - "time": "2021-02-18T10:52:56+00:00" - }, - { - "name": "symfony/console", - "version": "v4.4.21", - "source": { - "type": "git", - "url": "https://github.com/symfony/console.git", - "reference": "1ba4560dbbb9fcf5ae28b61f71f49c678086cf23" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/1ba4560dbbb9fcf5ae28b61f71f49c678086cf23", - "reference": "1ba4560dbbb9fcf5ae28b61f71f49c678086cf23", - "shasum": "" - }, - "require": { - "php": ">=7.1.3", - "symfony/polyfill-mbstring": "~1.0", - "symfony/polyfill-php73": "^1.8", - "symfony/polyfill-php80": "^1.15", - "symfony/service-contracts": "^1.1|^2" - }, - "conflict": { - "symfony/dependency-injection": "<3.4", - "symfony/event-dispatcher": "<4.3|>=5", - "symfony/lock": "<4.4", - "symfony/process": "<3.3" - }, - "provide": { - "psr/log-implementation": "1.0" - }, - "require-dev": { - "psr/log": "~1.0", - "symfony/config": "^3.4|^4.0|^5.0", - "symfony/dependency-injection": "^3.4|^4.0|^5.0", - "symfony/event-dispatcher": "^4.3", - "symfony/lock": "^4.4|^5.0", - "symfony/process": "^3.4|^4.0|^5.0", - "symfony/var-dumper": "^4.3|^5.0" - }, - "suggest": { - "psr/log": "For using the console logger", - "symfony/event-dispatcher": "", - "symfony/lock": "", - "symfony/process": "" - }, - "type": "library", - "autoload": { - "psr-4": { - "Symfony\\Component\\Console\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Eases the creation of beautiful and testable command line interfaces", - "homepage": "https://symfony.com", - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2021-03-26T09:23:24+00:00" + "time": "2021-05-26T17:43:10+00:00" }, { "name": "symfony/css-selector", - "version": "v4.4.20", + "version": "v5.3.0", "source": { "type": "git", "url": "https://github.com/symfony/css-selector.git", - "reference": "f907d3e53ecb2a5fad8609eb2f30525287a734c8" + "reference": "fcd0b29a7a0b1bb5bfbedc6231583d77fea04814" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/css-selector/zipball/f907d3e53ecb2a5fad8609eb2f30525287a734c8", - "reference": "f907d3e53ecb2a5fad8609eb2f30525287a734c8", + "url": "https://api.github.com/repos/symfony/css-selector/zipball/fcd0b29a7a0b1bb5bfbedc6231583d77fea04814", + "reference": "fcd0b29a7a0b1bb5bfbedc6231583d77fea04814", "shasum": "" }, "require": { - "php": ">=7.1.3" + "php": ">=7.2.5" }, "type": "library", "autoload": { @@ -8065,97 +8923,35 @@ "type": "tidelift" } ], - "time": "2021-01-27T09:09:26+00:00" - }, - { - "name": "symfony/deprecation-contracts", - "version": "v2.2.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/deprecation-contracts.git", - "reference": "5fa56b4074d1ae755beb55617ddafe6f5d78f665" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/5fa56b4074d1ae755beb55617ddafe6f5d78f665", - "reference": "5fa56b4074d1ae755beb55617ddafe6f5d78f665", - "shasum": "" - }, - "require": { - "php": ">=7.1" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.2-dev" - }, - "thanks": { - "name": "symfony/contracts", - "url": "https://github.com/symfony/contracts" - } - }, - "autoload": { - "files": [ - "function.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "A generic function and convention to trigger deprecation notices", - "homepage": "https://symfony.com", - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2020-09-07T11:33:47+00:00" + "time": "2021-05-26T17:40:38+00:00" }, { "name": "symfony/dom-crawler", - "version": "v4.4.20", + "version": "v5.3.0", "source": { "type": "git", "url": "https://github.com/symfony/dom-crawler.git", - "reference": "be133557f1b0e6672367325b508e65da5513a311" + "reference": "55fff62b19f413f897a752488ade1bc9c8a19cdd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/dom-crawler/zipball/be133557f1b0e6672367325b508e65da5513a311", - "reference": "be133557f1b0e6672367325b508e65da5513a311", + "url": "https://api.github.com/repos/symfony/dom-crawler/zipball/55fff62b19f413f897a752488ade1bc9c8a19cdd", + "reference": "55fff62b19f413f897a752488ade1bc9c8a19cdd", "shasum": "" }, "require": { - "php": ">=7.1.3", + "php": ">=7.2.5", + "symfony/deprecation-contracts": "^2.1", "symfony/polyfill-ctype": "~1.8", - "symfony/polyfill-mbstring": "~1.0" + "symfony/polyfill-mbstring": "~1.0", + "symfony/polyfill-php80": "^1.15" }, "conflict": { "masterminds/html5": "<2.6" }, "require-dev": { "masterminds/html5": "^2.6", - "symfony/css-selector": "^3.4|^4.0|^5.0" + "symfony/css-selector": "^4.4|^5.0" }, "suggest": { "symfony/css-selector": "" @@ -8199,346 +8995,7 @@ "type": "tidelift" } ], - "time": "2021-02-14T12:29:41+00:00" - }, - { - "name": "symfony/event-dispatcher", - "version": "v4.4.20", - "source": { - "type": "git", - "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "c352647244bd376bf7d31efbd5401f13f50dad0c" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/c352647244bd376bf7d31efbd5401f13f50dad0c", - "reference": "c352647244bd376bf7d31efbd5401f13f50dad0c", - "shasum": "" - }, - "require": { - "php": ">=7.1.3", - "symfony/event-dispatcher-contracts": "^1.1" - }, - "conflict": { - "symfony/dependency-injection": "<3.4" - }, - "provide": { - "psr/event-dispatcher-implementation": "1.0", - "symfony/event-dispatcher-implementation": "1.1" - }, - "require-dev": { - "psr/log": "~1.0", - "symfony/config": "^3.4|^4.0|^5.0", - "symfony/dependency-injection": "^3.4|^4.0|^5.0", - "symfony/error-handler": "~3.4|~4.4", - "symfony/expression-language": "^3.4|^4.0|^5.0", - "symfony/http-foundation": "^3.4|^4.0|^5.0", - "symfony/service-contracts": "^1.1|^2", - "symfony/stopwatch": "^3.4|^4.0|^5.0" - }, - "suggest": { - "symfony/dependency-injection": "", - "symfony/http-kernel": "" - }, - "type": "library", - "autoload": { - "psr-4": { - "Symfony\\Component\\EventDispatcher\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Provides tools that allow your application components to communicate with each other by dispatching events and listening to them", - "homepage": "https://symfony.com", - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2021-01-27T09:09:26+00:00" - }, - { - "name": "symfony/event-dispatcher-contracts", - "version": "v1.1.9", - "source": { - "type": "git", - "url": "https://github.com/symfony/event-dispatcher-contracts.git", - "reference": "84e23fdcd2517bf37aecbd16967e83f0caee25a7" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher-contracts/zipball/84e23fdcd2517bf37aecbd16967e83f0caee25a7", - "reference": "84e23fdcd2517bf37aecbd16967e83f0caee25a7", - "shasum": "" - }, - "require": { - "php": ">=7.1.3" - }, - "suggest": { - "psr/event-dispatcher": "", - "symfony/event-dispatcher-implementation": "" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.1-dev" - }, - "thanks": { - "name": "symfony/contracts", - "url": "https://github.com/symfony/contracts" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Contracts\\EventDispatcher\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Generic abstractions related to dispatching event", - "homepage": "https://symfony.com", - "keywords": [ - "abstractions", - "contracts", - "decoupling", - "interfaces", - "interoperability", - "standards" - ], - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2020-07-06T13:19:58+00:00" - }, - { - "name": "symfony/filesystem", - "version": "v4.4.21", - "source": { - "type": "git", - "url": "https://github.com/symfony/filesystem.git", - "reference": "940826c465be2690c9fae91b2793481e5cbd6834" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/940826c465be2690c9fae91b2793481e5cbd6834", - "reference": "940826c465be2690c9fae91b2793481e5cbd6834", - "shasum": "" - }, - "require": { - "php": ">=7.1.3", - "symfony/polyfill-ctype": "~1.8" - }, - "type": "library", - "autoload": { - "psr-4": { - "Symfony\\Component\\Filesystem\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Provides basic utilities for the filesystem", - "homepage": "https://symfony.com", - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2021-03-28T09:59:32+00:00" - }, - { - "name": "symfony/finder", - "version": "v4.4.20", - "source": { - "type": "git", - "url": "https://github.com/symfony/finder.git", - "reference": "2543795ab1570df588b9bbd31e1a2bd7037b94f6" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/2543795ab1570df588b9bbd31e1a2bd7037b94f6", - "reference": "2543795ab1570df588b9bbd31e1a2bd7037b94f6", - "shasum": "" - }, - "require": { - "php": ">=7.1.3" - }, - "type": "library", - "autoload": { - "psr-4": { - "Symfony\\Component\\Finder\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Finds files and directories via an intuitive fluent interface", - "homepage": "https://symfony.com", - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2021-02-12T10:48:09+00:00" - }, - { - "name": "symfony/options-resolver", - "version": "v5.2.4", - "source": { - "type": "git", - "url": "https://github.com/symfony/options-resolver.git", - "reference": "5d0f633f9bbfcf7ec642a2b5037268e61b0a62ce" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/options-resolver/zipball/5d0f633f9bbfcf7ec642a2b5037268e61b0a62ce", - "reference": "5d0f633f9bbfcf7ec642a2b5037268e61b0a62ce", - "shasum": "" - }, - "require": { - "php": ">=7.2.5", - "symfony/deprecation-contracts": "^2.1", - "symfony/polyfill-php73": "~1.0", - "symfony/polyfill-php80": "^1.15" - }, - "type": "library", - "autoload": { - "psr-4": { - "Symfony\\Component\\OptionsResolver\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Provides an improved replacement for the array_replace PHP function", - "homepage": "https://symfony.com", - "keywords": [ - "config", - "configuration", - "options" - ], - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2021-01-27T12:56:27+00:00" + "time": "2021-05-26T17:43:10+00:00" }, { "name": "symfony/polyfill-php70", @@ -8605,152 +9062,18 @@ ], "time": "2020-10-23T14:02:19+00:00" }, - { - "name": "symfony/process", - "version": "v4.4.20", - "source": { - "type": "git", - "url": "https://github.com/symfony/process.git", - "reference": "7e950b6366d4da90292c2e7fa820b3c1842b965a" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/7e950b6366d4da90292c2e7fa820b3c1842b965a", - "reference": "7e950b6366d4da90292c2e7fa820b3c1842b965a", - "shasum": "" - }, - "require": { - "php": ">=7.1.3" - }, - "type": "library", - "autoload": { - "psr-4": { - "Symfony\\Component\\Process\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Executes commands in sub-processes", - "homepage": "https://symfony.com", - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2021-01-27T09:09:26+00:00" - }, - { - "name": "symfony/service-contracts", - "version": "v2.2.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/service-contracts.git", - "reference": "d15da7ba4957ffb8f1747218be9e1a121fd298a1" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/service-contracts/zipball/d15da7ba4957ffb8f1747218be9e1a121fd298a1", - "reference": "d15da7ba4957ffb8f1747218be9e1a121fd298a1", - "shasum": "" - }, - "require": { - "php": ">=7.2.5", - "psr/container": "^1.0" - }, - "suggest": { - "symfony/service-implementation": "" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.2-dev" - }, - "thanks": { - "name": "symfony/contracts", - "url": "https://github.com/symfony/contracts" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Contracts\\Service\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Generic abstractions related to writing services", - "homepage": "https://symfony.com", - "keywords": [ - "abstractions", - "contracts", - "decoupling", - "interfaces", - "interoperability", - "standards" - ], - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2020-09-07T11:33:47+00:00" - }, { "name": "symfony/stopwatch", - "version": "v5.2.4", + "version": "v5.3.0", "source": { "type": "git", "url": "https://github.com/symfony/stopwatch.git", - "reference": "b12274acfab9d9850c52583d136a24398cdf1a0c" + "reference": "313d02f59d6543311865007e5ff4ace05b35ee65" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/stopwatch/zipball/b12274acfab9d9850c52583d136a24398cdf1a0c", - "reference": "b12274acfab9d9850c52583d136a24398cdf1a0c", + "url": "https://api.github.com/repos/symfony/stopwatch/zipball/313d02f59d6543311865007e5ff4ace05b35ee65", + "reference": "313d02f59d6543311865007e5ff4ace05b35ee65", "shasum": "" }, "require": { @@ -8796,7 +9119,7 @@ "type": "tidelift" } ], - "time": "2021-01-27T10:15:41+00:00" + "time": "2021-05-26T17:43:10+00:00" }, { "name": "theseer/tokenizer", @@ -8905,7 +9228,7 @@ "prefer-stable": true, "prefer-lowest": false, "platform": { - "php": ">=7.2.9", + "php": ">=7.3.0", "ext-curl": "*", "ext-gd": "*", "ext-imap": "*", @@ -8915,7 +9238,7 @@ }, "platform-dev": [], "platform-overrides": { - "php": "7.2.9" + "php": "7.3.0" }, - "plugin-api-version": "1.1.0" + "plugin-api-version": "2.1.0" } diff --git a/include/language/en_us.lang.php b/include/language/en_us.lang.php index a357d378d..50ab61fa8 100755 --- a/include/language/en_us.lang.php +++ b/include/language/en_us.lang.php @@ -3826,3 +3826,5 @@ $app_strings['LBL_PHOTO'] = 'Photo'; $app_strings['LBL_CASE_UPDATES'] = 'Case Updates'; $app_strings['LBL_SUMMARY_DEFAULT'] = "{{fields.name.value}}"; $app_strings['LBL_CREATE'] = "Create"; +$app_strings['LBL_USE_ADVANCED_SEARCH'] = 'Use Advanced Search'; +$app_strings['LBL_USE_BASIC_SEARCH'] = 'Use Basic Search'; diff --git a/include/utils.php b/include/utils.php index 98a110c9e..bc42ec82a 100755 --- a/include/utils.php +++ b/include/utils.php @@ -5,7 +5,7 @@ * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. * * SuiteCRM is an extension to SugarCRM Community Edition developed by SalesAgility Ltd. - * Copyright (C) 2011 - 2020 SalesAgility Ltd. + * Copyright (C) 2011 - 2021 SalesAgility Ltd. * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU Affero General Public License version 3 as published by the @@ -269,18 +269,15 @@ function make_sugar_config(&$sugar_config) } /** + * Used for getting base values for array style config.php * @return array + * @throws Exception */ -function get_sugar_config_defaults() +function get_sugar_config_defaults(): array { global $locale; - /* - * used for getting base values for array style config.php. used by the - * installer and to fill in new entries on upgrades. see also: - * sugar_config_union - */ - $sugar_config_defaults = array( + $sugar_config_defaults = [ 'disableAjaxUI' => true, 'admin_export_only' => false, 'export_delimiter' => ',', @@ -289,7 +286,7 @@ function get_sugar_config_defaults() 'calculate_response_time' => true, 'create_default_user' => false, 'chartEngine' => 'Jit', - 'date_formats' => array( + 'date_formats' => [ 'Y-m-d' => '2010-12-23', 'm-d-Y' => '12-23-2010', 'd-m-Y' => '23-12-2010', @@ -299,8 +296,8 @@ function get_sugar_config_defaults() 'Y.m.d' => '2010.12.23', 'd.m.Y' => '23.12.2010', 'm.d.Y' => '12.23.2010', - ), - 'name_formats' => array( + ], + 'name_formats' => [ 's f l' => 's f l', 'f l' => 'f l', 's l' => 's l', @@ -309,20 +306,22 @@ function get_sugar_config_defaults() 's l, f' => 's l, f', 'l s f' => 'l s f', 'l f s' => 'l f s', - ), - 'dbconfigoption' => array( + ], + 'dbconfigoption' => [ 'persistent' => true, 'autofree' => false, 'debug' => 0, 'ssl' => false, - ), + ], 'default_action' => 'index', 'default_charset' => return_session_value_or_default('default_charset', 'UTF-8'), 'default_currency_name' => return_session_value_or_default('default_currency_name', 'US Dollar'), 'default_currency_symbol' => return_session_value_or_default('default_currency_symbol', '$'), 'default_currency_iso4217' => return_session_value_or_default('default_currency_iso4217', 'USD'), - 'default_currency_significant_digits' => return_session_value_or_default('default_currency_significant_digits', 2), - 'default_number_grouping_seperator' => return_session_value_or_default('default_number_grouping_seperator', ','), + 'default_currency_significant_digits' => return_session_value_or_default('default_currency_significant_digits', + 2), + 'default_number_grouping_seperator' => return_session_value_or_default('default_number_grouping_seperator', + ','), 'default_decimal_seperator' => return_session_value_or_default('default_decimal_seperator', '.'), 'default_date_format' => 'm/d/Y', 'default_locale_name_format' => 's f l', @@ -330,18 +329,23 @@ function get_sugar_config_defaults() 'default_language' => return_session_value_or_default('default_language', 'en_us'), 'default_module' => 'Home', 'default_password' => '', - 'default_permissions' => array( + 'default_permissions' => [ 'dir_mode' => 02770, 'file_mode' => 0755, 'user' => '', 'group' => '', - ), + ], 'default_theme' => return_session_value_or_default('site_default_theme', 'SuiteP'), 'default_time_format' => 'h:ia', 'default_user_is_admin' => false, 'default_user_name' => '', 'disable_export' => false, - 'disable_persistent_connections' => return_session_value_or_default('disable_persistent_connections', 'false'), + 'disable_persistent_connections' => return_session_value_or_default('disable_persistent_connections', false), + 'default_module_favicon' => false, + 'dashlet_auto_refresh_min' => 30, + 'stack_trace_errors' => false, + 'developerMode' => false, + 'stackTrace' => false, 'display_email_template_variable_chooser' => false, 'display_inbound_email_buttons' => false, 'dump_slow_queries' => false, @@ -352,8 +356,8 @@ function get_sugar_config_defaults() 'email_warning_notifications' => true, 'email_enable_auto_send_opt_in' => false, 'email_enable_confirm_opt_in' => SugarEmailAddress::COI_STAT_DISABLED, - 'filter_module_fields' => array( - 'Users' => array( + 'filter_module_fields' => [ + 'Users' => [ 'show_on_employees', 'portal_only', 'is_group', @@ -368,8 +372,8 @@ function get_sugar_config_defaults() 'password', 'last_login', 'oauth_tokens', - ), - 'Employees' => array( + ], + 'Employees' => [ 'show_on_employees', 'portal_only', 'is_group', @@ -384,14 +388,14 @@ function get_sugar_config_defaults() 'password', 'last_login', 'oauth_tokens', - ) - ), + ] + ], 'google_auth_json' => '', 'history_max_viewed' => 50, 'installer_locked' => true, 'import_max_records_per_file' => 100, 'import_max_records_total_limit' => '', - 'languages' => array('en_us' => 'English (US)'), + 'languages' => ['en_us' => 'English (US)'], 'large_scale_test' => false, 'list_max_entries_per_page' => 20, 'list_max_entries_per_subpanel' => 10, @@ -399,11 +403,11 @@ function get_sugar_config_defaults() 'log_memory_usage' => false, 'oauth2_encryption_key' => base64_encode(random_bytes(32)), 'portal_view' => 'single_user', - 'resource_management' => array( + 'resource_management' => [ 'special_query_limit' => 50000, - 'special_query_modules' => array('AOR_Reports', 'Export', 'Import', 'Administration', 'Sync'), + 'special_query_modules' => ['AOR_Reports', 'Export', 'Import', 'Administration', 'Sync'], 'default_limit' => 1000, - ), + ], 'require_accounts' => true, 'rss_cache_time' => return_session_value_or_default('rss_cache_time', '10800'), 'save_query' => 'all', @@ -411,7 +415,7 @@ function get_sugar_config_defaults() 'showThemePicker' => true, 'slow_query_time_msec' => '100', 'sugarbeet' => true, - 'time_formats' => array( + 'time_formats' => [ 'H:i' => '23:00', 'h:ia' => '11:00pm', 'h:iA' => '11:00PM', @@ -422,10 +426,10 @@ function get_sugar_config_defaults() 'h.iA' => '11.00PM', 'h.i a' => '11.00 pm', 'h.i A' => '11.00 PM', - ), + ], 'tracker_max_display_length' => 15, 'translation_string_prefix' => return_session_value_or_default('translation_string_prefix', false), - 'upload_badext' => array( + 'upload_badext' => [ 'php', 'php3', 'php4', @@ -440,7 +444,7 @@ function get_sugar_config_defaults() 'html', 'htm', 'phtml', - ), + ], 'upload_maxsize' => 30000000, 'import_max_execution_time' => 3600, // 'use_php_code_json' => returnPhpJsonStatus(), @@ -452,7 +456,7 @@ function get_sugar_config_defaults() 'lock_subpanels' => false, 'max_dashlets_homepage' => '15', 'default_max_tabs' => 8, - 'dashlet_display_row_options' => array('1', '3', '5', '10'), + 'dashlet_display_row_options' => ['1', '3', '5', '10'], 'default_subpanel_tabs' => true, 'default_subpanel_links' => false, 'default_swap_last_viewed' => false, @@ -462,7 +466,7 @@ function get_sugar_config_defaults() 'use_common_ml_dir' => false, 'common_ml_dir' => '', 'vcal_time' => '2', - 'calendar' => array( + 'calendar' => [ 'default_view' => 'week', 'show_calls_by_default' => true, 'show_tasks_by_default' => true, @@ -475,8 +479,8 @@ function get_sugar_config_defaults() 'items_resizable' => true, 'enable_repeat' => true, 'max_repeat_count' => 1000, - ), - 'passwordsetting' => empty($passwordsetting) ? array( + ], + 'passwordsetting' => empty($passwordsetting) ? [ 'SystemGeneratedPasswordON' => '', 'generatepasswordtmpl' => '', 'lostpasswordtmpl' => '', @@ -489,22 +493,22 @@ function get_sugar_config_defaults() 'systexpirationtime' => '7', 'systexpirationtype' => '1', 'systexpirationlogin' => '', - ) : $passwordsetting, + ] : $passwordsetting, 'use_real_names' => true, 'search_wildcard_infront' => false, 'search_wildcard_char' => '%', - 'jobs' => array( + 'jobs' => [ 'min_retry_interval' => 30, // 30 seconds minimal job retry 'max_retries' => 5, // how many times to retry the job 'timeout' => 86400, // how long a job may spend as running before being force-failed - ), - 'cron' => array( + ], + 'cron' => [ 'max_cron_jobs' => 10, // max jobs per cron schedule run 'max_cron_runtime' => 30, // max runtime for cron jobs 'min_cron_interval' => 30, // minimal interval between cron jobs - ), + ], 'strict_id_validation' => false, - ); + ]; if (!is_object($locale)) { $locale = new Localization(); diff --git a/lib/PDF/Exceptions/PDFEngineNotFoundException.php b/lib/PDF/Exceptions/PDFEngineNotFoundException.php new file mode 100644 index 000000000..1088b4083 --- /dev/null +++ b/lib/PDF/Exceptions/PDFEngineNotFoundException.php @@ -0,0 +1,52 @@ +pdf = $pdf ?? new mPDF(); + } + + /** + * @param string $html + * @param int $section 0=default; 1=headerCSS; 2=HTML body; 3=HTML parses; 4=HTML headers; + * @param bool $init Leaves buffers, etc, in current state so that it can continue a block. + * @param bool $close Clears and sets buffers to top level block. + * @return void + */ + public function writeHTML(string $html, int $section = 0, bool $init = true, bool $close = true): void + { + @$this->pdf->WriteHTML($html, $section, $init, $close); + + if ($section === 1) { + @$this->pdf->SetDefaultBodyCSS('background-color', '#FFFFFF'); + unset($this->pdf->cssmgr->CSS['INPUT']['FONT-SIZE']); + } + } + + /** + * @param string $name + * @param string $destination + * @return void|string + */ + public function outputPDF(string $name, string $destination): ?string + { + @$output = $this->pdf->Output($name, $destination); + + if (is_string($output)) { + return $output; + } + } + + /** + * @param string|array $html + * @return void + */ + public function writeHeader(string $html): void + { + @$this->pdf->setHeader($html); + } + + /** + * @param string|array $html + * @return void + */ + public function writeFooter(string $html): void + { + @$this->pdf->setFooter($html); + } + + public function writeBlankPage(): void + { + @$this->pdf->AddPage(); + } + + /** + * @param array $options + * @return void + */ + public function configurePDF(array $options): void + { + $configOptions = [ + 'mode' => $options['mode'] ?? '', + 'page_size' => $options['page_size'] ?? 'A4', + 'default_font_size' => $options['fontSize'] ?? 0, + 'default_font' => $options['font'] ?? '', + 'mgl' => $options['mgl'] ?? 15, + 'mgr' => $options['mgr'] ?? 15, + 'mgt' => $options['mgt'] ?? 16, + 'mgb' => $options['mgb'] ?? 16, + 'mgh' => $options['mgh'] ?? 9, + 'mgf' => $options['mgf'] ?? 9, + 'orientation' => $options['orientation'] ?? 'P' + ]; + + @$this->pdf = new mPDF( + $configOptions['mode'], + $configOptions['page_size'], + $configOptions['default_font_size'], + $configOptions['default_font'], + $configOptions['mgl'], + $configOptions['mgr'], + $configOptions['mgt'], + $configOptions['mgb'], + $configOptions['mgh'], + $configOptions['mgf'], + $configOptions['orientation'], + ); + + @$this->pdf->SetAutoFont(); + } +} diff --git a/lib/PDF/PDFEngine.php b/lib/PDF/PDFEngine.php new file mode 100644 index 000000000..e5096c4ba --- /dev/null +++ b/lib/PDF/PDFEngine.php @@ -0,0 +1,87 @@ + [ + 'name' => 'MPDFEngine', + 'FQN' => MPDFEngine::class, + 'filepath' => 'lib/PDF/MPDF/MPDFEngine.php' + ], + ]; + + /** @var string Path to the folder where to load custom engines from */ + private static $customEnginePath = __DIR__ . '/../../custom/Extension/PDFEngines/'; + + /** + * @param string $engineName + * @param string $file + * @param string $fqn + */ + public static function addEngine(string $engineName, string $file, string $fqn): void + { + self::$engines[$engineName] = [ + 'name' => $engineName, + 'FQN' => $fqn, + 'filepath' => $file, + ]; + } + + /** + * @return PDFEngine + */ + public static function getPDFEngine(): PDFEngine + { + $defaultEngine = self::getDefaultEngine(); + + return self::fetchEngine($defaultEngine); + } + + /** + * Retrieves the available PDF engine class names. + * + * @return string[] + */ + public static function getEngines(): array + { + $default = array_keys(self::$engines); + $custom = []; + foreach (glob(self::$customEnginePath . '*.php', GLOB_NOSORT) as $file) { + $file = pathinfo($file); + $custom[] = $file['filename']; + } + + return array_merge($default, $custom); + } + + /** + * @return string + */ + public static function getDefaultEngine(): string + { + $config = self::getPDFConfig('defaultEngine'); + + return $config ?? key(self::$engines); + } + + /** + * @param string|PDFEngine $engineName + * @return PDFEngine + * @throws PDFEngineNotFoundException + */ + private static function fetchEngine($engineName): PDFEngine + { + if (is_subclass_of($engineName, PDFEngine::class, false)) { + return $engineName; + } + + $customEnginePath = self::$customEnginePath . $engineName . '.php'; + + if (isset(self::$engines[$engineName])) { + $engine = self::$engines[$engineName]; + } elseif (isset($customEnginePath)) { + self::addEngine($engineName, $customEnginePath, $engineName); + $engine = self::$engines[$engineName]; + } else { + throw new PDFEngineNotFoundException( + "PDF engine not found for engine '$engineName''." + ); + } + + $filename = $engine['filepath']; + + if (!is_file($filename)) { + throw new PDFEngineNotFoundException( + "Unable to find PDF file '$filename'' for engine '$engineName''." + ); + } + + /** @noinspection PhpIncludeInspection */ + require_once $filename; + + if (!is_subclass_of($engine['FQN'], PDFEngine::class)) { + throw new PDFEngineNotFoundException( + "The provided class '$engineName' is not a subclass of PDFEngine" + ); + } + + /** @var PDFEngine */ + return new $engine['FQN'](); + } + + /** + * @param $key + * @return mixed|null + */ + private static function getPDFConfig($key) + { + global $sugar_config; + + return $sugar_config['pdf'][$key] ?? null; + } +} diff --git a/lib/Robo/Plugin/Commands/BuildCommands.php b/lib/Robo/Plugin/Commands/BuildCommands.php index 001e9311b..a14abbbd4 100644 --- a/lib/Robo/Plugin/Commands/BuildCommands.php +++ b/lib/Robo/Plugin/Commands/BuildCommands.php @@ -40,13 +40,13 @@ namespace SuiteCRM\Robo\Plugin\Commands; +use Robo\Tasks; +use RuntimeException; use SuiteCRM\Utility\OperatingSystem; use SuiteCRM\Robo\Traits\RoboTrait; -use Robo\Task\Base\loadTasks; -class BuildCommands extends \Robo\Tasks +class BuildCommands extends Tasks { - use loadTasks; use RoboTrait; // define public methods as commands @@ -57,7 +57,7 @@ class BuildCommands extends \Robo\Tasks * @param array $opts optional command line arguments * theme - The name of the theme you want to compile css * color-scheme - set which color scheme you wish to build - * @throws \RuntimeException + * @throws RuntimeException */ public function buildTheme(array $opts = ['theme' => '', 'color-scheme' => '']) { @@ -97,7 +97,7 @@ class BuildCommands extends \Robo\Tasks * Build SuiteP theme * @param array $opts optional command line arguments * color-scheme - set which color scheme you wish to build - * @throws \RuntimeException + * @throws RuntimeException */ public function buildSuiteP(array $opts = ['color-scheme' => '']) { @@ -107,7 +107,7 @@ class BuildCommands extends \Robo\Tasks /** * @param string $colorScheme eg Dawn * @param string $location eg Directory to work from - * @throws \RuntimeException + * @throws RuntimeException */ private function buildColorScheme($colorScheme, $location) { diff --git a/lib/Robo/Plugin/Commands/CodeCoverageCommands.php b/lib/Robo/Plugin/Commands/CodeCoverageCommands.php index 4cf8277ee..7f5a8ed4d 100644 --- a/lib/Robo/Plugin/Commands/CodeCoverageCommands.php +++ b/lib/Robo/Plugin/Commands/CodeCoverageCommands.php @@ -40,13 +40,13 @@ namespace SuiteCRM\Robo\Plugin\Commands; +use Robo\Tasks; +use RuntimeException; use SuiteCRM\Utility\OperatingSystem; use SuiteCRM\Robo\Traits\RoboTrait; -use Robo\Task\Base\loadTasks; -class CodeCoverageCommands extends \Robo\Tasks +class CodeCoverageCommands extends Tasks { - use loadTasks; use RoboTrait; /** @@ -63,7 +63,7 @@ class CodeCoverageCommands extends \Robo\Tasks if ($this->isEnvironmentTravisCI()) { $range = $this->getCommitRangeForTravisCi(); } else { - throw new \RuntimeException('Unable to detect continuous integration environment'); + throw new RuntimeException('Unable to detect continuous integration environment'); } } $this->generateCodeCoverageFile(); diff --git a/lib/Robo/Plugin/Commands/CodingStandardCommands.php b/lib/Robo/Plugin/Commands/CodingStandardCommands.php index cfb5db681..177b9fa8d 100644 --- a/lib/Robo/Plugin/Commands/CodingStandardCommands.php +++ b/lib/Robo/Plugin/Commands/CodingStandardCommands.php @@ -40,13 +40,12 @@ namespace SuiteCRM\Robo\Plugin\Commands; -use Robo\Task\Base\loadTasks; +use Robo\Tasks; use SuiteCRM\Robo\Traits\RoboTrait; use SuiteCRM\Utility\Paths; -class CodingStandardCommands extends \Robo\Tasks +class CodingStandardCommands extends Tasks { - use loadTasks; use RoboTrait; /** diff --git a/lib/Robo/Plugin/Commands/ElasticSearchCommands.php b/lib/Robo/Plugin/Commands/ElasticSearchCommands.php index 5d9052647..90e6c687b 100644 --- a/lib/Robo/Plugin/Commands/ElasticSearchCommands.php +++ b/lib/Robo/Plugin/Commands/ElasticSearchCommands.php @@ -40,7 +40,7 @@ namespace SuiteCRM\Robo\Plugin\Commands; use BeanFactory; -use Robo\Task\Base\loadTasks; +use Robo\Tasks; use SuiteCRM\Robo\Traits\CliRunnerTrait; use SuiteCRM\Robo\Traits\RoboTrait; use SuiteCRM\Search\ElasticSearch\ElasticSearchIndexer; @@ -56,9 +56,8 @@ use SuiteCRM\Utility\BeanJsonSerializer; * * @package SuiteCRM\Robo\Plugin\Commands */ -class ElasticSearchCommands extends \Robo\Tasks +class ElasticSearchCommands extends Tasks { - use loadTasks; use RoboTrait; use CliRunnerTrait; diff --git a/lib/Robo/Plugin/Commands/UpgradeCommands.php b/lib/Robo/Plugin/Commands/UpgradeCommands.php index 98d0b651d..77716aed8 100644 --- a/lib/Robo/Plugin/Commands/UpgradeCommands.php +++ b/lib/Robo/Plugin/Commands/UpgradeCommands.php @@ -40,12 +40,11 @@ namespace SuiteCRM\Robo\Plugin\Commands; -use Robo\Task\Base\loadTasks; +use Robo\Tasks; use SuiteCRM\Robo\Traits\RoboTrait; -class UpgradeCommands extends \Robo\Tasks +class UpgradeCommands extends Tasks { - use loadTasks; use RoboTrait; /** diff --git a/lib/Search/AOD/LuceneSearchEngine.php b/lib/Search/AOD/LuceneSearchEngine.php new file mode 100644 index 000000000..f8226685d --- /dev/null +++ b/lib/Search/AOD/LuceneSearchEngine.php @@ -0,0 +1,178 @@ +index = BeanFactory::getBean("AOD_Index")->getIndex(); + } + + /** + * Search function run when user goes to Show All and runs a search again. This outputs the search results + * calling upon the various listview display functions for each module searched on. + * + * @param SearchQuery $query + * + * @return SearchResults + * @throws Exception + */ + public function search(SearchQuery $query): SearchResults + { + $queryString = $query->getSearchString(); + + $start = microtime(true); + $hits = $this->runLucene($queryString); + $results = $this->parseHits($hits); + $end = microtime(true); + $elapsed = $end - $start; + + return new SearchResults($results['modules'], true, $elapsed, count($results['hits'])); + } + + /** + * + * @param string $queryString + * @return array + */ + private function runLucene(string $queryString): array + { + $cachePath = 'cache/modules/AOD_Index/QueryCache/' . md5($queryString); + if (is_file($cachePath)) { + $mTime = filemtime($cachePath); + if ($mTime > (time() - 5 * 60)) { + $hits = unserialize(sugar_file_get_contents($cachePath)); + } + } + + if (!isset($hits)) { + $hits = $this->newHit($queryString); + } + + return $hits; + } + + /** + * @param string $queryString + * @return array + */ + private function newHit(string $queryString): array + { + global $current_user; + + $tmphits = $this->index->find($queryString); + $hits = []; + foreach ($tmphits as $hit) { + $bean = BeanFactory::getBean($hit->record_module, $hit->record_id); + if (empty($bean)) { + continue; + } + if ($bean->bean_implements('ACL') && !is_admin($current_user)) { + $in_group = SecurityGroup::groupHasAccess($bean->module_dir, $bean->id, 'list'); + $is_owner = $bean->isOwner($current_user->id); + $access = ACLController::checkAccess($bean->module_dir, 'list', $is_owner, 'module', $in_group); + if (!$access) { + continue; + } + } + $newHit = new stdClass; + $newHit->record_module = $hit->record_module; + $newHit->record_id = $hit->record_id; + $hits[] = $newHit; + } + $this->cacheQuery($queryString, $hits); + + return $hits; + } + + /** + * @param mixed $hits + * @return array + */ + private function parseHits(array $hits): array + { + $searchResults = []; + + foreach ($hits as $hit) { + $recordModule = $hit->record_module; + $searchResults[$recordModule][] = $hit->record_id; + } + + return [ + 'hits' => $hits, + 'modules' => $searchResults + ]; + } + + /** + * @param string $queryString + * @param array $resArray + */ + private function cacheQuery(string $queryString, array $resArray): void + { + $file = create_cache_directory('modules/AOD_Index/QueryCache/' . md5($queryString)); + $out = serialize($resArray); + sugar_file_put_contents_atomic($file, $out); + } +} diff --git a/lib/Search/BasicSearch/BasicSearchEngine.php b/lib/Search/BasicSearch/BasicSearchEngine.php new file mode 100644 index 000000000..3bfc12852 --- /dev/null +++ b/lib/Search/BasicSearch/BasicSearchEngine.php @@ -0,0 +1,247 @@ +getSearchModules(); + + $start = microtime(true); + + $results = $this->searchModules($modulesToSearch, $query->getSearchString()); + + $end = microtime(true); + $elapsed = $end - $start; + + return new SearchResults($results['modules'], true, $elapsed, count($results['hits'])); + } + + /** + * @return array + */ + protected function getSearchModules(): array + { + $unifiedSearchModuleDisplay = SearchModules::getUnifiedSearchModulesDisplay(); + + require_once 'include/ListView/ListViewSmarty.php'; + + global $beanList, $current_user; + + $users_modules = $current_user->getPreference('globalSearch', 'search'); + $modulesToSearch = []; + + if (!empty($users_modules)) { + // Use user's previous selections + foreach ($users_modules as $key => $value) { + if (isset($unifiedSearchModuleDisplay[$key]) && !empty($unifiedSearchModuleDisplay[$key]['visible'])) { + $modulesToSearch[$key] = $beanList[$key]; + } + } + } else { + foreach ($unifiedSearchModuleDisplay as $module => $data) { + if (!empty($data['visible'])) { + $modulesToSearch[$module] = $beanList[$module]; + } + } + } + + $current_user->setPreference('globalSearch', $modulesToSearch, 'search'); + + return $modulesToSearch; + } + + /** + * + * @param array $modulesToSearch + * @param string $searchQuery + * @return array + * @noinspection DisconnectedForeachInstructionInspection + * @noinspection PhpIncludeInspection + */ + private function searchModules(array $modulesToSearch, string $searchQuery): array + { + global $beanFiles; + + $unifiedSearchModules = SearchModules::getUnifiedSearchModules(); + + $moduleResults = []; + $moduleCounts = []; + $listViewDefs = []; + + if (!empty($searchQuery)) { + foreach ($modulesToSearch as $moduleName => $beanName) { + require_once $beanFiles[$beanName]; + $seed = new $beanName(); + + $listViewData = new ListViewData(); + + // Retrieve the original list view defs and store for processing in case of custom layout changes + require(__DIR__ . '/../../../modules/' . $seed->module_dir . '/metadata/listviewdefs.php'); + $origListViewDefs = $listViewDefs; + + if (file_exists('custom/modules/' . $seed->module_dir . '/metadata/listviewdefs.php')) { + require('custom/modules/' . $seed->module_dir . '/metadata/listviewdefs.php'); + } + + if (!isset($listViewDefs[$seed->module_dir])) { + continue; + } + + $unifiedSearchFields = []; + $innerJoins = []; + foreach ($unifiedSearchModules[$moduleName]['fields'] as $field => $def) { + $listViewCheckField = strtoupper($field); + // Check to see if the field is in listview defs + // Check to see if field is in original list view defs (in case we are using custom layout defs) + if (empty($listViewDefs[$seed->module_dir][$listViewCheckField]['default']) && + !empty($origListViewDefs[$seed->module_dir][$listViewCheckField]['default'])) { + // If we are here then the layout has been customized, but the field is still needed for query + // creation + $listViewDefs[$seed->module_dir][$listViewCheckField] = $origListViewDefs[$seed->module_dir][$listViewCheckField]; + } + + if (!empty($def['innerjoin'])) { + if (empty($def['db_field'])) { + continue; + } + $def['innerjoin'] = str_replace('INNER', 'LEFT', $def['innerjoin']); + } + + if (isset($seed->field_defs[$field]['type'])) { + $type = $seed->field_defs[$field]['type']; + if ($type === 'int' && !is_numeric($searchQuery)) { + continue; + } + } + + $unifiedSearchFields[$moduleName] [$field] = $def; + $unifiedSearchFields[$moduleName] [$field]['value'] = $searchQuery; + } + + /* + * Use searchForm2->generateSearchWhere() to create the search query, as it can generate SQL for the full set of comparisons required + * generateSearchWhere() expects to find the search conditions for a field in the 'value' parameter of the searchFields entry for that field + */ + require_once $beanFiles[$beanName]; + $seed = new $beanName(); + + require_once $this->searchFormPath; + $searchForm = new $this->searchFormClass($seed, $moduleName); + + $searchForm->setup( + [$moduleName => []], + $unifiedSearchFields, + '', + 'saved_views' + ); + $whereClauses = $searchForm->generateSearchWhere(); + //add inner joins back into the where clause + $params = ['custom_select' => ""]; + foreach ($innerJoins as $field => $def) { + if (isset($def['db_field'])) { + foreach ($def['db_field'] as $dbfield) { + $whereClauses[] = $dbfield . " LIKE '" . DBManagerFactory::getInstance()->quote($searchQuery) . "%'"; + } + $params['custom_select'] .= ", $dbfield"; + $params['distinct'] = true; + } + } + + if (!empty($whereClauses)) { + $where = '((' . implode(' ) OR ( ', $whereClauses) . '))'; + } else { + $where = ''; + } + + $listData = $listViewData->getListViewData($seed, $where, 0, -1, [], $params); + + $moduleCounts[$moduleName] = $listData['pageData']['offsets']['total']; + + foreach ($listData['data'] as $hit) { + $moduleResults[$moduleName][] = $hit['ID']; + } + } + } + + return [ + 'hits' => $moduleCounts, + 'modules' => $moduleResults + ]; + } +} diff --git a/lib/Search/ElasticSearch/ElasticSearchEngine.php b/lib/Search/ElasticSearch/ElasticSearchEngine.php index 3259f5095..3a3f2ea03 100644 --- a/lib/Search/ElasticSearch/ElasticSearchEngine.php +++ b/lib/Search/ElasticSearch/ElasticSearchEngine.php @@ -4,7 +4,7 @@ * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. * * SuiteCRM is an extension to SugarCRM Community Edition developed by SalesAgility Ltd. - * Copyright (C) 2011 - 2018 SalesAgility Ltd. + * Copyright (C) 2011 - 2021 SalesAgility Ltd. * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU Affero General Public License version 3 as published by the @@ -37,14 +37,14 @@ * display the words "Powered by SugarCRM" and "Supercharged by SuiteCRM". */ +namespace SuiteCRM\Search\ElasticSearch; + if (!defined('sugarEntry') || !sugarEntry) { die('Not A Valid Entry Point'); } use Elasticsearch\Client; -use Elasticsearch\Common\Exceptions\BadRequest400Exception; -use SuiteCRM\Search\ElasticSearch\ElasticSearchClientBuilder; -use SuiteCRM\Search\Exceptions\SearchInvalidRequestException; +use SuiteCRM\Exception\InvalidArgumentException; use SuiteCRM\Search\SearchEngine; use SuiteCRM\Search\SearchQuery; use SuiteCRM\Search\SearchResults; @@ -67,7 +67,7 @@ class ElasticSearchEngine extends SearchEngine public function __construct(Client $client = null) { global $sugar_config; - $this->client = $client === null ? ElasticSearchClientBuilder::getClient() : $client; + $this->client = $client ?? ElasticSearchClientBuilder::getClient(); if (!empty($sugar_config['search']['ElasticSearch']['index'])) { $this->index = $sugar_config['search']['ElasticSearch']['index']; @@ -76,8 +76,9 @@ class ElasticSearchEngine extends SearchEngine /** * @inheritdoc + * @throws InvalidArgumentException */ - public function search(SearchQuery $query) + public function search(SearchQuery $query): SearchResults { $this->validateQuery($query); $params = $this->createSearchParams($query); @@ -90,26 +91,10 @@ class ElasticSearchEngine extends SearchEngine return new SearchResults($results, true, $searchTime, $hits['hits']['total']); } - /** - * @return string - */ - public function getIndex() - { - return $this->index; - } - - /** - * @param string $index - */ - public function setIndex($index) - { - $this->index = $index; - } - /** * @param SearchQuery $query */ - protected function validateQuery(SearchQuery &$query) + protected function validateQuery(SearchQuery $query): void { $query->trim(); $query->convertEncoding(); @@ -122,7 +107,7 @@ class ElasticSearchEngine extends SearchEngine * * @return array */ - private function createSearchParams($query) + private function createSearchParams(SearchQuery $query): array { $searchStr = $query->getSearchString(); @@ -174,15 +159,9 @@ class ElasticSearchEngine extends SearchEngine * * @return array */ - private function runElasticSearch($params) + private function runElasticSearch(array $params): array { - try { - $results = $this->client->search($params); - } /** @noinspection PhpRedundantCatchClauseInspection */ catch (BadRequest400Exception $exception) { - throw new SearchInvalidRequestException('The query was not valid.'); - } - - return $results; + return $this->client->search($params); } /** @@ -193,7 +172,7 @@ class ElasticSearchEngine extends SearchEngine * * @return array */ - private function parseHits($hits) + private function parseHits(array $hits): array { $hitsArray = $hits['hits']['hits']; @@ -205,4 +184,20 @@ class ElasticSearchEngine extends SearchEngine return $results; } + + /** + * @return string + */ + public function getIndex(): string + { + return $this->index; + } + + /** + * @param string $index + */ + public function setIndex(string $index): void + { + $this->index = $index; + } } diff --git a/lib/Search/SearchConfigurator.php b/lib/Search/SearchConfigurator.php index 104375dd8..8895eca55 100644 --- a/lib/Search/SearchConfigurator.php +++ b/lib/Search/SearchConfigurator.php @@ -4,7 +4,7 @@ * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. * * SuiteCRM is an extension to SugarCRM Community Edition developed by SalesAgility Ltd. - * Copyright (C) 2011 - 2018 SalesAgility Ltd. + * Copyright (C) 2011 - 2021 SalesAgility Ltd. * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU Affero General Public License version 3 as published by the @@ -77,7 +77,7 @@ class SearchConfigurator * * @return SearchConfigurator */ - public static function make() + public static function make(): SearchConfigurator { return new self(); } @@ -91,16 +91,12 @@ class SearchConfigurator * * @return SearchConfigurator */ - public function setEngine($engine) + public function setEngine(string $engine): SearchConfigurator { if (empty($engine)) { throw new InvalidArgumentException('$engine cannot be empty'); } - if (!is_string($engine)) { - throw new InvalidArgumentException('$engine must be a string'); - } - $searchController = 'UnifiedSearch'; $enableAod = false; @@ -129,7 +125,7 @@ class SearchConfigurator * * @return SearchConfigurator */ - public function save() + public function save(): SearchConfigurator { $this->configurator->saveConfig(); diff --git a/lib/Search/SearchEngine.php b/lib/Search/SearchEngine.php index 346b984c8..6ec7c2242 100644 --- a/lib/Search/SearchEngine.php +++ b/lib/Search/SearchEngine.php @@ -4,7 +4,7 @@ * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. * * SuiteCRM is an extension to SugarCRM Community Edition developed by SalesAgility Ltd. - * Copyright (C) 2011 - 2018 SalesAgility Ltd. + * Copyright (C) 2011 - 2021 SalesAgility Ltd. * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU Affero General Public License version 3 as published by the @@ -59,7 +59,7 @@ abstract class SearchEngine * * @return SearchResults */ - abstract public function search(SearchQuery $query); + abstract public function search(SearchQuery $query): SearchResults; /** * Performs a search using the given query and shows a search view. @@ -68,7 +68,7 @@ abstract class SearchEngine * * @param SearchQuery $query */ - public function searchAndDisplay(SearchQuery $query) + public function searchAndDisplay(SearchQuery $query): void { $this->validateQuery($query); $this->displayForm($query); @@ -84,7 +84,7 @@ abstract class SearchEngine * * @param SearchQuery $query */ - public function displayForm(SearchQuery $query) + public function displayForm(SearchQuery $query): void { $controller = new SearchFormController($query); $controller->display(); @@ -93,10 +93,10 @@ abstract class SearchEngine /** * Shows the default search results for the given search query and results. * - * @param SearchQuery $query + * @param SearchQuery $query * @param SearchResults $results */ - public function displayResults(SearchQuery $query, SearchResults $results) + public function displayResults(SearchQuery $query, SearchResults $results): void { $controller = new SearchResultsController($query, $results); $controller->display(); @@ -114,7 +114,7 @@ abstract class SearchEngine * * @throws SearchInvalidRequestException if the query is not valid */ - protected function validateQuery(SearchQuery &$query) + protected function validateQuery(SearchQuery $query): void { $query->trim(); } diff --git a/lib/Search/SearchModules.php b/lib/Search/SearchModules.php index 249d078c3..b4fe56edb 100644 --- a/lib/Search/SearchModules.php +++ b/lib/Search/SearchModules.php @@ -4,7 +4,7 @@ * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. * * SuiteCRM is an extension to SugarCRM Community Edition developed by SalesAgility Ltd. - * Copyright (C) 2011 - 2018 SalesAgility Ltd. + * Copyright (C) 2011 - 2021 SalesAgility Ltd. * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU Affero General Public License version 3 as published by the @@ -39,6 +39,12 @@ namespace SuiteCRM\Search; +use LoggerManager; +use RuntimeException; +use UnifiedSearchAdvanced; +use BeanFactory; +use VardefManager; + if (!defined('sugarEntry') || !sugarEntry) { die('Not A Valid Entry Point'); } @@ -47,8 +53,6 @@ require_once __DIR__ . '/../../modules/Home/UnifiedSearchAdvanced.php'; /** * Class SearchModules fetches the search modules. - * - * This class currently depends on the Unified Advanced Search to find the modules. */ class SearchModules { @@ -59,7 +63,7 @@ class SearchModules * * @return string[] */ - public static function getModulesList() + public static function getModulesList(): array { $allModules = self::getAllModules(); $allModules = array_merge($allModules['enabled'], $allModules['disabled']); @@ -78,7 +82,7 @@ class SearchModules * * @return string[] */ - public static function getEnabledModules() + public static function getEnabledModules(): array { $allModules = self::getAllModules(); $enabledModules = $allModules['enabled']; @@ -93,12 +97,246 @@ class SearchModules } /** + * saveGlobalSearchSettings + * This method handles the administrator's request to save the searchable modules selected and stores + * the results in the unified_search_modules_display.php file + * + */ + public static function saveGlobalSearchSettings(): void + { + if (isset($_REQUEST['enabled_modules'])) { + $unified_search_modules_display = self::getUnifiedSearchModulesDisplay(); + + $new_unified_search_modules_display = []; + + foreach (explode(',', $_REQUEST['enabled_modules']) as $module) { + $new_unified_search_modules_display[$module]['visible'] = true; + } + + foreach ($unified_search_modules_display as $module => $data) { + if (!isset($new_unified_search_modules_display[$module])) { + $new_unified_search_modules_display[$module]['visible'] = false; + } + } + + self::writeUnifiedSearchModulesDisplayFile($new_unified_search_modules_display); + } + } + + /** + * getUnifiedSearchModulesDisplay + * + * Returns the value of the $unified_search_modules_display variable which is based on the $unified_search_modules + * entries that have been selected to be allowed for searching. + * + * @return array $unified_search_modules_display Array value of modules that have enabled for searching + */ + public static function getUnifiedSearchModulesDisplay(): array + { + $unified_search_modules_display = []; + + if (!file_exists(__DIR__ . '/../../custom/modules/unified_search_modules_display.php')) { + $unified_search_modules = self::getUnifiedSearchModules(); + + if (!empty($unified_search_modules)) { + foreach ($unified_search_modules as $module => $data) { + $unified_search_modules_display[$module]['visible'] = (!empty($data['default'])); + } + } + + self::writeUnifiedSearchModulesDisplayFile($unified_search_modules_display); + } + + include(__DIR__ . '/../../custom/modules/unified_search_modules_display.php'); + + return $unified_search_modules_display; + } + + /** + * getUnifiedSearchModules + * + * Returns the value of the $unified_search_modules variable based on the module's vardefs.php file + * and which fields are marked with the unified_search attribute. + * + * @return array metadata module definitions along with their fields + */ + public static function getUnifiedSearchModules(): array + { + // Make directory if it doesn't exist + $cachedir = sugar_cached('modules'); + if (!file_exists($cachedir)) { + mkdir_recursive($cachedir); + } + + $unified_search_modules = []; + + // Load unified_search_modules.php file + $cachedFile = sugar_cached('modules/unified_search_modules.php'); + if (!is_file($cachedFile)) { + self::buildCache(); + } + + /** @noinspection PhpIncludeInspection */ + include $cachedFile; + + return $unified_search_modules; + } + + /** + * writeUnifiedSearchModulesDisplayFile + * Private method to handle writing the unified_search_modules_display value to file + * + * @param mixed $unified_search_modules_display The array of the unified search modules and their display attributes + * @return bool value indication whether or not file was successfully written + */ + private static function writeUnifiedSearchModulesDisplayFile($unified_search_modules_display): bool + { + if (is_null($unified_search_modules_display) || empty($unified_search_modules_display)) { + return false; + } + + if (!write_array_to_file( + 'unified_search_modules_display', + $unified_search_modules_display, + 'custom/modules/unified_search_modules_display.php' + )) { + global $app_strings; + $msg = string_format($app_strings['ERR_FILE_WRITE'], ['custom/modules/unified_search_modules_display.php']); + LoggerManager::getLogger()->error($msg); + throw new RuntimeException($msg); + } + + return true; + } + + /** @noinspection PhpIncludeInspection */ + public static function buildCache(): void + { + global $beanList, $beanFiles, $dictionary; + + $supportedModules = []; + $metafiles = []; + $searchFields = []; + + foreach ($beanList as $moduleName => $beanName) { + if (!isset($beanFiles[$beanName])) { + continue; + } + + $beanName = BeanFactory::getObjectName($moduleName); + VardefManager::loadVardef($moduleName, $beanName); + + // Obtain the field definitions used by generateSearchWhere (duplicate code in view.list.php) + if (file_exists('custom/modules/' . $moduleName . '/metadata/metafiles.php')) { + require('custom/modules/' . $moduleName . '/metadata/metafiles.php'); + } elseif (file_exists('modules/' . $moduleName . '/metadata/metafiles.php')) { + require('modules/' . $moduleName . '/metadata/metafiles.php'); + } + + + if (!empty($metafiles[$moduleName]['searchfields'])) { + /** @noinspection PhpIncludeInspection */ + require $metafiles[$moduleName]['searchfields']; + } elseif (is_file("modules/{$moduleName}/metadata/SearchFields.php")) { + require "modules/{$moduleName}/metadata/SearchFields.php"; + } + + // Load custom SearchFields.php if it exists + if (is_file("custom/modules/{$moduleName}/metadata/SearchFields.php")) { + require "custom/modules/{$moduleName}/metadata/SearchFields.php"; + } + + // If there are $searchFields are empty, just continue, there are no search fields defined for the module + if (empty($searchFields[$moduleName])) { + continue; + } + + $isCustomModule = preg_match('/^([a-z0-9]{1,5})_([a-z0-9_]+)$/i', $moduleName); + + // If the bean supports unified search or if it's a custom module bean and unified search is not defined + if (!empty($dictionary[$beanName]['unified_search']) || $isCustomModule) { + $fields = []; + foreach ($dictionary [$beanName]['fields'] as $field => $def) { + // We cannot enable or disable unified_search for email in the vardefs as we don't actually have a vardef entry for 'email' + // the searchFields entry for 'email' doesn't correspond to any vardef entry. Instead it contains SQL to directly perform the search. + // So as a proxy we allow any field in the vardefs that has a name starting with 'email...' to be tagged with the 'unified_search' parameter + + if (str_contains($field, 'email')) { + $field = 'email'; + } + + if (str_contains($field, 'phone')) { + $field = 'phone'; + } + + if (!empty($def['unified_search']) && isset($searchFields [$moduleName] [$field])) { + $fields [$field] = $searchFields [$moduleName] [$field]; + } + } + + foreach ($searchFields[$moduleName] as $field => $def) { + if (!empty($def['force_unifiedsearch'])) { + $fields[$field] = $def; + } + } + + if (!empty($fields)) { + $supportedModules[$moduleName]['fields'] = $fields; + if (isset($dictionary[$beanName]['unified_search_default_enabled']) && $dictionary[$beanName]['unified_search_default_enabled'] === true) { + $supportedModules[$moduleName]['default'] = true; + } else { + $supportedModules[$moduleName]['default'] = false; + } + } + } + } + $cacheSearch = sugar_cached('modules/unified_search_modules.php'); + + ksort($supportedModules); + write_array_to_file('unified_search_modules', $supportedModules, $cacheSearch); + } + + /** + * Retrieve the enabled and disabled modules used for global search. * @return array */ - private static function getAllModules() + public static function getAllModules(): array { - $unifiedSearch = new \UnifiedSearchAdvanced(); - $allModules = $unifiedSearch->retrieveEnabledAndDisabledModules(); - return $allModules; + global $app_list_strings; + + $unified_search_modules_display = self::getUnifiedSearchModulesDisplay(); + + $json_enabled = []; + $json_disabled = []; + foreach ($unified_search_modules_display as $module=>$data) { + $label = $app_list_strings['moduleList'][$module] ?? $module; + if ($data['visible'] === true) { + $json_enabled[] = ["module" => $module, 'label' => $label]; + } else { + $json_disabled[] = ["module" => $module, 'label' => $label]; + } + } + + $cacheSearch = sugar_cached('modules/unified_search_modules.php'); + + if (!file_exists($cacheSearch)) { + self::buildCache(); + } + + include($cacheSearch); + + //Now add any new modules that may have since been added to unified_search_modules.php + foreach ($unified_search_modules as $module=>$data) { + if (!isset($unified_search_modules_display[$module])) { + $label = $app_list_strings['moduleList'][$module] ?? $module; + if ($data['default']) { + $json_enabled[] = ["module" => $module, 'label' => $label]; + } else { + $json_disabled[] = ["module" => $module, 'label' => $label]; + } + } + } + + return ['enabled' => $json_enabled, 'disabled' => $json_disabled]; } } diff --git a/lib/Search/SearchQuery.php b/lib/Search/SearchQuery.php index 7022c88f3..d3ed91b99 100644 --- a/lib/Search/SearchQuery.php +++ b/lib/Search/SearchQuery.php @@ -1,10 +1,11 @@ query = strval($searchString); - $this->size = $size ? intval($size) : $this->getDefaultSearchSize(); - $this->from = intval($from); + $this->query = $searchString; + $this->size = $size ? (int)$size : $this->getDefaultSearchSize(); + $this->from = (int)$from; $this->options = $options; - $this->engine = $engine !== null ? strval($engine) : null; + $this->engine = $engine ? (string)$engine : $this->getDefaultEngine(); } /** @@ -102,16 +105,21 @@ class SearchQuery implements \JsonSerializable * * `$size` and `$from` are for pagination. * - * @param string $searchString A string containing the search query. - * @param int $size The number of results - * @param int $from The results offset (for pagination) - * @param string|null $engine Name of the search engine to use. Use default if `null` - * @param array|null $options Array with options (optional) + * @param string $searchString A string containing the search query. + * @param int $size The number of results + * @param int $from The results offset (for pagination) + * @param string|null $engine Name of the search engine to use. Use default if `null` + * @param array|null $options Array with options (optional) * * @return SearchQuery a fully built query */ - public static function fromString($searchString, $size = 50, $from = 0, $engine = null, array $options = []) - { + public static function fromString( + string $searchString, + $size = 50, + $from = 0, + $engine = null, + array $options = [] + ): SearchQuery { return new self($searchString, $engine, $size, $from, $options); } @@ -127,7 +135,7 @@ class SearchQuery implements \JsonSerializable * * @return SearchQuery */ - public static function fromRequestArray(array $request) + public static function fromRequestArray(array $request): SearchQuery { $searchQuery = self::filterArray($request, 'search-query-string', '', FILTER_SANITIZE_STRING); $searchQueryAlt = self::filterArray($request, 'query_string', '', FILTER_SANITIZE_STRING); @@ -153,10 +161,10 @@ class SearchQuery implements \JsonSerializable /** * Makes a Query from a GET request. * - * @see fromRequestArray * @return SearchQuery + * @see fromRequestArray */ - public static function fromGetRequest() + public static function fromGetRequest(): SearchQuery { return self::fromRequestArray($_GET); } @@ -164,10 +172,10 @@ class SearchQuery implements \JsonSerializable /** * Validates and filters values from an array. * - * @param array $array The array to filter - * @param string $key The key of the array to load - * @param mixed $default The default value in case the array value is empty - * @param null|string $filter Optional filter to be used. e.g. FILTER_SANITIZE_STRING + * @param array $array The array to filter + * @param string $key The key of the array to load + * @param mixed $default The default value in case the array value is empty + * @param null|string $filter Optional filter to be used. e.g. FILTER_SANITIZE_STRING * * @return mixed */ @@ -191,9 +199,9 @@ class SearchQuery implements \JsonSerializable * * @return int */ - public function getFrom() + public function getFrom(): int { - return (int)$this->from; + return $this->from; } /** @@ -201,12 +209,42 @@ class SearchQuery implements \JsonSerializable * * @return int */ - public function getSize() + public function getSize(): int { - if ((int)$this->size < 0) { + if ($this->size < 0) { $this->size = 1; } - return (int)$this->size; + + return $this->size; + } + + /** + * Get the default engine by checking the config + * + * @return string + */ + public function getDefaultEngine(): string + { + global $sugar_config; + + if (!empty($sugar_config['search']['defaultEngine'])) { + $defaultEngine = $sugar_config['search']['defaultEngine']; + + if ($defaultEngine === 'BasicAndAodEngine') { + $luceneSearch = !empty($sugar_config['aod']['enable_aod']); + + if (array_key_exists('showGSDiv', $_REQUEST) || !empty($_REQUEST['search_fallback'])) { + // Search from vanilla sugar search or request for the same + $luceneSearch = false; + } + + return $luceneSearch ? 'LuceneSearchEngine' : 'BasicSearchEngine'; + } + + return (string)$sugar_config['search']['defaultEngine']; + } + + return 'BasicSearchEngine'; } /** @@ -214,25 +252,25 @@ class SearchQuery implements \JsonSerializable * * @return int */ - public function getDefaultSearchSize() + public function getDefaultSearchSize(): int { global $sugar_config; - if(isset($sugar_config['search']['query_size'])){ - return (int) $sugar_config['search']['query_size']; + if (isset($sugar_config['search']['query_size'])) { + return (int)$sugar_config['search']['query_size']; } - if(isset($sugar_config['search']['pagination']['min'])){ - return (int) $sugar_config['search']['pagination']['min']; + if (isset($sugar_config['search']['pagination']['min'])) { + return (int)$sugar_config['search']['pagination']['min']; } return static::DEFAULT_SEARCH_SIZE; } /** - * @return null|string + * @return string */ - public function getEngine() + public function getEngine(): string { return $this->engine; } @@ -250,7 +288,7 @@ class SearchQuery implements \JsonSerializable /** * @return array */ - public function getOptions() + public function getOptions(): array { return $this->options; } @@ -260,7 +298,7 @@ class SearchQuery implements \JsonSerializable * * @return bool */ - public function isEmpty() + public function isEmpty(): bool { return empty($this->query); } @@ -272,7 +310,7 @@ class SearchQuery implements \JsonSerializable * * @return string */ - public function getSearchString() + public function getSearchString(): string { return $this->query; } @@ -280,7 +318,7 @@ class SearchQuery implements \JsonSerializable /** * Makes the search string lowercase. */ - public function toLowerCase() + public function toLowerCase(): void { $this->query = strtolower($this->query); } @@ -288,7 +326,7 @@ class SearchQuery implements \JsonSerializable /** * Trims the search string. */ - public function trim() + public function trim(): void { $this->query = trim($this->query); } @@ -299,7 +337,7 @@ class SearchQuery implements \JsonSerializable * @param $what * @param $with */ - public function replace($what, $with) + public function replace($what, $with): void { $this->query = str_replace($what, $with, $this->query); } @@ -307,7 +345,7 @@ class SearchQuery implements \JsonSerializable /** * Removes forward facing slashes used for escaping in the query string. */ - public function stripSlashes() + public function stripSlashes(): void { $this->query = stripslashes($this->query); } @@ -315,7 +353,7 @@ class SearchQuery implements \JsonSerializable /** * Escapes regular expressions so that they are not recognised as such in the query string. */ - public function escapeRegex() + public function escapeRegex(): void { $this->query = preg_quote($this->query, '/'); } @@ -323,7 +361,7 @@ class SearchQuery implements \JsonSerializable /** * Removes HTML entities and converts them in UTF-8 characters. */ - public function convertEncoding() + public function convertEncoding(): void { $this->query = mb_convert_encoding($this->query, 'UTF-8', 'HTML-ENTITIES'); } diff --git a/lib/Search/SearchResults.php b/lib/Search/SearchResults.php index aa3395c5b..522a6d508 100644 --- a/lib/Search/SearchResults.php +++ b/lib/Search/SearchResults.php @@ -4,7 +4,7 @@ * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. * * SuiteCRM is an extension to SugarCRM Community Edition developed by SalesAgility Ltd. - * Copyright (C) 2011 - 2018 SalesAgility Ltd. + * Copyright (C) 2011 - 2021 SalesAgility Ltd. * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU Affero General Public License version 3 as published by the @@ -39,11 +39,11 @@ namespace SuiteCRM\Search; -use SugarBean; use BeanFactory; use LoggerManager; -use RuntimeException; +use SugarBean; use SuiteCRM\Exception\Exception; +use SuiteCRM\Exception\InvalidArgumentException; if (!defined('sugarEntry') || !sugarEntry) { die('Not A Valid Entry Point'); @@ -72,15 +72,22 @@ class SearchResults /** * SearchResults constructor. * - * @param array $hits Contains the results ids - * @param bool $groupedByModule Flag specifying if the (nested) hits are grouped by the modules - * @param float $searchTime The number of seconds it took to perform the search - * @param int $total The number of total hits (without pagination) - * @param array $scores Contains the scores of each hit. This should match in structure with $hits - * @param array $options Similar to scores, but customisable by the search engine + * @param array $hits Contains the results ids + * @param bool $groupedByModule Flag specifying if the (nested) hits are grouped by the modules + * @param float|null $searchTime The number of seconds it took to perform the search + * @param int|null $total The number of total hits (without pagination) + * @param array|null $scores Contains the scores of each hit. This should match in structure with $hits + * @param array|null $options Similar to scores, but customisable by the search engine + * @throws InvalidArgumentException */ - public function __construct(array $hits, $groupedByModule = true, $searchTime = null, $total = null, array $scores = null, array $options = null) - { + public function __construct( + array $hits, + $groupedByModule = true, + float $searchTime = null, + int $total = null, + array $scores = null, + array $options = null + ) { $this->hits = $hits; $this->scores = $scores; $this->options = $options; @@ -88,8 +95,8 @@ class SearchResults $this->searchTime = $searchTime; $this->total = $total; - if ($this->scores != null && count($hits) != count($scores)) { - throw new RuntimeException('The sizes of $hits and $scores must match.'); + if ($this->scores !== null && count($hits) !== count($scores)) { + throw new InvalidArgumentException('The sizes of $hits and $scores must match.'); } } @@ -100,7 +107,7 @@ class SearchResults * * @return array */ - public function getHits() + public function getHits(): array { return $this->hits; } @@ -108,15 +115,16 @@ class SearchResults /** * Fetches the results (originally just module->id) as Beans. * - * @see getHits() * @return array + * @throws Exception + * @see getHits() */ - public function getHitsAsBeans() + public function getHitsAsBeans(): array { - $hits = $this->hits; + $searchHits = $this->hits; $parsed = []; - foreach ($hits as $module => $beans) { + foreach ($searchHits as $module => $beans) { foreach ((array)$beans as $bean) { $obj = BeanFactory::getBean($module, $bean); @@ -129,12 +137,12 @@ class SearchResults } if (!$obj) { - throw new Exception('Error retrieveing bean: ' . $module . ' [' . $bean . ']'); + throw new Exception('Error retrieving bean: ' . $module . ' [' . $bean . ']'); } + $obj->load_relationships(); $fieldDefs = $obj->getFieldDefinitions(); - $objUpdatedLinks = $this->updateFieldDefLinks($obj, $fieldDefs); - $parsed[$module][] = $objUpdatedLinks; + $parsed[$module][] = $this->updateFieldDefLinks($obj, $fieldDefs); } } @@ -147,13 +155,14 @@ class SearchResults * @param array $fieldDefs * @return SugarBean */ - protected function updateFieldDefLinks(SugarBean $obj, $fieldDefs) + protected function updateFieldDefLinks(SugarBean $obj, array $fieldDefs): SugarBean { - foreach ($fieldDefs as &$fieldDef) { + foreach ($fieldDefs as $fieldDef) { if (isset($obj->{$fieldDef['name']})) { $obj = $this->updateObjLinks($obj, $fieldDef); } } + return $obj; } @@ -164,35 +173,43 @@ class SearchResults * @param array $fieldDef * @return SugarBean */ - protected function updateObjLinks(SugarBean $obj, &$fieldDef) + protected function updateObjLinks(SugarBean $obj, array $fieldDef): SugarBean { - if ($fieldDef['type'] == 'relate' && isset($fieldDef['link']) && isset($fieldDef['id_name']) && $fieldDef['id_name']) { + if (isset($fieldDef['link']) && !empty($fieldDef['id_name']) && $fieldDef['type'] === 'relate') { $relId = $this->getRelatedId($obj, $fieldDef['id_name'], $fieldDef['link']); if (!empty($relId)) { - $obj->{$fieldDef['name']} = $this->getLink($obj->{$fieldDef['name']}, $fieldDef['module'], $relId, - 'DetailView'); + $obj->{$fieldDef['name']} = $this->getLink( + $obj->{$fieldDef['name']}, + $fieldDef['module'], + $relId, + 'DetailView' + ); } - } elseif ($fieldDef['name'] == 'name') { - $obj->{$fieldDef['name']} = $this->getLink($obj->{$fieldDef['name']}, $obj->module_name, $obj->id, 'DetailView'); + } elseif ($fieldDef['name'] === 'name') { + $obj->{$fieldDef['name']} = $this->getLink( + $obj->{$fieldDef['name']}, + $obj->module_name, + $obj->id, + 'DetailView' + ); } + return $obj; } /** * resolve related record ID * + * @param SugarBean $obj * @param string $idName * @param string $link * @return null|string */ - protected function getRelatedId(SugarBean $obj, $idName, $link) + protected function getRelatedId(SugarBean $obj, string $idName, string $link): string { - $relId = $obj->id; $relField = $idName; if (isset($obj->$link)) { - $link2 = $obj->$link; - $link2Focus = $link2->getFocus(); - $relId = $link2Focus->$relField; + $relId = $obj->$link->getFocus()->$relField; if (is_object($relId)) { if (method_exists($relId, "getFocus")) { $relId = $relId->getFocus()->id; @@ -204,25 +221,26 @@ class SearchResults $relId = $obj->$relField; } else { $relId = null; - LoggerManager::getLogger()->warn('Unresolved related ID for field: '. $relField); + LoggerManager::getLogger()->warn('Unresolved related ID for field: ' . $relField); } + return $relId; } /** * - * @global array $sugar_config * @param string $label * @param string $module * @param string $record * @param string $action * @return string + * @global array $sugar_config */ - protected function getLink($label, $module, $record, $action) + protected function getLink(string $label, string $module, string $record, string $action): string { global $sugar_config; - $link = "{$label}"; - return $link; + + return "{$label}"; } /** @@ -230,7 +248,7 @@ class SearchResults * * @return array */ - public function getScores() + public function getScores(): ?array { return $this->scores; } @@ -240,7 +258,7 @@ class SearchResults * * @return int */ - public function getTotal() + public function getTotal(): ?int { return $this->total; } @@ -248,7 +266,7 @@ class SearchResults /** * @return array */ - public function getOptions() + public function getOptions(): ?array { return $this->options; } @@ -258,7 +276,7 @@ class SearchResults * * @return array */ - public function getOption($key) + public function getOption(string $key): array { return $this->options[$key]; } @@ -268,7 +286,7 @@ class SearchResults * * @return float */ - public function getSearchTime() + public function getSearchTime(): ?float { return $this->searchTime; } @@ -276,7 +294,7 @@ class SearchResults /** * @return bool */ - public function isGroupedByModule() + public function isGroupedByModule(): bool { return $this->groupedByModule; } diff --git a/lib/Search/SearchWrapper.php b/lib/Search/SearchWrapper.php index 0444377b0..5a05a4f68 100644 --- a/lib/Search/SearchWrapper.php +++ b/lib/Search/SearchWrapper.php @@ -4,7 +4,7 @@ * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. * * SuiteCRM is an extension to SugarCRM Community Edition developed by SalesAgility Ltd. - * Copyright (C) 2011 - 2018 SalesAgility Ltd. + * Copyright (C) 2011 - 2021 SalesAgility Ltd. * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU Affero General Public License version 3 as published by the @@ -43,6 +43,9 @@ if (!defined('sugarEntry') || !sugarEntry) { die('Not A Valid Entry Point'); } +use SuiteCRM\Search\AOD\LuceneSearchEngine; +use SuiteCRM\Search\BasicSearch\BasicSearchEngine; +use SuiteCRM\Search\ElasticSearch\ElasticSearchEngine; use SuiteCRM\Search\Exceptions\SearchEngineNotFoundException; /** @@ -56,7 +59,21 @@ class SearchWrapper * @var array stores an associative array matching the search engine class name with the file it is stored in. */ private static $engines = [ - 'ElasticSearchEngine' => 'lib/Search/ElasticSearch/ElasticSearchEngine.php', + 'ElasticSearchEngine' => [ + 'name' => 'ElasticSearchEngine', + 'FQN' => ElasticSearchEngine::class, + 'filepath' => 'lib/Search/ElasticSearch/ElasticSearchEngine.php' + ], + 'BasicSearchEngine' => [ + 'name' => 'BasicSearchEngine', + 'FQN' => BasicSearchEngine::class, + 'filepath' => 'lib/Search/BasicSearch/BasicSearchEngine.php' + ], + 'LuceneSearchEngine' => [ + 'name' => 'LuceneSearchEngine', + 'FQN' => LuceneSearchEngine::class, + 'filepath' => 'lib/Search/AOD/LuceneSearchEngine.php' + ], ]; /** @var string Path to the folder where to load custom engines from */ @@ -69,7 +86,7 @@ class SearchWrapper * * @param SearchQuery $query */ - public static function searchAndDisplay(SearchQuery $query) + public static function searchAndDisplay(SearchQuery $query): void { $engine = $query->getEngine() ?: self::getDefaultEngine(); @@ -83,26 +100,31 @@ class SearchWrapper * Results are grouped by module. * * @param string|SearchEngine $engine - * @param SearchQuery $query + * @param SearchQuery $query * * @return SearchResults */ - public static function search($engine, SearchQuery $query) + public static function search($engine, SearchQuery $query): SearchResults { $engine = self::fetchEngine($engine); - $results = $engine->search($query); - return $results; + + return $engine->search($query); } /** * Binds a class name / engine name to a file. * - * @param string $className + * @param string $engineName * @param string $file + * @param $fqn */ - public static function addEngine($className, $file) + public static function addEngine(string $engineName, string $file, $fqn): void { - self::$engines[$className] = $file; + self::$engines[$engineName] = [ + 'name' => $engineName, + 'FQN' => $fqn, + 'filepath' => $file, + ]; } /** @@ -110,14 +132,15 @@ class SearchWrapper * * @return string[] */ - public static function getEngines() + public static function getEngines(): array { $default = array_keys(self::$engines); $custom = []; - foreach (glob(self::$customEnginePath . '*.php') as $file) { + foreach (glob(self::$customEnginePath . '*.php', GLOB_NOSORT) as $file) { $file = pathinfo($file); $custom[] = $file['filename']; } + return array_merge($default, $custom); } @@ -128,13 +151,11 @@ class SearchWrapper * * @return string */ - public static function getDefaultEngine() + public static function getDefaultEngine(): string { $config = self::getSearchConfig('defaultEngine'); - return $config === null - ? key(self::$engines) // first engine in the array - : $config; + return $config ?? key(self::$engines); } /** @@ -144,7 +165,7 @@ class SearchWrapper * * @return string|null */ - public static function getController() + public static function getController(): ?string { return self::getSearchConfig('controller'); } @@ -154,7 +175,7 @@ class SearchWrapper * * @return array|null */ - public static function getModules() + public static function getModules(): ?array { return SearchModules::getEnabledModules(); } @@ -167,42 +188,41 @@ class SearchWrapper * * @param string|SearchEngine $engineName * - * @throws SearchEngineNotFoundException * @return SearchEngine + * @throws SearchEngineNotFoundException */ - private static function fetchEngine($engineName) + private static function fetchEngine($engineName): SearchEngine { if (is_subclass_of($engineName, SearchEngine::class, false)) { return $engineName; } - if (!is_string($engineName)) { - throw new SearchEngineNotFoundException('$engineName should either be a string or a SearchEngine'); + $customEnginePath = self::$customEnginePath . $engineName . '.php'; + + if (isset(self::$engines[$engineName])) { + $engine = self::$engines[$engineName]; + } elseif (isset($customEnginePath)) { + self::addEngine($engineName, $customEnginePath, $engineName); + $engine = self::$engines[$engineName]; + } else { + throw new SearchEngineNotFoundException("Search engine not found for engine '$engineName''."); } - if (!preg_match("/^[a-zA-Z0-9_]*$/", $engineName)) { - throw new SearchEngineNotFoundException("'$engineName' is not a valid class name. Only letters, digits and underscores are allowed."); - } + $filename = $engine['filepath']; - $filename = isset(self::$engines[$engineName]) - ? self::$engines[$engineName] - : self::$customEnginePath . $engineName . '.php'; - - if (!file_exists($filename)) { + if (!is_file($filename)) { throw new SearchEngineNotFoundException("Unable to find search file '$filename'' for engine '$engineName''."); } /** @noinspection PhpIncludeInspection */ require_once $filename; - if (!is_subclass_of($engineName, SearchEngine::class)) { + if (!is_subclass_of($engine['FQN'], SearchEngine::class)) { throw new SearchEngineNotFoundException("The provided class '$engineName' is not a subclass of SearchEngine"); } - /** @var SearchEngine $engineName */ - $engineName = new $engineName(); - - return $engineName; + /** @var SearchEngine */ + return new $engine['FQN'](); } /** @@ -219,10 +239,6 @@ class SearchWrapper /** @noinspection PhpVariableNamingConventionInspection */ global $sugar_config; - if (!isset($sugar_config['search'][$key])) { - return null; - } - - return $sugar_config['search'][$key]; + return $sugar_config['search'][$key] ?? null; } } diff --git a/lib/Search/SqlSearch/SimpleSqlSearchEngine.php b/lib/Search/SqlSearch/SimpleSqlSearchEngine.php index 5f43f8547..8b086bd2c 100644 --- a/lib/Search/SqlSearch/SimpleSqlSearchEngine.php +++ b/lib/Search/SqlSearch/SimpleSqlSearchEngine.php @@ -4,7 +4,7 @@ * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. * * SuiteCRM is an extension to SugarCRM Community Edition developed by SalesAgility Ltd. - * Copyright (C) 2011 - 2018 SalesAgility Ltd. + * Copyright (C) 2011 - 2021 SalesAgility Ltd. * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU Affero General Public License version 3 as published by the @@ -37,10 +37,15 @@ * display the words "Powered by SugarCRM" and "Supercharged by SuiteCRM". */ +namespace SuiteCRM\Search\SqlSearch; + if (!defined('sugarEntry') || !sugarEntry) { die('Not A Valid Entry Point'); } +use BeanFactory; +use DBManagerFactory; +use SuiteCRM\Exception\InvalidArgumentException; use SuiteCRM\Search\SearchEngine; use SuiteCRM\Search\SearchQuery; use SuiteCRM\Search\SearchResults; @@ -59,8 +64,9 @@ class SimpleSqlSearchEngine extends SearchEngine * @param SearchQuery $query * * @return SearchResults + * @throws InvalidArgumentException */ - public function search(SearchQuery $query) + public function search(SearchQuery $query): SearchResults { $modules = SearchWrapper::getModules(); @@ -83,16 +89,16 @@ class SimpleSqlSearchEngine extends SearchEngine * * @return array */ - protected function filterTableStructure(array $fields) + protected function filterTableStructure(array $fields): array { $filteredFields = []; foreach ($fields as $name => $type) { - if (strpos($type, 'varchar') == 0) { + if (strpos($type, 'varchar') === 0) { $filteredFields[$name] = 'varchar'; } - if (strpos($type, 'text') == 0) { + if (strpos($type, 'text') === 0) { $filteredFields[$name] = 'text'; } } @@ -103,13 +109,12 @@ class SimpleSqlSearchEngine extends SearchEngine /** * Uses the DBManager getTableDescription method to retrieve the structure of the table in a name->type format. * - * @see \DBManager::getTableDescription() - * * @param string $table * * @return array + * @see \DBManager::getTableDescription() */ - protected function getTableStructure($table) + protected function getTableStructure(string $table): array { $descriptions = DBManagerFactory::getInstance()->getTableDescription($table); @@ -123,7 +128,7 @@ class SimpleSqlSearchEngine extends SearchEngine } /** @inheritdoc */ - protected function validateQuery(SearchQuery &$query) + protected function validateQuery(SearchQuery $query): void { parent::validateQuery($query); $query->convertEncoding(); @@ -133,14 +138,13 @@ class SimpleSqlSearchEngine extends SearchEngine * Performs a search in a single module table and returns a list of ids. * * @param SearchQuery $query - * @param string $module + * @param string $module * * @return array */ - private function searchModule(SearchQuery $query, $module) + private function searchModule(SearchQuery $query, string $module): array { - $seed = BeanFactory::getBean($module); - $table = $seed->table_name; + $table = BeanFactory::getBean($module)->table_name; $fields = $this->filterTableStructure($this->getTableStructure($table)); @@ -150,10 +154,12 @@ class SimpleSqlSearchEngine extends SearchEngine $db = DBManagerFactory::getInstance(); - $result = $db->query($sql); + if (isset($db)) { + $result = $db->query($sql); - while ($row = $db->fetchRow($result)) { - $hits [] = $row['id']; + while ($row = $db->fetchRow($result)) { + $hits [] = $row['id']; + } } return $hits; @@ -163,12 +169,12 @@ class SimpleSqlSearchEngine extends SearchEngine * Makes the search SQL query. * * @param SearchQuery $query - * @param string $table - * @param array $fields + * @param string $table + * @param array $fields * * @return string */ - private function makeSearchQuery(SearchQuery $query, $table, array $fields) + private function makeSearchQuery(SearchQuery $query, string $table, array $fields): string { $sql = 'SELECT id FROM %s WHERE %s AND deleted=0'; @@ -182,7 +188,6 @@ class SimpleSqlSearchEngine extends SearchEngine $wheres[] = sprintf("%s LIKE '%s'", $name, $slashedString); } - $sql = sprintf($sql, $table, implode(' OR ', $wheres)); - return $sql; + return sprintf($sql, $table, implode(' OR ', $wheres)); } } diff --git a/lib/Search/UI/MVC/Controller.php b/lib/Search/UI/MVC/Controller.php index 400c5dfc7..6574aeebb 100644 --- a/lib/Search/UI/MVC/Controller.php +++ b/lib/Search/UI/MVC/Controller.php @@ -4,7 +4,7 @@ * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. * * SuiteCRM is an extension to SugarCRM Community Edition developed by SalesAgility Ltd. - * Copyright (C) 2011 - 2018 SalesAgility Ltd. + * Copyright (C) 2011 - 2021 SalesAgility Ltd. * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU Affero General Public License version 3 as published by the @@ -39,6 +39,9 @@ namespace SuiteCRM\Search\UI\MVC; +use JsonException; +use LoggerManager; + if (!defined('sugarEntry') || !sugarEntry) { die('Not A Valid Entry Point'); } @@ -66,11 +69,12 @@ abstract class Controller * * Always falls back to the 'display' method. */ - public function handle() + public function handle(): void { if ($this->isActionRequest()) { $methodName = $this->getActionName(); $this->$methodName(); + return; } @@ -80,7 +84,7 @@ abstract class Controller /** * Echoes the view. */ - public function display() + public function display(): void { $this->view->preDisplay(); $this->view->display(); @@ -91,7 +95,7 @@ abstract class Controller * * @param string $location */ - public function redirect($location) + public function redirect(string $location): void { header("Location: $location"); exit; @@ -102,9 +106,9 @@ abstract class Controller * * @return bool */ - public function isAjax() + public function isAjax(): bool { - return !empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest'; + return !empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) === 'xmlhttprequest'; } /** @@ -112,11 +116,15 @@ abstract class Controller * * @param array $data */ - public function yieldJson(array $data) + public function yieldJson(array $data): void { - ob_clean(); // deletes the rest of the html previous to this. + ob_clean(); header('Content-Type: application/json'); - echo json_encode($data); + try { + echo json_encode($data, JSON_THROW_ON_ERROR); + } catch (JSONException $e) { + LoggerManager::getLogger()->warn('Search UI JSON encoding failed: ' . $e->getMessage()); + } exit; } @@ -125,7 +133,7 @@ abstract class Controller * * @return bool */ - private function isActionRequest() + private function isActionRequest(): bool { return method_exists($this, $this->getActionName()); } @@ -135,7 +143,7 @@ abstract class Controller * * @return string */ - private function getActionName() + private function getActionName(): string { return 'do' . filter_input(INPUT_GET, 'do', FILTER_SANITIZE_STRING); } diff --git a/lib/Search/UI/MVC/View.php b/lib/Search/UI/MVC/View.php index d7b8fff43..ffd970473 100644 --- a/lib/Search/UI/MVC/View.php +++ b/lib/Search/UI/MVC/View.php @@ -4,7 +4,7 @@ * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. * * SuiteCRM is an extension to SugarCRM Community Edition developed by SalesAgility Ltd. - * Copyright (C) 2011 - 2018 SalesAgility Ltd. + * Copyright (C) 2011 - 2021 SalesAgility Ltd. * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU Affero General Public License version 3 as published by the @@ -60,7 +60,7 @@ abstract class View * * @param string $file */ - public function __construct($file) + public function __construct(string $file) { $this->smarty = new Sugar_Smarty(); $this->templateFile = $file; @@ -69,7 +69,7 @@ abstract class View /** * @return Sugar_Smarty */ - public function getTemplate() + public function getTemplate(): Sugar_Smarty { return $this->smarty; } @@ -77,14 +77,14 @@ abstract class View /** * Where to assign vars to the template. */ - public function preDisplay() + public function preDisplay(): void { } /** * Renders the template. */ - public function display() + public function display(): void { $this->smarty->display($this->templateFile); } @@ -92,7 +92,7 @@ abstract class View /** * @return string */ - public function getTemplateFile() + public function getTemplateFile(): string { return $this->templateFile; } @@ -100,7 +100,7 @@ abstract class View /** * @param string $templateFile */ - public function setTemplateFile($templateFile) + public function setTemplateFile(string $templateFile): void { $this->templateFile = $templateFile; } diff --git a/lib/Search/UI/SearchFormController.php b/lib/Search/UI/SearchFormController.php index f1de92b33..40f184796 100644 --- a/lib/Search/UI/SearchFormController.php +++ b/lib/Search/UI/SearchFormController.php @@ -4,7 +4,7 @@ * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. * * SuiteCRM is an extension to SugarCRM Community Edition developed by SalesAgility Ltd. - * Copyright (C) 2011 - 2018 SalesAgility Ltd. + * Copyright (C) 2011 - 2021 SalesAgility Ltd. * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU Affero General Public License version 3 as published by the @@ -58,18 +58,23 @@ class SearchFormController extends Controller * * @param SearchQuery $query */ - public function __construct($query) + public function __construct(SearchQuery $query) { parent::__construct(new SearchFormView()); $this->query = $query; } - public function display() + public function display(): void { - $this->view->getTemplate()->assign('searchQueryString', htmlspecialchars($this->query->getSearchString(), ENT_COMPAT | ENT_XHTML, 'UTF-8')); - $this->view->getTemplate()->assign('searchQuerySize', $this->query->getSize()); - $this->view->getTemplate()->assign('searchQueryFrom', $this->query->getFrom()); - $this->view->getTemplate()->assign('searchQueryEngine', $this->query->getEngine()); + $smarty = $this->view->getTemplate(); + + $smarty->assign( + 'searchQueryString', + htmlspecialchars($this->query->getSearchString(), ENT_COMPAT | ENT_XHTML, 'UTF-8') + ); + $smarty->assign('searchQuerySize', $this->query->getSize()); + $smarty->assign('searchQueryFrom', $this->query->getFrom()); + $smarty->assign('searchQueryEngine', $this->query->getEngine()); parent::display(); } diff --git a/lib/Search/UI/SearchFormView.php b/lib/Search/UI/SearchFormView.php index 8ba3696cd..556f23036 100644 --- a/lib/Search/UI/SearchFormView.php +++ b/lib/Search/UI/SearchFormView.php @@ -4,7 +4,7 @@ * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. * * SuiteCRM is an extension to SugarCRM Community Edition developed by SalesAgility Ltd. - * Copyright (C) 2011 - 2018 SalesAgility Ltd. + * Copyright (C) 2011 - 2021 SalesAgility Ltd. * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU Affero General Public License version 3 as published by the @@ -60,7 +60,7 @@ class SearchFormView extends View } /** @inheritdoc */ - public function display() + public function display(): void { $sizes = $this->makeSizesFromConfig(); $engines = []; @@ -80,25 +80,25 @@ class SearchFormView extends View * * @return array */ - protected function makeSizesFromConfig() + protected function makeSizesFromConfig(): ?array { global $sugar_config; - + if (!isset($sugar_config['search']['pagination']['min'])) { LoggerManager::getLogger()->warn('Configuration does not contains value for search pagination min'); } - + if (!isset($sugar_config['search']['pagination']['step'])) { LoggerManager::getLogger()->warn('Configuration does not contains value for search pagination step'); } - + if (!isset($sugar_config['search']['pagination']['max'])) { LoggerManager::getLogger()->warn('Configuration does not contains value for search pagination max'); } - - $min = isset($sugar_config['search']['pagination']['min']) ? $sugar_config['search']['pagination']['min'] : null; - $step = isset($sugar_config['search']['pagination']['step']) ? $sugar_config['search']['pagination']['step'] : null; - $max = isset($sugar_config['search']['pagination']['max']) ? $sugar_config['search']['pagination']['max'] : null; + + $min = $sugar_config['search']['pagination']['min'] ?? null; + $step = $sugar_config['search']['pagination']['step'] ?? null; + $max = $sugar_config['search']['pagination']['max'] ?? null; try { return $this->makeSizes($min, $step, $max); @@ -110,32 +110,31 @@ class SearchFormView extends View /** * Makes an array with the page size from the given parameters. * - * @param int $min - * @param int $step - * @param int $max - * - * @throws InvalidArgumentException in case of failure + * @param int|null $min + * @param int|null $step + * @param int|null $max * * @return array + * @throws InvalidArgumentException in case of failure */ - protected function makeSizes($min, $step, $max) + protected function makeSizes(?int $min, ?int $step, ?int $max): array { - $min = intval($min); - $step = intval($step); - $max = intval($max); + $min = (int)$min; + $step = (int)$step; + $max = (int)$max; - if (!is_integer($min) || !is_integer($step) || !is_integer($max)) { + if (!is_int($min) || !is_int($step) || !is_int($max)) { throw new InvalidArgumentException('Arguments must be integers'); } + if ($max === 0 || $step === 0 || $min === 0) { + throw new InvalidArgumentException('Arguments cannot be zero'); + } + if ($min > $max) { throw new InvalidArgumentException('$min must be smaller than $max'); } - if ($max == 0 || $min == 0 || $min == 0) { - throw new InvalidArgumentException('Arguments cannot be zero'); - } - $sizes = []; for ($it = $min; $it <= $max; $it += $step) { diff --git a/lib/Search/UI/SearchResultsController.php b/lib/Search/UI/SearchResultsController.php index 7b8cd2ade..36e78ab7d 100644 --- a/lib/Search/UI/SearchResultsController.php +++ b/lib/Search/UI/SearchResultsController.php @@ -1,11 +1,10 @@ results = $results; } - public function display() + public function display(): void { - $headers = $this->getListViewHeaders(); + $headers = []; + + try { + $headers = $this->getListViewHeaders(); + } catch (Exception $e) { + LoggerManager::getLogger()->warn('Failed to fetch list-view headers: ' . $e->getMessage()); + } $total = $this->results->getTotal(); if ($total > 1) { @@ -99,7 +106,7 @@ class SearchResultsController extends Controller $page = (int)($from / $size) + 1; $prev = $page > 1; $next = $total - $from > $size; - $last = (int)($total / $size) + ($total%$size === 0 ? 0 : 1); + $last = (int)($total / $size) + ($total % $size === 0 ? 0 : 1); $this->view->getTemplate()->assign('pagination', [ 'prev' => $prev, @@ -115,11 +122,16 @@ class SearchResultsController extends Controller throw new SearchException('Search Size can not be Zero.', SearchException::ZERO_SIZE); } } - $this->view->getTemplate()->assign('total', $total); - $this->view->getTemplate()->assign('headers', $headers); - $this->view->getTemplate()->assign('results', $this->results); - $this->view->getTemplate()->assign('resultsAsBean', $this->results->getHitsAsBeans()); + $smarty = $this->view->getTemplate(); + $smarty->assign('total', $total); + $smarty->assign('headers', $headers); + $smarty->assign('results', $this->results); + try { + $smarty->assign('resultsAsBean', $this->results->getHitsAsBeans()); + } catch (\SuiteCRM\Exception\Exception $e) { + LoggerManager::getLogger()->fatal("Failed to retrieve ElasticSearch options"); + } parent::display(); } @@ -127,25 +139,30 @@ class SearchResultsController extends Controller /** * * @return array of header info - * @throws Exception + * @throws SearchException */ - protected function getListViewHeaders() + protected function getListViewHeaders(): array { $headers = []; - $listViewDefs = $this->getListViewDefs(); - foreach ($listViewDefs as $module => $listViewDef) { + foreach ($this->getListViewDefs() as $module => $listViewDef) { $bean = BeanFactory::getBean($module); if (!$bean) { - throw new Exception('Module bean not found for search results: ' . $module); + throw new SearchException('Module bean not found for search results: ' . $module); } foreach ($listViewDef as $fieldKey => $fieldValue) { - if (isset($fieldValue['default']) && $fieldValue['default']) { - $header = $this->getListViewHeader($bean, $fieldKey, $fieldValue); + if (!empty($fieldValue['default'])) { + $header = []; + try { + $header = $this->getListViewHeader($bean, $fieldKey, $fieldValue); + } catch (ErrorMessageException $e) { + LoggerManager::getLogger()->warn('Failed to fetch list-view headers: ' . $e->getMessage()); + } $headers[$module][$fieldKey] = array_merge($fieldValue, $header); } } } + return $headers; } @@ -153,20 +170,21 @@ class SearchResultsController extends Controller * * @return array of list view definitions */ - protected function getListViewDefs() + protected function getListViewDefs(): array { $listViewDefs = []; if ($this->results->isGroupedByModule()) { - $modules = array_keys($this->results->getHits()); - foreach ($modules as $module) { + foreach (array_keys($this->results->getHits()) as $module) { $viewList = new ViewList(); $viewList->type = 'list'; $viewList->module = $module; $metaDataFile = $viewList->getMetaDataFile(); + /** @noinspection PhpIncludeInspection */ require($metaDataFile); } } + return $listViewDefs; } @@ -176,16 +194,17 @@ class SearchResultsController extends Controller * @param string $fieldKey * @param string $fieldValue * @return array of header + * @throws ErrorMessageException */ - protected function getListViewHeader(SugarBean $bean, $fieldKey, $fieldValue) + protected function getListViewHeader(SugarBean $bean, string $fieldKey, $fieldValue): array { $fieldDef = $bean->getFieldDefinition(strtolower($fieldKey)); - $header = [ + + return [ 'label' => $this->getListViewHeaderLabel($bean, $fieldValue, $fieldDef), - 'comment' => isset($fieldDef['comment']) ? $fieldDef['comment'] : null, + 'comment' => $fieldDef['comment'] ?? null, 'field' => $fieldDef['name'], ]; - return $header; } /** @@ -193,9 +212,10 @@ class SearchResultsController extends Controller * @param SugarBean $bean * @param array $fieldValue * @param array $fieldDef - * @return array of label + * @return string|null of label + * @throws ErrorMessageException */ - protected function getListViewHeaderLabel(SugarBean $bean, $fieldValue, $fieldDef) + protected function getListViewHeaderLabel(SugarBean $bean, $fieldValue, $fieldDef): ?string { $label = isset($fieldValue['label']) ? LangText::get( @@ -212,6 +232,7 @@ class SearchResultsController extends Controller LangText::get($fieldDef['vname'], null, LangText::USING_ALL_STRINGS, true, false, $bean->module_name) : null; } + return $label; } } diff --git a/lib/Search/UI/SearchThrowableHandler.php b/lib/Search/UI/SearchThrowableHandler.php index bea94b2ba..cc6a317fb 100644 --- a/lib/Search/UI/SearchThrowableHandler.php +++ b/lib/Search/UI/SearchThrowableHandler.php @@ -4,7 +4,7 @@ * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. * * SuiteCRM is an extension to SugarCRM Community Edition developed by SalesAgility Ltd. - * Copyright (C) 2011 - 2018 SalesAgility Ltd. + * Copyright (C) 2011 - 2021 SalesAgility Ltd. * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU Affero General Public License version 3 as published by the @@ -44,6 +44,7 @@ if (!defined('sugarEntry') || !sugarEntry) { } use Elasticsearch\Common\Exceptions\NoNodesAvailableException; +use Exception; use SuiteCRM\Search\Exceptions\SearchEngineNotFoundException; use SuiteCRM\Search\Exceptions\SearchException; use SuiteCRM\Search\Exceptions\SearchInvalidRequestException; @@ -71,10 +72,10 @@ class SearchThrowableHandler /** * SearchThrowableHandler constructor. * - * @param Throwable $throwable + * @param Throwable $throwable * @param SearchQuery $query */ - public function __construct($throwable, SearchQuery $query) + public function __construct(Throwable $throwable, SearchQuery $query) { $this->throwable = $throwable; $this->query = $query; @@ -85,7 +86,7 @@ class SearchThrowableHandler * * If developer mode is enabled, a full exception page will be shown. */ - public function handle() + public function handle(): void { global $sugar_config; @@ -97,6 +98,7 @@ class SearchThrowableHandler if ($sugar_config['developerMode'] === true) { $this->printStackTrace(); + return; } @@ -108,30 +110,37 @@ class SearchThrowableHandler * * @return string */ - private function getFriendlyMessage() + private function getFriendlyMessage(): string { global $mod_strings; switch (get_class($this->throwable)) { case SearchUserFriendlyException::class: - return $this->throwable->getMessage(); + $message = $this->throwable->getMessage(); + break; case SearchInvalidRequestException::class: - return $mod_strings['LBL_ELASTIC_SEARCH_EXCEPTION_SEARCH_INVALID_REQUEST']; + $message = $mod_strings['LBL_ELASTIC_SEARCH_EXCEPTION_SEARCH_INVALID_REQUEST']; + break; case SearchEngineNotFoundException::class: - return $mod_strings['LBL_ELASTIC_SEARCH_EXCEPTION_SEARCH_ENGINE_NOT_FOUND']; + $message = $mod_strings['LBL_ELASTIC_SEARCH_EXCEPTION_SEARCH_ENGINE_NOT_FOUND']; + break; case NoNodesAvailableException::class: - return $mod_strings['LBL_ELASTIC_SEARCH_EXCEPTION_NO_NODES_AVAILABLE']; + $message = $mod_strings['LBL_ELASTIC_SEARCH_EXCEPTION_NO_NODES_AVAILABLE']; + break; case SearchException::class: - return $mod_strings['LBL_ELASTIC_SEARCH_EXCEPTION_SEARCH']; + $message = $mod_strings['LBL_ELASTIC_SEARCH_EXCEPTION_SEARCH']; + break; default: - return $mod_strings['LBL_ELASTIC_SEARCH_EXCEPTION_DEFAULT']; + $message = $mod_strings['LBL_ELASTIC_SEARCH_EXCEPTION_DEFAULT']; } + + return $message; } /** * Cancels the current output and prints a full screen detailed exception page */ - private function printStackTrace() + private function printStackTrace(): void { $whoops = new Run; $handler = new PrettyPageHandler; @@ -142,7 +151,7 @@ class SearchThrowableHandler $whoops->pushHandler($handler); $whoops->register(); - $whoops->handleException($this->throwable); + echo $whoops->handleException($this->throwable); } /** @@ -150,7 +159,7 @@ class SearchThrowableHandler * * @return array */ - private function getSearchWrapperStatus() + private function getSearchWrapperStatus(): ?array { try { return [ @@ -159,7 +168,7 @@ class SearchThrowableHandler 'Default Search Engine' => SearchWrapper::getDefaultEngine(), 'Friendly Error Message' => $this->getFriendlyMessage(), ]; - } catch (\Exception $exception) { + } catch (Exception $exception) { return ['error' => 'failed to get SearchWrapper status']; } } @@ -167,7 +176,7 @@ class SearchThrowableHandler /** * Prints the error on the page. */ - private function printFriendlyMessage() + private function printFriendlyMessage(): void { global $mod_strings; diff --git a/lib/Search/UI/templates/search.form.tpl b/lib/Search/UI/templates/search.form.tpl index 1e1495d22..8e98160d6 100644 --- a/lib/Search/UI/templates/search.form.tpl +++ b/lib/Search/UI/templates/search.form.tpl @@ -3,7 +3,7 @@ * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. * * SuiteCRM is an extension to SugarCRM Community Edition developed by SalesAgility Ltd. - * Copyright (C) 2011 - 2018 SalesAgility Ltd. + * Copyright (C) 2011 - 2021 SalesAgility Ltd. * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU Affero General Public License version 3 as published by the @@ -44,54 +44,53 @@ {*hidden input to handle actions*} {search_controller} - - - - - - - - - -
- - -   -
-
- - - + +
- - {html_options options=$sizeOptions selected=$searchQuerySize id="search-query-size" name="search-query-size"} -    - + + + + + + + - - + {if $engineOptions|@count gt 1} + + {html_options options=$engineOptions selected=$searchQueryEngine id="search-engine" name="search-engine"} + {else} + {assign var=firstRow value=$engineOptions|@key} + + {/if} + +
+ + +   +
+
+ + + + {html_options options=$sizeOptions selected=$searchQuerySize id="search-query-size" name="search-query-size"} +    + - {if $engineOptions|@count gt 1} - - {html_options options=$engineOptions selected=$searchQueryEngine id="search-engine" name="search-engine"} - {else} - {assign var=firstRow value=$engineOptions|@key} - - {/if} - - -
-
-
+ +
diff --git a/modules/AOR_Reports/controller.php b/modules/AOR_Reports/controller.php index 6cc1d03a6..3f3e64c71 100755 --- a/modules/AOR_Reports/controller.php +++ b/modules/AOR_Reports/controller.php @@ -1,5 +1,4 @@ */ +use SuiteCRM\PDF\Exceptions\PDFException; +use SuiteCRM\PDF\PDFWrapper; -require_once("modules/AOW_WorkFlow/aow_utils.php"); -require_once("modules/AOR_Reports/aor_utils.php"); +require_once __DIR__ . '/../../modules/AOW_WorkFlow/aow_utils.php'; +require_once __DIR__ . '/../../modules/AOR_Reports/aor_utils.php'; +/** + * Class AOR_ReportsController + */ class AOR_ReportsController extends SugarController { protected function action_getModuleFields() @@ -172,7 +176,7 @@ class AOR_ReportsController extends SugarController set_time_limit(0); if (!$this->bean->ACLAccess('Export')) { SugarApplication::appendErrorMessage(translate('LBL_NO_ACCESS', 'ACL')); - SugarApplication::redirect("index.php?module=AOR_Reports&action=DetailView&record=".$this->bean->id); + SugarApplication::redirect("index.php?module=AOR_Reports&action=DetailView&record=" . $this->bean->id); sugar_die(''); } $this->bean->user_parameters = requestToUserParameters($this->bean); @@ -180,48 +184,45 @@ class AOR_ReportsController extends SugarController die; } - protected function action_downloadPDF() + /** + * @throws Exception + * @noinspection PhpMethodParametersCountMismatchInspection + */ + protected function action_downloadPDF(): void { if (!$this->bean->ACLAccess('Export')) { SugarApplication::appendErrorMessage(translate('LBL_NO_ACCESS', 'ACL')); - SugarApplication::redirect("index.php?module=AOR_Reports&action=DetailView&record=".$this->bean->id); + SugarApplication::redirect('index.php?module=AOR_Reports&action=DetailView&record=' . $this->bean->id); sugar_die(''); } - $errorLevelStored = error_reporting(); - error_reporting(0); - require_once('modules/AOS_PDF_Templates/PDF_Lib/mpdf.php'); - error_reporting($errorLevelStored); - - $d_image = explode('?', SugarThemeRegistry::current()->getImageURL('company_logo.png')); + $d_image = explode('?', SugarThemeRegistry::current()->getImageURL('company_logo.png'), 2); $graphs = $_POST["graphsForPDF"]; $graphHtml = "
"; $chartsPerRow = $this->bean->graphs_per_row; - $countOfCharts = count($graphs); - if ($countOfCharts > 0) { - $width = ((int)100 / $chartsPerRow); + + if (is_countable($graphs)) { + $countOfCharts = count($graphs); + } + if (!empty($countOfCharts) && $countOfCharts > 0) { + $width = (100 / $chartsPerRow); $modulusRemainder = $countOfCharts % $chartsPerRow; if ($modulusRemainder > 0) { - $modulusWidth = ((int)100 / $modulusRemainder); + $modulusWidth = (100 / $modulusRemainder); $itemsWithModulus = $countOfCharts - $modulusRemainder; } - - for ($x = 0; $x < $countOfCharts; $x++) { + foreach ($graphs as $x => $xValue) { if (is_null($itemsWithModulus) || $x < $itemsWithModulus) { - $graphHtml .= ""; + $graphHtml .= ""; } else { - $graphHtml .= ""; + $graphHtml .= ""; } } - /* foreach($graphs as $g) - { - $graphHtml.=""; - }*/ $graphHtml .= "
"; } @@ -249,25 +250,23 @@ class AOR_ReportsController extends SugarController

' . $graphHtml; $this->bean->user_parameters = requestToUserParameters($this->bean); - $printable = $this->bean->build_group_report(-1, false); $stylesheet = file_get_contents(SugarThemeRegistry::current()->getCSSURL('style.css', false)); - ob_clean(); - try { - $pdf = new mPDF('en', 'A4', '', 'DejaVuSansCondensed'); - $pdf->SetAutoFont(); - $pdf->setFooter('{PAGENO}'); - $pdf->WriteHTML($stylesheet, 1); - $pdf->SetDefaultBodyCSS('background-color', '#FFFFFF'); - unset($pdf->cssmgr->CSS['INPUT']['FONT-SIZE']); - $pdf->WriteHTML($head, 2); - $pdf->WriteHTML($printable, 3); - $pdf->Output($this->bean->name . '.pdf', "D"); - } catch (mPDF_exception $e) { - echo $e; - } - die; + try { + $pdf = PDFWrapper::getPDFEngine(); + $pdf->configurePDF([ + 'mode' => 'en', + 'font' => 'DejaVuSansCondensed', + ]); + $pdf->writeFooter('{PAGENO}'); + $pdf->writeHTML($stylesheet, 1); + $pdf->writeHTML($head, 2); + $pdf->writeHTML($printable, 3); + $pdf->outputPDF($this->bean->name . '.pdf', 'D'); + } catch (PDFException $e) { + LoggerManager::getLogger()->warn('PDFException: ' . $e->getMessage()); + } } protected function action_getModuleFunctionField() @@ -282,9 +281,9 @@ class AOR_ReportsController extends SugarController if ($view == 'EditView') { echo ""; + $app_list_strings['aor_function_list'], + $value + ) . ""; } else { echo $app_list_strings['aor_function_list'][$value]; } @@ -383,9 +382,9 @@ class AOR_ReportsController extends SugarController $app_list_strings['aor_operator_list']; if ($view == 'EditView') { echo ""; + $app_list_strings['aor_operator_list'], + $value + ) . ""; } else { echo $app_list_strings['aor_operator_list'][$value]; } @@ -465,9 +464,9 @@ class AOR_ReportsController extends SugarController if ($view == 'EditView') { echo ""; + $app_list_strings['aor_condition_type_list'], + $value + ) . ""; } else { echo $app_list_strings['aor_condition_type_list'][$value]; } @@ -547,9 +546,9 @@ class AOR_ReportsController extends SugarController if ($view == 'EditView') { echo ""; + $app_list_strings['aor_action_type_list'], + $value + ) . ""; } else { echo $app_list_strings['aor_action_type_list'][$value]; } @@ -589,10 +588,10 @@ class AOR_ReportsController extends SugarController } if ($view == 'EditView') { echo ""; + $module, + $view, + $value + ) . ""; } else { echo getModuleFields($module, $view, $value); } @@ -606,9 +605,9 @@ class AOR_ReportsController extends SugarController case 'Period': if ($view == 'EditView') { echo ""; + 'date_time_period_list', + $_REQUEST['aor_value'] + ) . ""; } else { echo getDropdownList('date_time_period_list', $_REQUEST['aor_value']); } @@ -649,10 +648,10 @@ class AOR_ReportsController extends SugarController } if ($view == 'EditView') { echo ""; + $module, + $view, + $value + ) . ""; } else { echo getModuleFields($module, $view, $value); } @@ -725,10 +724,10 @@ class AOR_ReportsController extends SugarController } if ($view == 'EditView') { echo ""; + $module, + $view, + $value + ) . ""; } else { echo getModuleFields($module, $view, $value); } @@ -784,9 +783,9 @@ class AOR_ReportsController extends SugarController if ($view == 'EditView') { echo ""; + $app_list_strings['aor_rel_action_type_list'], + $value + ) . ""; } else { echo $app_list_strings['aor_rel_action_type_list'][$value]; } diff --git a/modules/AOS_PDF_Templates/PDF_Lib/classes/bmp.php b/modules/AOS_PDF_Templates/PDF_Lib/classes/bmp.php index ffb78ab1c..1fdb4c53a 100755 --- a/modules/AOS_PDF_Templates/PDF_Lib/classes/bmp.php +++ b/modules/AOS_PDF_Templates/PDF_Lib/classes/bmp.php @@ -4,12 +4,10 @@ class bmp { public $mpdf = null; -var $mpdf = null; - -function __construct(&$mpdf) { - $this->mpdf = $mpdf; -} - + public function __construct(&$mpdf) + { + $this->mpdf = $mpdf; + } public function _getBMPimage($data, $file) { diff --git a/modules/AOS_PDF_Templates/PDF_Lib/classes/cssmgr.php b/modules/AOS_PDF_Templates/PDF_Lib/classes/cssmgr.php index 5a0ce975f..1309b9339 100755 --- a/modules/AOS_PDF_Templates/PDF_Lib/classes/cssmgr.php +++ b/modules/AOS_PDF_Templates/PDF_Lib/classes/cssmgr.php @@ -12,16 +12,16 @@ class cssmgr public $listCSSlvl; - -function __construct(&$mpdf) { - $this->mpdf = $mpdf; - $this->tablecascadeCSS = array(); - $this->listcascadeCSS = array(); - $this->CSS=array(); - $this->cascadeCSS = array(); - $this->tbCSSlvl = 0; - $this->listCSSlvl = 0; -} + public function __construct(&$mpdf) + { + $this->mpdf = $mpdf; + $this->tablecascadeCSS = array(); + $this->listcascadeCSS = array(); + $this->CSS = array(); + $this->cascadeCSS = array(); + $this->tbCSSlvl = 0; + $this->listCSSlvl = 0; + } public function ReadDefaultCSS($CSSstr) diff --git a/modules/AOS_PDF_Templates/PDF_Lib/classes/directw.php b/modules/AOS_PDF_Templates/PDF_Lib/classes/directw.php index 130e6fbe2..7b0549b70 100755 --- a/modules/AOS_PDF_Templates/PDF_Lib/classes/directw.php +++ b/modules/AOS_PDF_Templates/PDF_Lib/classes/directw.php @@ -4,11 +4,10 @@ class directw { public $mpdf = null; -var $mpdf = null; - -function __construct(&$mpdf) { - $this->mpdf = $mpdf; -} + public function __construct(&$mpdf) + { + $this->mpdf = $mpdf; + } public function Write($h, $txt, $currentx=0, $link='', $directionality='ltr', $align='') diff --git a/modules/AOS_PDF_Templates/PDF_Lib/classes/form.php b/modules/AOS_PDF_Templates/PDF_Lib/classes/form.php index 04f72b4c7..58c9e9318 100755 --- a/modules/AOS_PDF_Templates/PDF_Lib/classes/form.php +++ b/modules/AOS_PDF_Templates/PDF_Lib/classes/form.php @@ -49,7 +49,7 @@ class form // FORMS public $textarea_lineheight; -function __construct(&$mpdf) { +public function __construct(&$mpdf) { $this->mpdf = $mpdf; // ACTIVE FORMS diff --git a/modules/AOS_PDF_Templates/PDF_Lib/classes/gif.php b/modules/AOS_PDF_Templates/PDF_Lib/classes/gif.php index eb1ce92cf..7f6a12faf 100755 --- a/modules/AOS_PDF_Templates/PDF_Lib/classes/gif.php +++ b/modules/AOS_PDF_Templates/PDF_Lib/classes/gif.php @@ -42,7 +42,7 @@ class CGIFLZW /////////////////////////////////////////////////////////////////////////// // CONSTRUCTOR - function __construct() + public function __construct() { $this->MAX_LZW_BITS = 12; unSet($this->Next); @@ -255,7 +255,7 @@ class CGIFCOLORTABLE /////////////////////////////////////////////////////////////////////////// // CONSTRUCTOR - function __construct() + public function __construct() { unSet($this->m_nColors); unSet($this->m_arColors); @@ -342,7 +342,7 @@ class CGIFFILEHEADER /////////////////////////////////////////////////////////////////////////// // CONSTRUCTOR - function __construct() + public function __construct() { unSet($this->m_lpVer); unSet($this->m_nWidth); @@ -418,7 +418,7 @@ class CGIFIMAGEHEADER /////////////////////////////////////////////////////////////////////////// // CONSTRUCTOR - function __construct() + public function __construct() { unSet($this->m_nLeft); unSet($this->m_nTop); @@ -488,7 +488,7 @@ class CGIFIMAGE /////////////////////////////////////////////////////////////////////////// - function __construct() + public function __construct() { unSet($this->m_disp); unSet($this->m_bUser); @@ -662,7 +662,7 @@ class CGIF /////////////////////////////////////////////////////////////////////////// // CONSTRUCTOR - function __construct() + public function __construct() { $this->m_gfh = new CGIFFILEHEADER(); $this->m_img = new CGIFIMAGE(); diff --git a/modules/AOS_PDF_Templates/PDF_Lib/classes/grad.php b/modules/AOS_PDF_Templates/PDF_Lib/classes/grad.php index 5d6ee416f..0d65ba751 100755 --- a/modules/AOS_PDF_Templates/PDF_Lib/classes/grad.php +++ b/modules/AOS_PDF_Templates/PDF_Lib/classes/grad.php @@ -4,11 +4,10 @@ class grad { public $mpdf = null; -var $mpdf = null; - -function __construct(&$mpdf) { - $this->mpdf = $mpdf; -} + public function __construct(&$mpdf) + { + $this->mpdf = $mpdf; + } // mPDF 5.3.A1 public function CoonsPatchMesh($x, $y, $w, $h, $patch_array=array(), $x_min=0, $x_max=1, $y_min=0, $y_max=1, $colspace='RGB', $return=false) diff --git a/modules/AOS_PDF_Templates/PDF_Lib/classes/indic.php b/modules/AOS_PDF_Templates/PDF_Lib/classes/indic.php index 654964d08..33e880b4c 100755 --- a/modules/AOS_PDF_Templates/PDF_Lib/classes/indic.php +++ b/modules/AOS_PDF_Templates/PDF_Lib/classes/indic.php @@ -2,9 +2,10 @@ class indic { -function __construct() { + public function __construct() + { -} + } public function substituteIndic($earr, $lang, $font) diff --git a/modules/AOS_PDF_Templates/PDF_Lib/classes/svg.php b/modules/AOS_PDF_Templates/PDF_Lib/classes/svg.php index 9a7784756..47b0c92f6 100755 --- a/modules/AOS_PDF_Templates/PDF_Lib/classes/svg.php +++ b/modules/AOS_PDF_Templates/PDF_Lib/classes/svg.php @@ -31,25 +31,7 @@ class SVG public $kp; // mPDF 4.4.003 convert pixels to PDF units public $pathBBox; // mPDF 5.0.039 - var $svg_gradient; // array - contient les infos sur les gradient fill du svg class� par id du svg - var $svg_shadinglist; // array - contient les ids des objet shading - var $svg_info; // array contenant les infos du svg voulue par l'utilisateur - var $svg_attribs; // array - holds all attributes of root tag - var $svg_style; // array contenant les style de groupes du svg - var $svg_string; // String contenant le tracage du svg en lui m�me. - var $txt_data; // array - holds string info to write txt to image - var $txt_style; // array - current text style - var $mpdf_ref; - var $xbase; // mPDF 4.4.003 - var $ybase; // mPDF 4.4.003 - var $svg_error; // mPDF 4.4.003 - var $subPathInit; // mPDF 4.4.003 - var $spxstart; // mPDF 4.4.003 - var $spystart; // mPDF 4.4.003 - var $kp; // mPDF 4.4.003 convert pixels to PDF units - var $pathBBox; // mPDF 5.0.039 - - function __construct(&$mpdf){ + public function __construct(&$mpdf){ $this->svg_gradient = array(); $this->svg_shadinglist = array(); $this->txt_data = array(); diff --git a/modules/AOS_PDF_Templates/PDF_Lib/classes/tocontents.php b/modules/AOS_PDF_Templates/PDF_Lib/classes/tocontents.php index 6590e0d26..fec704bde 100755 --- a/modules/AOS_PDF_Templates/PDF_Lib/classes/tocontents.php +++ b/modules/AOS_PDF_Templates/PDF_Lib/classes/tocontents.php @@ -29,39 +29,13 @@ class tocontents public $TOC_page_selector; public $m_TOC; -var $mpdf = null; -var $_toc; -var $TOCmark; -var $TOCoutdent; // mPDF 5.6.31 -var $TOCpreHTML; -var $TOCpostHTML; -var $TOCbookmarkText; -var $TOCusePaging; -var $TOCuseLinking; -var $TOCorientation; -var $TOC_margin_left; -var $TOC_margin_right; -var $TOC_margin_top; -var $TOC_margin_bottom; -var $TOC_margin_header; -var $TOC_margin_footer; -var $TOC_odd_header_name; -var $TOC_even_header_name; -var $TOC_odd_footer_name; -var $TOC_even_footer_name; -var $TOC_odd_header_value; -var $TOC_even_header_value; -var $TOC_odd_footer_value; -var $TOC_even_footer_value; -var $TOC_page_selector; -var $m_TOC; - -function __construct(&$mpdf) { - $this->mpdf = $mpdf; - $this->_toc=array(); - $this->TOCmark = 0; - $this->m_TOC=array(); -} + public function __construct(&$mpdf) + { + $this->mpdf = $mpdf; + $this->_toc = array(); + $this->TOCmark = 0; + $this->m_TOC = array(); + } public function TOCpagebreak($tocfont='', $tocfontsize='', $tocindent='', $TOCusePaging=true, $TOCuseLinking='', $toc_orientation='', $toc_mgl='', $toc_mgr='', $toc_mgt='', $toc_mgb='', $toc_mgh='', $toc_mgf='', $toc_ohname='', $toc_ehname='', $toc_ofname='', $toc_efname='', $toc_ohvalue=0, $toc_ehvalue=0, $toc_ofvalue=0, $toc_efvalue=0, $toc_preHTML='', $toc_postHTML='', $toc_bookmarkText='', $resetpagenum='', $pagenumstyle='', $suppress='', $orientation='', $mgl='', $mgr='', $mgt='', $mgb='', $mgh='', $mgf='', $ohname='', $ehname='', $ofname='', $efname='', $ohvalue=0, $ehvalue=0, $ofvalue=0, $efvalue=0, $toc_id=0, $pagesel='', $toc_pagesel='', $sheetsize='', $toc_sheetsize='', $tocoutdent='') { // mPDF 5.6.19 diff --git a/modules/AOS_PDF_Templates/PDF_Lib/classes/ttfontsuni.php b/modules/AOS_PDF_Templates/PDF_Lib/classes/ttfontsuni.php index 641a5be5d..7fb73012c 100755 --- a/modules/AOS_PDF_Templates/PDF_Lib/classes/ttfontsuni.php +++ b/modules/AOS_PDF_Templates/PDF_Lib/classes/ttfontsuni.php @@ -83,48 +83,7 @@ class TTFontFile public $maxUniChar; public $kerninfo; -var $unAGlyphs; // mPDF 5.4.05 -var $panose; -var $maxUni; -var $sFamilyClass; -var $sFamilySubClass; -var $sipset; -var $smpset; -var $_pos; -var $numTables; -var $searchRange; -var $entrySelector; -var $rangeShift; -var $tables; -var $otables; -var $filename; -var $fh; -var $glyphPos; -var $charToGlyph; -var $ascent; -var $descent; -var $name; -var $familyName; -var $styleName; -var $fullName; -var $uniqueFontID; -var $unitsPerEm; -var $bbox; -var $capHeight; -var $stemV; -var $italicAngle; -var $flags; -var $underlinePosition; -var $underlineThickness; -var $charWidths; -var $defaultWidth; -var $maxStrLenRead; -var $numTTCFonts; -var $TTCFonts; -var $maxUniChar; -var $kerninfo; - - function __construct() { + public function __construct() { $this->maxStrLenRead = 200000; // Maximum size of glyf table to read in as string (otherwise reads each glyph from file) } diff --git a/modules/AOS_PDF_Templates/PDF_Lib/classes/wmf.php b/modules/AOS_PDF_Templates/PDF_Lib/classes/wmf.php index e555bce14..63bb4fd1f 100755 --- a/modules/AOS_PDF_Templates/PDF_Lib/classes/wmf.php +++ b/modules/AOS_PDF_Templates/PDF_Lib/classes/wmf.php @@ -5,12 +5,10 @@ class wmf public $mpdf = null; public $gdiObjectArray; -var $mpdf = null; -var $gdiObjectArray; - -function __construct(&$mpdf) { - $this->mpdf = $mpdf; -} + public function __construct(&$mpdf) + { + $this->mpdf = $mpdf; + } public function _getWMFimage($data) diff --git a/modules/AOS_PDF_Templates/PDF_Lib/mpdf.php b/modules/AOS_PDF_Templates/PDF_Lib/mpdf.php index 4290229c6..b07d86e98 100755 --- a/modules/AOS_PDF_Templates/PDF_Lib/mpdf.php +++ b/modules/AOS_PDF_Templates/PDF_Lib/mpdf.php @@ -839,7 +839,7 @@ public $aliasNbPgHex; // ********************************** // ********************************** -function __construct($mode='',$format='A4',$default_font_size=0,$default_font='',$mgl=15,$mgr=15,$mgt=16,$mgb=16,$mgh=9,$mgf=9, $orientation='P') { +public function __construct($mode='',$format='A4',$default_font_size=0,$default_font='',$mgl=15,$mgr=15,$mgt=16,$mgb=16,$mgh=9,$mgf=9, $orientation='P') { /*-- BACKGROUNDS --*/ if (!class_exists('grad', false)) { diff --git a/modules/AOS_PDF_Templates/PDF_Lib/mpdfi/fpdi_pdf_parser.php b/modules/AOS_PDF_Templates/PDF_Lib/mpdfi/fpdi_pdf_parser.php index f6dcf843e..936ea4514 100755 --- a/modules/AOS_PDF_Templates/PDF_Lib/mpdfi/fpdi_pdf_parser.php +++ b/modules/AOS_PDF_Templates/PDF_Lib/mpdfi/fpdi_pdf_parser.php @@ -61,7 +61,7 @@ class fpdi_pdf_parser extends pdf_parser * @param string $filename Source-Filename * @param object $fpdi Object of type fpdi */ - function __construct($filename,&$fpdi) { + public function __construct($filename,&$fpdi) { $this->fpdi =& $fpdi; $this->filename = $filename; diff --git a/modules/AOS_PDF_Templates/PDF_Lib/mpdfi/pdf_context.php b/modules/AOS_PDF_Templates/PDF_Lib/mpdfi/pdf_context.php index 868761137..7b9a10631 100755 --- a/modules/AOS_PDF_Templates/PDF_Lib/mpdfi/pdf_context.php +++ b/modules/AOS_PDF_Templates/PDF_Lib/mpdfi/pdf_context.php @@ -28,7 +28,7 @@ class pdf_context // Constructor - function __construct($f) { + public function __construct($f) { $this->file = $f; $this->reset(); } diff --git a/modules/AOS_PDF_Templates/PDF_Lib/mpdfi/pdf_parser.php b/modules/AOS_PDF_Templates/PDF_Lib/mpdfi/pdf_parser.php index 16d00a725..4c5fe7232 100755 --- a/modules/AOS_PDF_Templates/PDF_Lib/mpdfi/pdf_parser.php +++ b/modules/AOS_PDF_Templates/PDF_Lib/mpdfi/pdf_parser.php @@ -94,7 +94,7 @@ class pdf_parser * * @param string $filename Source-Filename */ - function __construct($filename) { + public function __construct($filename) { $this->filename = $filename; // mPDF 4.0 $this->success = true; diff --git a/modules/AOS_PDF_Templates/formLetterPdf.php b/modules/AOS_PDF_Templates/formLetterPdf.php index 28af29749..ff945fd22 100755 --- a/modules/AOS_PDF_Templates/formLetterPdf.php +++ b/modules/AOS_PDF_Templates/formLetterPdf.php @@ -38,7 +38,9 @@ * display the words "Powered by SugarCRM" and "Supercharged by SuiteCRM". */ -require_once('modules/AOS_PDF_Templates/PDF_Lib/mpdf.php'); +use SuiteCRM\PDF\Exceptions\PDFException; +use SuiteCRM\PDF\PDFWrapper; + require_once('modules/AOS_PDF_Templates/templateParser.php'); require_once('modules/AOS_PDF_Templates/AOS_PDF_Templates.php'); @@ -77,13 +79,44 @@ if (!$template) { $file_name = str_replace(" ", "_", $template->name) . ".pdf"; -$format = $template->page_size . ($template->orientation === 'Landscape' ? '-L' : ''); - -$pdf = new mPDF('en', $format, '', 'DejaVuSansCondensed', $template->margin_left, $template->margin_right, $template->margin_top, $template->margin_bottom, $template->margin_header, $template->margin_footer); +try { + $pdf = PDFWrapper::getPDFEngine(); + $pdf->configurePDF([ + 'mode' => 'en', + 'page_size' => $template->page_size, + 'font' => 'DejaVuSansCondensed', + 'mgl' => $template->margin_left, + 'mgr' => $template->margin_right, + 'mgt' => $template->margin_top, + 'mgb' => $template->margin_bottom, + 'mgh' => $template->margin_header, + 'mgf' => $template->margin_footer, + 'orientation' => $template->orientation + ]); +} catch (PDFException $e) { + LoggerManager::getLogger()->warn('PDFException: ' . $e->getMessage()); +} foreach ($recordIds as $recordId) { $bean->retrieve($recordId); - $pdf_history = new mPDF('en', $format, '', 'DejaVuSansCondensed', $template->margin_left, $template->margin_right, $template->margin_top, $template->margin_bottom, $template->margin_header, $template->margin_footer); + + try { + $pdfHistory = PDFWrapper::getPDFEngine(); + $pdfHistory->configurePDF([ + 'mode' => 'en', + 'page_size' => $template->page_size, + 'font' => 'DejaVuSansCondensed', + 'mgl' => $template->margin_left, + 'mgr' => $template->margin_right, + 'mgt' => $template->margin_top, + 'mgb' => $template->margin_bottom, + 'mgh' => $template->margin_header, + 'mgf' => $template->margin_footer, + 'orientation' => $template->orientation + ]); + } catch (PDFException $e) { + LoggerManager::getLogger()->warn('PDFException: ' . $e->getMessage()); + } $object_arr = array(); $object_arr[$bean->module_dir] = $bean->id; @@ -92,7 +125,8 @@ foreach ($recordIds as $recordId) { $object_arr['Accounts'] = $bean->account_id; } - $search = array('@]*?>.*?@si', // Strip out javascript + $search = array( + '@]*?>.*?@si', // Strip out javascript '@<[\/\!]*?[^<>]*?>@si', // Strip out HTML tags '@([\r\n])[\s]+@', // Strip out white space '@&(quot|#34);@i', // Replace HTML entities @@ -104,7 +138,8 @@ foreach ($recordIds as $recordId) { '@]*?>@si' ); - $replace = array('', + $replace = array( + '', '', '\1', '"', @@ -133,7 +168,6 @@ foreach ($recordIds as $recordId) { $printable = str_replace("\n", "
", $converted); - ob_clean(); try { $note = BeanFactory::newBean('Notes'); $note->modified_user_id = $current_user->id; @@ -153,22 +187,20 @@ foreach ($recordIds as $recordId) { $fp = fopen($sugar_config['upload_dir'] . 'nfile.pdf', 'wb'); fclose($fp); - $pdf_history->SetAutoFont(); - $pdf_history->SetHTMLHeader($header); - $pdf_history->SetHTMLFooter($footer); - $pdf_history->WriteHTML($printable); - $pdf_history->Output($sugar_config['upload_dir'] . 'nfile.pdf', 'F'); + $pdfHistory->writeHeader($header); + $pdfHistory->writeFooter($footer); + $pdfHistory->writeHTML($printable); + $pdfHistory->outputPDF($sugar_config['upload_dir'] . 'nfile.pdf', 'F'); - $pdf->SetHTMLHeader($header); - $pdf->AddPage(); - $pdf->setAutoFont(); - $pdf->SetHTMLFooter($footer); + $pdf->writeHeader($header); + $pdf->writeBlankPage(); + $pdf->writeFooter($footer); $pdf->writeHTML($printable); rename($sugar_config['upload_dir'] . 'nfile.pdf', $sugar_config['upload_dir'] . $note->id); - } catch (mPDF_exception $e) { - echo $e; + } catch (PDFException $e) { + LoggerManager::getLogger()->warn('PDFException: ' . $e->getMessage()); } } -$pdf->Output($file_name, "D"); +$pdf->outputPDF($file_name, 'D'); diff --git a/modules/AOS_PDF_Templates/generatePdf.php b/modules/AOS_PDF_Templates/generatePdf.php index 050ab04ca..5b0fb33aa 100755 --- a/modules/AOS_PDF_Templates/generatePdf.php +++ b/modules/AOS_PDF_Templates/generatePdf.php @@ -5,7 +5,7 @@ * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. * * SuiteCRM is an extension to SugarCRM Community Edition developed by SalesAgility Ltd. - * Copyright (C) 2011 - 2018 SalesAgility Ltd. + * Copyright (C) 2011 - 2021 SalesAgility Ltd. * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU Affero General Public License version 3 as published by the @@ -38,17 +38,16 @@ * display the words "Powered by SugarCRM" and "Supercharged by SuiteCRM". */ +use SuiteCRM\PDF\Exceptions\PDFException; +use SuiteCRM\PDF\PDFWrapper; + if (!isset($_REQUEST['uid']) || empty($_REQUEST['uid']) || !isset($_REQUEST['templateID']) || empty($_REQUEST['templateID'])) { die('Error retrieving record. This record may be deleted or you may not be authorized to view it.'); } -$errorLevelStored = error_reporting(); -error_reporting(0); -require_once('modules/AOS_PDF_Templates/PDF_Lib/mpdf.php'); require_once('modules/AOS_PDF_Templates/templateParser.php'); require_once('modules/AOS_PDF_Templates/sendEmail.php'); require_once('modules/AOS_PDF_Templates/AOS_PDF_Templates.php'); -error_reporting($errorLevelStored); global $mod_strings, $sugar_config; @@ -139,28 +138,39 @@ $footer = templateParser::parse_template($footer, $object_arr); $printable = str_replace("\n", "
", $converted); -if ($task == 'pdf' || $task == 'emailpdf') { +if ($task === 'pdf' || $task === 'emailpdf') { $file_name = $mod_strings['LBL_PDF_NAME'] . "_" . str_replace(" ", "_", $bean->name) . ".pdf"; - ob_clean(); try { - $orientation = ($template->orientation == "Landscape") ? "-L" : ""; - $pdf = new mPDF('en', $template->page_size . $orientation, '', 'DejaVuSansCondensed', $template->margin_left, $template->margin_right, $template->margin_top, $template->margin_bottom, $template->margin_header, $template->margin_footer); - $pdf->SetAutoFont(); - $pdf->SetHTMLHeader($header); - $pdf->SetHTMLFooter($footer); - $pdf->WriteHTML($printable); - if ($task == 'pdf') { - $pdf->Output($file_name, "D"); + $pdf = PDFWrapper::getPDFEngine(); + $pdf->configurePDF([ + 'mode' => 'en', + 'page_size' => $template->page_size, + 'font' => 'DejaVuSansCondensed', + 'mgl' => $template->margin_left, + 'mgr' => $template->margin_right, + 'mgt' => $template->margin_top, + 'mgb' => $template->margin_bottom, + 'mgh' => $template->margin_header, + 'mgf' => $template->margin_footer, + 'orientation' => $template->orientation + ]); + + $pdf->writeHeader($header); + $pdf->writeFooter($footer); + $pdf->writeHTML($printable); + + if ($task === 'pdf') { + $pdf->outputPDF($file_name, "D"); } else { $fp = fopen($sugar_config['upload_dir'] . 'attachfile.pdf', 'wb'); fclose($fp); - $pdf->Output($sugar_config['upload_dir'] . 'attachfile.pdf', 'F'); + $pdf->outputPDF($sugar_config['upload_dir'] . 'attachfile.pdf', 'F'); $sendEmail = new sendEmail(); $sendEmail->send_email($bean, $bean->module_dir, '', $file_name, true); } - } catch (mPDF_exception $e) { - echo $e; + } catch (PDFException $e) { + LoggerManager::getLogger()->warn('PDFException: ' . $e->getMessage()); } } elseif ($task == 'email') { $sendEmail = new sendEmail(); diff --git a/modules/Administration/AODAdmin.php b/modules/Administration/AODAdmin.php deleted file mode 100644 index 242d258c0..000000000 --- a/modules/Administration/AODAdmin.php +++ /dev/null @@ -1,107 +0,0 @@ -" . translate('LBL_MODULE_NAME', 'Administration') . "", - $mod_strings['LBL_AOD_ADMIN_MANAGE_AOD'], - ), - false -); - -$cfg = new Configurator(); -$sugar_smarty = new Sugar_Smarty(); -$errors = array(); - -if (!array_key_exists('aod', $cfg->config)) { - $cfg->config['aod'] = array( - 'enable_aod' => '', - ); -} -if (isset($_REQUEST['do']) && $_REQUEST['do'] == 'save') { - $cfg->config['aod']['enable_aod'] = !empty($_REQUEST['enable_aod']); - $cfg->saveConfig(); - header('Location: index.php?module=Administration&action=index'); - exit(); -} -$sugar_smarty->assign('MOD', $mod_strings); -$sugar_smarty->assign('APP', $app_strings); -$sugar_smarty->assign('APP_LIST', $app_list_strings); -$sugar_smarty->assign('LANGUAGES', get_languages()); -$sugar_smarty->assign("JAVASCRIPT", get_set_focus_js()); -$sugar_smarty->assign('config', $cfg->config['aod']); -$sugar_smarty->assign('error', $errors); - - -$buttons = << -   -EOQ; - -$sugar_smarty->assign("BUTTONS", $buttons); - -$sugar_smarty->display('modules/Administration/AODAdmin.tpl'); - -$javascript = new javascript(); -$javascript->setFormName('ConfigureSettings'); -echo $javascript->getScript(); diff --git a/modules/Administration/AODAdmin.tpl b/modules/Administration/AODAdmin.tpl deleted file mode 100644 index 07e598554..000000000 --- a/modules/Administration/AODAdmin.tpl +++ /dev/null @@ -1,31 +0,0 @@ - - -
- - {$error.main} - - - - - -
- {$BUTTONS} -
- - - - - - - - - -

{$MOD.LBL_GENERAL_SETTINGS}

{$MOD.LBL_AOD_ENABLE}: - -
-
- {$BUTTONS} -
- {$JAVASCRIPT} -
diff --git a/modules/Administration/Search/Controller.php b/modules/Administration/Search/Controller.php index 077130bc5..b3584ea73 100644 --- a/modules/Administration/Search/Controller.php +++ b/modules/Administration/Search/Controller.php @@ -40,15 +40,18 @@ namespace SuiteCRM\Modules\Administration\Search; use SuiteCRM\Search\SearchConfigurator; +use SuiteCRM\Modules\Administration\Search\MVC\Controller as AbstractController; +use Configurator; +use Exception; +use SuiteCRM\Search\SearchModules; if (!defined('sugarEntry') || !sugarEntry) { die('Not A Valid Entry Point'); } - /** * Class Controller handles the the actions for the search settings. */ -class Controller extends MVC\Controller +class Controller extends AbstractController { public function __construct() { @@ -59,19 +62,43 @@ class Controller extends MVC\Controller * Saves the configuration from a POST request. * * If called from ajax it will return a json. + * @throws Exception */ - public function doSave() + public function doSave(): void { $searchEngine = filter_input(INPUT_POST, 'search-engine', FILTER_SANITIZE_STRING); + $aod = $searchEngine === 'BasicAndAodEngine'; SearchConfigurator::make() ->setEngine($searchEngine) ->save(); + SearchModules::saveGlobalSearchSettings(); + $this->doSaveAODConfig($aod); + if ($this->isAjax()) { $this->yieldJson(['status' => 'success']); } $this->redirect('index.php?module=Administration&action=index'); } + + /** + * Saves the configuration getting data from POST. + * @param bool $enabled + */ + public function doSaveAODConfig(bool $enabled): void + { + $cfg = new Configurator(); + + if (!array_key_exists('aod', $cfg->config)) { + $cfg->config['aod'] = [ + 'enable_aod' => '', + ]; + } + + $cfg->config['aod']['enable_aod'] = $enabled; + + $cfg->saveConfig(); + } } diff --git a/modules/Administration/Search/ElasticSearch/Controller.php b/modules/Administration/Search/ElasticSearch/Controller.php index 0fd2affa2..1b7bcc1d4 100644 --- a/modules/Administration/Search/ElasticSearch/Controller.php +++ b/modules/Administration/Search/ElasticSearch/Controller.php @@ -76,7 +76,7 @@ class Controller extends AbstractController /** * Shows the view. */ - public function display() + public function display(): void { $this->view->getTemplate()->assign('schedulers', $this->getSchedulers()); parent::display(); @@ -184,6 +184,7 @@ class Controller extends AbstractController $where = "schedulers.job='function::runElasticSearchIndexerScheduler'"; /** @var Scheduler[]|null $schedulers */ $schedulers = BeanFactory::getBean('Schedulers')->get_full_list(null, $where); + return $schedulers; } diff --git a/modules/Administration/Search/ElasticSearch/View.php b/modules/Administration/Search/ElasticSearch/View.php index 6329266d1..9fd692b18 100644 --- a/modules/Administration/Search/ElasticSearch/View.php +++ b/modules/Administration/Search/ElasticSearch/View.php @@ -58,7 +58,7 @@ class View extends AbstractView parent::__construct(__DIR__ . '/view.tpl'); } - public function preDisplay() + public function preDisplay(): void { parent::preDisplay(); @@ -67,9 +67,9 @@ class View extends AbstractView if (!isset($sugar_config['search']['ElasticSearch']) || $sugar_config['search']['ElasticSearch']) { LoggerManager::getLogger()->warn('Configuration does not contains Elasticsearch default settings.'); } - + $elasticsearchConfig = isset($sugar_config['search']['ElasticSearch']) ? $sugar_config['search']['ElasticSearch'] : null; - + $this->smarty->assign('config', $elasticsearchConfig); } } diff --git a/modules/Administration/templates/GlobalSearchSettings.tpl b/modules/Administration/Search/GlobalSearchSettings.tpl old mode 100755 new mode 100644 similarity index 50% rename from modules/Administration/templates/GlobalSearchSettings.tpl rename to modules/Administration/Search/GlobalSearchSettings.tpl index 494d3698b..3b8c6fd46 --- a/modules/Administration/templates/GlobalSearchSettings.tpl +++ b/modules/Administration/Search/GlobalSearchSettings.tpl @@ -5,7 +5,7 @@ * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. * * SuiteCRM is an extension to SugarCRM Community Edition developed by SalesAgility Ltd. - * Copyright (C) 2011 - 2018 SalesAgility Ltd. + * Copyright (C) 2011 - 2021 SalesAgility Ltd. * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU Affero General Public License version 3 as published by the @@ -37,17 +37,10 @@ * reasonably feasible for technical reasons, the Appropriate Legal Notices must * display the words "Powered by SugarCRM" and "Supercharged by SuiteCRM". */ - *} +

{$MOD.LBL_SEARCH_MODULES}

+ - - - - - - -deprecated( + 'UnifiedSearchAdvanced is deprecated since v7.12.0, please use Search.php instead' + ); + if (!empty($_REQUEST['query_string'])) { $query_string = trim($_REQUEST['query_string']); if (!empty($query_string)) { @@ -67,6 +76,11 @@ class UnifiedSearchAdvanced $this->cache_display = sugar_cached('modules/unified_search_modules_display.php'); } + /** + * @deprecated since v7.12.0 + * @param string $tpl + * @return string + */ public function getDropDownDiv($tpl = 'modules/Home/UnifiedSearchAdvanced.tpl') { global $app_list_strings, $app_strings; @@ -153,6 +167,7 @@ class UnifiedSearchAdvanced /** + * @deprecated since v7.12.0 * search * * Search function run when user goes to Show All and runs a search again. This outputs the search results @@ -281,7 +296,7 @@ class UnifiedSearchAdvanced */ require_once $beanFiles[$beanName] ; $seed = new $beanName(); - + require_once $this->searchFormPath; $searchForm = new $this->searchFormClass($seed, $moduleName) ; @@ -359,6 +374,9 @@ class UnifiedSearchAdvanced } } + /** + * @deprecated since v7.12.0 + */ public function buildCache() { global $beanList, $beanFiles, $dictionary; @@ -449,6 +467,7 @@ class UnifiedSearchAdvanced } /** + * @deprecated since v7.12.0 * Retrieve the enabled and disabled modules used for global search. * * @return array @@ -494,6 +513,7 @@ class UnifiedSearchAdvanced /** + * @deprecated since v7.12.0 * saveGlobalSearchSettings * This method handles the administrator's request to save the searchable modules selected and stores * the results in the unified_search_modules_display.php file @@ -520,7 +540,9 @@ class UnifiedSearchAdvanced } } - + /** + * @deprecated since v7.12.0 + */ public static function unlinkUnifiedSearchModulesFile() { //clear the unified_search_module.php file @@ -530,9 +552,10 @@ class UnifiedSearchAdvanced unlink($cache_search); } } - + /** + * @deprecated since v7.12.0 * getUnifiedSearchModules * * Returns the value of the $unified_search_modules variable based on the module's vardefs.php file @@ -560,6 +583,7 @@ class UnifiedSearchAdvanced /** + * @deprecated since v7.12.0 * getUnifiedSearchModulesDisplay * * Returns the value of the $unified_search_modules_display variable which is based on the $unified_search_modules @@ -587,7 +611,8 @@ class UnifiedSearchAdvanced return $unified_search_modules_display; } - /* + /** + * @deprecated since v7.12.0 * writeUnifiedSearchModulesDisplayFile * Private method to handle writing the unified_search_modules_display value to file * @@ -613,10 +638,15 @@ class UnifiedSearchAdvanced } } - +/** + * @deprecated since v7.12.0 + * @param $a + * @param $b + * @return int + */ function unified_search_modules_cmp($a, $b) { - if (!isset($a['translated']) || !isset($b['translated'])) { + if (!isset($a['translated'], $b['translated'])) { return 0; } diff --git a/tests/SuiteCRM/Enumerator/DatabaseDriver.php b/tests/SuiteCRM/Enumerator/DatabaseDriver.php index f01c814a4..5f2293aa5 100644 --- a/tests/SuiteCRM/Enumerator/DatabaseDriver.php +++ b/tests/SuiteCRM/Enumerator/DatabaseDriver.php @@ -1,10 +1,51 @@ refreshModuleGlobals(); @@ -92,7 +134,7 @@ class BeanFactoryTestCase extends SuitePHPUnitFrameworkTestCase /** * @return array */ - protected function getModuleList() + protected function getModuleList(): array { global $beanList; @@ -107,7 +149,7 @@ class BeanFactoryTestCase extends SuitePHPUnitFrameworkTestCase * @param $moduleClass * @return bool */ - protected function shouldSkipModule($moduleClass) + protected function shouldSkipModule($moduleClass): bool { global $beanFiles; @@ -126,7 +168,7 @@ class BeanFactoryTestCase extends SuitePHPUnitFrameworkTestCase /** * @return void */ - public function compileIncludeExtFiles() + public function compileIncludeExtFiles(): void { $extensionContents = 'assertTrue(is_writable($compiledIncludePath), 'Not writable: ' . $compiledIncludePath); + self::assertTrue(is_writable($compiledIncludePath), 'Not writable: ' . $compiledIncludePath); - if (is_writable($compiledIncludePath) && !$noExtensions) { + if (!$noExtensions && is_writable($compiledIncludePath)) { file_put_contents("$compiledIncludePath/modules.ext.php", $extensionContents); } - if ($noExtensions) { - if (file_exists("$compiledIncludePath/modules.ext.php")) { - unlink("$compiledIncludePath/modules.ext.php"); - } + if ($noExtensions && file_exists("$compiledIncludePath/modules.ext.php")) { + unlink("$compiledIncludePath/modules.ext.php"); } } @@ -172,7 +212,7 @@ class BeanFactoryTestCase extends SuitePHPUnitFrameworkTestCase * @param $path * @return bool */ - protected function shouldSkipFileEntry($file, $path) + protected function shouldSkipFileEntry($file, $path): bool { if ($file === '.' || $file === '..' || strtolower(substr($file, -4)) !== '.php') { return true; @@ -190,7 +230,7 @@ class BeanFactoryTestCase extends SuitePHPUnitFrameworkTestCase * @param string $className * @return void */ - public function addCoreModuleExtension($moduleName, $className) + public function addCoreModuleExtension(string $moduleName, string $className): void { $extIncludePath = 'custom/Extension/application/Ext/Include'; $customClassPath = "custom/modules/$moduleName"; @@ -214,7 +254,7 @@ EOT; mkdir_recursive($extIncludePath, true); } - $this->assertTrue(is_writable($extIncludePath), 'Directory not writable: ' . $extIncludePath); + self::assertTrue(is_writable($extIncludePath), 'Directory not writable: ' . $extIncludePath); if (is_writable($extIncludePath)) { file_put_contents("$extIncludePath/ZzzTestCustom$moduleName.php", $extIncludeContents); @@ -224,7 +264,7 @@ EOT; mkdir_recursive($customClassPath, true); } - $this->assertTrue(is_writable($customClassPath), 'Directory not writable: ' . $customClassPath); + self::assertTrue(is_writable($customClassPath), 'Directory not writable: ' . $customClassPath); if (is_writable($customClassPath)) { file_put_contents("$customClassPath/TestCustom$className.php", $classContents); @@ -238,7 +278,7 @@ EOT; * @param string $className * @return void */ - public function removeCoreModuleExtension($moduleName, $className) + public function removeCoreModuleExtension(string $moduleName, string $className): void { if (file_exists("custom/Extension/application/Ext/Include/ZzzTestCustom$moduleName.php")) { unlink("custom/Extension/application/Ext/Include/ZzzTestCustom$moduleName.php"); @@ -254,11 +294,9 @@ EOT; /** * @return void */ - public function removeCoreModuleAllExtension() + public function removeCoreModuleAllExtension(): void { - $modulesConfig = $this->moduleConfigProvider(); - - foreach ($modulesConfig as $moduleName => $moduleConfig) { + foreach ($this->moduleConfigProvider() as $moduleName => $moduleConfig) { if (file_exists("custom/Extension/application/Ext/Include/ZzzTestCustom$moduleName.php")) { unlink("custom/Extension/application/Ext/Include/ZzzTestCustom$moduleName.php"); } @@ -274,7 +312,7 @@ EOT; /** * @return void */ - public function refreshModuleGlobals() + public function refreshModuleGlobals(): void { $beanList = $customBeanList = $objectList = $customObjectList = $beanFiles = $customBeanFiles = []; diff --git a/tests/SuiteCRM/Test/Driver/PhpBrowserDriver.php b/tests/SuiteCRM/Test/Driver/PhpBrowserDriver.php index 4e30adca5..71e5ad900 100644 --- a/tests/SuiteCRM/Test/Driver/PhpBrowserDriver.php +++ b/tests/SuiteCRM/Test/Driver/PhpBrowserDriver.php @@ -1,8 +1,51 @@ _getConfig(); - $width = isset($config['width']) ? $config['width'] : 1920; - $height = isset($config['height']) ? $config['height'] : 1080; + $width = $config['width'] ?? 1920; + $height = $config['height'] ?? 1080; $this->resizeWindow($width, $height); } diff --git a/tests/SuiteCRM/Test/SuitePHPUnitFrameworkTestCase.php b/tests/SuiteCRM/Test/SuitePHPUnitFrameworkTestCase.php index 83074cf9f..6c6ff3ea5 100644 --- a/tests/SuiteCRM/Test/SuitePHPUnitFrameworkTestCase.php +++ b/tests/SuiteCRM/Test/SuitePHPUnitFrameworkTestCase.php @@ -1,4 +1,41 @@ checkConnection(); } + /** + * @throws Exception + * @noinspection UnusedFunctionResultInspection + */ protected function setUp(): void { parent::setUp(); diff --git a/tests/SuiteCRM/Test/TestLogger.php b/tests/SuiteCRM/Test/TestLogger.php index 23cb70d63..ad7a9459d 100644 --- a/tests/SuiteCRM/Test/TestLogger.php +++ b/tests/SuiteCRM/Test/TestLogger.php @@ -1,8 +1,47 @@ calls[$name][] = $arguments; - $this->notes[] = array( + $this->notes[] = [ 'entry_date' => date('Y-m-d H:i:s'), 'level' => $name, 'message' => array_shift($arguments), 'arguments' => $arguments, 'backtrace' => debug_backtrace(), - ); + ]; } /** * @param string|string[] $levels * @return array */ - public function getNotes($levels = 'fatal') + public function getNotes($levels = 'fatal'): array { - $results = array(); + $results = []; if (is_string($levels)) { $levels = explode(',', $levels); foreach ($levels as &$level) { @@ -59,15 +98,13 @@ class TestLogger $results[] = $note; } } + return $results; } - /** - * - */ - public function reset() + public function reset(): void { - $this->calls = array(); - $this->notes = array(); + $this->calls = []; + $this->notes = []; } } diff --git a/tests/_support/Helper/Acceptance.php b/tests/_support/Helper/Acceptance.php index ea6610295..5e955355a 100644 --- a/tests/_support/Helper/Acceptance.php +++ b/tests/_support/Helper/Acceptance.php @@ -1,4 +1,41 @@ getModule(WebDriver::class)->see($text, $selector); - } catch (PHPUnit_Framework_AssertionFailedError $f) { - return false; - } catch (ModuleException $e) { + } catch (AssertionFailedError | ModuleException $f) { return false; } @@ -40,7 +79,7 @@ class Acceptance extends Module } // Clean up any files left behind by module builder tests. - private function deleteModulesHelper() + private function deleteModulesHelper(): void { $modules = [ 'BasicTestModule', @@ -56,7 +95,7 @@ class Acceptance extends Module try { $this->deleteModuleFiles($module); } catch (ModuleException $e) { - return false; + return; } } } @@ -67,7 +106,7 @@ class Acceptance extends Module * @param string $module * @throws ModuleException */ - private function deleteModuleFiles($module) + private function deleteModuleFiles(string $module): void { $directories = [ "custom/modulebuilder/builds/{$module}", @@ -80,14 +119,14 @@ class Acceptance extends Module "custom/Extension/application/Ext/Include/{$module}.php" ]; - foreach ($directories as $_index => $directory) { + foreach ($directories as $directory) { if (is_dir($directory)) { $this->getModule('Filesystem')->deleteDir($directory); } } - foreach ($files as $_index => $file) { - if (file_exists($file)) { + foreach ($files as $file) { + if (is_file($file)) { unlink($file); } } diff --git a/tests/_support/Helper/PhpBrowserDriverHelper.php b/tests/_support/Helper/PhpBrowserDriverHelper.php index 5971f9db7..847e84c55 100644 --- a/tests/_support/Helper/PhpBrowserDriverHelper.php +++ b/tests/_support/Helper/PhpBrowserDriverHelper.php @@ -1,4 +1,41 @@ getBrowserWidth(); $breakpoint = null; diff --git a/tests/_support/Step/Acceptance/AccountsTester.php b/tests/_support/Step/Acceptance/AccountsTester.php index 5b3963932..6a3e52686 100644 --- a/tests/_support/Step/Acceptance/AccountsTester.php +++ b/tests/_support/Step/Acceptance/AccountsTester.php @@ -1,35 +1,53 @@ getScenario()); $DetailView = new DetailView($this->getScenario()); @@ -76,10 +95,9 @@ class AccountsTester extends \AcceptanceTester } /** - * * @return Scenario */ - public function getPublicScenario() + public function getPublicScenario(): Scenario { return $this->getScenario(); } diff --git a/tests/_support/Step/Acceptance/ModuleBuilder.php b/tests/_support/Step/Acceptance/ModuleBuilder.php index c43ad070e..caf2ae5c5 100644 --- a/tests/_support/Step/Acceptance/ModuleBuilder.php +++ b/tests/_support/Step/Acceptance/ModuleBuilder.php @@ -11,7 +11,7 @@ class ModuleBuilder extends Administration * @param string $moduleType * @see SugarObjectType */ - public function createModule($packageName, $moduleName, $moduleType) + public function createModule($packageName, $moduleName, $moduleType): void { $I = $this; @@ -86,7 +86,7 @@ class ModuleBuilder extends Administration /** * @param string $packageName */ - public function selectPackage($packageName) + public function selectPackage($packageName): void { $I = $this; @@ -103,7 +103,7 @@ class ModuleBuilder extends Administration * @param string $packageName * @param string $moduleName */ - public function selectModule($packageName, $moduleName) + public function selectModule($packageName, $moduleName): void { $I = $this; @@ -118,7 +118,7 @@ class ModuleBuilder extends Administration $I->waitForElementVisible(['name' => 'savebtn']); } - public function closePopupSuccess() + public function closePopupSuccess(): void { $I = $this; $I->wait(1); @@ -132,7 +132,7 @@ class ModuleBuilder extends Administration * @param boolean $packageExists * */ - public function deployPackage($packageName, $packageExists = false) + public function deployPackage($packageName, $packageExists = false): void { $I = $this; diff --git a/tests/_support/Step/Acceptance/NavigationBarTester.php b/tests/_support/Step/Acceptance/NavigationBarTester.php index 341d40c10..04207788d 100644 --- a/tests/_support/Step/Acceptance/NavigationBarTester.php +++ b/tests/_support/Step/Acceptance/NavigationBarTester.php @@ -1,33 +1,45 @@ getBreakpointString(); + $breakpoint = (new Design($I))->getBreakpointString(); switch ($breakpoint) { // The home button is only available on the large desktop // We need to select the home module from the all menu for tablet and mobile. @@ -67,11 +78,10 @@ class NavigationBarTester extends Tester * $I->clickUserMenuItem('Admin') * $I->clickUserMenuItem('#admin_link') */ - public function clickUserMenuItem($link) + public function clickUserMenuItem($link): void { $I = $this; - $design = new Design($I); - $breakpoint = $design->getBreakpointString(); + $breakpoint = (new Design($I))->getBreakpointString(); switch ($breakpoint) { case DesignBreakPoint::lg: $I->moveMouseOver('.desktop-bar #toolbar .globalLinks-desktop'); @@ -105,11 +115,10 @@ class NavigationBarTester extends Tester * Also: * the non filter navigation is not supported by this method */ - public function clickAllMenuItem($link) + public function clickAllMenuItem($link): void { $I = $this; - $design = new Design($I); - $breakpoint = $design->getBreakpointString(); + $breakpoint = (new Design($I))->getBreakpointString(); switch ($breakpoint) { case DesignBreakPoint::lg: $allMenuButton = '#toolbar.desktop-toolbar > ul.nav.navbar-nav > li.topnav.all'; @@ -159,11 +168,10 @@ class NavigationBarTester extends Tester * Also: * the non filter navigation is not supported by this method */ - public function clickCurrentMenuItem($link) + public function clickCurrentMenuItem($link): void { $I = $this; - $design = new Design($I); - $breakpoint = $design->getBreakpointString(); + $breakpoint = (new Design($I))->getBreakpointString(); switch ($breakpoint) { case DesignBreakPoint::lg: $I->moveMouseOver('//*[@id="toolbar"]/ul/li[2]/span[2]/a'); diff --git a/tests/acceptance/Core/BasicModuleCest.php b/tests/acceptance/Core/BasicModuleCest.php index db30cdde0..66ca7f58f 100644 --- a/tests/acceptance/Core/BasicModuleCest.php +++ b/tests/acceptance/Core/BasicModuleCest.php @@ -1,7 +1,48 @@ createModule( \Page\BasicModule::$PACKAGE_NAME, \Page\BasicModule::$NAME, - \SuiteCRM\Enumerator\SugarObjectType::basic + SugarObjectType::basic ); $repair->clickQuickRepairAndRebuild(); diff --git a/tests/acceptance/Core/CompanyModuleCest.php b/tests/acceptance/Core/CompanyModuleCest.php index 9ad1bf01a..179c52f9c 100644 --- a/tests/acceptance/Core/CompanyModuleCest.php +++ b/tests/acceptance/Core/CompanyModuleCest.php @@ -1,6 +1,44 @@ fakeData) { $this->fakeData = Faker\Factory::create(); @@ -32,7 +70,7 @@ class CompanyModuleCest /** * @param AcceptanceTester $I */ - public function _after(AcceptanceTester $I) + public function _after(AcceptanceTester $I): void { } @@ -48,14 +86,14 @@ class CompanyModuleCest public function testScenarioCreateCompanyModule( \AcceptanceTester $I, \Step\Acceptance\ModuleBuilder $moduleBuilder - ) { + ): void { $I->wantTo('Create a company module for testing'); $I->loginAsAdmin(); $moduleBuilder->createModule( \Page\CompanyModule::$PACKAGE_NAME, \Page\CompanyModule::$NAME, - \SuiteCRM\Enumerator\SugarObjectType::company + SugarObjectType::company ); } @@ -71,7 +109,7 @@ class CompanyModuleCest \AcceptanceTester $I, \Step\Acceptance\NavigationBarTester $navigationBar, \Step\Acceptance\ListView $listView - ) { + ): void { $I->wantTo('View Company Test Module'); $I->loginAsAdmin(); @@ -98,7 +136,7 @@ class CompanyModuleCest \Step\Acceptance\ListView $listView, \Step\Acceptance\EditView $editView, \Step\Acceptance\DetailView $detailView - ) { + ): void { $I->wantTo('Create Company Test Module Record'); $I->loginAsAdmin(); @@ -147,7 +185,7 @@ class CompanyModuleCest \Step\Acceptance\NavigationBarTester $navigationBar, \Step\Acceptance\ListView $listView, \Step\Acceptance\DetailView $detailView - ) { + ): void { $I->wantTo('Select Record from list view'); $I->loginAsAdmin(); @@ -185,7 +223,7 @@ class CompanyModuleCest \Step\Acceptance\ListView $listView, \Step\Acceptance\DetailView $detailView, \Step\Acceptance\EditView $editView - ) { + ): void { $I->wantTo('Edit Company Test Module Record from detail view'); $I->loginAsAdmin(); @@ -230,7 +268,7 @@ class CompanyModuleCest \Step\Acceptance\ListView $listView, \Step\Acceptance\DetailView $detailView, \Step\Acceptance\EditView $editView - ) { + ): void { $I->wantTo('Duplicate Company Test Module Record from detail view'); $I->loginAsAdmin(); @@ -278,7 +316,7 @@ class CompanyModuleCest \Step\Acceptance\NavigationBarTester $navigationBar, \Step\Acceptance\ListView $listView, \Step\Acceptance\DetailView $detailView - ) { + ): void { $I->wantTo('Delete Company Test Module Record from detail view'); $I->loginAsAdmin(); diff --git a/tests/acceptance/Core/FileModuleCest.php b/tests/acceptance/Core/FileModuleCest.php index c70b2c299..d318f3e59 100644 --- a/tests/acceptance/Core/FileModuleCest.php +++ b/tests/acceptance/Core/FileModuleCest.php @@ -1,6 +1,44 @@ createModule( \Page\FileModule::$PACKAGE_NAME, \Page\FileModule::$NAME, - \SuiteCRM\Enumerator\SugarObjectType::file + SugarObjectType::file ); } @@ -120,7 +158,7 @@ class FileModuleCest $editView->clickSaveButton(); $detailview->waitForDetailViewVisible(); $detailview->see($fileName, '#uploadfile'); - + $I->deleteFile($fileDir.$fileName); } @@ -139,7 +177,7 @@ class FileModuleCest \Step\Acceptance\DetailView $detailView ) { $I->wantTo('Select Record from list view'); - + $I->loginAsAdmin(); // Go to File Test Module diff --git a/tests/acceptance/Core/IssueModuleCest.php b/tests/acceptance/Core/IssueModuleCest.php index f3065bc46..2bcfcab46 100644 --- a/tests/acceptance/Core/IssueModuleCest.php +++ b/tests/acceptance/Core/IssueModuleCest.php @@ -1,6 +1,44 @@ createModule( \Page\IssueModule::$PACKAGE_NAME, \Page\IssueModule::$NAME, - \SuiteCRM\Enumerator\SugarObjectType::issue + SugarObjectType::issue ); } diff --git a/tests/acceptance/Core/ModuleBuilderFieldsCest.php b/tests/acceptance/Core/ModuleBuilderFieldsCest.php index 26cd8d9b7..4394c6de7 100644 --- a/tests/acceptance/Core/ModuleBuilderFieldsCest.php +++ b/tests/acceptance/Core/ModuleBuilderFieldsCest.php @@ -1,6 +1,44 @@ createModule( \Page\ModuleFields::$PACKAGE_NAME, \Page\ModuleFields::$NAME, - \SuiteCRM\Enumerator\SugarObjectType::basic + SugarObjectType::basic ); } diff --git a/tests/acceptance/Core/PersonModuleCest.php b/tests/acceptance/Core/PersonModuleCest.php index f51121e4c..c03cb208e 100644 --- a/tests/acceptance/Core/PersonModuleCest.php +++ b/tests/acceptance/Core/PersonModuleCest.php @@ -1,7 +1,45 @@ createModule( \Page\PersonModule::$PACKAGE_NAME, \Page\PersonModule::$NAME, - \SuiteCRM\Enumerator\SugarObjectType::person + SugarObjectType::person ); } diff --git a/tests/acceptance/Core/SaleModuleCest.php b/tests/acceptance/Core/SaleModuleCest.php index c9561b74d..5b14adffa 100644 --- a/tests/acceptance/Core/SaleModuleCest.php +++ b/tests/acceptance/Core/SaleModuleCest.php @@ -1,6 +1,44 @@ createModule( \Page\SaleModule::$PACKAGE_NAME, \Page\SaleModule::$NAME, - \SuiteCRM\Enumerator\SugarObjectType::sale + SugarObjectType::sale ); } diff --git a/tests/acceptance/lib/Search/ElasticsearchCest.php b/tests/acceptance/lib/Search/ElasticsearchCest.php index 88fcf429a..3da83b1e5 100644 --- a/tests/acceptance/lib/Search/ElasticsearchCest.php +++ b/tests/acceptance/lib/Search/ElasticsearchCest.php @@ -5,7 +5,7 @@ * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. * * SuiteCRM is an extension to SugarCRM Community Edition developed by SalesAgility Ltd. - * Copyright (C) 2011 - 2018 SalesAgility Ltd. + * Copyright (C) 2011 - 2021 SalesAgility Ltd. * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU Affero General Public License version 3 as published by the @@ -38,36 +38,32 @@ * display the words "Powered by SugarCRM" and "Supercharged by SuiteCRM". */ -use Facebook\WebDriver\Exception\UnexpectedAlertOpenException; +use Codeception\Exception\ModuleException; use Helper\WebDriverHelper; use Step\Acceptance\AccountsTester; use Step\Acceptance\NavigationBarTester; /** - * ElasticsearchCest - * + * Class ElasticsearchCest * @author gyula */ class ElasticsearchCest { /** - * * @param AcceptanceTester $I * @param WebDriverHelper $helper + * @throws ModuleException */ - public function testSearchSetup(AcceptanceTester $I, WebDriverHelper $helper) - { - // login.. + public function testSearchSetup(AcceptanceTester $I, WebDriverHelper $helper): void + { $I->loginAsAdmin(); - - // setup elasticsearch.. - + $I->click('admin'); - + // Click on Admin menu: // TODO: Page css selector error: I found element #admin_link at 3 times. Html tag should have uniqe ID. $I->click('.navbar.navbar-inverse.navbar-fixed-top .container-fluid .desktop-bar #toolbar #globalLinks .dropdown-menu.user-dropdown.user-menu #admin_link'); - + $I->click('Search Settings'); $I->selectOption('#search-engine', 'Elasticsearch Engine'); $I->click('Save'); @@ -83,7 +79,7 @@ class ElasticsearchCest $I->wait(1); $I->seeInPopup('A full indexing has been scheduled and will start in the next 60 seconds. Search results might be inconsistent until the process is complete.'); $I->acceptPopup(); - + $I->click('Schedule partial indexing'); $I->wait(1); $I->seeInPopup('A partial indexing has been scheduled and will start in the next 60 seconds.'); @@ -96,68 +92,60 @@ class ElasticsearchCest $I->click('Save'); } - + /** - * * @param AcceptanceTester $I */ - public function testSearchNotFound(AcceptanceTester $I) + public function testSearchNotFound(AcceptanceTester $I): void { - - // login.. $I->loginAsAdmin(); - + // lets try out elasticsearch.. // TODO [Selenium browser Logs] 12:47:10.930 SEVERE - http://localhost/SuiteCRM/index.php?action=Login&module=Users - [DOM] Found 2 elements with non-unique id #form: (More info: https://goo.gl/9p2vKq) - $I->fillField('div.desktop-bar ul#toolbar li #searchform .input-group #query_string', 'I_bet_there_is_nothing_to_contains_this'); - + $I->fillField('div.desktop-bar ul#toolbar li #searchform .input-group #query_string', + 'I_bet_there_is_nothing_to_contains_this'); + // click on search icon: TODO: search icon ID is not unique: $I->click('.desktop-bar #searchform > div > span > button'); - - $I->see('SEARCH'); - $I->see('Results'); - $I->see('No results matching your search criteria. Try broadening your search.'); - - $I->fillField('div.desktop-bar ul#toolbar li #searchform .input-group #query_string', 'acc'); - $I->click('#search-wrapper-form > table > tbody > tr:nth-child(1) > td > input.button.primary'); - + $I->see('SEARCH'); $I->see('Results'); $I->see('No results matching your search criteria. Try broadening your search.'); + $I->see('Search performed in'); } - + /** - * * @param AccountsTester $accounts - * @param type $max + * @param int $max + * @param int $from */ - protected function createTestAccounts(AccountsTester $accounts, $max, $from = 0) + protected function createTestAccounts(AccountsTester $accounts, int $max, int $from = 0): void { $navi = new NavigationBarTester($accounts->getPublicScenario()); $navi->clickAllMenuItem('Accounts'); - - for ($i=$from; $i<$max; $i++) { + + for ($i = $from; $i < $max; $i++) { $accounts->createAccountForElasticSearch('acc_for_test ' . $i); - // waiting few second to elasticsearch indexer makes the job done: + // Wait for ElasticSearch indexer: $accounts->wait(3); } - - // waiting few second to elasticsearch indexer makes the job done: + + // Wait for ElasticSearch indexer: $accounts->wait(5); } - + /** - * * @param AcceptanceTester $I * @param AccountsTester $accounts - * @param type $max + * @param int $max + * @throws ModuleException */ - protected function deleteTestAccounts(AcceptanceTester $I, AccountsTester $accounts, $max) + protected function deleteTestAccounts(AcceptanceTester $I, AccountsTester $accounts, int $max): void { $navi = new NavigationBarTester($accounts->getPublicScenario()); $navi->clickAllMenuItem('Accounts'); - - for ($i=0; $i<$max; $i++) { + + for ($i = 0; $i < $max; $i++) { $I->waitForElementVisible('//*[@id="MassUpdate"]/div[3]/table/tbody/tr[1]/td[3]/b/a'); $I->click('//*[@id="MassUpdate"]/div[3]/table/tbody/tr[1]/td[3]/b/a'); $I->waitForElementVisible('//*[@id="tab-actions"]/a'); @@ -168,66 +156,54 @@ class ElasticsearchCest $I->acceptPopup(); } } - + /** * * @param AcceptanceTester $I * @param AccountsTester $accounts + * @throws ModuleException */ - public function testSearchFounds(AcceptanceTester $I, AccountsTester $accounts) + public function testSearchFounds(AcceptanceTester $I, AccountsTester $accounts): void { - $max = 15; - - // login.. $I->loginAsAdmin(); - - // adding some account.. + + $max = 15; $this->createTestAccounts($accounts, $max); - - // search for them.. - + $I->fillField('div.desktop-bar ul#toolbar li #searchform .input-group #query_string', 'acc_for_test'); $I->click('.desktop-bar #searchform > div > span > button'); - + $I->see('SEARCH'); $I->see('Results'); -// $I->see('Total result(s): ' . $max); $I->see('Search performed in'); $I->see('Page 1 of 2'); - + $I->click('Next'); $I->see('SEARCH'); $I->see('Results'); -// $I->see('Total result(s): ' . $max); $I->see('Search performed in'); $I->see('Page 2 of 2'); - - + + $I->fillField('div.desktop-bar ul#toolbar li #searchform .input-group #query_string', '11'); $I->see('SEARCH'); $I->see('Results'); - //sometimes elasticsearch indexer randomly broken in travis, so the next check randomly failing: - // $I->see('Total result(s): 1'); $I->see('Search performed in'); $I->see('Accounts'); $I->see('Account Name'); $I->see('acc_for_test 11'); - - // add few more until end of the last page + $end = 20; $this->createTestAccounts($accounts, $end, $max); - + $I->fillField('div.desktop-bar ul#toolbar li #searchform .input-group #query_string', 'acc_for_test'); $I->click('.desktop-bar #searchform > div > span > button'); - + $I->see('SEARCH'); $I->see('Results'); - //sometimes elasticsearch indexer randomly broken in travis, so the next check randomly failing: - //$I->see('Total result(s): ' . $end); $I->see('Search performed in'); $I->see('Page 1 of 2'); - - // clean up test accounts + $this->deleteTestAccounts($I, $accounts, $end); } } diff --git a/tests/api/v8/ModulesCest.php b/tests/api/v8/ModulesCest.php new file mode 100644 index 000000000..434e2a7f2 --- /dev/null +++ b/tests/api/v8/ModulesCest.php @@ -0,0 +1,1616 @@ +fakeData) { + $this->fakeData = Faker\Factory::create(); + $this->fakeDataSeed = mt_rand(0, 2048); + } + $this->fakeData->seed($this->fakeDataSeed); + } + + /** + * Get list of modules + * @param ApiTester $I + * @see http://jsonapi.org/format/1.0/#crud-creating + * + * HTTP Verb: GET + * URL: /api/v8/modules + * + */ + public function TestScenarioListModules(ApiTester $I) + { + $I->comment('Test list modules'); + $I->sendJsonApiContentNegotiation(); + $I->loginAsAdmin(); + $I->sendJwtAuthorisation(); + $I->sendGET( + $I->getInstanceURL() . '/api/v8/modules/meta/list' + ); + $I->seeResponseCodeIs(200); + $I->seeJsonApiContentNegotiation(); + $I->seeJsonAPISuccess(); + $response = json_decode($I->grabResponse(), true); + $I->assertArrayHasKey('meta', $response); + $I->assertArrayHasKey('modules', $response['meta']); + $I->assertNotEmpty($response['meta']['modules']); + $I->assertArrayHasKey('list', $response['meta']['modules']); + $I->assertNotEmpty($response['meta']['modules']['list']); + } + + /** + * Create a new entry with missing type + * @param ApiTester $I + * @see http://jsonapi.org/format/1.0/#crud-creating + * + * HTTP Verb: POST + * URL: /api/v8/modules/{module_name} (with id in $_POST) + * URL: /api/v8/modules/{module_name}/{id} + * + */ + public function TestScenarioCreateWithMissingType(ApiTester $I) + { + $I->comment('Test missing type'); + $I->sendJsonApiContentNegotiation(); + $I->loginAsAdmin(); + $I->sendJwtAuthorisation(); + $I->sendPOST( + $I->getInstanceURL() . self::$ACCOUNT_RESOURCE, + json_encode( + array( + 'data' => array( + ) + ) + ) + ); + $I->seeResponseCodeIs(409); + $I->seeJsonApiContentNegotiation(); + $I->seeJsonApiFailure(); + } + + /** + * Create a new entry with missing attributes + * @param ApiTester $I + * @see http://jsonapi.org/format/1.0/#crud-creating + * + * HTTP Verb: POST + * URL: /api/v8/modules/{module_name} (with id in $_POST) + * URL: /api/v8/modules/{module_name}/{id} + * + */ + public function TestScenarioCreateWithMissingAttributes(ApiTester $I) + { + $I->comment('Test required attributes'); + $I->sendJsonApiContentNegotiation(); + $I->loginAsAdmin(); + $I->sendJwtAuthorisation(); + $I->sendPOST( + $I->getInstanceURL() . self::$ACCOUNT_RESOURCE, + json_encode( + array( + 'data' => array( + 'type' => 'Accounts', + ) + ) + ) + ); + $I->seeResponseCodeIs(400); + $I->seeJsonApiContentNegotiation(); + $I->seeJsonApiFailure(); + } + + + /** + * Create a new entry with required fields + * @param ApiTester $I + * @see http://jsonapi.org/format/1.0/#crud-creating + * + * HTTP Verb: POST + * URL: /api/v8/modules/{module_name} (with id in $_POST) + * URL: /api/v8/modules/{module_name}/{id} + * + */ + public function TestScenarioCreateWithMissingRequiredFields(ApiTester $I) + { + $I->comment('Test required attributes'); + $I->sendJsonApiContentNegotiation(); + $I->loginAsAdmin(); + $I->sendJwtAuthorisation(); + $I->sendPOST( + $I->getInstanceURL() . self::$ACCOUNT_RESOURCE, + json_encode( + array( + 'data' => array( + 'type' => 'Accounts', + 'attributes' => array() + ) + ) + ) + ); + $I->seeResponseCodeIs(400); + $I->seeJsonApiContentNegotiation(); + $I->seeJsonApiFailure(); + } + + /** + * Create a new entry + * @param ApiTester $I + * @see http://jsonapi.org/format/1.0/#crud-creating + * + * HTTP Verb: POST + * URL: /api/v8/modules/{module_name} (with id in $_POST) + * URL: /api/v8/modules/{module_name}/{id} + * + */ + public function TestScenarioCreateNew(ApiTester $I) + { + $faker = \Faker\Factory::create(); + $I->comment('Test create account'); + $I->loginAsAdmin(); + $I->sendJwtAuthorisation(); + $I->sendJsonApiContentNegotiation(); + $this->fakeData->seed(mt_rand(0, 2148)); + $I->sendPOST( + $I->getInstanceURL() . self::$ACCOUNT_RESOURCE, + json_encode( + array( + 'data' => array( + 'id' => '', + 'type' => 'Accounts', + 'attributes' => array( + 'name' => $faker->name() + ) + ) + ) + ) + ); + $I->seeResponseCodeIs(201); + $I->seeJsonApiContentNegotiation(); + $response = json_decode($I->grabResponse(), true); + $I->assertArrayHasKey('data', $response); + $I->assertArrayHasKey('links', $response); + $I->assertArrayHasKey('self', $response['links']); + $I->assertArrayHasKey('type', $response['data']); + $I->assertArrayHasKey('id', $response['data']); + $I->assertArrayHasKey('attributes', $response['data']); + + self::$RECORD = $response['data']['id']; + } + + /** + * Create a new entry + * @param ApiTester $I + * @see http://jsonapi.org/format/1.0/#crud-creating + * + * HTTP Verb: POST + * URL: /api/v8/modules/{module_name} (with id in $_POST) + * URL: /api/v8/modules/{module_name}/{id} + * @throws \Codeception\Exception\ModuleException + */ + public function TestScenarioCreateNewWithClientCredentialsGrant(ApiTester $I) + { + $faker = \Faker\Factory::create(); + $I->comment('Test create account'); + $I->loginAsAdminWithClientCredentials(); + $I->sendJwtAuthorisation(); + $I->sendJsonApiContentNegotiation(); + $this->fakeData->seed(mt_rand(0, 2148)); + $I->sendPOST( + $I->getInstanceURL() . self::$ACCOUNT_RESOURCE, + json_encode( + array( + 'data' => array( + 'id' => '', + 'type' => 'Accounts', + 'attributes' => array( + 'name' => $faker->name() + ) + ) + ) + ) + ); + $I->seeResponseCodeIs(201); + $I->seeJsonApiContentNegotiation(); + $response = json_decode($I->grabResponse(), true); + $I->assertArrayHasKey('data', $response); + $I->assertArrayHasKey('links', $response); + $I->assertArrayHasKey('self', $response['links']); + $I->assertArrayHasKey('type', $response['data']); + $I->assertArrayHasKey('id', $response['data']); + $I->assertArrayHasKey('attributes', $response['data']); + + self::$RECORD = $response['data']['id']; + + $I->loginAsAdmin(); + } + + /** + * Create a existing entry + * @param ApiTester $I + * @see http://jsonapi.org/format/1.0/#crud-creating + * + * HTTP Verb: POST + * URL: /api/v8/modules/{module_name} (with id in $_POST) + * URL: /api/v8/modules/{module_name}/{id} + * + */ + public function TestScenarioCreateExisting(ApiTester $I) + { + $faker = \Faker\Factory::create(); + + $I->comment('Test already exists'); + $I->loginAsAdmin(); + $I->sendJwtAuthorisation(); + $I->sendJsonApiContentNegotiation(); + $this->fakeData->seed(mt_rand(0, 2148)); + $I->sendPOST( + $I->getInstanceURL() . self::$ACCOUNT_RESOURCE, + json_encode( + array( + 'data' => array( + 'id' => self::$RECORD, + 'type' => 'Accounts', + 'attributes' => array( + 'name' => $faker->name() + ) + ) + ) + ) + ); + $I->seeResponseCodeIs(403); + $I->seeJsonApiContentNegotiation(); + $I->seeJsonApiFailure(); + } + + + /** + * Create a notes resource and attaches file + * @param ApiTester $I + * @see http://jsonapi.org/format/1.0/#crud-creating + * + * HTTP Verb: POST + * URL: /api/v8/modules/{Notes} (with id in $_POST) + * URL: /api/v8/modules/{Notes}/{id} + * + * Also: + * @see \SuiteCRM\API\JsonApi\v1\Resource\SuiteBeanResource + * @see SugarFieldFile::save() + */ + public function TestScenarioCreateNoteWithAttachment(ApiTester $I) + { + $faker = \Faker\Factory::create(); + + // Test create a note with a binary document + $I->comment('Create a notes resource and attach binary a document'); + $filenameBinaryFile = 'testFile.png'; + $pathToBinaryFile = codecept_data_dir() . $filenameBinaryFile; + $binaryFile = file_get_contents($pathToBinaryFile); + $binaryFileEncoded = ''; + + $I->loginAsAdmin(); + $I->sendJwtAuthorisation(); + $I->sendJsonApiContentNegotiation(); + $this->fakeData->seed(mt_rand(0, 2148)); + + + $payload = json_encode( + array( + 'data' => array( + 'id' => '', + 'type' => 'Notes', + 'attributes' => array( + 'name' => $faker->name(), + 'portal_flag' => true, + // The api looks for fields with the type set to file + // file name has the type set to "file" in the vardefs + 'filename' => $filenameBinaryFile, + // $prefix . $filed_name . "_file" represents the actual data + 'filename_file' => $binaryFileEncoded + ) + ) + ) + ); + + $I->sendPOST( + $I->getInstanceURL() . self::$NOTES_RESOURCE, + $payload + ); + + $I->seeResponseCodeIs(201); + $I->seeJsonApiContentNegotiation(); + $I->seeJsonAPISuccess(); + $response = json_decode($I->grabResponse(), true); + $I->assertArrayHasKey('data', $response); + $I->assertArrayHasKey('type', $response['data']); + $I->assertArrayHasKey('id', $response['data']); + self::$NOTES_RESOURCE_ID = $response['data']['id']; + + // Test retrieve a note with a binary document to validate that the note had been created + $I->sendGET( + $I->getInstanceURL() . self::$NOTES_RESOURCE . '/' . self::$NOTES_RESOURCE_ID + ); + + $I->seeResponseCodeIs(200); + $I->seeJsonApiContentNegotiation(); + $I->seeJsonAPISuccess(); + $response = json_decode($I->grabResponse(), true); + $I->assertArrayHasKey('data', $response); + $I->assertArrayHasKey('type', $response['data']); + $I->assertArrayHasKey('id', $response['data']); + $I->assertEquals(self::$NOTES_RESOURCE_ID, $response['data']['id']); + $I->assertEquals('Notes', $response['data']['type']); + $I->assertArrayHasKey('attributes', $response['data']); + $I->assertArrayHasKey('filename', $response['data']['attributes']); + $I->assertArrayHasKey('filename_file', $response['data']['attributes']); + $I->assertNotEmpty('filename', $response['data']['attributes']['filename']); + $I->assertNotEmpty('filename_file', $response['data']['attributes']['filename_file']); + $I->assertEquals($filenameBinaryFile, $response['data']['attributes']['filename']); + $I->assertEquals($binaryFileEncoded, ''); + } + + /** + * Create a document resource and attaches a file + * @param ApiTester $I + * @see http://jsonapi.org/format/1.0/#crud-creating + * + * HTTP Verb: POST + * URL: /api/v8/modules/{Documents} (with id in $_POST) + * URL: /api/v8/modules/{Documents}/{id} + * + * Also: + * @see \SuiteCRM\API\JsonApi\v1\Resource\SuiteBeanResource + * @see SugarFieldFile::save() + */ + public function TestScenarioCreateDocumentWithAttachment(ApiTester $I) + { + $faker = \Faker\Factory::create(); + + // Test create a note with a binary document + $I->comment('Create a notes resource and attach binary a document'); + $filenameBinaryFile = 'testFile.png'; + $pathToBinaryFile = codecept_data_dir().'/'.$filenameBinaryFile; + $binaryFile = file_get_contents($pathToBinaryFile); + $binaryFileEncoded = ''; + + $I->loginAsAdmin(); + $I->sendJwtAuthorisation(); + $I->sendJsonApiContentNegotiation(); + $this->fakeData->seed(mt_rand(0, 2148)); + + $document_name = $faker->name(); + // Publish date + $active_date = (new \DateTime())->format(DATE_ATOM); + + $payload = json_encode( + array( + 'data' => array( + 'id' => '', + 'type' => 'Documents', + 'attributes' => array( + 'name' => $document_name, + 'document_name' => $document_name, + 'portal_flag' => true, + 'active_date' => $active_date, + // The api looks for fields with the type set to file + // file name has the type set to "file" in the vardefs + 'filename' => $filenameBinaryFile, + // $prefix . $filed_name . "_file" represents the actual data + 'filename_file' => $binaryFileEncoded, + 'revision' => 1 + ) + ) + ) + ); + + $I->sendPOST( + $I->getInstanceURL() . self::$DOCUMENTS_RESOURCE, + $payload + ); + + $I->seeResponseCodeIs(201); + $I->seeJsonApiContentNegotiation(); + $I->seeJsonAPISuccess(); + $response = json_decode($I->grabResponse(), true); + $I->assertArrayHasKey('data', $response); + $I->assertArrayHasKey('type', $response['data']); + $I->assertArrayHasKey('id', $response['data']); + self::$DOCUMENTS_RESOURCE_ID = $response['data']['id']; + + // Test retrieve a note with a binary document to validate that the note had been created + $I->sendGET( + $I->getInstanceURL() . self::$DOCUMENTS_RESOURCE . '/' . self::$DOCUMENTS_RESOURCE_ID + ); + + $I->seeResponseCodeIs(200); + $I->seeJsonApiContentNegotiation(); + $I->seeJsonAPISuccess(); + $response = json_decode($I->grabResponse(), true); + $I->assertArrayHasKey('data', $response); + $I->assertArrayHasKey('type', $response['data']); + $I->assertArrayHasKey('id', $response['data']); + $I->assertEquals(self::$DOCUMENTS_RESOURCE_ID, $response['data']['id']); + $I->assertEquals('Documents', $response['data']['type']); + $I->assertArrayHasKey('attributes', $response['data']); + $I->assertArrayHasKey('filename', $response['data']['attributes']); + $I->assertArrayHasKey('filename_file', $response['data']['attributes']); + $I->assertNotEmpty('filename', $response['data']['attributes']['filename']); + $I->assertNotEmpty('filename_file', $response['data']['attributes']['filename_file']); + $I->assertEquals($filenameBinaryFile, $response['data']['attributes']['filename']); + $I->assertEquals($binaryFileEncoded, $response['data']['attributes']['filename_file']); + } + + /** + * Retrieves an entry + * @param ApiTester $I + * @see http://jsonapi.org/format/1.0/#fetching + * + * HTTP Verb: GET + * URL: /api/v8/modules/{module_name}/{id} + * + */ + public function TestScenarioRetrieveEntry(ApiTester $I) + { + $I->loginAsAdmin(); + $I->sendJwtAuthorisation(); + $I->sendJsonApiContentNegotiation(); + $I->sendGET($I->getInstanceURL() . self::$ACCOUNT_RESOURCE . '/' . self::$RECORD); + $I->seeResponseCodeIs(200); + $I->seeJsonAPISuccess(); + $response = json_decode($I->grabResponse(), true); + + $I->assertArrayHasKey('data', $response); + $I->assertArrayHasKey('id', $response['data']); + $I->assertArrayHasKey('type', $response['data']); + $I->assertArrayHasKey('attributes', $response['data']); + $I->assertArrayHasKey('relationships', $response['data']); + } + + /** + * Update entry + * @param ApiTester $I + * @see http://jsonapi.org/format/1.0/#crud-updating + * + * HTTP Verb: POST (update and replace) / PATCH (update and modify) + * URL: /api/v8/modules/{module_name}/{id} + * + */ + public function TestScenarioUpdateEntry(ApiTester $I) + { + $faker = \Faker\Factory::create(); + + $I->comment('Test update account'); + $I->loginAsAdmin(); + $I->sendJwtAuthorisation(); + $I->sendJsonApiContentNegotiation(); + + $newName = $faker->name(); + + $I->sendPATCH( + $I->getInstanceURL() . self::$ACCOUNT_RESOURCE . '/' . self::$RECORD, + json_encode( + array( + 'data' => array( + 'id' => self::$RECORD, + 'type' => 'Accounts', + 'attributes' => array( + 'name' => $newName + ) + ) + ) + ) + ); + + $I->seeResponseCodeIs(200); + $I->seeJsonAPISuccess(); + $response = json_decode($I->grabResponse(), true); + $I->assertArrayHasKey('data', $response); + $I->assertArrayHasKey('type', $response['data']); + $I->assertArrayHasKey('id', $response['data']); + $I->assertArrayHasKey('attributes', $response['data']); + $I->assertEquals($newName, $response['data']['attributes']['name']); + } + + /** + * Update entry + * @param ApiTester $I + * @see http://jsonapi.org/format/1.0/#crud-deleting + * + * HTTP Verb: DELETE + * URL: /api/v8/modules/{module_name}/{id} + * + */ + public function TestScenarioDeleteEntry(ApiTester $I) + { + $I->loginAsAdmin(); + $I->sendJwtAuthorisation(); + $I->sendJsonApiContentNegotiation(); + $I->sendDELETE($I->getInstanceURL() . self::$ACCOUNT_RESOURCE . '/' . self::$RECORD); + $I->seeResponseCodeIs(200); + $I->seeJsonAPISuccess(); + } + + + /** + * Retrieves a list of entries + * @param ApiTester $I + * @see http://jsonapi.org/format/1.0/#fetching + * + * HTTP Verb: GET + * URL: /api/v8/modules/{module_name} + */ + public function TestScenarioRetrieveList(ApiTester $I) + { + // Send Request + $I->loginAsAdmin(); + $I->sendJwtAuthorisation(); + $I->sendJsonApiContentNegotiation(); + $I->sendGET($I->getInstanceURL() . self::$ACCOUNT_RESOURCE); + + // Validate Response + $I->seeResponseCodeIs(200); + $I->seeJsonApiContentNegotiation(); + $I->seeJsonAPISuccess(); + + $response = json_decode($I->grabResponse(), true); + $I->assertArrayHasKey('data', $response); + $I->assertIsArray($response['data']); + + if (!empty($response['data'])) { + $I->assertTrue(isset($response['data']['0'])); + $I->assertTrue(isset($response['data']['0']['id'])); + $I->assertTrue(isset($response['data']['0']['type'])); + $I->assertTrue(isset($response['data']['0']['attributes'])); + $I->assertIsArray($response['data']['0']['attributes']); + } + + $I->assertArrayHasKey('links', $response); + $I->assertArrayHasKey('self', $response['links']); + } + + + /** + * Retrieves a list of entries + * @param ApiTester $I + * @see http://jsonapi.org/format/1.0/#fetching + * + * HTTP Verb: GET + * URL: /api/v8/modules/{module_name} + */ + public function TestScenarioRetrieveFilteredList(ApiTester $I) + { + // Send Request + $I->loginAsAdmin(); + $I->sendJwtAuthorisation(); + $I->sendJsonApiContentNegotiation(); + $I->sendGET( + $I->getInstanceURL() . self::$ACCOUNT_RESOURCE . + '?filter[Accounts.date_entered]=[[gte]]2017-11-17T11:40:00+00:00' + ); + + // Validate Response + $I->seeResponseCodeIs(200); + $I->seeJsonApiContentNegotiation(); + $I->seeJsonAPISuccess(); + + $response = json_decode($I->grabResponse(), true); + $I->assertArrayHasKey('data', $response); + $I->assertIsArray($response['data']); + + if (!empty($response['data'])) { + $I->assertTrue(isset($response['data']['0'])); + $I->assertTrue(isset($response['data']['0']['id'])); + $I->assertTrue(isset($response['data']['0']['type'])); + $I->assertTrue(isset($response['data']['0']['attributes'])); + $I->assertIsArray($response['data']['0']['attributes']); + } + + $I->assertArrayHasKey('links', $response); + $I->assertArrayHasKey('self', $response['links']); + } + + + /** + * Create product and create a relationship with product categories (One To Many) + * @param ApiTester $I + * @see http://jsonapi.org/format/1.0/#fetching-resources-responses + * + * HTTP Verb: POST + * URL: /api/v8/modules/{module_name} + */ + public function TestScenarioCreateProductWithAnOneToManyRelationship(ApiTester $I) + { + $I->loginAsAdmin(); + $I->sendJwtAuthorisation(); + $I->sendJsonApiContentNegotiation(); + + $this->fakeData->seed(mt_rand(0, 2148)); + // Create AOS_Product_Categories + $payloadProductCategory = json_encode( + array( + 'data' => array( + 'id' => '', + 'type' => self::$PRODUCT_CATEGORY_RECORD_TYPE, + 'attributes' => array( + 'name' => $this->fakeData->colorName() + ), + ) + ) + ); + + $I->sendPOST( + $I->getInstanceURL() . self::$PRODUCT_CATEGORY_RESOURCE, + $payloadProductCategory + ); + // Validate response + $I->seeResponseCodeIs(201); + $responseProductCategory = json_decode($I->grabResponse(), true); + self::$PRODUCT_CATEGORY_RECORD_ID = $responseProductCategory['data']['id']; + + $this->fakeData->seed(mt_rand(0, 2148)); + // Create AOS_Products and Relate to AOS_Product_Categories + $payload = json_encode( + array( + 'data' => array( + 'id' => '', + 'type' => self::$PRODUCT_RECORD_TYPE, + 'attributes' => array( + 'name' => $this->fakeData->name(), + 'price' => $this->fakeData->randomDigit() + ), + 'relationships' => array( + 'aos_product_category' => array( + 'data' => array( + 'id' => self::$PRODUCT_CATEGORY_RECORD_ID, + 'type' => self::$PRODUCT_CATEGORY_RECORD_TYPE + ) + ) + ) + ) + ) + ); + + // Send Request + $I->sendPOST( + $I->getInstanceURL() . self::$PRODUCT_RESOURCE, + $payload + ); + // Validate response + $I->seeResponseCodeIs(201); + $responseProduct = json_decode($I->grabResponse(), true); + self::$PRODUCT_RECORD_ID = $responseProduct['data']['id']; + } + + /** + * Use product to retrieve a relationship (One To Many) + * @param ApiTester $I + * @see http://jsonapi.org/format/1.0/#crud-creating + * + * HTTP Verb: GET + * URL: /api/v8/modules/{module_name}/relationships/{link} + */ + public function TestScenarioRetrieveOneToManyRelationship(ApiTester $I) + { + // Retrieve Product + // Retrieve relationship + $I->loginAsAdmin(); + $I->sendJwtAuthorisation(); + $I->sendJsonApiContentNegotiation(); + $I->sendGET( + $I->getInstanceURL() . self::$PRODUCT_RESOURCE . '/' . + self::$PRODUCT_RECORD_ID . '/relationships/aos_product_category' + ); + // Verify that the objects have been created + // Validate response + $I->seeResponseCodeIs(200); + $responseProduct = json_decode($I->grabResponse(), true); + $I->assertArrayHasKey('data', $responseProduct); + $I->assertArrayHasKey('id', $responseProduct['data']); + $I->assertNotEmpty($responseProduct['data']['id']); + + $I->assertArrayHasKey('type', $responseProduct['data']); + $I->assertEquals(self::$PRODUCT_CATEGORY_RECORD_TYPE, $responseProduct['data']['type']); + + $I->assertArrayHasKey('links', $responseProduct['data']); + $I->assertArrayHasKey('href', $responseProduct['data']['links']); + } + + + /** + * Use product to create a new relationship with product categories (One To Many) + * @param ApiTester $I + * @see http://jsonapi.org/format/1.0/#fetching-resources-responses + * + * HTTP Verb: POST + * URL: /api/v8/modules/{module_name}/relationships/{link} + */ + public function TestScenarioCreateAnOneToManyRelationship(ApiTester $I) + { + $I->loginAsAdmin(); + $I->sendJwtAuthorisation(); + $I->sendJsonApiContentNegotiation(); + // Create AOS_Product_Categories + $this->fakeData->seed(mt_rand(0, 2148)); + $payloadProductCategory = json_encode( + array( + 'data' => array( + 'id' => '', + 'type' => self::$PRODUCT_CATEGORY_RECORD_TYPE, + 'attributes' => array( + 'name' => $this->fakeData->colorName() + ), + ) + ) + ); + + $I->sendPOST( + $I->getInstanceURL() . self::$PRODUCT_CATEGORY_RESOURCE, + $payloadProductCategory + ); + // Validate response + $I->seeResponseCodeIs(201); + $responseProductCategory = json_decode($I->grabResponse(), true); + self::$PRODUCT_CATEGORY_RECORD_ID = $responseProductCategory['data']['id']; + + // Create AOS_Products and Relate to AOS_Product_Categories + $payload = json_encode( + array( + 'data' => array( + 'id' => self::$PRODUCT_CATEGORY_RECORD_ID, + 'type' => self::$PRODUCT_CATEGORY_RECORD_TYPE, + ) + ) + ); + + $url = $I->getInstanceURL() . self::$PRODUCT_RESOURCE . '/' . + self::$PRODUCT_RECORD_ID . '/relationships/aos_product_category'; + // Send Request + $I->sendPOST( + $url, + $payload + ); + + // Validate response + $I->seeResponseCodeIs(200); + $responseProduct = json_decode($I->grabResponse(), true); + + // Verify that the product category has changed + $url = $I->getInstanceURL() . self::$PRODUCT_RESOURCE . '/' . + self::$PRODUCT_RECORD_ID . '/relationships/aos_product_category'; + + // Verify that the link has been deleted + $I->sendGET( + $url + ); + + $responseProductCategories = json_decode($I->grabResponse(), true); + $I->assertArrayHasKey('data', $responseProductCategories); + $I->assertNotEmpty($responseProductCategories['data']); + $I->assertArrayHasKey('id', $responseProductCategories['data']); + $I->assertEquals(self::$PRODUCT_CATEGORY_RECORD_ID, $responseProductCategories['data']['id']); + $I->assertArrayHasKey('type', $responseProductCategories['data']); + $I->assertEquals(self::$PRODUCT_CATEGORY_RECORD_TYPE, $responseProductCategories['data']['type']); + } + + /** + * Update a relationship (One To Many) + * @param ApiTester $I + * @see http://jsonapi.org/format/#crud-updating-relationships + * + * HTTP Verb: PATCH + * URL: /api/v8/modules/{module_name}/relationships/{link} + */ + public function TestScenarioUpdateOneToManyRelationship(ApiTester $I) + { + $I->loginAsAdmin(); + $I->sendJwtAuthorisation(); + $I->sendJsonApiContentNegotiation(); + $this->fakeData->seed(mt_rand(0, 2148)); + // Create AOS_Product_Categories + $payloadProductCategory = json_encode( + array( + 'data' => array( + 'id' => '', + 'type' => self::$PRODUCT_CATEGORY_RECORD_TYPE, + 'attributes' => array( + 'name' => $this->fakeData->colorName() + ), + ) + ) + ); + + $I->sendPOST( + $I->getInstanceURL() . self::$PRODUCT_CATEGORY_RESOURCE, + $payloadProductCategory + ); + // Validate response + $I->seeResponseCodeIs(201); + $responseProductCategory = json_decode($I->grabResponse(), true); + self::$PRODUCT_CATEGORY_RECORD_ID = $responseProductCategory['data']['id']; + + // Create AOS_Products and Relate to AOS_Product_Categories + $payload = json_encode( + array( + 'data' => array( + 'id' => self::$PRODUCT_CATEGORY_RECORD_ID, + 'type' => self::$PRODUCT_CATEGORY_RECORD_TYPE, + ) + ) + ); + + $url = $I->getInstanceURL() . self::$PRODUCT_RESOURCE . '/' . + self::$PRODUCT_RECORD_ID . '/relationships/aos_product_category'; + // Send Request + $I->sendPATCH( + $url, + $payload + ); + + // Validate response + $I->seeResponseCodeIs(200); + $responseProduct = json_decode($I->grabResponse(), true); + + // Verify that the product category has changed + $url = $I->getInstanceURL() . self::$PRODUCT_RESOURCE . '/' . + self::$PRODUCT_RECORD_ID . '/relationships/aos_product_category'; + + // Verify that the link has been deleted + $I->sendGET( + $url + ); + + $responseProductCategories = json_decode($I->grabResponse(), true); + $I->assertArrayHasKey('data', $responseProductCategories); + $I->assertNotEmpty($responseProductCategories['data']); + $I->assertArrayHasKey('id', $responseProductCategories['data']); + $I->assertEquals(self::$PRODUCT_CATEGORY_RECORD_ID, $responseProductCategories['data']['id']); + $I->assertArrayHasKey('type', $responseProductCategories['data']); + $I->assertEquals(self::$PRODUCT_CATEGORY_RECORD_TYPE, $responseProductCategories['data']['type']); + } + + /** + * Update a relationship (One To Many) + * @param ApiTester $I + * @see http://jsonapi.org/format/#crud-updating-relationships + * + * HTTP Verb: PATCH + * URL: /api/v8/modules/{module_name}/relationships/{link} + */ + public function TestScenarioClearOneToManyRelationshipUsingRelationshipLink(ApiTester $I) + { + $I->loginAsAdmin(); + $I->sendJwtAuthorisation(); + $I->sendJsonApiContentNegotiation(); + // Clear AOS_Product_Categories relationship + $payload = json_encode( + array( + 'data' => array() + ) + ); + + $url = $I->getInstanceURL() . self::$PRODUCT_RESOURCE . '/' . + self::$PRODUCT_RECORD_ID . '/relationships/aos_product_category'; + + // Send Request + $I->sendPATCH( + $url, + $payload + ); + + // Validate response + $I->seeResponseCodeIs(200); + $responseProduct = json_decode($I->grabResponse(), true); + $I->assertArrayHasKey('data', $responseProduct); + + // Verify that the link has been deleted + $I->sendGET( + $url + ); + + $responseProductCategories = json_decode($I->grabResponse(), true); + $I->assertArrayHasKey('data', $responseProductCategories); + $I->assertEmpty($responseProductCategories['data']); + } + + /** + * Delete a relationship (One To Many) + * @param ApiTester $I + * @see http://jsonapi.org/format/1.0/#crud-deleting + * + * HTTP Verb: DELETE + * URL: /api/v8/modules/{module_name}/relationships/{link} + */ + public function TestScenarioDeleteOneToManyRelationship(ApiTester $I) + { + $I->loginAsAdmin(); + $I->sendJwtAuthorisation(); + $I->sendJsonApiContentNegotiation(); + $this->fakeData->seed(mt_rand(0, 2148)); + // Create AOS_Product_Categories + $payloadProductCategory = json_encode( + array( + 'data' => array( + 'id' => '', + 'type' => self::$PRODUCT_CATEGORY_RECORD_TYPE, + 'attributes' => array( + 'name' => $this->fakeData->colorName() + ), + ) + ) + ); + + $I->sendPOST( + $I->getInstanceURL() . self::$PRODUCT_CATEGORY_RESOURCE, + $payloadProductCategory + ); + // Validate response + $I->seeResponseCodeIs(201); + $responseProductCategory = json_decode($I->grabResponse(), true); + self::$PRODUCT_CATEGORY_RECORD_ID = $responseProductCategory['data']['id']; + + // Create AOS_Products and Relate to AOS_Product_Categories + $payload = json_encode( + array( + 'data' => array( + 'id' => self::$PRODUCT_CATEGORY_RECORD_ID, + 'type' => self::$PRODUCT_CATEGORY_RECORD_TYPE, + ) + ) + ); + + $url = $I->getInstanceURL() . self::$PRODUCT_RESOURCE . '/' . + self::$PRODUCT_RECORD_ID . '/relationships/aos_product_category'; + // Send Request + $I->sendPOST( + $url, + $payload + ); + + // Validate response + $I->seeResponseCodeIs(200); + + // Delete Relationship + $url = $I->getInstanceURL() . self::$PRODUCT_RESOURCE . '/' . + self::$PRODUCT_RECORD_ID . '/relationships/aos_product_category'; + + $I->sendDELETE($url, $payload); + $I->seeResponseCodeIs(204); + + // Verify that the link has been deleted + $I->sendGET( + $url + ); + + $responseProductCategories = json_decode($I->grabResponse(), true); + $I->assertArrayHasKey('data', $responseProductCategories); + $I->assertEmpty($responseProductCategories['data']); + } + + + /** + * Retrieve a relationship (Many To Many) + * @param ApiTester $I + * @see http://jsonapi.org/format/#fetching-relationships + * + * HTTP Verb: GET + * URL: /api/v8/modules/{module_name}/relationships/{link} + */ + public function TestScenarioCreateManyToManyRelationships(ApiTester $I) + { + $I->loginAsAdmin(); + $I->sendJwtAuthorisation(); + $I->sendJsonApiContentNegotiation(); + + // Create Products of Product Categories + // Create AOS_Product #1 + $this->fakeData->seed(mt_rand(0, 2148)); + $payloadProduct1 = json_encode( + array( + 'data' => array( + 'id' => '', + 'type' => self::$PRODUCT_RECORD_TYPE, + 'attributes' => array( + 'name' => $this->fakeData->colorName(), + 'price' => $this->fakeData->randomDigit() + ), + ) + ) + ); + + $I->sendPOST( + $I->getInstanceURL() . self::$PRODUCT_RESOURCE, + $payloadProduct1 + ); + + // Validate response + $I->seeResponseCodeIs(201); + $responseProduct1 = json_decode($I->grabResponse(), true); + self::$PRODUCT_CATEGORY_RELATED_RECORD_IDS[] = $responseProduct1['data']['id']; + + // Create AOS_Product #2 + $this->fakeData->seed(mt_rand(0, 2148)); + $payloadProduct2 = json_encode( + array( + 'data' => array( + 'id' => '', + 'type' => self::$PRODUCT_RECORD_TYPE, + 'attributes' => array( + 'name' => $this->fakeData->colorName(), + 'price' => $this->fakeData->randomDigit() + ), + ) + ) + ); + + $I->sendPOST( + $I->getInstanceURL() . self::$PRODUCT_RESOURCE, + $payloadProduct2 + ); + + // Validate response + $I->seeResponseCodeIs(201); + $responseProduct2 = json_decode($I->grabResponse(), true); + self::$PRODUCT_CATEGORY_RELATED_RECORD_IDS[] = $responseProduct2['data']['id']; + + + // Create AOS_Product_Categories Parent + $this->fakeData->seed(mt_rand(0, 2148)); + $payloadProduct = json_encode( + array( + 'data' => array( + 'id' => '', + 'type' => self::$PRODUCT_CATEGORY_RECORD_TYPE, + 'attributes' => array( + 'name' => $this->fakeData->colorName() + ), + ) + ) + ); + + $I->sendPOST( + $I->getInstanceURL() . self::$PRODUCT_CATEGORY_RESOURCE, + $payloadProduct + ); + // Validate response + $I->seeResponseCodeIs(201); + $responseProductCategory = json_decode($I->grabResponse(), true); + self::$PRODUCT_CATEGORY_RECORD_ID = $responseProductCategory['data']['id']; + + + // Relate to Parent AOS_Product_Categories with child AOS_Product_Categories + $payload = json_encode( + array( + 'data' => array( + array( + 'id' => self::$PRODUCT_CATEGORY_RELATED_RECORD_IDS[0], + 'type' => self::$PRODUCT_RECORD_TYPE + ), + array( + 'id' => self::$PRODUCT_CATEGORY_RELATED_RECORD_IDS[1], + 'type' => self::$PRODUCT_RECORD_TYPE + ) + ) + ) + ); + + $url = $I->getInstanceURL() . self::$PRODUCT_CATEGORY_RESOURCE . '/' . + self::$PRODUCT_CATEGORY_RECORD_ID . '/relationships/aos_products'; + + // Send Request + $I->sendPOST( + $url, + $payload + ); + + // Validate response + $responseParentCategory = json_decode($I->grabResponse(), true); + $I->seeResponseCodeIs(200); + $I->assertArrayHasKey('data', $responseParentCategory); + $I->assertNotEmpty($responseParentCategory['data']); + } + + /** + * Retrieve a relationship (Many To Many) + * @param ApiTester $I + * @see http://jsonapi.org/format/#fetching-relationships + * + * HTTP Verb: GET + * URL: /api/v8/modules/{module_name}/relationships/{link} + */ + public function TestScenarioRetrieveManyToManyRelationships(ApiTester $I) + { + $I->loginAsAdmin(); + $I->sendJwtAuthorisation(); + $I->sendJsonApiContentNegotiation(); + // + $url = $I->getInstanceURL() . self::$PRODUCT_CATEGORY_RESOURCE . '/' . + self::$PRODUCT_CATEGORY_RECORD_ID . '/relationships/aos_products'; + // Get Subcategories of Product Categories + $I->sendGET( + $url + ); + + $I->seeResponseCodeIs(200); + $responseProducts = json_decode($I->grabResponse(), true); + $I->assertArrayHasKey('data', $responseProducts); + $I->assertNotEmpty($responseProducts['data']); + + // Validate product #1 + $I->assertArrayHasKey('id', $responseProducts['data'][0]); + $I->assertArrayHasKey('type', $responseProducts['data'][0]); + $I->assertEquals(self::$PRODUCT_RECORD_TYPE, $responseProducts['data'][0]['type']); + + // Validate product #2 + $I->assertArrayHasKey('id', $responseProducts['data'][1]); + $I->assertArrayHasKey('type', $responseProducts['data'][1]); + $I->assertEquals(self::$PRODUCT_RECORD_TYPE, $responseProducts['data'][1]['type']); + } + + /** + * Replaces a relationship + * @param ApiTester $I + * @see http://jsonapi.org/format/1.0/#crud-updating-relationships + * + * HTTP Verb: PATCH + * URL: /api/v8/modules/{module_name}/relationships/{link} + */ + public function TestScenarioUpdateManyToManyRelationships(ApiTester $I) + { + $I->loginAsAdmin(); + $I->sendJwtAuthorisation(); + $I->sendJsonApiContentNegotiation(); + // Replace the relationships with just one of the related items + // We should only see the item we have posted in the responses + $payload = json_encode( + array( + 'data' => array( + array( + 'id' => self::$PRODUCT_CATEGORY_RELATED_RECORD_IDS[1], + 'type' => self::$PRODUCT_RECORD_TYPE + ) + ) + ) + ); + + $url = $I->getInstanceURL() . self::$PRODUCT_CATEGORY_RESOURCE . '/' . + self::$PRODUCT_CATEGORY_RECORD_ID . '/relationships/aos_products'; + + // Send Request + $I->sendPATCH( + $url, + $payload + ); + + // Validate response + $I->seeResponseCodeIs(200); + $responseParentCategory = json_decode($I->grabResponse(), true); + $I->assertArrayHasKey('data', $responseParentCategory); + $I->assertNotEmpty($responseParentCategory['data']); + + // Validate that the relationship has been replaced + $I->sendGET( + $url + ); + + $I->seeResponseCodeIs(200); + $responseProducts = json_decode($I->grabResponse(), true); + $I->assertArrayHasKey('data', $responseProducts); + $I->assertNotEmpty($responseProducts['data']); + $I->assertCount(1, $responseProducts['data']); + + // Validate product #2 which will now be the first in the data array (index === 0) + $I->assertArrayHasKey('id', $responseProducts['data'][0]); + $I->assertEquals(self::$PRODUCT_CATEGORY_RELATED_RECORD_IDS[1], $responseProducts['data'][0]['id']); + $I->assertArrayHasKey('type', $responseProducts['data'][0]); + $I->assertEquals(self::$PRODUCT_RECORD_TYPE, $responseProducts['data'][0]['type']); + } + + + /** + * Clears all related items + * @param ApiTester $I + * @see http://jsonapi.org/format/1.0/#crud-updating-relationships + * + * HTTP Verb: PATCH + * URL: /api/v8/modules/{module_name}/relationships/{link} + */ + public function TestScenarioClearManyToManyRelationships(ApiTester $I) + { + // PATCH {"data": []} to clear all relationships + + $I->loginAsAdmin(); + $I->sendJwtAuthorisation(); + $I->sendJsonApiContentNegotiation(); + + // Replace the relationships with just one of the related items + // We should only see the item we have posted in the responses + $payload = json_encode( + array( + 'data' => array() + ) + ); + + $url = $I->getInstanceURL() . self::$PRODUCT_CATEGORY_RESOURCE . '/' . + self::$PRODUCT_CATEGORY_RECORD_ID . '/relationships/aos_products'; + + // Send Request + $I->sendPATCH( + $url, + $payload + ); + + // Validate response + $I->seeResponseCodeIs(200); + $responseParentCategory = json_decode($I->grabResponse(), true); + $I->assertArrayHasKey('data', $responseParentCategory); + $I->assertEmpty($responseParentCategory['data']); + + // Validate that the relationship has been replaced + $I->sendGET( + $url + ); + + $I->seeResponseCodeIs(200); + $responseProducts = json_decode($I->grabResponse(), true); + $I->assertArrayHasKey('data', $responseProducts); + $I->assertEmpty($responseProducts['data']); + } + + /** + * Removes a relationship + * @param ApiTester $I + * @see http://jsonapi.org/format/1.0/#crud-updating-relationships + * + * HTTP Verb: DELETE + * URL: /api/v8/modules/{module_name}/relationships/{link} + */ + public function TestScenarioDeleteManyToManyRelationships(ApiTester $I) + { + // DELETE single resource + $I->loginAsAdmin(); + $I->sendJwtAuthorisation(); + $I->sendJsonApiContentNegotiation(); + + // Create Products of Product Categories + // Create AOS_Product #1 + $this->fakeData->seed(mt_rand(0, 2148)); + $payloadProduct1 = json_encode( + array( + 'data' => array( + 'id' => '', + 'type' => self::$PRODUCT_RECORD_TYPE, + 'attributes' => array( + 'name' => $this->fakeData->colorName(), + 'price' => $this->fakeData->randomDigit() + ), + ) + ) + ); + + $I->sendPOST( + $I->getInstanceURL() . self::$PRODUCT_RESOURCE, + $payloadProduct1 + ); + + // Validate response + $I->seeResponseCodeIs(201); + $responseProduct1 = json_decode($I->grabResponse(), true); + self::$PRODUCT_CATEGORY_RELATED_RECORD_IDS[] = $responseProduct1['data']['id']; + + // Create AOS_Product #2 + $this->fakeData->seed(mt_rand(0, 2148)); + $payloadProduct2 = json_encode( + array( + 'data' => array( + 'id' => '', + 'type' => self::$PRODUCT_RECORD_TYPE, + 'attributes' => array( + 'name' => $this->fakeData->colorName(), + 'price' => $this->fakeData->randomDigit() + ), + ) + ) + ); + + $I->sendPOST( + $I->getInstanceURL() . self::$PRODUCT_RESOURCE, + $payloadProduct2 + ); + + // Validate response + $I->seeResponseCodeIs(201); + $responseProduct2 = json_decode($I->grabResponse(), true); + self::$PRODUCT_CATEGORY_RELATED_RECORD_IDS[] = $responseProduct2['data']['id']; + + + // Create AOS_Product_Categories Parent + $this->fakeData->seed(mt_rand(0, 2148)); + $payloadProduct = json_encode( + array( + 'data' => array( + 'id' => '', + 'type' => self::$PRODUCT_CATEGORY_RECORD_TYPE, + 'attributes' => array( + 'name' => $this->fakeData->colorName() + ), + ) + ) + ); + + $I->sendPOST( + $I->getInstanceURL() . self::$PRODUCT_CATEGORY_RESOURCE, + $payloadProduct + ); + // Validate response + $I->seeResponseCodeIs(201); + $responseProductCategory = json_decode($I->grabResponse(), true); + self::$PRODUCT_CATEGORY_RECORD_ID = $responseProductCategory['data']['id']; + + + // Relate to Parent AOS_Product_Categories with child AOS_Product_Categories + $payload = json_encode( + array( + 'data' => array( + array( + 'id' => self::$PRODUCT_CATEGORY_RELATED_RECORD_IDS[0], + 'type' => self::$PRODUCT_RECORD_TYPE + ), + array( + 'id' => self::$PRODUCT_CATEGORY_RELATED_RECORD_IDS[1], + 'type' => self::$PRODUCT_RECORD_TYPE + ) + ) + ) + ); + + $url = $I->getInstanceURL() . self::$PRODUCT_CATEGORY_RESOURCE . '/' . + self::$PRODUCT_CATEGORY_RECORD_ID . '/relationships/aos_products'; + + // Send Request + $I->sendPOST( + $url, + $payload + ); + + // Validate response + $I->seeResponseCodeIs(200); + $responseParentCategory = json_decode($I->grabResponse(), true); + $I->assertArrayHasKey('data', $responseParentCategory); + $I->assertNotEmpty($responseParentCategory['data']); + + // Delete first product + $payloadDelete = json_encode( + array( + 'data' => array( + array( + 'id' => self::$PRODUCT_CATEGORY_RELATED_RECORD_IDS[0], + 'type' => self::$PRODUCT_RECORD_TYPE + ) + ) + ) + ); + + // Send Request + $I->sendDELETE( + $url, + $payloadDelete + ); + + // Validate response + $I->seeResponseCodeIs(204); + + // Verify deletion + $I->sendGET( + $url + ); + + $I->seeResponseCodeIs(200); + $responseProducts = json_decode($I->grabResponse(), true); + $I->assertArrayHasKey('data', $responseProducts); + $I->assertNotEmpty($responseProducts['data']); + $I->assertCount(1, $responseProducts['data']); + + // Validate product #2 which will now be the first in the data array (index === 0) + $I->assertArrayHasKey('id', $responseProducts['data'][0]); + $I->assertEquals(self::$PRODUCT_CATEGORY_RELATED_RECORD_IDS[1], $responseProducts['data'][0]['id']); + $I->assertArrayHasKey('type', $responseProducts['data'][0]); + $I->assertEquals(self::$PRODUCT_RECORD_TYPE, $responseProducts['data'][0]['type']); + } + + + public function TestScenarioCreateMeetingsWithUsersAndMiddleTableFields(ApiTester $I) + { + // Temporary removing this. The API seems does not save correctly the relations on meetings but other problem blocking to solve this +// +// $I->loginAsAdmin(); +// $I->sendJwtAuthorisation(); +// $I->sendJsonApiContentNegotiation(); +// +// $url = $I->getInstanceURL() . self::$MEETINGS_RESOURCE; +// +// $I->comment('Create a meeting with invitees'); +// $meetingDateStart = new DateTimeImmutable(); +// $meetingDateStart = $meetingDateStart->add(new DateInterval('PT1H')); +// $meetingDateEnd = $meetingDateStart->add(new DateInterval('PT15M')); +// +// $meetingsPayload = array( +// 'data' => array( +// 'id'=> '', +// 'type' => 'Meetings', +// 'attributes' => array( +// 'name' => 'RelationshipsTest', +// 'date_start' => $meetingDateStart->format(DATE_ATOM), +// 'date_end' => $meetingDateEnd->format(DATE_ATOM), +// 'duration_hours' => 0, +// 'duration_minutes' => 15, +// 'assigned_user_id' => '1', +// 'assigned_user_name' => 'Administrator' +// ), +// 'relationships' => array( +// 'users' => array( +// 'data' => array( +// array( +// 'id' => '1', +// 'type' => 'Users', +// 'meta' => array( +// 'middle_table' => array( +// 'data' => array( +// 'id' => '', +// 'type' => 'Link', +// 'attributes' => array( +// 'user_id' => '1', +// 'accept_status' => 'accept' +// ) +// ) +// ) +// ) +// ), +// array( +// 'id' => 'seed_max_id', +// 'type' => 'Users', +// 'meta' => array( +// 'middle_table' => array( +// 'data' => array( +// 'id' => '', +// 'type' => 'Link', +// 'attributes' => array( +// 'user_id' => 'seed_max_id', +// 'accept_status' => 'none' +// ) +// ) +// ) +// ) +// ), +// array( +// 'id' => 'seed_chris_id', +// 'type' => 'Users', +// 'meta' => array( +// 'middle_table' => array( +// 'data' => array( +// 'id' => '', +// 'type' => 'Link', +// 'attributes' => array( +// 'user_id' => 'seed_chris_id', +// 'accept_status' => 'none' +// ) +// ) +// ) +// ) +// ) +// ) +// ) +// ) +// ) +// ); +// +// $I->sendPOST($url, json_encode($meetingsPayload)); +// $I->seeResponseCodeIs(201); +// $responseMeeting = json_decode($I->grabResponse(), true); +// self::$MEETINGS_RECORD_ID = $responseMeeting['data']['id']; +// +// $I->comment('Verify Invitees and Verify middle table fields'); +// $url = $I->getInstanceURL() . self::$MEETINGS_RESOURCE . '/' . +// self::$MEETINGS_RECORD_ID . '/relationships/users'; +// $I->sendGET($url); +// $responseMeetingUsers = json_decode($I->grabResponse(), true); +// +// $I->assertTrue(isset($responseMeetingUsers['data'][0]['links']['href'])); +// $I->assertTrue(isset($responseMeetingUsers['data'][0]['meta']['middle_table']['data']['attributes']['id'])); +// $I->assertTrue(isset($responseMeetingUsers['data'][0]['meta']['middle_table']['data']['attributes']['meeting_id'])); +// $I->assertTrue(isset($responseMeetingUsers['data'][0]['meta']['middle_table']['data']['attributes']['required'])); +// $I->assertTrue(isset($responseMeetingUsers['data'][0]['meta']['middle_table']['data']['attributes']['date_modified'])); +// $I->assertTrue(isset($responseMeetingUsers['data'][0]['meta']['middle_table']['data']['attributes']['deleted'])); +// +// +// unset($responseMeetingUsers['data'][0]['links']); +// unset($responseMeetingUsers['data'][0]['meta']['middle_table']['data']['attributes']['id']); +// unset($responseMeetingUsers['data'][0]['meta']['middle_table']['data']['attributes']['meeting_id']); +// unset($responseMeetingUsers['data'][0]['meta']['middle_table']['data']['attributes']['required']); +// unset($responseMeetingUsers['data'][0]['meta']['middle_table']['data']['attributes']['date_modified']); +// unset($responseMeetingUsers['data'][0]['meta']['middle_table']['data']['attributes']['deleted']); +// +// unset($responseMeetingUsers['data'][1]['links']); +// unset($responseMeetingUsers['data'][1]['meta']['middle_table']['data']['attributes']['id']); +// unset($responseMeetingUsers['data'][1]['meta']['middle_table']['data']['attributes']['meeting_id']); +// unset($responseMeetingUsers['data'][1]['meta']['middle_table']['data']['attributes']['required']); +// unset($responseMeetingUsers['data'][1]['meta']['middle_table']['data']['attributes']['date_modified']); +// unset($responseMeetingUsers['data'][1]['meta']['middle_table']['data']['attributes']['deleted']); +// +// unset($responseMeetingUsers['data'][2]['links']); +// unset($responseMeetingUsers['data'][2]['meta']['middle_table']['data']['attributes']['id']); +// unset($responseMeetingUsers['data'][2]['meta']['middle_table']['data']['attributes']['meeting_id']); +// unset($responseMeetingUsers['data'][2]['meta']['middle_table']['data']['attributes']['required']); +// unset($responseMeetingUsers['data'][2]['meta']['middle_table']['data']['attributes']['date_modified']); +// unset($responseMeetingUsers['data'][2]['meta']['middle_table']['data']['attributes']['deleted']); +// +// $I->assertSame($meetingsPayload['data']['relationships']['users']['data'], $responseMeetingUsers['data']); +// +// $I->comment('Update a chris accept_status using POST'); +// $url = $I->getInstanceURL() . self::$MEETINGS_RESOURCE . '/' . +// self::$MEETINGS_RECORD_ID . '/relationships/users'; +// $payloadUpdateChrisAccept = array( +// 'data' => array( +// 'id' => 'seed_chris_id', +// 'type' => 'Users', +// 'meta' => array( +// 'middle_table' => array( +// 'data' => array( +// 'id' => '', +// 'type' => 'Link', +// 'attributes' => array( +// 'user_id' => 'seed_chris_id', +// 'accept_status' => 'accept' +// ) +// ) +// ) +// ) +// ) +// ); +// +// $I->sendPOST($url, json_encode($payloadUpdateChrisAccept)); +// $I->seeResponseIsJson(); +// $responseChrisAccept = json_decode($I->grabResponse(), true); +// $I->seeResponseCodeIs(200); +// +// $exp = $payloadUpdateChrisAccept['data']; +// +// $I->comment('Verify that user accept_status has been update'); +// $I->assertSame($exp, $responseChrisAccept['data'][0]); + } +} diff --git a/tests/phpunit.xml.dist b/tests/phpunit.xml.dist index f22c301af..7140dc600 100644 --- a/tests/phpunit.xml.dist +++ b/tests/phpunit.xml.dist @@ -1,17 +1,16 @@ + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd" + backupGlobals="true" + backupStaticAttributes="false" + colors="true" + convertNoticesToExceptions="true" + convertWarningsToExceptions="true" + convertErrorsToExceptions="true" + processIsolation="false" + stopOnFailure="false" + stopOnError="false" + bootstrap="bootstrap.php"> @@ -19,19 +18,27 @@ - - + + + + ../ - - ../.git - ../.github - ../XTemplate - ../cache - ../vendor - ../tests - - - + + + + ../.git + ../.github + ../XTemplate + ../cache + ../vendor + ../tests + + diff --git a/tests/unit/phpunit/Api/Core/Loader/CustomLoaderTest.php b/tests/unit/phpunit/Api/Core/Loader/CustomLoaderTest.php index 9dd9e6fb7..28fcb4de6 100644 --- a/tests/unit/phpunit/Api/Core/Loader/CustomLoaderTest.php +++ b/tests/unit/phpunit/Api/Core/Loader/CustomLoaderTest.php @@ -49,53 +49,53 @@ use SuiteCRM\Test\SuitePHPUnitFrameworkTestCase; */ class CustomLoaderTest extends SuitePHPUnitFrameworkTestCase { - public function testArrayMerge() + public function testArrayMerge(): void { $result = CustomLoader::arrayMerge([ ['first' => ['one.1', 'one.2', 'one.3'], 'second' => 'two', 'third' => 'three'], ['first' => ['one.4', 'one.5'], 'foo' => ['bar', 'bazz']] ]); - $this->assertEquals([ + self::assertEquals([ 'first' => ['one.1', 'one.2', 'one.3', 'one.4', 'one.5'], 'second' => 'two', 'third' => 'three', 'foo' => ['bar', 'bazz'], ], $result); } - - public function testMergeCustomArray() + + public function testMergeCustomArray(): void { $result = CustomLoader::mergeCustomArray(['one', 'two', 'three'], 'testCustom.php'); - $this->assertEquals(CustomLoader::ERR_FILE_NOT_FOUND, CustomLoader::getLastError()); - $this->assertEquals(['one', 'two', 'three'], $result); - + self::assertEquals(CustomLoader::ERR_FILE_NOT_FOUND, CustomLoader::getLastError()); + self::assertEquals(['one', 'two', 'three'], $result); + CustomLoader::setCustomPath(__DIR__ . DIRECTORY_SEPARATOR); $result = CustomLoader::mergeCustomArray(['foo', 'bar'], 'testArray.php'); - $this->assertEquals(CustomLoader::ERR_NO_ERROR, CustomLoader::getLastError()); - $this->assertEquals(['foo', 'bar', 'bazz', 1, 2, 3], $result); - + self::assertEquals(CustomLoader::ERR_NO_ERROR, CustomLoader::getLastError()); + self::assertEquals(['foo', 'bar', 'bazz', 1, 2, 3], $result); + try { $result = CustomLoader::mergeCustomArray(['foo', 'bar'], 'testArrayWrong.php'); - $this->assertTrue(false, 'It should throws an exception because the customization is not an array.'); + self::assertTrue(false, 'It should throws an exception because the customization is not an array.'); } catch (Exception $e) { - $this->assertEquals(CustomLoader::ERR_WRONG_CUSTOM_FORMAT, $e->getCode()); + self::assertEquals(CustomLoader::ERR_WRONG_CUSTOM_FORMAT, $e->getCode()); } - + // restore custom route CustomLoader::setCustomPath(); } - - public function testLoadCustomRoutes() + + public function testLoadCustomRoutes(): void { $app = new App(); - + CustomLoader::loadCustomRoutes($app, 'testRoutes.php'); - $this->assertEquals(CustomLoader::ERR_ROUTE_FILE_NOT_FOUND, CustomLoader::getLastError()); - + self::assertEquals(CustomLoader::ERR_ROUTE_FILE_NOT_FOUND, CustomLoader::getLastError()); + CustomLoader::setCustomPath(__DIR__ . DIRECTORY_SEPARATOR); CustomLoader::loadCustomRoutes($app, 'testRoutes.php'); - $this->assertEquals(CustomLoader::ERR_NO_ERROR, CustomLoader::getLastError()); - + self::assertEquals(CustomLoader::ERR_NO_ERROR, CustomLoader::getLastError()); + // restore custom route CustomLoader::setCustomPath(); } diff --git a/tests/unit/phpunit/ConfigTest.php b/tests/unit/phpunit/ConfigTest.php new file mode 100644 index 000000000..94ec1b029 --- /dev/null +++ b/tests/unit/phpunit/ConfigTest.php @@ -0,0 +1,60 @@ +assertNotEmpty($sugar_config, 'SuiteCRM config is empty'); - } - - public function testFoo() - { - $this->assertTrue(true); - } -} diff --git a/tests/unit/phpunit/data/BeanFactoryTest.php b/tests/unit/phpunit/data/BeanFactoryTest.php index 6817bfcb3..1caec47a2 100644 --- a/tests/unit/phpunit/data/BeanFactoryTest.php +++ b/tests/unit/phpunit/data/BeanFactoryTest.php @@ -1,4 +1,42 @@ removeCoreModuleExtension($moduleName, $moduleConfig['className']); $bean = BeanFactory::newBean($moduleName); - $this->assertNotFalse($bean, 'Unable to get core bean for module: ' . $moduleName); - $this->assertInstanceOf( + self::assertNotFalse($bean, 'Unable to get core bean for module: ' . $moduleName); + self::assertInstanceOf( $moduleConfig['className'], $bean, 'Loaded bean not instance of core class: ' . $moduleConfig['className'] @@ -37,8 +75,8 @@ class BeanFactoryTest extends BeanFactoryTestCase $refreshedConfig = $this->moduleConfigProvider()[$moduleName]['meta']; $customBean = BeanFactory::newBean($moduleName); - $this->assertNotFalse($customBean, 'Unable to get custom bean for module: ' . $moduleName); - $this->assertInstanceOf( + self::assertNotFalse($customBean, 'Unable to get custom bean for module: ' . $moduleName); + self::assertInstanceOf( $refreshedConfig['customClassName'], $customBean, 'Loaded bean not instance of custom class: ' . $refreshedConfig['customClassName'] @@ -56,13 +94,13 @@ class BeanFactoryTest extends BeanFactoryTestCase * @param array $moduleConfig * @return void */ - public function testGetBean($moduleName, $moduleConfig) + public function testGetBean($moduleName, $moduleConfig): void { $this->removeCoreModuleExtension($moduleName, $moduleConfig['className']); $bean = BeanFactory::getBean($moduleName); - $this->assertNotFalse($bean, 'Unable to get core test record bean for module: ' . $moduleName); - $this->assertInstanceOf( + self::assertNotFalse($bean, 'Unable to get core test record bean for module: ' . $moduleName); + self::assertInstanceOf( $moduleConfig['className'], $bean, 'Loaded bean not instance of core class: ' . $moduleConfig['className'] @@ -72,8 +110,8 @@ class BeanFactoryTest extends BeanFactoryTestCase $refreshedConfig = $this->moduleConfigProvider()[$moduleName]['meta']; $customBean = BeanFactory::getBean($moduleName); - $this->assertNotFalse($customBean, 'Unable to get custom test record bean for module: ' . $moduleName); - $this->assertInstanceOf( + self::assertNotFalse($customBean, 'Unable to get custom test record bean for module: ' . $moduleName); + self::assertInstanceOf( $refreshedConfig['customClassName'], $customBean, 'Loaded bean not instance of custom class: ' . $refreshedConfig['customClassName'] @@ -89,24 +127,24 @@ class BeanFactoryTest extends BeanFactoryTestCase * @param array $moduleConfig * @return void */ - public function testGetBeanMeta($moduleName, $moduleConfig) + public function testGetBeanMeta($moduleName, $moduleConfig): void { $this->removeCoreModuleExtension($moduleName, $moduleConfig['className']); $beanMeta = BeanFactory::getBeanMeta($moduleName); - $this->assertEquals($moduleConfig['className'], $beanMeta['beanName']); - $this->assertEquals($moduleConfig['className'], $beanMeta['beanClass']); - $this->assertEquals($moduleConfig['objectName'], $beanMeta['objectName']); - $this->assertEquals($moduleConfig['classFile'], $beanMeta['classFile']); + self::assertEquals($moduleConfig['className'], $beanMeta['beanName']); + self::assertEquals($moduleConfig['className'], $beanMeta['beanClass']); + self::assertEquals($moduleConfig['objectName'], $beanMeta['objectName']); + self::assertEquals($moduleConfig['classFile'], $beanMeta['classFile']); $this->addCoreModuleExtension($moduleName, $moduleConfig['className']); $refreshedConfig = $this->moduleConfigProvider()[$moduleName]['meta']; $customBeanMeta = BeanFactory::getBeanMeta($moduleName); - $this->assertEquals($refreshedConfig['customClassName'], $customBeanMeta['customBeanName']); - $this->assertEquals($refreshedConfig['customClassName'], $customBeanMeta['beanClass']); - $this->assertEquals($refreshedConfig['customObjectName'], $customBeanMeta['customObjectName']); - $this->assertEquals($refreshedConfig['customClassFile'], $customBeanMeta['customClassFile']); + self::assertEquals($refreshedConfig['customClassName'], $customBeanMeta['customBeanName']); + self::assertEquals($refreshedConfig['customClassName'], $customBeanMeta['beanClass']); + self::assertEquals($refreshedConfig['customObjectName'], $customBeanMeta['customObjectName']); + self::assertEquals($refreshedConfig['customClassFile'], $customBeanMeta['customClassFile']); $this->removeCoreModuleExtension($moduleName, $moduleConfig['className']); } @@ -118,18 +156,18 @@ class BeanFactoryTest extends BeanFactoryTestCase * @param array $moduleConfig * @return void */ - public function testGetBeanClass($moduleName, $moduleConfig) + public function testGetBeanClass($moduleName, $moduleConfig): void { $this->removeCoreModuleExtension($moduleName, $moduleConfig['className']); $coreBeanClass = BeanFactory::getBeanClass($moduleName); - $this->assertEquals($moduleConfig['className'], $coreBeanClass); + self::assertEquals($moduleConfig['className'], $coreBeanClass); $this->addCoreModuleExtension($moduleName, $moduleConfig['className']); $refreshedConfig = $this->moduleConfigProvider()[$moduleName]['meta']; $customBeanClass = BeanFactory::getBeanClass($moduleName); - $this->assertEquals($refreshedConfig['customClassName'], $customBeanClass); + self::assertEquals($refreshedConfig['customClassName'], $customBeanClass); $this->removeCoreModuleExtension($moduleName, $moduleConfig['className']); } @@ -139,20 +177,20 @@ class BeanFactoryTest extends BeanFactoryTestCase * * @param string $moduleName * @param array $moduleConfig - * @return array + * @return void */ - public function testGetBeanName($moduleName, $moduleConfig) + public function testGetBeanName($moduleName, $moduleConfig): void { $this->removeCoreModuleExtension($moduleName, $moduleConfig['className']); $beanName = BeanFactory::getBeanName($moduleName); - $this->assertEquals($moduleConfig['className'], $beanName); + self::assertEquals($moduleConfig['className'], $beanName); $this->addCoreModuleExtension($moduleName, $moduleConfig['className']); $refreshedConfig = $this->moduleConfigProvider()[$moduleName]['meta']; $beanName = BeanFactory::getBeanName($moduleName); - $this->assertNotEquals($refreshedConfig['customClassName'], $beanName); + self::assertNotEquals($refreshedConfig['customClassName'], $beanName); $this->subTestGetCustomBeanName(compact('moduleName', 'refreshedConfig')); } @@ -163,10 +201,10 @@ class BeanFactoryTest extends BeanFactoryTestCase * @param array $meta * @return void */ - public function subTestGetCustomBeanName($meta) + public function subTestGetCustomBeanName($meta): void { $customBeanName = BeanFactory::getCustomBeanName($meta['moduleName']); - $this->assertEquals($meta['refreshedConfig']['customClassName'], $customBeanName); + self::assertEquals($meta['refreshedConfig']['customClassName'], $customBeanName); $this->removeCoreModuleExtension($meta['moduleName'], $meta['refreshedConfig']['className']); } @@ -176,20 +214,20 @@ class BeanFactoryTest extends BeanFactoryTestCase * * @param string $moduleName * @param array $moduleConfig - * @return array + * @return void */ - public function testGetObjectName($moduleName, $moduleConfig) + public function testGetObjectName($moduleName, $moduleConfig): void { $this->removeCoreModuleExtension($moduleName, $moduleConfig['className']); $objectName = BeanFactory::getObjectName($moduleName); - $this->assertEquals($moduleConfig['objectName'], $objectName); + self::assertEquals($moduleConfig['objectName'], $objectName); $this->addCoreModuleExtension($moduleName, $moduleConfig['className']); $refreshedConfig = $this->moduleConfigProvider()[$moduleName]['meta']; $objectName = BeanFactory::getObjectName($moduleName); - $this->assertNotEquals($refreshedConfig['customObjectName'], $objectName); + self::assertNotEquals($refreshedConfig['customObjectName'], $objectName); $this->subTestGetCustomObjectName(compact('moduleName', 'refreshedConfig')); } @@ -200,10 +238,10 @@ class BeanFactoryTest extends BeanFactoryTestCase * @param array $meta * @return void */ - public function subTestGetCustomObjectName($meta) + public function subTestGetCustomObjectName($meta): void { $customObjectName = BeanFactory::getCustomObjectName($meta['moduleName']); - $this->assertEquals($meta['refreshedConfig']['customObjectName'], $customObjectName); + self::assertEquals($meta['refreshedConfig']['customObjectName'], $customObjectName); $this->removeCoreModuleExtension($meta['moduleName'], $meta['refreshedConfig']['className']); } @@ -214,20 +252,20 @@ class BeanFactoryTest extends BeanFactoryTestCase * @param string $moduleName * @param array $moduleConfig * - * @return array + * @return void */ - public function testGetBeanFile($moduleName, $moduleConfig) + public function testGetBeanFile($moduleName, $moduleConfig): void { $this->removeCoreModuleExtension($moduleName, $moduleConfig['className']); $beanFile = BeanFactory::getBeanFile($moduleName); - $this->assertEquals($moduleConfig['classFile'], $beanFile); + self::assertEquals($moduleConfig['classFile'], $beanFile); $this->addCoreModuleExtension($moduleName, $moduleConfig['className']); $refreshedConfig = $this->moduleConfigProvider()[$moduleName]['meta']; $beanFile = BeanFactory::getBeanFile($moduleName); - $this->assertNotEquals($refreshedConfig['customClassFile'], $beanFile); + self::assertNotEquals($refreshedConfig['customClassFile'], $beanFile); $this->subTestGetCustomBeanFile(compact('moduleName', 'refreshedConfig')); } @@ -238,10 +276,10 @@ class BeanFactoryTest extends BeanFactoryTestCase * @param array $meta * @return void */ - public function subTestGetCustomBeanFile($meta) + public function subTestGetCustomBeanFile($meta): void { $customBeanFile = BeanFactory::getCustomBeanFile($meta['moduleName']); - $this->assertEquals($meta['refreshedConfig']['customClassFile'], $customBeanFile); + self::assertEquals($meta['refreshedConfig']['customClassFile'], $customBeanFile); $this->removeCoreModuleExtension($meta['moduleName'], $meta['refreshedConfig']['className']); } @@ -252,20 +290,20 @@ class BeanFactoryTest extends BeanFactoryTestCase * @param string $moduleName * @param array $moduleConfig */ - public function testLoadBeanFile($moduleName, $moduleConfig) + public function testLoadBeanFile($moduleName, $moduleConfig): void { $this->removeCoreModuleExtension($moduleName, $moduleConfig['className']); $coreFileLoaded = BeanFactory::loadBeanFile($moduleName); - $this->assertTrue($coreFileLoaded); - $this->assertTrue(class_exists($moduleConfig['className'])); + self::assertTrue($coreFileLoaded); + self::assertTrue(class_exists($moduleConfig['className'])); $this->addCoreModuleExtension($moduleName, $moduleConfig['className']); $refreshedConfig = $this->moduleConfigProvider()[$moduleName]['meta']; $customFileLoaded = BeanFactory::loadBeanFile($moduleName); - $this->assertTrue($customFileLoaded); - $this->assertTrue(class_exists($refreshedConfig['customClassName'])); + self::assertTrue($customFileLoaded); + self::assertTrue(class_exists($refreshedConfig['customClassName'])); $this->removeCoreModuleExtension($moduleName, $moduleConfig['className']); } diff --git a/tests/unit/phpunit/data/SugarBeanMock.php b/tests/unit/phpunit/data/SugarBeanMock.php index f008d8dc0..3bfdbd5ea 100644 --- a/tests/unit/phpunit/data/SugarBeanMock.php +++ b/tests/unit/phpunit/data/SugarBeanMock.php @@ -8,7 +8,6 @@ class SugarBeanMock extends SugarBean */ public $foo; - /** @noinspection SenselessMethodDuplicationInspection */ /** @noinspection PhpMissingParentConstructorInspection */ /** @noinspection MagicMethodsValidityInspection */ @@ -40,14 +39,12 @@ class SugarBeanMock extends SugarBean } //setup custom fields - /** @noinspection UnSafeIsSetOverArrayInspection */ if (!isset($this->custom_fields) && empty($this->disable_custom_fields) ) { $this->setupCustomFields($this->module_dir); } - /** @noinspection NotOptimalIfConditionsInspection */ if (isset($GLOBALS['dictionary'][$this->object_name]) && !$this->disable_vardefs) { $this->field_name_map = $dictionary[$this->object_name]['fields']; $this->field_defs = $dictionary[$this->object_name]['fields']; @@ -69,7 +66,6 @@ class SugarBeanMock extends SugarBean $this->field_defs =& $loaded_definitions[$this->object_name]['field_defs']; $this->added_custom_field_defs = true; - /** @noinspection UnSafeIsSetOverArrayInspection */ if (!isset($this->custom_fields) && empty($this->disable_custom_fields) ) { @@ -93,7 +89,7 @@ class SugarBeanMock extends SugarBean * @return string * @throws \Exception */ - public function publicParseDateDefault($value, $time = false) + public function publicParseDateDefault($value, $time = false): string { return $this->parseDateDefault($value, $time); }/** @noinspection MoreThanThreeArgumentsInspection */ @@ -105,7 +101,7 @@ class SugarBeanMock extends SugarBean * @param string $order_by * @return array */ - public static function publicBuildSubQueriesForUnion($subpanel_list, $subpanel_def, $parentbean, $order_by) + public static function publicBuildSubQueriesForUnion($subpanel_list, $subpanel_def, $parentbean, $order_by): array { return self::build_sub_queries_for_union($subpanel_list, $subpanel_def, $parentbean, $order_by); } @@ -113,12 +109,12 @@ class SugarBeanMock extends SugarBean /** * @param mixed $testValue */ - public function setLoadedRelationships($testValue) + public function setLoadedRelationships($testValue): void { $this->loaded_relationships = $testValue; } - public function getEncryptKeyPublic() + public function getEncryptKeyPublic(): string { return parent::getEncryptKey(); } diff --git a/tests/unit/phpunit/data/SugarBeanTest.php b/tests/unit/phpunit/data/SugarBeanTest.php index 4d4ecd5b2..4bdd1c3b3 100644 --- a/tests/unit/phpunit/data/SugarBeanTest.php +++ b/tests/unit/phpunit/data/SugarBeanTest.php @@ -7,7 +7,6 @@ include_once __DIR__ . '/../../../../modules/AM_ProjectTemplates/AM_ProjectTempl use SuiteCRM\Test\SuitePHPUnitFrameworkTestCase; use SuiteCRM\Utility\SuiteValidator; -/** @noinspection PhpUndefinedClassInspection */ class SugarBeanTest extends SuitePHPUnitFrameworkTestCase { /** @@ -31,36 +30,35 @@ class SugarBeanTest extends SuitePHPUnitFrameworkTestCase * Store static field_defs per modules * @param string $key */ - protected function fieldDefsStore($key = 'base') + protected function fieldDefsStore($key = 'base'): void { - $object = BeanFactory::newBean('Contacts'); - $this->fieldDefsStore[$key]['Contact'] = $object->field_defs; + $this->fieldDefsStore[$key]['Contact'] = BeanFactory::newBean('Contacts')->field_defs; } /** * Restore static field_defs per modules * @param string $key */ - protected function fieldDefsRestore($key = 'base') + protected function fieldDefsRestore($key = 'base'): void { $object = BeanFactory::newBean('Contacts'); $object->field_defs = $this->fieldDefsStore[$key]['Contact']; } - public function testFactoryGetCachedDeleted() + public function testFactoryGetCachedDeleted(): void { // Create a lead and cache it $lead = BeanFactory::newBean('Leads'); $lead->save(); $bean = BeanFactory::getBean($lead->module_dir, $lead->id); - $this->assertNotEmpty($bean); + self::assertNotEmpty($bean); // Don't return a cached result if the bean was deleted $lead->mark_deleted($lead->id); - $this->assertEmpty(BeanFactory::getBean($lead->module_dir, $lead->id)); + self::assertEmpty(BeanFactory::getBean($lead->module_dir, $lead->id)); // Unless explicitly specified - $this->assertNotEmpty(BeanFactory::getBean($lead->module_dir, $lead->id, [], false)); + self::assertNotEmpty(BeanFactory::getBean($lead->module_dir, $lead->id, [], false)); } protected function getModuleBean($module) @@ -77,7 +75,7 @@ class SugarBeanTest extends SuitePHPUnitFrameworkTestCase /** * @see SugarBean::__construct() */ - public function testConstruct() + public function testConstruct(): void { global $dictionary; @@ -566,7 +564,7 @@ class SugarBeanTest extends SuitePHPUnitFrameworkTestCase /** * @see SugarBean::setupCustomFields() */ - public function testSetupCustomFields() + public function testSetupCustomFields(): void { $bean = BeanFactory::getBean('Users'); @@ -582,19 +580,17 @@ class SugarBeanTest extends SuitePHPUnitFrameworkTestCase /** * @see SugarBean::bean_implements() */ - public function testBeanImplements() + public function testBeanImplements(): void { - $bean = BeanFactory::getBean('Users'); - // test - $results = $bean->bean_implements('test'); + $results = BeanFactory::getBean('Users')->bean_implements('test'); self::assertEquals(false, $results); } /** * @see SugarBean::populateDefaultValues() */ - public function testPopulateDefaultValues() + public function testPopulateDefaultValues(): void { $testBean1 = BeanFactory::getBean('Users'); $origFieldDefs = $testBean1->field_defs; @@ -672,7 +668,7 @@ class SugarBeanTest extends SuitePHPUnitFrameworkTestCase /** * @see SugarBean::parseDateDefault() */ - public function testParseDateDefault() + public function testParseDateDefault(): void { $bean = new SugarBeanMock(); @@ -684,7 +680,7 @@ class SugarBeanTest extends SuitePHPUnitFrameworkTestCase // test $results = $bean->publicParseDateDefault('2015-05-05', true); self::assertNotEquals('05/05/2015', $results); - self::assertEquals(1, preg_match('/05\/05\/2015 \d{2}:\d{2}/', $results)); + self::assertMatchesRegularExpression('/05\/05\/2015 \d{2}:\d{2}/', $results); // test $results = $bean->publicParseDateDefault('2015-05-05 11:11', true); @@ -698,7 +694,7 @@ class SugarBeanTest extends SuitePHPUnitFrameworkTestCase /** * @see SugarBean::removeRelationshipMeta() */ - public function testRemoveRelationshipMeta() + public function testRemoveRelationshipMeta(): void { // test $GLOBALS['log']->reset(); @@ -728,7 +724,7 @@ class SugarBeanTest extends SuitePHPUnitFrameworkTestCase /** * @see SugarBean::createRelationshipMeta() */ - public function testCreateRelationshipMeta() + public function testCreateRelationshipMeta(): void { // test $GLOBALS['log']->reset(); @@ -770,7 +766,7 @@ class SugarBeanTest extends SuitePHPUnitFrameworkTestCase * @see SugarBean::get_union_related_list() * @todo need more test coverage and less function complexity */ - public function testGetUnionRelatedList() + public function testGetUnionRelatedList(): void { $request = $_REQUEST; self::assertFalse(isset($_SESSION)); @@ -853,7 +849,7 @@ class SugarBeanTest extends SuitePHPUnitFrameworkTestCase /** * @see SugarBean::build_sub_queries_for_union() */ - public function testBuildSubQueriesForUnion() + public function testBuildSubQueriesForUnion(): void { // test $bean = new SugarBeanMock(); @@ -924,7 +920,7 @@ class SugarBeanTest extends SuitePHPUnitFrameworkTestCase /** * @see SugarBean::process_union_list_query() */ - public function testProcessUnionListQuery() + public function testProcessUnionListQuery(): void { self::markTestIncomplete('environment dependency'); @@ -1262,7 +1258,7 @@ class SugarBeanTest extends SuitePHPUnitFrameworkTestCase /** * @see SugarBean::retrieve_parent_fields() */ - public function testRetrieveParentFields() + public function testRetrieveParentFields(): void { $GLOBALS['log']->reset(); @@ -1386,7 +1382,7 @@ class SugarBeanTest extends SuitePHPUnitFrameworkTestCase /** * @see SugarBean::getAuditEnabledFieldDefinitions() */ - public function testGetAuditEnabledFieldDefinitions() + public function testGetAuditEnabledFieldDefinitions(): void { $GLOBALS['log']->reset(); @@ -1483,7 +1479,7 @@ class SugarBeanTest extends SuitePHPUnitFrameworkTestCase /** * @see SugarBean::isOwner() */ - public function testIsOwner() + public function testIsOwner(): void { // test $GLOBALS['log']->reset(); @@ -1555,12 +1551,11 @@ class SugarBeanTest extends SuitePHPUnitFrameworkTestCase /** * @see SugarBean::get_custom_table_name() */ - public function testGetCustomTableName() + public function testGetCustomTableName(): void { // test $GLOBALS['log']->reset(); - $bean = BeanFactory::newBean('Contacts'); - $result = $bean->get_custom_table_name(); + $result = BeanFactory::newBean('Contacts')->get_custom_table_name(); self::assertEquals('contacts_cstm', $result); self::assertFalse(isset($GLOBALS['log']->calls['fatal'])); } @@ -1568,7 +1563,7 @@ class SugarBeanTest extends SuitePHPUnitFrameworkTestCase /** * @see SugarBean::getTableName() */ - public function testGetTableName() + public function testGetTableName(): void { // test $GLOBALS['log']->reset(); @@ -1594,7 +1589,7 @@ class SugarBeanTest extends SuitePHPUnitFrameworkTestCase /** * @see SugarBean::getObjectName() */ - public function testGetObjectName() + public function testGetObjectName(): void { // test $GLOBALS['log']->reset(); @@ -1632,7 +1627,7 @@ class SugarBeanTest extends SuitePHPUnitFrameworkTestCase /** * @see SugarBean::getIndices() */ - public function testGetIndices() + public function testGetIndices(): void { // test $GLOBALS['log']->reset(); @@ -1710,7 +1705,7 @@ class SugarBeanTest extends SuitePHPUnitFrameworkTestCase /** * @see SugarBean::getPrimaryFieldDefinition() */ - public function testGetPrimaryFieldDefinition() + public function testGetPrimaryFieldDefinition(): void { // test $GLOBALS['log']->reset(); @@ -1758,7 +1753,7 @@ class SugarBeanTest extends SuitePHPUnitFrameworkTestCase /** * @see SugarBean::getFieldDefinition() */ - public function testGetFieldDefinition() + public function testGetFieldDefinition(): void { // test $GLOBALS['log']->reset(); @@ -1808,7 +1803,7 @@ class SugarBeanTest extends SuitePHPUnitFrameworkTestCase /** * @see SugarBean::getFieldValue() */ - public function testGetFieldValue() + public function testGetFieldValue(): void { // test $GLOBALS['log']->reset(); @@ -1846,7 +1841,7 @@ class SugarBeanTest extends SuitePHPUnitFrameworkTestCase /** * @see SugarBean::unPopulateDefaultValues() */ - public function testUnPopulateDefaultValues() + public function testUnPopulateDefaultValues(): void { // test $bean = BeanFactory::newBean('Contacts'); @@ -1877,7 +1872,7 @@ class SugarBeanTest extends SuitePHPUnitFrameworkTestCase /** * @see SugarBean::__clone() */ - public function testClone() + public function testClone(): void { // test $GLOBALS['log']->reset(); @@ -1895,7 +1890,6 @@ class SugarBeanTest extends SuitePHPUnitFrameworkTestCase $bean->setLoadedRelationships(array('foo')); $clone = clone $bean; self::assertEquals('bar', $bean->foo); - /** @noinspection UnSafeIsSetOverArrayInspection */ self::assertNotTrue(isset($clone->foo)); unset($bean->foo); self::assertEquals($bean, $clone); @@ -1904,7 +1898,7 @@ class SugarBeanTest extends SuitePHPUnitFrameworkTestCase /** * @see SugarBean::get_linked_fields() */ - public function testGetLinkedFields() + public function testGetLinkedFields(): void { // test $GLOBALS['log']->reset(); @@ -1950,7 +1944,7 @@ class SugarBeanTest extends SuitePHPUnitFrameworkTestCase /** * @see SugarBean::getFieldDefinitions() */ - public function testGetFieldDefinitions() + public function testGetFieldDefinitions(): void { // test $GLOBALS['log']->reset(); @@ -1964,7 +1958,7 @@ class SugarBeanTest extends SuitePHPUnitFrameworkTestCase /** * @see SugarBean::load_relationship() */ - public function testLoadRelationship() + public function testLoadRelationship(): void { // test $GLOBALS['log']->reset(); @@ -2008,7 +2002,6 @@ class SugarBeanTest extends SuitePHPUnitFrameworkTestCase $GLOBALS['log']->fatal('test'); $bean = BeanFactory::newBean('Contacts'); $bean->field_defs['testKey'] = array('type' => 'link'); - /** @noinspection PhpUndefinedFieldInspection */ $bean->testKey = 'testValue'; $results = $bean->load_relationship('testKey'); self::assertEquals(false, $results); @@ -2025,7 +2018,6 @@ class SugarBeanTest extends SuitePHPUnitFrameworkTestCase 'link_class' => 'testClass', 'link_file' => 'testClass.php', ); - /** @noinspection PhpUndefinedFieldInspection */ $bean->testKey = 'testValue'; $results = $bean->load_relationship('testKey'); self::assertEquals(false, $results); @@ -2042,11 +2034,9 @@ class SugarBeanTest extends SuitePHPUnitFrameworkTestCase 'link_class' => 'testClass', 'link_file' => 'modules/Campaigns/ProspectLink.php', ); - /** @noinspection PhpUndefinedFieldInspection */ $bean->testKey = 'testValue'; $results = $bean->load_relationship('testKey'); self::assertEquals(true, $results); - /** @noinspection PhpUndefinedFieldInspection */ self::assertEquals('testValue', $bean->testKey); self::assertCount(2, $GLOBALS['log']->calls['fatal']); @@ -2059,11 +2049,9 @@ class SugarBeanTest extends SuitePHPUnitFrameworkTestCase 'link_class' => 'ProspectLink', 'link_file' => 'modules/Campaigns/ProspectLink.php', ); - /** @noinspection PhpUndefinedFieldInspection */ $bean->testKey = 'testValue'; $results = $bean->load_relationship('testKey'); self::assertEquals(true, $results); - /** @noinspection PhpUndefinedFieldInspection */ self::assertEquals('testValue', $bean->testKey); self::assertCount(2, $GLOBALS['log']->calls['fatal']); @@ -2078,7 +2066,6 @@ class SugarBeanTest extends SuitePHPUnitFrameworkTestCase 'link_file' => 'modules/Campaigns/ProspectLink.php', 'relationship' => 'campaign_leads', ); - /** @noinspection PhpUndefinedFieldInspection */ $bean->testKey = 'testValue'; $results = $bean->load_relationship('testKey'); self::assertEquals(false, $results); @@ -2090,7 +2077,7 @@ class SugarBeanTest extends SuitePHPUnitFrameworkTestCase /** * @see SugarBean::get_linked_beans() */ - public function testGetLinkedBeans() + public function testGetLinkedBeans(): void { // test $GLOBALS['log']->reset(); @@ -2122,7 +2109,6 @@ class SugarBeanTest extends SuitePHPUnitFrameworkTestCase $GLOBALS['log']->reset(); $GLOBALS['log']->fatal('test'); $bean = BeanFactory::newBean('Contacts'); - /** @noinspection PhpUndefinedFieldInspection */ $bean->testKey = new ProspectLink('test', $bean); $results = $bean->get_linked_beans('testKey', 'Case', '', 0, 1); self::assertEquals(array(), $results); @@ -2132,7 +2118,7 @@ class SugarBeanTest extends SuitePHPUnitFrameworkTestCase /** * @see SugarBean::get_import_required_fields() */ - public function testGetImportRequiredFields() + public function testGetImportRequiredFields(): void { // test $GLOBALS['log']->reset(); @@ -2147,7 +2133,7 @@ class SugarBeanTest extends SuitePHPUnitFrameworkTestCase /** * @see SugarBean::get_importable_fields() */ - public function testGetImportableFields() + public function testGetImportableFields(): void { // test $GLOBALS['log']->reset(); @@ -2162,7 +2148,7 @@ class SugarBeanTest extends SuitePHPUnitFrameworkTestCase /** * @see SugarBean::create_tables() */ - public function testCreateTables() + public function testCreateTables(): void { // test $bean = BeanFactory::newBean('Contacts'); @@ -2179,7 +2165,7 @@ class SugarBeanTest extends SuitePHPUnitFrameworkTestCase /** * @see SugarBean::getACLCategory() */ - public function testGetACLCategory() + public function testGetACLCategory(): void { // test $bean = BeanFactory::newBean('Contacts'); @@ -2190,7 +2176,7 @@ class SugarBeanTest extends SuitePHPUnitFrameworkTestCase /** * @see SugarBean::is_AuditEnabled() */ - public function testIsAuditEnabled() + public function testIsAuditEnabled(): void { // test $bean = new SugarBeanMock(); @@ -2206,34 +2192,32 @@ class SugarBeanTest extends SuitePHPUnitFrameworkTestCase /** * @see SugarBean::get_audit_table_name() */ - public function testGetAuditTableNames() + public function testGetAuditTableNames(): void { // test - $bean = BeanFactory::newBean('Contacts'); - $results = $bean->get_audit_table_name(); + $results = BeanFactory::newBean('Contacts')->get_audit_table_name(); self::assertEquals('contacts_audit', $results); } /** * @see SugarBean::create_audit_table() */ - public function testCreateAuditTable() + public function testCreateAuditTable(): void { $query = /** @lang sql */ 'DROP TABLE contacts_audit;'; $this->db->query($query); // test - $bean = BeanFactory::newBean('Contacts'); /** @noinspection PhpVoidFunctionResultUsedInspection */ - $results = $bean->create_audit_table(); + $results = BeanFactory::newBean('Contacts')->create_audit_table(); self::assertEquals(null, $results); } /** * @see SugarBean::save() */ - public function testSave() + public function testSave(): void { $userFieldDefs = BeanFactory::getBean('Users')->field_defs; $contactFieldDefs = BeanFactory::getBean('Contacts')->field_defs; @@ -2259,7 +2243,6 @@ class SugarBeanTest extends SuitePHPUnitFrameworkTestCase self::assertEquals($current_user->user_name, $bean->modified_by_name); self::assertEquals(0, $bean->deleted); self::assertEquals($bean->date_modified, $bean->date_entered); - /** @noinspection UnSafeIsSetOverArrayInspection */ self::assertEquals(isset($current_user) ? $current_user->id : '', $bean->created_by); self::assertEquals($bean, $bean->custom_fields->bean); @@ -2285,7 +2268,6 @@ class SugarBeanTest extends SuitePHPUnitFrameworkTestCase self::assertEquals($current_user->user_name, $bean->modified_by_name); self::assertEquals(0, $bean->deleted); self::assertEquals($bean->date_modified, $bean->date_entered); - /** @noinspection UnSafeIsSetOverArrayInspection */ self::assertEquals(isset($current_user) ? $current_user->id : '', $bean->created_by); self::assertFalse($isValidator->isValidId($bean->id)); self::assertEquals($bean, $bean->custom_fields->bean); @@ -2311,7 +2293,6 @@ class SugarBeanTest extends SuitePHPUnitFrameworkTestCase self::assertEquals(0, $bean->deleted); self::assertEquals($bean->date_modified, $bean->date_entered); - /** @noinspection UnSafeIsSetOverArrayInspection */ self::assertEquals(isset($current_user) ? $current_user->id : '', $bean->created_by); self::assertFalse($isValidator->isValidId($bean->id)); self::assertEquals($bean, $bean->custom_fields->bean); @@ -2337,9 +2318,7 @@ class SugarBeanTest extends SuitePHPUnitFrameworkTestCase self::assertEquals($current_user->id, $bean->modified_user_id); self::assertEquals(0, $bean->deleted); - /** @noinspection UnSafeIsSetOverArrayInspection */ self::assertFalse(isset($bean->date_entered)); - /** @noinspection UnSafeIsSetOverArrayInspection */ self::assertEquals(isset($current_user) ? $current_user->id : '', $bean->created_by); $GLOBALS['sugar_config']['strict_id_validation'] = false; @@ -2380,11 +2359,9 @@ class SugarBeanTest extends SuitePHPUnitFrameworkTestCase self::assertEquals($current_user->id, $bean->modified_user_id); - self::assertEquals($current_user->user_name, null); + self::assertEquals(null, $current_user->user_name); self::assertEquals(0, $bean->deleted); - /** @noinspection UnSafeIsSetOverArrayInspection */ self::assertFalse(isset($bean->date_entered)); - /** @noinspection UnSafeIsSetOverArrayInspection */ self::assertEquals(isset($current_user) ? $current_user->id : '', $bean->created_by); self::assertFalse($isValidator->isValidId($bean->id)); self::assertEquals($bean, $bean->custom_fields->bean); @@ -2404,9 +2381,7 @@ class SugarBeanTest extends SuitePHPUnitFrameworkTestCase 'type' => 'email', ), ); - /** @noinspection PhpUndefinedFieldInspection */ $bean->emailAddress = BeanFactory::newBean('EmailAddresses'); - /** @noinspection PhpUndefinedFieldInspection */ $bean->email_addresses_non_primary = array(true); $results = null; try { @@ -2420,11 +2395,9 @@ class SugarBeanTest extends SuitePHPUnitFrameworkTestCase self::assertEquals($current_user->id, $bean->modified_user_id); - self::assertEquals($current_user->user_name, null); + self::assertEquals(null, $current_user->user_name); self::assertEquals(0, $bean->deleted); - /** @noinspection UnSafeIsSetOverArrayInspection */ self::assertFalse(isset($bean->date_entered)); - /** @noinspection UnSafeIsSetOverArrayInspection */ self::assertEquals(isset($current_user) ? $current_user->id : '', $bean->created_by); self::assertFalse($isValidator->isValidId($bean->id)); self::assertEquals($bean, $bean->custom_fields->bean); @@ -2445,9 +2418,7 @@ class SugarBeanTest extends SuitePHPUnitFrameworkTestCase 'type' => 'email', ), ); - /** @noinspection PhpUndefinedFieldInspection */ $bean->emailAddress = BeanFactory::newBean('EmailAddresses'); - /** @noinspection PhpUndefinedFieldInspection */ $bean->email_addresses_non_primary = array(true); $results = null; try { @@ -2461,11 +2432,9 @@ class SugarBeanTest extends SuitePHPUnitFrameworkTestCase self::assertEquals($current_user->id, $bean->modified_user_id); - self::assertEquals($current_user->user_name, null); + self::assertEquals(null, $current_user->user_name); self::assertEquals(0, $bean->deleted); - /** @noinspection UnSafeIsSetOverArrayInspection */ self::assertFalse(isset($bean->date_entered)); - /** @noinspection UnSafeIsSetOverArrayInspection */ self::assertEquals(isset($current_user) ? $current_user->id : '', $bean->created_by); self::assertFalse($isValidator->isValidId($bean->id)); self::assertEquals($bean, $bean->custom_fields->bean); @@ -2487,9 +2456,7 @@ class SugarBeanTest extends SuitePHPUnitFrameworkTestCase 'type' => 'email', ), )); - /** @noinspection PhpUndefinedFieldInspection */ $bean->emailAddress = BeanFactory::newBean('EmailAddresses'); - /** @noinspection PhpUndefinedFieldInspection */ $bean->email_addresses_non_primary = array('testbean1@email.com'); $results = null; try { @@ -2504,9 +2471,7 @@ class SugarBeanTest extends SuitePHPUnitFrameworkTestCase self::assertEquals($current_user->id, $bean->modified_user_id); self::assertEquals($current_user->user_name, $bean->modified_by_name); self::assertEquals(0, $bean->deleted); - /** @noinspection UnSafeIsSetOverArrayInspection */ self::assertFalse(isset($bean->date_entered)); - /** @noinspection UnSafeIsSetOverArrayInspection */ self::assertEquals(isset($current_user) ? $current_user->id : '', $bean->created_by); self::assertFalse($isValidator->isValidId($bean->id)); self::assertEquals($bean, $bean->custom_fields->bean); @@ -2531,7 +2496,7 @@ class SugarBeanTest extends SuitePHPUnitFrameworkTestCase /** * @see SugarBean::cleanBean() */ - public function testCleanBean() + public function testCleanBean(): void { // test $bean = BeanFactory::newBean('Contacts'); @@ -2539,14 +2504,13 @@ class SugarBeanTest extends SuitePHPUnitFrameworkTestCase /** @noinspection PhpUndefinedFieldInspection */ $bean->testField = '

test html value

'; $bean->cleanBean(); - /** @noinspection PhpUndefinedFieldInspection */ self::assertEquals('<p>test <b>html</b> value</p>', $bean->testField); } /** * @see SugarBean::fixUpFormatting() */ - public function testFixUpFormatting() + public function testFixUpFormatting(): void { // test $bean = BeanFactory::newBean('Contacts'); @@ -2562,7 +2526,6 @@ class SugarBeanTest extends SuitePHPUnitFrameworkTestCase /** @noinspection PhpUndefinedFieldInspection */ $bean->testField1 = 'NULL'; $bean->fixUpFormatting(); - /** @noinspection PhpUndefinedFieldInspection */ self::assertEquals('', $bean->testField1); @@ -2571,10 +2534,8 @@ class SugarBeanTest extends SuitePHPUnitFrameworkTestCase $bean->id = 'test_contact_10'; $bean->fetched_row['id'] = 'test_contact_10'; $bean->field_defs['testField1'] = array('type' => 'datetime'); - /** @noinspection PhpUndefinedFieldInspection */ $bean->testField1 = 'invalid-format'; $bean->fixUpFormatting(); - /** @noinspection PhpUndefinedFieldInspection */ self::assertEquals('', $bean->testField1); @@ -2583,10 +2544,8 @@ class SugarBeanTest extends SuitePHPUnitFrameworkTestCase $bean->id = 'test_contact_10'; $bean->fetched_row['id'] = 'test_contact_10'; $bean->field_defs['testField1'] = array('type' => 'date'); - /** @noinspection PhpUndefinedFieldInspection */ $bean->testField1 = 'NULL'; $bean->fixUpFormatting(); - /** @noinspection PhpUndefinedFieldInspection */ self::assertEquals('', $bean->testField1); // test @@ -2594,10 +2553,8 @@ class SugarBeanTest extends SuitePHPUnitFrameworkTestCase $bean->id = 'test_contact_10'; $bean->fetched_row['id'] = 'test_contact_10'; $bean->field_defs['testField1'] = array('type' => 'date'); - /** @noinspection PhpUndefinedFieldInspection */ $bean->testField1 = 'invalid-format'; $bean->fixUpFormatting(); - /** @noinspection PhpUndefinedFieldInspection */ self::assertEquals('', $bean->testField1); @@ -2606,10 +2563,8 @@ class SugarBeanTest extends SuitePHPUnitFrameworkTestCase $bean->id = 'test_contact_10'; $bean->fetched_row['id'] = 'test_contact_10'; $bean->field_defs['testField1'] = array('type' => 'time'); - /** @noinspection PhpUndefinedFieldInspection */ $bean->testField1 = 'NULL'; $bean->fixUpFormatting(); - /** @noinspection PhpUndefinedFieldInspection */ self::assertEquals('', $bean->testField1); @@ -2618,10 +2573,8 @@ class SugarBeanTest extends SuitePHPUnitFrameworkTestCase $bean->id = 'test_contact_10'; $bean->fetched_row['id'] = 'test_contact_10'; $bean->field_defs['testField1'] = array('type' => 'time'); - /** @noinspection PhpUndefinedFieldInspection */ $bean->testField1 = 'invalid-format'; $bean->fixUpFormatting(); - /** @noinspection PhpUndefinedFieldInspection */ self::assertEquals('invalid-format', $bean->testField1); // test @@ -2629,10 +2582,8 @@ class SugarBeanTest extends SuitePHPUnitFrameworkTestCase $bean->id = 'test_contact_10'; $bean->fetched_row['id'] = 'test_contact_10'; $bean->field_defs['testField1'] = array('type' => 'time'); - /** @noinspection PhpUndefinedFieldInspection */ $bean->testField1 = 'am'; $bean->fixUpFormatting(); - /** @noinspection PhpUndefinedFieldInspection */ self::assertEquals('am', $bean->testField1); @@ -2641,10 +2592,8 @@ class SugarBeanTest extends SuitePHPUnitFrameworkTestCase $bean->id = 'test_contact_10'; $bean->fetched_row['id'] = 'test_contact_10'; $bean->field_defs['testField1'] = array('type' => 'float'); - /** @noinspection PhpUndefinedFieldInspection */ $bean->testField1 = 'NULL'; $bean->fixUpFormatting(); - /** @noinspection PhpUndefinedFieldInspection */ self::assertEquals('NULL', $bean->testField1); @@ -2653,10 +2602,8 @@ class SugarBeanTest extends SuitePHPUnitFrameworkTestCase $bean->id = 'test_contact_10'; $bean->fetched_row['id'] = 'test_contact_10'; $bean->field_defs['testField1'] = array('type' => 'int'); - /** @noinspection PhpUndefinedFieldInspection */ $bean->testField1 = 'NULL'; $bean->fixUpFormatting(); - /** @noinspection PhpUndefinedFieldInspection */ self::assertEquals('NULL', $bean->testField1); @@ -2665,10 +2612,8 @@ class SugarBeanTest extends SuitePHPUnitFrameworkTestCase $bean->id = 'test_contact_10'; $bean->fetched_row['id'] = 'test_contact_10'; $bean->field_defs['testField1'] = array('type' => 'int'); - /** @noinspection PhpUndefinedFieldInspection */ $bean->testField1 = 'a string here..'; $bean->fixUpFormatting(); - /** @noinspection PhpUndefinedFieldInspection */ self::assertEquals(0, $bean->testField1); @@ -2677,12 +2622,9 @@ class SugarBeanTest extends SuitePHPUnitFrameworkTestCase $bean->id = 'test_contact_10'; $bean->fetched_row['id'] = 'test_contact_10'; $bean->field_defs['testField1'] = array('type' => 'bool'); - /** @noinspection PhpUndefinedFieldInspection */ $bean->testField1 = true; $bean->fixUpFormatting(); - /** @noinspection PhpUndefinedFieldInspection */ self::assertTrue($bean->testField1); - /** @noinspection PhpUndefinedFieldInspection */ self::assertNotNull($bean->testField1); // test @@ -2690,12 +2632,9 @@ class SugarBeanTest extends SuitePHPUnitFrameworkTestCase $bean->id = 'test_contact_10'; $bean->fetched_row['id'] = 'test_contact_10'; $bean->field_defs['testField1'] = array('type' => 'bool'); - /** @noinspection PhpUndefinedFieldInspection */ $bean->testField1 = 1; $bean->fixUpFormatting(); - /** @noinspection PhpUndefinedFieldInspection */ self::assertTrue($bean->testField1); - /** @noinspection PhpUndefinedFieldInspection */ self::assertNotNull($bean->testField1); @@ -2704,12 +2643,9 @@ class SugarBeanTest extends SuitePHPUnitFrameworkTestCase $bean->id = 'test_contact_10'; $bean->fetched_row['id'] = 'test_contact_10'; $bean->field_defs['testField1'] = array('type' => 'bool'); - /** @noinspection PhpUndefinedFieldInspection */ $bean->testField1 = 'true'; $bean->fixUpFormatting(); - /** @noinspection PhpUndefinedFieldInspection */ self::assertTrue($bean->testField1); - /** @noinspection PhpUndefinedFieldInspection */ self::assertNotNull($bean->testField1); // test @@ -2717,12 +2653,9 @@ class SugarBeanTest extends SuitePHPUnitFrameworkTestCase $bean->id = 'test_contact_10'; $bean->fetched_row['id'] = 'test_contact_10'; $bean->field_defs['testField1'] = array('type' => 'bool'); - /** @noinspection PhpUndefinedFieldInspection */ $bean->testField1 = 'TRUE'; $bean->fixUpFormatting(); - /** @noinspection PhpUndefinedFieldInspection */ self::assertTrue($bean->testField1); - /** @noinspection PhpUndefinedFieldInspection */ self::assertNotNull($bean->testField1); @@ -2731,12 +2664,9 @@ class SugarBeanTest extends SuitePHPUnitFrameworkTestCase $bean->id = 'test_contact_10'; $bean->fetched_row['id'] = 'test_contact_10'; $bean->field_defs['testField1'] = array('type' => 'bool'); - /** @noinspection PhpUndefinedFieldInspection */ $bean->testField1 = 'on'; $bean->fixUpFormatting(); - /** @noinspection PhpUndefinedFieldInspection */ self::assertTrue($bean->testField1); - /** @noinspection PhpUndefinedFieldInspection */ self::assertNotNull($bean->testField1); @@ -2745,12 +2675,9 @@ class SugarBeanTest extends SuitePHPUnitFrameworkTestCase $bean->id = 'test_contact_10'; $bean->fetched_row['id'] = 'test_contact_10'; $bean->field_defs['testField1'] = array('type' => 'bool'); - /** @noinspection PhpUndefinedFieldInspection */ $bean->testField1 = false; $bean->fixUpFormatting(); - /** @noinspection PhpUndefinedFieldInspection */ self::assertFalse($bean->testField1); - /** @noinspection PhpUndefinedFieldInspection */ self::assertNotNull($bean->testField1); @@ -2759,12 +2686,9 @@ class SugarBeanTest extends SuitePHPUnitFrameworkTestCase $bean->id = 'test_contact_10'; $bean->fetched_row['id'] = 'test_contact_10'; $bean->field_defs['testField1'] = array('type' => 'bool'); - /** @noinspection PhpUndefinedFieldInspection */ $bean->testField1 = ''; $bean->fixUpFormatting(); - /** @noinspection PhpUndefinedFieldInspection */ self::assertFalse($bean->testField1); - /** @noinspection PhpUndefinedFieldInspection */ self::assertNotNull($bean->testField1); // test @@ -2772,12 +2696,9 @@ class SugarBeanTest extends SuitePHPUnitFrameworkTestCase $bean->id = 'test_contact_10'; $bean->fetched_row['id'] = 'test_contact_10'; $bean->field_defs['testField1'] = array('type' => 'bool'); - /** @noinspection PhpUndefinedFieldInspection */ $bean->testField1 = 0; $bean->fixUpFormatting(); - /** @noinspection PhpUndefinedFieldInspection */ self::assertFalse($bean->testField1); - /** @noinspection PhpUndefinedFieldInspection */ self::assertNotNull($bean->testField1); @@ -2786,12 +2707,9 @@ class SugarBeanTest extends SuitePHPUnitFrameworkTestCase $bean->id = 'test_contact_10'; $bean->fetched_row['id'] = 'test_contact_10'; $bean->field_defs['testField1'] = array('type' => 'bool'); - /** @noinspection PhpUndefinedFieldInspection */ $bean->testField1 = '0'; $bean->fixUpFormatting(); - /** @noinspection PhpUndefinedFieldInspection */ self::assertFalse($bean->testField1); - /** @noinspection PhpUndefinedFieldInspection */ self::assertNotNull($bean->testField1); @@ -2800,14 +2718,10 @@ class SugarBeanTest extends SuitePHPUnitFrameworkTestCase $bean->id = 'test_contact_10'; $bean->fetched_row['id'] = 'test_contact_10'; $bean->field_defs['testField1'] = array('type' => 'bool'); - /** @noinspection PhpUndefinedFieldInspection */ $bean->testField1 = null; $bean->fixUpFormatting(); - /** @noinspection PhpUndefinedFieldInspection */ self::assertNotTrue($bean->testField1); - /** @noinspection PhpUndefinedFieldInspection */ self::assertNotFalse($bean->testField1); - /** @noinspection PhpUndefinedFieldInspection */ self::assertNull($bean->testField1); @@ -2816,10 +2730,8 @@ class SugarBeanTest extends SuitePHPUnitFrameworkTestCase $bean->id = 'test_contact_10'; $bean->fetched_row['id'] = 'test_contact_10'; $bean->field_defs['testField1'] = array('type' => 'bool'); - /** @noinspection PhpUndefinedFieldInspection */ $bean->testField1 = 'NULL'; $bean->fixUpFormatting(); - /** @noinspection PhpUndefinedFieldInspection */ self::assertTrue($bean->testField1); @@ -2828,14 +2740,10 @@ class SugarBeanTest extends SuitePHPUnitFrameworkTestCase $bean->id = 'test_contact_10'; $bean->fetched_row['id'] = 'test_contact_10'; $bean->field_defs['testField1'] = array('type' => 'encrypt'); - /** @noinspection PhpUndefinedFieldInspection */ $bean->testField1 = ''; $bean->fixUpFormatting(); - /** @noinspection PhpUndefinedFieldInspection */ self::assertNotTrue($bean->testField1); - /** @noinspection PhpUndefinedFieldInspection */ self::assertNotFalse($bean->testField1); - /** @noinspection PhpUndefinedFieldInspection */ self::assertEquals('', $bean->testField1); // test @@ -2843,21 +2751,17 @@ class SugarBeanTest extends SuitePHPUnitFrameworkTestCase $bean->id = 'test_contact_10'; $bean->fetched_row['id'] = 'test_contact_10'; $bean->field_defs['testField1'] = array('type' => 'encrypt'); - /** @noinspection PhpUndefinedFieldInspection */ $bean->testField1 = 'a test string value'; $bean->fixUpFormatting(); - /** @noinspection PhpUndefinedFieldInspection */ self::assertNotTrue($bean->testField1); - /** @noinspection PhpUndefinedFieldInspection */ self::assertNotFalse($bean->testField1); - /** @noinspection PhpUndefinedFieldInspection */ self::assertNotEquals('', $bean->testField1); } /** * @see SugarBean::encrpyt_before_save() */ - public function testEncrpytBeforeSave() + public function testEncrpytBeforeSave(): void { $bean = BeanFactory::newBean('Contacts'); @@ -2870,17 +2774,16 @@ class SugarBeanTest extends SuitePHPUnitFrameworkTestCase /** * @see SugarBean::getEncryptKey() */ - public function testGetEncryptKey() + public function testGetEncryptKey(): void { - $bean = new SugarBeanMock(); - $results = $bean->getEncryptKeyPublic(); + $results = (new SugarBeanMock())->getEncryptKeyPublic(); self::assertEquals(blowfishGetKey('encrypt_field'), $results); } /** * @see SugarBean::has_been_modified_since() */ - public function testHasBeenModifiedSince() + public function testHasBeenModifiedSince(): void { // test $bean = BeanFactory::newBean('Contacts'); diff --git a/tests/unit/phpunit/include/MVC/Controller/ControllerFactoryTest.php b/tests/unit/phpunit/include/MVC/Controller/ControllerFactoryTest.php deleted file mode 100644 index ac23dba0f..000000000 --- a/tests/unit/phpunit/include/MVC/Controller/ControllerFactoryTest.php +++ /dev/null @@ -1,18 +0,0 @@ -assertInstanceOf('SugarController', $controller); - - //execute the method with valid input and check if it returns correct instance - $controller = ControllerFactory::getController('Users'); - $this->assertInstanceOf('UsersController', $controller); - $this->assertInstanceOf('SugarController', $controller); - } -} diff --git a/tests/unit/phpunit/include/MVC/SugarModuleTest.php b/tests/unit/phpunit/include/MVC/SugarModuleTest.php deleted file mode 100644 index 8f1698ef9..000000000 --- a/tests/unit/phpunit/include/MVC/SugarModuleTest.php +++ /dev/null @@ -1,61 +0,0 @@ -assertAttributeEquals(null, '_moduleName', $sugarmodule); - - //test for valid input - $sugarmodule_user = SugarModule::get('User'); - $this->assertAttributeEquals('User', '_moduleName', $sugarmodule_user); - } - - public function testget() - { - //test for invalid input - $sugarmodule = SugarModule::get(''); - $this->assertInstanceOf('SugarModule', $sugarmodule); - $this->assertAttributeEquals(null, '_moduleName', $sugarmodule); - - //test for valid input - $sugarmodule_user = SugarModule::get('User'); - $this->assertInstanceOf('SugarModule', $sugarmodule_user); - $this->assertAttributeEquals('User', '_moduleName', $sugarmodule_user); - } - - public function testmoduleImplements() - { - //test for invalid input - $sugarmodule = new SugarModule(''); - $result = $sugarmodule->moduleImplements('Basic'); - $this->assertEquals(false, $result); - - //test for invalid input - $sugarmodule_user = new SugarModule('Users'); - $result = $sugarmodule_user->moduleImplements('SugarModule'); - $this->assertFalse($result); - - //test for valid input - $sugarmodule_user = new SugarModule('Users'); - $result = $sugarmodule_user->moduleImplements('Basic'); - $this->assertEquals(true, $result); - } - - public function testloadBean() - { - //test for invalid input - $sugarmodule = new SugarModule(''); - $result = $sugarmodule->loadBean(); - $this->assertFalse($result); - - //test for valid input - $sugarmodule_user = new SugarModule('Users'); - $result = $sugarmodule_user->loadBean(); - $this->assertInstanceOf('User', $result); - } -} diff --git a/tests/unit/phpunit/include/MVC/View/SugarViewTest.php b/tests/unit/phpunit/include/MVC/View/SugarViewTest.php deleted file mode 100644 index 963d91e59..000000000 --- a/tests/unit/phpunit/include/MVC/View/SugarViewTest.php +++ /dev/null @@ -1,278 +0,0 @@ -init(); - } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); - } - - $this->assertTrue(true); - } - - public function testprocess() - { - // test - $SugarView = new SugarView(); - $SugarView->module = 'Users'; - $GLOBALS['app'] = new SugarApplication(); - - //execute the method and check if it works and doesn't throws an exception - //secondly check if it outputs any content to browser - try { - ob_start(); - - $SugarView->process(); - - $renderedContent = ob_get_contents(); - ob_end_clean(); - - $this->assertGreaterThan(0, strlen($renderedContent)); - } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); - } - } - - public function testdisplayErrors() - { - $SugarView = new SugarView(); - - //execute the method and check if it works and doesn't throws an exception - try { - $errors = $SugarView->displayErrors(); - $this->assertEmpty($errors, print_r($SugarView, true)); - } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); - } - - $this->assertTrue(true); - } - - public function testpreDisplay() - { - $SugarView = new SugarView(); - - //execute the method and check if it works and doesn't throws an exception - try { - $SugarView->preDisplay(); - } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); - } - - $this->assertTrue(true); - } - - public function testdisplay() - { - $SugarView = new SugarView(); - - //execute the method and check if it works and doesn't throws an exception - try { - $SugarView->display(); - } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); - } - - $this->assertTrue(true); - } - - public function testdisplayHeader() - { - $SugarView = new SugarView(); - $SugarView->module = 'Users'; - $GLOBALS['app'] = new SugarApplication(); - - //execute the method and check if it works and doesn't throws an exception - //secondly check if it outputs any content to browser - try { - ob_start(); - - $SugarView->displayHeader(); - - $renderedContent = ob_get_contents(); - ob_end_clean(); - - $this->assertGreaterThan(0, strlen($renderedContent)); - } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); - } - } - - public function testgetModuleMenuHTML() - { - $SugarView = new SugarView(); - - //execute the method and check if it works and doesn't throws an exception - try { - $SugarView->getModuleMenuHTML(); - } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); - } - - $this->assertTrue(true); - } - - public function testincludeClassicFile() - { - $SugarView = new SugarView(); - - //execute the method and check if it works and doesn't throws an exception - //use any valid file path, we just need to avoid failing require_once - try { - $SugarView->includeClassicFile('config.php'); - } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); - } - - $this->assertTrue(true); - } - - public function testgetJavascriptValidation() - { - //check if it returns any text i-e JS code - $js = SugarView::getJavascriptValidation(); - $this->assertGreaterThan(0, strlen($js)); - } - - public function testdisplayFooter() - { - $SugarView = new SugarView(); - - //execute the method and check if it works and doesn't throws an exception - //secondly check if it outputs any content to browser - try { - ob_start(); - - $SugarView->displayFooter(); - - $renderedContent = ob_get_contents(); - ob_end_clean(); - - $this->assertGreaterThan(0, strlen($renderedContent)); - } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); - } - } - - public function testrenderJavascript() - { - $SugarView = new SugarView(); - - //execute the method and check if it works and doesn't throws an exception - //secondly check if it outputs any content to browser - try { - ob_start(); - - $SugarView->renderJavascript(); - - $renderedContent = ob_get_contents(); - ob_end_clean(); - - $this->assertGreaterThan(0, strlen($renderedContent)); - } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); - } - } - - public function testgetMenu() - { - ////error_reporting(E_ALL); - - $SugarView = new SugarView(); - - //execute the method and check if it works and throws an exception if no module is provided - //it creates memory Fatal errors which causes PHPunit to crash so we will skip this scenario - /* - try { - //check first with invalid value and test if it throws an exception - $menu = $SugarView->getMenu(); - //$this->assertTrue(is_array($menu)); - - } catch (Exception $e) { - $this->assertTrue(TRUE); - //$this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); - } */ - - //check with valid value and check if it returns an array. - $menu = $SugarView->getMenu('Users'); - $this->assertTrue(is_array($menu)); - } - - public function testgetModuleTitle() - { - $SugarView = new SugarView(); - - //first execute the method with default value - $moduleTitle = $SugarView->getModuleTitle(); - $this->assertGreaterThan(0, strlen($moduleTitle)); - - //second execute the method with true value - $moduleTitle = $SugarView->getModuleTitle(true); - $this->assertGreaterThan(0, strlen($moduleTitle)); - - //third execute the method with false value - $moduleTitle = $SugarView->getModuleTitle(false); - $this->assertGreaterThan(0, strlen($moduleTitle)); - } - - public function testgetMetaDataFile() - { - $SugarView = new SugarView(); - - //first execute the method with missing attributes. it should return Null. - $metaDataFile = $SugarView->getMetaDataFile(); - $this->assertEquals(null, $metaDataFile); - - //second execute the method with valid attributes set. it should return a file path string. - $SugarView->type = 'detail'; - $SugarView->module = 'Users'; - - $metaDataFile = $SugarView->getMetaDataFile(); - $this->assertGreaterThan(0, strlen($metaDataFile)); - } - - public function testgetBrowserTitle() - { - $SugarView = new SugarView(); - - //execute the method. it should return a title string. - $browserTitle = $SugarView->getBrowserTitle(); - $this->assertGreaterThan(0, strlen($browserTitle)); - } - - public function testgetBreadCrumbSymbol() - { - $SugarView = new SugarView(); - - //execute the method. it should return a string. - $breadCrumbSymbol = $SugarView->getBreadCrumbSymbol(); - $this->assertGreaterThan(0, strlen($breadCrumbSymbol)); - } - - public function testcheckPostMaxSizeError() - { - $SugarView = new SugarView(); - - //execute the method. it should return False because Request parameters are not available. - $postMaxSizeError = $SugarView->checkPostMaxSizeError(); - $this->assertFalse($postMaxSizeError); - } -} diff --git a/tests/unit/phpunit/include/MVC/View/ViewFactoryTest.php b/tests/unit/phpunit/include/MVC/View/ViewFactoryTest.php deleted file mode 100644 index a83a3168a..000000000 --- a/tests/unit/phpunit/include/MVC/View/ViewFactoryTest.php +++ /dev/null @@ -1,71 +0,0 @@ -assertInstanceOf('SugarView', $view); - - //check with a valid module without a specific view, must return sugarview instance - $view = ViewFactory::loadView('default', 'Users'); - $this->assertInstanceOf('SugarView', $view); - - //check with a valid module and specific view, must reutern speciifc view instance - $view = ViewFactory::loadView('list', 'Users'); - $this->assertInstanceOf('UsersViewList', $view); - } - - public function test_loadConfig() - { - //check with a invalid module, method must not change the view options. - $view = ViewFactory::loadView('default', ''); - $options = $view->options; - ViewFactory::_loadConfig($view, 'default'); - $this->assertSame($options, $view->options); - - //check with a valid module which does not implement it's own view config. method must not change the view options. - $view = ViewFactory::loadView('detail', 'Users'); - $options = $view->options; - ViewFactory::_loadConfig($view, 'detail'); - $this->assertSame($options, $view->options); - - //check with a valid module which implement it's own view config. method still must not change the view options because it needs. - $view = ViewFactory::loadView('area_detail_map', 'jjwg_Areas'); - $view->module = 'jjwg_Areas'; - $options = $view->options; - ViewFactory::_loadConfig($view, 'area_detail_map'); - $this->assertSame($options, $view->options); - } - - public function test_buildFromFile() - { - //check with valid values and test if it returns correct view instance - $type = 'list'; - $target_module = 'Users'; - $bean = null; - $view = ViewFactory::_buildFromFile('modules/'.$target_module.'/views/view.'.$type.'.php', $bean, array(), $type, $target_module); - $this->assertInstanceOf('UsersViewList', $view); - - //check with valid values and test if it returns correct view instance - $type = 'detail'; - $target_module = 'Users'; - $bean = null; - $view = ViewFactory::_buildFromFile('modules/'.$target_module.'/views/view.'.$type.'.php', $bean, array(), $type, $target_module); - $this->assertInstanceOf('UsersViewDetail', $view); - } - - public function test_buildClass() - { - //check with valid values and test if it returns correct view instance - $view = ViewFactory::_buildClass('UsersViewList', null, array()); - $this->assertInstanceOf('UsersViewList', $view); - - //check with valid values and test if it returns correct view instance - $view = ViewFactory::_buildClass('UsersViewDetail', null, array()); - $this->assertInstanceOf('UsersViewDetail', $view); - } -} diff --git a/tests/unit/phpunit/include/MVC/View/views/view.ajaxTest.php b/tests/unit/phpunit/include/MVC/View/views/view.ajaxTest.php deleted file mode 100644 index 41f799f21..000000000 --- a/tests/unit/phpunit/include/MVC/View/views/view.ajaxTest.php +++ /dev/null @@ -1,24 +0,0 @@ -assertInstanceOf('ViewAjax', $view); - $this->assertInstanceOf('SugarView', $view); - $this->assertTrue(is_array($view->options)); - } -} diff --git a/tests/unit/phpunit/include/MVC/View/views/view.ajaxuiTest.php b/tests/unit/phpunit/include/MVC/View/views/view.ajaxuiTest.php deleted file mode 100644 index 71e73cd02..000000000 --- a/tests/unit/phpunit/include/MVC/View/views/view.ajaxuiTest.php +++ /dev/null @@ -1,28 +0,0 @@ -assertInstanceOf('ViewAjaxUI', $view); - $this->assertInstanceOf('SugarView', $view); - $this->assertTrue(is_array($view->options)); - } - - public function testdisplay() - { -// $view = new ViewAjaxUI(); -// -//// //execute the method and test if it works and does not throws an exception other than headers output exception. -//// try { -//// $view->display(); -//// } catch (Exception $e) { -//// $this->assertStringStartsWith('Cannot modify header information', $e->getMessage()); -//// } -// $this->markTestIncomplete('Can Not be implemented'); - } -} diff --git a/tests/unit/phpunit/include/MVC/View/views/view.classicTest.php b/tests/unit/phpunit/include/MVC/View/views/view.classicTest.php deleted file mode 100644 index 463333b93..000000000 --- a/tests/unit/phpunit/include/MVC/View/views/view.classicTest.php +++ /dev/null @@ -1,73 +0,0 @@ -assertInstanceOf('ViewClassic', $view); - $this->assertInstanceOf('SugarView', $view); - $this->assertAttributeEquals('', 'type', $view); - - //test with bean parameter; - $bean = BeanFactory::newBean('Users'); - $view = new ViewClassic($bean); - $this->assertInstanceOf('ViewClassic', $view); - $this->assertInstanceOf('SugarView', $view); - $this->assertAttributeEquals('', 'type', $view); - } - - public function testdisplay() - { - if (isset($_SESSION)) { - $session = $_SESSION; - } - - //test with a valid module but invalid action. it should return false. - $view = new ViewClassic(); - $view->module = 'Home'; - $view->action = ''; - $ret = $view->display(); - $this->assertFalse($ret); - - //test with a valid module and uncustomized action. it should return true - $view = new ViewClassic(); - $view->module = 'Home'; - $view->action = 'About'; - - $this->markTestIncomplete("Warning was: Test code or tested code did not (only) close its own output buffers"); - - //test with a valid module and customized action. it should return true - $view = new ViewClassic(); - $view->module = 'Home'; - $view->action = 'index'; - - ob_start(); - $ret = $view->display(); - $renderedContent = ob_get_contents(); - ob_end_clean(); - $this->assertGreaterThan(0, strlen($renderedContent)); - $this->assertTrue($ret); - - - if (isset($session)) { - $_SESSION = $session; - } else { - unset($_SESSION); - } - } -} diff --git a/tests/unit/phpunit/include/MVC/View/views/view.detailTest.php b/tests/unit/phpunit/include/MVC/View/views/view.detailTest.php deleted file mode 100644 index c044b48a9..000000000 --- a/tests/unit/phpunit/include/MVC/View/views/view.detailTest.php +++ /dev/null @@ -1,66 +0,0 @@ -assertInstanceOf('ViewDetail', $view); - $this->assertInstanceOf('SugarView', $view); - $this->assertAttributeEquals('detail', 'type', $view); - } - - public function testpreDisplay() - { - //execute the method with required attributes preset, it will initialize the dv(detail view) attribute. - $view = new ViewDetail(); - $view->module = 'Users'; - $view->bean = BeanFactory::newBean('Users'); - $view->ss = new Sugar_Smarty(); - $view->preDisplay(); - $this->assertInstanceOf('DetailView2', $view->dv); - $this->asserttrue(is_array($view->dv->defs)); - - //execute the method again for a different module with required attributes preset, it will initialize the dv(detail view) attribute. - $view = new ViewDetail(); - $view->module = 'Meetings'; - $view->bean = BeanFactory::newBean('Meetings'); - $view->ss = new Sugar_Smarty(); - $view->preDisplay(); - $this->assertInstanceOf('DetailView2', $view->dv); - $this->asserttrue(is_array($view->dv->defs)); - } - - public function testdisplay() - { - //execute the method with essential parameters set. it should return some html. - $view = new ViewDetail(); - $view->module = 'Users'; - $view->bean = BeanFactory::newBean('Users'); - $view->bean->id = 1; - $view->ss = new Sugar_Smarty(); - $view->preDisplay(); - - ob_start(); - $view->display(); - $renderedContent = ob_get_contents(); - ob_end_clean(); - $this->assertGreaterThan(0, strlen($renderedContent)); - } -} diff --git a/tests/unit/phpunit/include/MVC/View/views/view.editTest.php b/tests/unit/phpunit/include/MVC/View/views/view.editTest.php deleted file mode 100644 index 19e0d3898..000000000 --- a/tests/unit/phpunit/include/MVC/View/views/view.editTest.php +++ /dev/null @@ -1,72 +0,0 @@ -assertInstanceOf('ViewEdit', $view); - $this->assertInstanceOf('SugarView', $view); - $this->assertAttributeEquals('edit', 'type', $view); - - $this->assertAttributeEquals(false, 'useForSubpanel', $view); - $this->assertAttributeEquals(false, 'useModuleQuickCreateTemplate', $view); - $this->assertAttributeEquals(true, 'showTitle', $view); - } - - public function testpreDisplay() - { - if (isset($_SESSION)) { - $session = $_SESSION; - } - - //execute the method with required attributes preset, it will initialize the ev(edit view) attribute. - $view = new ViewEdit(); - $view->module = 'Users'; - $view->bean = BeanFactory::newBean('Users'); - $view->preDisplay(); - $this->assertInstanceOf('EditView', $view->ev); - - //execute the method again for a different module with required attributes preset, it will initialize the ev(edit view) attribute. - $view = new ViewEdit(); - $view->module = 'Meetings'; - $view->bean = BeanFactory::newBean('Meetings'); - $view->preDisplay(); - $this->assertInstanceOf('EditView', $view->ev); - - - if (isset($session)) { - $_SESSION = $session; - } else { - unset($_SESSION); - } - } - - public function testdisplay() - { - //execute the method with essential parameters set. it should return some html. - $view = new ViewEdit(); - $view->module = 'Users'; - $view->bean = BeanFactory::newBean('Users'); - $view->preDisplay(); - $view->ev->ss = new Sugar_Smarty(); - - ob_start(); - $view->display(); - $renderedContent = ob_get_contents(); - ob_end_clean(); - $this->assertGreaterThan(0, strlen($renderedContent)); - } -} diff --git a/tests/unit/phpunit/include/MVC/View/views/view.favoritesTest.php b/tests/unit/phpunit/include/MVC/View/views/view.favoritesTest.php deleted file mode 100644 index 719739bb3..000000000 --- a/tests/unit/phpunit/include/MVC/View/views/view.favoritesTest.php +++ /dev/null @@ -1,20 +0,0 @@ -markTestIncomplete('Can Not be implemented'); - } - - public function testdisplay() - { -// $this->markTestIncomplete('Can Not be implemented'); - } -} diff --git a/tests/unit/phpunit/include/MVC/View/views/view.htmlTest.php b/tests/unit/phpunit/include/MVC/View/views/view.htmlTest.php deleted file mode 100644 index 18bedf67e..000000000 --- a/tests/unit/phpunit/include/MVC/View/views/view.htmlTest.php +++ /dev/null @@ -1,35 +0,0 @@ -assertInstanceOf('ViewHtml', $view); - $this->assertInstanceOf('SugarView', $view); - } - - public function testdisplay() - { - $view = new ViewHtml(); - - // Execute the method and test that it works and doesn't throw an exception. - try { - $view->display(); - } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); - } - } -} diff --git a/tests/unit/phpunit/include/MVC/View/views/view.importvcardTest.php b/tests/unit/phpunit/include/MVC/View/views/view.importvcardTest.php deleted file mode 100644 index 20f5e1741..000000000 --- a/tests/unit/phpunit/include/MVC/View/views/view.importvcardTest.php +++ /dev/null @@ -1,42 +0,0 @@ -assertInstanceOf('ViewImportvcard', $view); - $this->assertInstanceOf('SugarView', $view); - $this->assertAttributeEquals('edit', 'type', $view); - } - - public function testdisplay() - { - if (isset($_REQUEST)) { - $request = $_REQUEST; - } - - //execute the method with essential parameters set. it should return some html. - $view = new ViewImportvcard(); - $_REQUEST['module'] = 'Users'; - $GLOBALS['mod_strings'] = return_module_language($GLOBALS['current_language'], 'Contacts'); - $view->ss = new Sugar_Smarty(); - - ob_start(); - $view->display(); - $renderedContent = ob_get_contents(); - ob_end_clean(); - $this->assertGreaterThan(0, strlen($renderedContent)); - - // cleanup - - if (isset($request)) { - $_REQUEST = $request; - } else { - unset($_REQUEST); - } - } -} diff --git a/tests/unit/phpunit/include/MVC/View/views/view.importvcardsaveTest.php b/tests/unit/phpunit/include/MVC/View/views/view.importvcardsaveTest.php deleted file mode 100644 index 5212bcd0f..000000000 --- a/tests/unit/phpunit/include/MVC/View/views/view.importvcardsaveTest.php +++ /dev/null @@ -1,33 +0,0 @@ -assertInstanceOf('ViewImportvcardsave', $view); - $this->assertInstanceOf('SugarView', $view); - $this->assertAttributeEquals('save', 'type', $view); - } - - //incomplete test. this method uses exit() so it cannot be tested. - public function testdisplay() - { - $this->markTestIncomplete('Cannot be implemented due to use of exit().'); - - $view = new ViewImportvcardsave(); - - //execute without any parameters set. it should return some html/JS - //this method uses exit() which causes PHP unit to quit a well. so this method cannot be tested. - /* - ob_start(); - $view->display(); - $renderedContent = ob_get_contents(); - ob_end_clean(); - $this->assertGreaterThan(0,strlen($renderedContent)); - */ - } -} diff --git a/tests/unit/phpunit/include/MVC/View/views/view.jsonTest.php b/tests/unit/phpunit/include/MVC/View/views/view.jsonTest.php deleted file mode 100644 index c6fef861f..000000000 --- a/tests/unit/phpunit/include/MVC/View/views/view.jsonTest.php +++ /dev/null @@ -1,38 +0,0 @@ -assertInstanceOf('ViewJson', $view); - $this->assertInstanceOf('SugarView', $view); - $this->assertAttributeEquals('detail', 'type', $view); - } - - //incomplete test. this method uses exit() so it cannot be tested. - public function testdisplay() - { - /* - setup required paramerers and execute the method. - it uses die/exit which stops the execution of PHP unit as well so this method cannot be tested. - */ - - /* - $view = new ViewJson(); - $GLOBALS['module'] = "Users" ; - $view->bean = BeanFactory::newBean('Users'); - - ob_start(); - $view->display(); - $renderedContent = ob_get_contents(); - ob_end_clean(); - $this->assertGreaterThan(0,strlen($renderedContent)); - $this->assertNotEquals(False,json_decode($renderedContent)); - */ - $this->markTestIncomplete('Can Not be implemented'); - } -} diff --git a/tests/unit/phpunit/include/MVC/View/views/view.modulelistmenuTest.php b/tests/unit/phpunit/include/MVC/View/views/view.modulelistmenuTest.php deleted file mode 100644 index 409ada639..000000000 --- a/tests/unit/phpunit/include/MVC/View/views/view.modulelistmenuTest.php +++ /dev/null @@ -1,41 +0,0 @@ -assertInstanceOf('ViewModulelistmenu', $view); - $this->assertInstanceOf('SugarView', $view); - $this->assertTrue(is_array($view->options)); - } - - public function testdisplay() - { - if (isset($_SESSION)) { - $session = $_SESSION; - } - - //execute the method with required child objects preset. it should return some html. - $view = new ViewModulelistmenu(); - $view->ss = new Sugar_Smarty(); - - ob_start(); - $view->display(); - $renderedContent = ob_get_contents(); - ob_end_clean(); - - $this->assertGreaterThan(0, strlen($renderedContent)); - $this->assertEquals(false, is_array($renderedContent)); - - if (isset($session)) { - $_SESSION = $session; - } else { - unset($_SESSION); - } - } -} diff --git a/tests/unit/phpunit/include/MVC/View/views/view.multieditTest.php b/tests/unit/phpunit/include/MVC/View/views/view.multieditTest.php deleted file mode 100644 index e1393a773..000000000 --- a/tests/unit/phpunit/include/MVC/View/views/view.multieditTest.php +++ /dev/null @@ -1,51 +0,0 @@ -assertInstanceOf('ViewMultiedit', $view); - $this->assertInstanceOf('SugarView', $view); - $this->assertAttributeEquals('edit', 'type', $view); - } - - public function testdisplay() - { - //test without action value and modules list in REQUEST object - $view = new ViewMultiedit(); - ob_start(); - $view->display(); - $renderedContent = ob_get_contents(); - ob_end_clean(); - $this->assertEquals(0, strlen($renderedContent)); - - //test with valid action value to get link in return - $view = new ViewMultiedit(); - $view->action = 'AjaxFormSave'; - $view->module = 'Users'; - $view->bean = BeanFactory::newBean('Users'); - $view->bean->id = 1; - ob_start(); - $view->display(); - $renderedContent = ob_get_contents(); - ob_end_clean(); - $this->assertGreaterThan(0, strlen($renderedContent)); - - //Fails with a fatal error, method creates editview without properly setting it up causing fatal errors. - /* - //test only with modules list in REQUEST object - $view = new ViewMultiedit(); - $GLOBALS['current_language']= 'en_us'; - $_REQUEST['modules']= Array('Calls','Accounts'); - ob_start(); - $view->display(); - $renderedContent = ob_get_contents(); - ob_end_clean(); - $this->assertGreaterThan(0,strlen($renderedContent)); - */ - } -} diff --git a/tests/unit/phpunit/include/MVC/View/views/view.noaccessTest.php b/tests/unit/phpunit/include/MVC/View/views/view.noaccessTest.php deleted file mode 100644 index c06bd6270..000000000 --- a/tests/unit/phpunit/include/MVC/View/views/view.noaccessTest.php +++ /dev/null @@ -1,24 +0,0 @@ -display(); - - $renderedContent = ob_get_contents(); - ob_end_clean(); - - $this->assertAttributeEquals('noaccess', 'type', $view); - $this->assertGreaterThan(0, strlen($renderedContent)); - - $this->assertEquals(false, json_decode($renderedContent)); //check that it doesn't return json. - } -} diff --git a/tests/unit/phpunit/include/MVC/View/views/view.quickTest.php b/tests/unit/phpunit/include/MVC/View/views/view.quickTest.php deleted file mode 100644 index 235a13bc1..000000000 --- a/tests/unit/phpunit/include/MVC/View/views/view.quickTest.php +++ /dev/null @@ -1,49 +0,0 @@ -assertInstanceOf('ViewQuick', $view); - $this->assertInstanceOf('ViewDetail', $view); - $this->assertAttributeEquals('detail', 'type', $view); - $this->assertTrue(is_array($view->options)); - } - - public function testdisplay() - { - if (isset($_SESSION)) { - $session = $_SESSION; - } - - $view = new ViewQuick(); - - //execute the method with required child objects preset. it will return some html. - $view->dv = new DetailView2(); - $view->dv->ss = new Sugar_Smarty(); - $view->dv->module = 'Users'; - $view->bean = BeanFactory::newBean('Users'); - $view->bean->id = 1; - $view->dv->setup('Users', $view->bean); - - if (isset($session)) { - $_SESSION = $session; - } else { - unset($_SESSION); - } - } -} diff --git a/tests/unit/phpunit/include/MVC/View/views/view.quickcreateTest.php b/tests/unit/phpunit/include/MVC/View/views/view.quickcreateTest.php deleted file mode 100644 index 5145251de..000000000 --- a/tests/unit/phpunit/include/MVC/View/views/view.quickcreateTest.php +++ /dev/null @@ -1,86 +0,0 @@ -preDisplay(); - $this->assertEquals(0, count($_REQUEST)); - - //check with values preset but without a valid bean id, it sould not change Request parameters - $_REQUEST['source_module'] = 'Users'; - $_REQUEST['module'] = 'Users'; - $_REQUEST['record'] = ''; - $request = $_REQUEST; - - $view->preDisplay(); - $this->assertSame($request, $_REQUEST); - - //check with values preset, it sould set some addiiotnal Request parameters - $_REQUEST['record'] = 1; - $view->preDisplay(); - $this->assertNotSame($request, $_REQUEST); - - if (isset($_request)) { - $_REQUEST = $_request; - } else { - unset($_REQUEST); - } - } - - public function testdisplay() - { - if (isset($_SESSION)) { - $_session = $_SESSION; - } - - if (isset($_REQUEST)) { - $_request = $_REQUEST; - } - - //execute the method with required child objects and parameters preset. it will return some html. - $view = new ViewQuickcreate(); - - $_REQUEST['module'] = 'Accounts'; - $view->bean = BeanFactory::newBean('Accounts'); - - ob_start(); - - $view->display(); - - $renderedContent = ob_get_contents(); - ob_end_clean(); - - $this->assertGreaterThan(0, strlen($renderedContent)); - $this->assertEquals(false, json_decode($renderedContent)); //check that it doesn't return json. - - if (isset($_session)) { - $_SESSION = $_session; - } else { - unset($_SESSION); - } - - if (isset($_request)) { - $_REQUEST = $_request; - } else { - unset($_REQUEST); - } - } -} diff --git a/tests/unit/phpunit/include/MVC/View/views/view.quickeditTest.php b/tests/unit/phpunit/include/MVC/View/views/view.quickeditTest.php deleted file mode 100644 index a76c9e911..000000000 --- a/tests/unit/phpunit/include/MVC/View/views/view.quickeditTest.php +++ /dev/null @@ -1,43 +0,0 @@ -preDisplay(); - $this->assertEquals(0, count($_REQUEST)); - - //check with values preset but without a valid bean id, it sould not change Request parameters - $_REQUEST['source_module'] = 'Users'; - $_REQUEST['module'] = 'Users'; - $_REQUEST['record'] = ''; - $request = $_REQUEST; - - $view->preDisplay(); - $this->assertSame($request, $_REQUEST); - - //check with values preset, it sould set some addiiotnal Request parameters - $_REQUEST['record'] = 1; - $view->preDisplay(); - $this->assertNotSame($request, $_REQUEST); - - if (isset($_request)) { - $_REQUEST = $_request; - } else { - unset($_REQUEST); - } - } -} diff --git a/tests/unit/phpunit/include/MVC/View/views/view.serializedTest.php b/tests/unit/phpunit/include/MVC/View/views/view.serializedTest.php deleted file mode 100644 index ce229c90e..000000000 --- a/tests/unit/phpunit/include/MVC/View/views/view.serializedTest.php +++ /dev/null @@ -1,34 +0,0 @@ -assertInstanceOf('ViewSerialized', $view); - $this->assertInstanceOf('SugarView', $view); - } - - //Incomplete Test. method uses exit() so it cannot be tested. - public function testdisplay() - { - /* //this method call uses exit() so it cannot be tested as it forces the PHP unit to quite as well - $view = new ViewSerialized(); - $view->bean = BeanFactory::newBean('Users'); - - ob_start(); - - $view->display(); - - $renderedContent = ob_get_contents(); - ob_end_clean(); - - $this->assertGreaterThan(0,strlen($renderedContent)); - */ - - $this->markTestIncomplete('Can Not be implemented'); - } -} diff --git a/tests/unit/phpunit/include/MVC/View/views/view.sugarpdfTest.php b/tests/unit/phpunit/include/MVC/View/views/view.sugarpdfTest.php deleted file mode 100644 index 16ea6bc24..000000000 --- a/tests/unit/phpunit/include/MVC/View/views/view.sugarpdfTest.php +++ /dev/null @@ -1,59 +0,0 @@ -assertEmpty("", $view); - } catch (Exception $e) { - $msg = $e->getMessage(); - $this->assertStringStartsWith('Cannot modify header information', $msg, 'Cannot modify header information? : ' . $msg . "\nTrace\n" . $e->getTraceAsString()); - } - - //execute the method with request parameters and test if it works. - $_REQUEST['sugarpdf'] = 'someValue'; - $view = new ViewSugarpdf(); - $view->module = 'Users'; - $this->assertInstanceOf('ViewSugarpdf', $view); - $this->assertInstanceOf('SugarView', $view); - $this->assertAttributeEquals('sugarpdf', 'type', $view); - $this->assertAttributeEquals('someValue', 'sugarpdf', $view); - $this->assertAttributeEquals(null, 'sugarpdfBean', $view); - - if (isset($_request)) { - $_REQUEST = $_request; - } else { - unset($_REQUEST); - } - } - - //Incomplete test. SugarpdfFactory::loadSugarpdf throws fatal error. error needs to be resolved before testing. - public function testpreDisplay() - { -// $this->markTestIncomplete('Can Not be implemented'); - } - - //Incomplete test. SugarpdfFactory::loadSugarpdf throws fatal error. error needs to be resolved before testing. - public function testdisplay() - { -// $this->markTestIncomplete('Can Not be implemented'); - } -} diff --git a/tests/unit/phpunit/include/MVC/View/views/view.vcardTest.php b/tests/unit/phpunit/include/MVC/View/views/view.vcardTest.php deleted file mode 100644 index 6d3c27c41..000000000 --- a/tests/unit/phpunit/include/MVC/View/views/view.vcardTest.php +++ /dev/null @@ -1,35 +0,0 @@ -module = 'Contacts'; - $view->bean = BeanFactory::newBean('Contacts'); - $this->expectOutputRegex('/.*BEGIN:VCARD.*/'); - //execute the method and test if it works and does not throws an exception other than headers output exception. - try { - $view->display(); - } catch (Exception $e) { - $msg = $e->getMessage(); - $this->assertStringStartsWith('Cannot modify header information', $msg, $msg . "\nTrace:\n" . $e->getTraceAsString()); - } - - $this->assertInstanceOf('ViewVcard', $view); - $this->assertInstanceOf('SugarView', $view); - $this->assertAttributeEquals('detail', 'type', $view); - } -} diff --git a/tests/unit/phpunit/include/MVC/View/views/view.xmlTest.php b/tests/unit/phpunit/include/MVC/View/views/view.xmlTest.php deleted file mode 100644 index 7d192e7e1..000000000 --- a/tests/unit/phpunit/include/MVC/View/views/view.xmlTest.php +++ /dev/null @@ -1,34 +0,0 @@ -assertInstanceOf('ViewXML', $view); - $this->assertInstanceOf('SugarView', $view); - $this->assertAttributeEquals('detail', 'type', $view); - } - - public function testdisplay() - { - //execute the method and check for rexcetions. it should return some html. - $view = new ViewXML(); - - try { - ob_start(); - - $view->display(); - - $renderedContent = ob_get_contents(); - ob_end_clean(); - - $this->assertGreaterThan(0, strlen($renderedContent)); - } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); - } - } -} diff --git a/tests/unit/phpunit/include/SugarDateTimeTest.php b/tests/unit/phpunit/include/SugarDateTimeTest.php deleted file mode 100644 index ff5d799dc..000000000 --- a/tests/unit/phpunit/include/SugarDateTimeTest.php +++ /dev/null @@ -1,77 +0,0 @@ -get_day_begin(); - $expected = new SugarDateTime('2019-01-01 00:00:00'); - $this->assertEquals($expected, $actual); - } - - public function testget_day_end() - { - // Test that the get_day_begin function creates a SugarDateTime - // object where the time is 23:59:59. - $day = new SugarDateTime('2019-01-01'); - $actual = $day->get_day_end(); - $expected = new SugarDateTime('2019-01-01 23:59:59'); - $this->assertEquals($expected, $actual); - } - - public function testasDb() - { - // Test that the asDb function returns a string formatted for use in - // the database. - $day = new SugarDateTime('2019-1-1'); - $actual = $day->asDb(); - $expected = '2019-01-01 00:00:00'; - $this->assertEquals($expected, $actual); - } - - public function testasDbDate() - { - // Test that the asDbDate function returns a string formatted for use - // in the database. - $day = new SugarDateTime('2019-1-1'); - $actual = $day->asDbDate(); - $expected = '2019-01-01'; - $this->assertEquals($expected, $actual); - } - - public function testget_date_str() - { - // Test that the get_date_str function returns a string for use in - // URL parameters. - $day = new SugarDateTime('2019-1-1'); - $actual = $day->get_date_str(); - $expected = '&year=2019&month=1&day=1&hour=0'; - $this->assertEquals($expected, $actual); - } - - public function testget_day_by_index_this_month() - { - // Test that the get_day_by_index_this_month function returns a - // SugarDateTime representing the correct day of the month. - $day = new SugarDateTime('2019-1-1'); - $actual = $day->get_day_by_index_this_month(28); - $expected = new SugarDateTime('2019-01-29'); - $this->assertEquals($expected, $actual); - } - - public function testget_day_by_index_this_monthWithExcessiveValue() - { - // Test that the get_day_by_index_this_month function returns a - // SugarDateTime representing the correct day of the month, even when - // the index provided is greater than the number of days in the month. - $day = new SugarDateTime('2019-1-1'); - $actual = $day->get_day_by_index_this_month(32); - $expected = new SugarDateTime('2019-02-02'); - $this->assertEquals($expected, $actual); - } -} diff --git a/tests/unit/phpunit/include/SugarTheme/SugarThemeTest.php b/tests/unit/phpunit/include/SugarTheme/SugarThemeTest.php deleted file mode 100644 index 03bc20b0b..000000000 --- a/tests/unit/phpunit/include/SugarTheme/SugarThemeTest.php +++ /dev/null @@ -1,15 +0,0 @@ -assertEquals($theme->getMimeType('svg'), 'image/svg+xml'); - $this->assertEquals($theme->getMimeType('gif'), 'image/gif'); - $this->assertEquals($theme->getMimeType('png'), 'image/png'); - $this->assertEquals($theme->getMimeType('notanextension'), null); - } -} diff --git a/tests/unit/phpunit/include/utils/activityUtilsTest.php b/tests/unit/phpunit/include/utils/activityUtilsTest.php deleted file mode 100644 index 399dc955a..000000000 --- a/tests/unit/phpunit/include/utils/activityUtilsTest.php +++ /dev/null @@ -1,33 +0,0 @@ -rel_users_table = 'users_signatures'; - $list = build_related_list_by_user_id($bean, '1', ''); - $this->assertTrue(is_array($list)); - - //with rel_users_table set by default - $bean = BeanFactory::newBean('Meetings'); - $list = build_related_list_by_user_id($bean, '1', ''); - $this->assertTrue(is_array($list)); - } -} diff --git a/tests/unit/phpunit/include/utils/autoloaderTest.php b/tests/unit/phpunit/include/utils/autoloaderTest.php deleted file mode 100644 index e98ab0957..000000000 --- a/tests/unit/phpunit/include/utils/autoloaderTest.php +++ /dev/null @@ -1,35 +0,0 @@ -assertFalse($result); - - // Test with a valid class out of autoload mappings. - $result = SugarAutoLoader::autoload('SugarArray'); - $this->assertFalse($result); - - // Test with a valid class registered in autoload mappings. - $result = SugarAutoLoader::autoload('User'); - $this->assertTrue($result); - } - - public function testloadAll() - { - // Execute the method and check that it works and doesn't throw an exception. - // This method only includes file so there is no output to test. - try { - SugarAutoLoader::loadAll(); - $this->assertTrue(true); - } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); - } - } -} diff --git a/tests/unit/phpunit/include/utils/dbUtilsTest.php b/tests/unit/phpunit/include/utils/dbUtilsTest.php deleted file mode 100644 index 054ddd37f..000000000 --- a/tests/unit/phpunit/include/utils/dbUtilsTest.php +++ /dev/null @@ -1,115 +0,0 @@ -assertSame($expected, $actual); - } - - public function testdb_concat() - { - //execute the method and test if it returns expected values - - $table = 'Table1'; - $fields = array('Col1', 'Col2', 'Col3'); - $expected = "LTRIM(RTRIM(CONCAT(IFNULL(Table1.Col1,''),' ',IFNULL(Table1.Col2,''),' ',IFNULL(Table1.Col3,''))))"; - $actual = db_concat($table, $fields); - $this->assertSame($expected, $actual); - } - - public function testfrom_db_convert() - { - //execute the method and test if it returns expected values - - $this->assertSame('2015-11-16 19:32:29', from_db_convert('2015-11-16 19:32:29', 'date')); - $this->assertSame('19:32:29', from_db_convert('19:32:29', 'time')); - $this->assertSame('2015-11-16 19:32:29', from_db_convert('2015-11-16 19:32:29', 'datetime')); - $this->assertSame('2015-11-16 19:32:29', from_db_convert('2015-11-16 19:32:29', 'datetimecombo')); - $this->assertSame('2015-11-16 19:32:29', from_db_convert('2015-11-16 19:32:29', 'timestamp')); - } - - public function testto_html() - { -// $this->markTestIncomplete('PHPUnit and codeception results are in conflict'); -// //execute the method and test if it returns expected values -// -// $string = ''; -// $expected = ''; -// $actual = to_html($string); -// $this->assertSame($expected, $actual); -// -// $string = "'test'&trial<\">"; -// $expected = ''test'&trial<">'; -// $actual = to_html($string, true); -// $this->assertSame($expected, $actual); - } - - public function testfrom_html() - { - $string = ''; - $expected = ''; - $actual = from_html($string); - $this->assertSame($expected, $actual); - - $string = ''test'&trial<">'; - $expected = "'test'&trial<\">"; - $actual = from_html($string); - $this->assertSame($expected, $actual); - } - - public function testgetValidDBName() - { - $expected = ''; - $actual = getValidDBName(''); - $this->assertSame($expected, $actual); - - $expected = 'col'; - $actual = getValidDBName('Col'); - $this->assertSame($expected, $actual); - } - - public function testisValidDBName() - { - //valid value - $expected = true; - $actual = isValidDBName('suitecrmtest', 'mysql'); - $this->assertSame($expected, $actual); - - //invalid value - $expected = false; - $actual = isValidDBName('suite/crm.test', 'mysql'); - $this->assertSame($expected, $actual); - } -} diff --git a/tests/unit/phpunit/include/utils/encryptionUtilsTest.php b/tests/unit/phpunit/include/utils/encryptionUtilsTest.php deleted file mode 100644 index 08c47f435..000000000 --- a/tests/unit/phpunit/include/utils/encryptionUtilsTest.php +++ /dev/null @@ -1,94 +0,0 @@ -assertSame($expected, $actual); - - //blank key and valid data - $expected = 'RGF0YQ=='; - $actual = sugarEncode('', 'Data'); - $this->assertSame($expected, $actual); - - //valid key and data - $expected = 'RGF0YQ=='; - $actual = sugarEncode('key', 'Data'); - $this->assertSame($expected, $actual); - } - - public function testsugarDecode() - { - //execute the method and test if it returns expected values - //key param does nothing currently. - - //blank key and data - $expected = ''; - $actual = sugarDecode('', ''); - $this->assertSame($expected, $actual); - - //blank key and valid data - $expected = 'Data'; - $actual = sugarDecode('', 'RGF0YQ=='); - $this->assertSame($expected, $actual); - - //valid key and data - $expected = 'Data'; - $actual = sugarDecode('key', 'RGF0YQ=='); - $this->assertSame($expected, $actual); - } - - public function testblowfishGetKey() - { - //execute the method and test if it returns expected length string - - //test key - $actual = blowfishGetKey('test'); - $this->assertGreaterThanOrEqual(36, strlen($actual)); - - //default key - $actual = blowfishGetKey('rapelcg_svryq'); - $this->assertGreaterThanOrEqual(36, strlen($actual)); - } - - public function testblowfishEncode() - { - //execute the method and test if it returns expected values - //it won't work with blank key, will throw an error - - //valid key and blank data - $expected = ''; - $actual = blowfishEncode('test', ''); - $this->assertSame($expected, $actual); - - //valid key and valid data - $expected = 'HI1/88NJJss='; - $actual = blowfishEncode('test', 'Data'); - $this->assertSame($expected, $actual); - } - - public function testblowfishDecode() - { - //execute the method and test if it returns expected values - //it won't work with blank key, will throw an error. - - //valid key and blank data - $expected = ''; - $actual = blowfishDecode('test', ''); - $this->assertSame($expected, $actual); - - //valid key and valid data - $expected = 'Data'; - $actual = blowfishDecode('test', 'HI1/88NJJss='); - $this->assertSame($expected, $actual); - } -} diff --git a/tests/unit/phpunit/include/utils/fileUtilsTest.php b/tests/unit/phpunit/include/utils/fileUtilsTest.php deleted file mode 100644 index e29ecd0fe..000000000 --- a/tests/unit/phpunit/include/utils/fileUtilsTest.php +++ /dev/null @@ -1,528 +0,0 @@ -rootFs = org\bovigo\vfs\vfsStream::setup('root'); - $this->rootFs->addChild(org\bovigo\vfs\vfsStream::newDirectory('testDir')); - $this->rootFs->addChild(org\bovigo\vfs\vfsStream::newFile('test.txt')->withContent('Hello world!')); - } - - public function testclean_path() - { - //execute the method and test if it returns expected values - - //invalid path - $expected = ''; - $path = ''; - $actual = clean_path($path); - $this->assertSame($expected, $actual); - - //a simple valid path - $expected = '/SuiteCRM-develop/include/utils'; - $path = '\SuiteCRM-develop\include\utils'; - $actual = clean_path($path); - $this->assertSame($expected, $actual); - - //valid network path - $expected = '//SuiteCRM-develop/include/utils'; - $path = '\\\\/SuiteCRM-develop/include/utils'; - $actual = clean_path($path); - $this->assertSame($expected, $actual); - - $expected = '/SuiteCRM-develop/include/utils'; - $path = '/SuiteCRM-develop/./include/utils'; - $actual = clean_path($path); - $this->assertSame($expected, $actual); - - $expected = '/SuiteCRM-develop/include/utils'; - $path = '/SuiteCRM-develop//include/utils'; - $actual = clean_path($path); - $this->assertSame($expected, $actual); - } - - public function testcreate_cache_directory() - { - //execute the method and test if it created file/dir exists - - $cache_dir = rtrim($GLOBALS['sugar_config']['cache_dir'], '/\\'); - $file = 'Test/'; - - if ($this->rootFs->hasChild($file) == true) { - rmdir($cache_dir.'/'.$file); - } - - $actual = create_cache_directory($file); - $this->assertFileExists($actual); - - if ($this->rootFs->hasChild($file) == true) { - rmdir($cache_dir.'/'.$file); - } - } - - public function testget_module_dir_list() - { - //execute the method and test if it returns expected values - - $expected = array( - 'Accounts' => 'Accounts', - 'ACL' => 'ACL', - 'ACLActions' => 'ACLActions', - 'ACLRoles' => 'ACLRoles', - 'Activities' => 'Activities', - 'Administration' => 'Administration', - 'Alerts' => 'Alerts', - 'AM_ProjectTemplates' => 'AM_ProjectTemplates', - 'AM_TaskTemplates' => 'AM_TaskTemplates', - 'AOBH_BusinessHours' => 'AOBH_BusinessHours', - 'AOD_Index' => 'AOD_Index', - 'AOD_IndexEvent' => 'AOD_IndexEvent', - 'AOK_KnowledgeBase' => 'AOK_KnowledgeBase', - 'AOK_Knowledge_Base_Categories' => 'AOK_Knowledge_Base_Categories', - 'AOP_Case_Events' => 'AOP_Case_Events', - 'AOP_Case_Updates' => 'AOP_Case_Updates', - 'AOR_Charts' => 'AOR_Charts', - 'AOR_Conditions' => 'AOR_Conditions', - 'AOR_Fields' => 'AOR_Fields', - 'AOR_Reports' => 'AOR_Reports', - 'AOR_Scheduled_Reports' => 'AOR_Scheduled_Reports', - 'AOS_Contracts' => 'AOS_Contracts', - 'AOS_Invoices' => 'AOS_Invoices', - 'AOS_Line_Item_Groups' => 'AOS_Line_Item_Groups', - 'AOS_PDF_Templates' => 'AOS_PDF_Templates', - 'AOS_Products' => 'AOS_Products', - 'AOS_Products_Quotes' => 'AOS_Products_Quotes', - 'AOS_Product_Categories' => 'AOS_Product_Categories', - 'AOS_Quotes' => 'AOS_Quotes', - 'AOW_Actions' => 'AOW_Actions', - 'AOW_Conditions' => 'AOW_Conditions', - 'AOW_Processed' => 'AOW_Processed', - 'AOW_WorkFlow' => 'AOW_WorkFlow', - 'Audit' => 'Audit', - 'Bugs' => 'Bugs', - 'Calendar' => 'Calendar', - 'Calls' => 'Calls', - 'Calls_Reschedule' => 'Calls_Reschedule', - 'CampaignLog' => 'CampaignLog', - 'Campaigns' => 'Campaigns', - 'CampaignTrackers' => 'CampaignTrackers', - 'Cases' => 'Cases', - 'Charts' => 'Charts', - 'Configurator' => 'Configurator', - 'Connectors' => 'Connectors', - 'Contacts' => 'Contacts', - 'Currencies' => 'Currencies', - 'Delegates' => 'Delegates', - 'DocumentRevisions' => 'DocumentRevisions', - 'Documents' => 'Documents', - 'DynamicFields' => 'DynamicFields', - 'EAPM' => 'EAPM', - 'EmailAddresses' => 'EmailAddresses', - 'EmailMan' => 'EmailMan', - 'EmailMarketing' => 'EmailMarketing', - 'Emails' => 'Emails', - 'EmailTemplates' => 'EmailTemplates', - 'EmailText' => 'EmailText', - 'Employees' => 'Employees', - 'Favorites' => 'Favorites', - 'FP_events' => 'FP_events', - 'FP_Event_Locations' => 'FP_Event_Locations', - 'Groups' => 'Groups', - 'Help' => 'Help', - 'History' => 'History', - 'Home' => 'Home', - 'iCals' => 'iCals', - 'Import' => 'Import', - 'InboundEmail' => 'InboundEmail', - 'jjwg_Address_Cache' => 'jjwg_Address_Cache', - 'jjwg_Areas' => 'jjwg_Areas', - 'jjwg_Maps' => 'jjwg_Maps', - 'jjwg_Markers' => 'jjwg_Markers', - 'LabelEditor' => 'LabelEditor', - 'Leads' => 'Leads', - 'MailMerge' => 'MailMerge', - 'Meetings' => 'Meetings', - 'MergeRecords' => 'MergeRecords', - 'ModuleBuilder' => 'ModuleBuilder', - 'MySettings' => 'MySettings', - 'Notes' => 'Notes', - 'OAuth2Clients' => 'OAuth2Clients', - 'OAuth2Tokens' => 'OAuth2Tokens', - 'OAuthKeys' => 'OAuthKeys', - 'OAuthTokens' => 'OAuthTokens', - 'Opportunities' => 'Opportunities', - 'OptimisticLock' => 'OptimisticLock', - 'OutboundEmailAccounts' => 'OutboundEmailAccounts', - 'Project' => 'Project', - 'ProjectTask' => 'ProjectTask', - 'ProspectLists' => 'ProspectLists', - 'Prospects' => 'Prospects', - 'Relationships' => 'Relationships', - 'Reminders' => 'Reminders', - 'Reminders_Invitees' => 'Reminders_Invitees', - 'ResourceCalendar' => 'ResourceCalendar', - 'Releases' => 'Releases', - 'Roles' => 'Roles', - 'SavedSearch' => 'SavedSearch', - 'Schedulers' => 'Schedulers', - 'SchedulersJobs' => 'SchedulersJobs', - 'SecurityGroups' => 'SecurityGroups', - 'Spots' => 'Spots', - 'Studio' => 'Studio', - 'SugarFeed' => 'SugarFeed', - 'SurveyQuestionOptions' => 'SurveyQuestionOptions', - 'SurveyQuestionResponses' => 'SurveyQuestionResponses', - 'SurveyQuestions' => 'SurveyQuestions', - 'SurveyResponses' => 'SurveyResponses', - 'Surveys' => 'Surveys', - 'Tasks' => 'Tasks', - 'Trackers' => 'Trackers', - 'TemplateSectionLine' => 'TemplateSectionLine', - 'UpgradeWizard' => 'UpgradeWizard', - 'UserPreferences' => 'UserPreferences', - 'Users' => 'Users', - 'vCals' => 'vCals', - ); - - $actual = get_module_dir_list(); - sort($actual); - sort($expected); - $this->assertSame($expected, $actual); - } - - public function testmk_temp_dir() - { -// self::markTestIncomplete('Test failing in php 7.1 and 7.2: tempnam(): file created in the system\'s temporary directory'); -// //execute the method and test if created dir/file exists -// -// //without prefix -// $actual = mk_temp_dir('vfs://root', ''); -// $this->assertFileExists($actual); -// -// //with prefix -// $actual = mk_temp_dir('vfs://root', 'pfx'); -// $this->assertFileExists($actual); - } - - public function testremove_file_extension() - { - //execute the method and test if it returns expected values - - //no file extension - $expected = ''; - $actual = remove_file_extension('fileNoExt'); - $this->assertSame($expected, $actual); - - //simple file extension - $expected = 'file1'; - $actual = remove_file_extension('file1.txt'); - $this->assertSame($expected, $actual); - - //complex filename - $expected = 'file2.ext1'; - $actual = remove_file_extension('file2.ext1.ext2'); - $this->assertSame($expected, $actual); - } - - public function testwrite_array_to_file() - { -// $this->markTestSkipped('write_array_to_file cannot be tested with vfsStream'); -// //execute the method and test if it returns true and verify contents -// -// $cache_dir = 'vfs://root'; -// $tempArray = array('Key1' => array('Key2' => 'value2', 'Key3' => 'value3')); -// -// //without header -// $expected = " \n array (\n 'Key2' => 'value2',\n 'Key3' => 'value3',\n ),\n);"; -// $actual = write_array_to_file('tempArray', $tempArray, $cache_dir.'\tempArray.txt'); -// $this->assertTrue($actual); -// $actual_contents = file_get_contents($cache_dir.'\tempArray.txt'); -// $this->assertSame($expected, $actual_contents); -// unlink($cache_dir.'\tempArray.txt'); -// -// //with header -// $expected = "test header \$tempArray = array (\n 'Key1' => \n array (\n 'Key2' => 'value2',\n 'Key3' => 'value3',\n ),\n);"; -// $actual = write_array_to_file('tempArray', $tempArray, $cache_dir.'\tempArray.txt', 'w', 'test header '); -// $this->assertTrue($actual); -// $actual_contents = file_get_contents($cache_dir.'\tempArray.txt'); -// $this->assertSame($expected, $actual_contents); -// unlink($cache_dir.'\tempArray.txt'); - } - - public function testwrite_encoded_file() - { - //execute the method and test if it created file exists - - $cache_dir = 'vfs://root'; - - //without filename - $tempArray = array('filename' => 'soap_array.txt', 'md5' => '523ef67de860fc54794f27117dba4fac', 'data' => 'some soap data'); - $actual = write_encoded_file($tempArray, $cache_dir, ''); - $this->assertFileExists($actual); - unlink($actual); - - //with filename - $tempArray = array('md5' => '523ef67de860fc54794f27117dba4fac', 'data' => 'some soap data'); - $actual = write_encoded_file($tempArray, $cache_dir, 'soap_array.txt'); - $this->assertFileExists($actual); - unlink($actual); - } - - public function testcreate_custom_directory() - { - //execute the method and test if it created file/dir exists - - $file = 'Test/'; - - $vfs = $this->rootFs; - if ($vfs->hasChild($file) == true) { - rmdir('custom/'.$file); - } - - $actual = create_custom_directory($file); - $this->assertFileExists($actual); - - if ($vfs->hasChild($file) == true) { - rmdir('custom/'.$file); - } - } - - public function testgenerateMD5array() - { -// self::markTestIncomplete('environment dependency'); -// -// //execute the method and test if it returns expected values -// -// $expected = array( -// 'data/Relationships/EmailAddressRelationship.php' => '2f04780ddd15f7b65a35c75c303ed5d7', -// 'data/Relationships/M2MRelationship.php' => 'd892195344955fe5b344fd48c3f0290a', -// 'data/Relationships/One2MBeanRelationship.php' => '687f93e57b8a8acdd9bb911bc153598d', -// 'data/Relationships/One2MRelationship.php' => '8a2fbfed8d6b74faf2851eb0a6c6bad3', -// 'data/Relationships/One2OneBeanRelationship.php' => '765b8785d5ca576a8530db99bdf4d411', -// 'data/Relationships/One2OneRelationship.php' => '0385f7577687a402d9603ef26984257e', -// 'data/Relationships/RelationshipFactory.php' => '3bf18f0ff637fb3700d3ac0b75a0fb1b', -// 'data/Relationships/SugarRelationship.php' => '87e9151907a03823b1045402d46f022c', -// ); -// -// $actual = generateMD5array('data/Relationships/'); -// $this->assertSame($expected, $actual); - } - - public function testmd5DirCompare() - { - //execute the method and test if it returns expected values - - $expected = array(); - - $actual = md5DirCompare('include/MVC/', 'include/MVC/', array('views')); - $this->assertSame($expected, $actual); - } - - public function testgetFiles() - { - //execute the method and test if it returns expected values - - //test without pattern - $expected = array( - 'include/MVC/Controller/ControllerFactory.php', - 'include/MVC/Controller/file_access_control_map.php', - 'include/MVC/Controller/action_file_map.php', - 'include/MVC/Controller/action_view_map.php', - 'include/MVC/Controller/entry_point_registry.php', - 'include/MVC/Controller/SugarController.php', - ); - $actual = array(); - getFiles($actual, 'include/MVC/Controller'); - sort($actual); - sort($expected); - $this->assertSame($expected, $actual); - - //test with pattern - $expected = array( - 'include/MVC/Controller/action_view_map.php', - 'include/MVC/View/views/view.ajax.php', - 'include/MVC/View/views/view.ajaxui.php', - 'include/MVC/View/views/view.classic.config.php', - 'include/MVC/View/views/view.classic.php', - 'include/MVC/View/views/view.config.php', - 'include/MVC/View/views/view.detail.config.php', - 'include/MVC/View/views/view.detail.php', - 'include/MVC/View/views/view.edit.php', - 'include/MVC/View/views/view.favorites.php', - 'include/MVC/View/views/view.html.php', - 'include/MVC/View/views/view.importvcard.php', - 'include/MVC/View/views/view.importvcardsave.php', - 'include/MVC/View/views/view.json.php', - 'include/MVC/View/views/view.list.php', - 'include/MVC/View/views/view.metadata.php', - 'include/MVC/View/views/view.modulelistmenu.php', - 'include/MVC/View/views/view.multiedit.php', - 'include/MVC/View/views/view.noaccess.php', - 'include/MVC/View/views/view.popup.php', - 'include/MVC/View/views/view.quick.php', - 'include/MVC/View/views/view.quickcreate.php', - 'include/MVC/View/views/view.quickedit.php', - 'include/MVC/View/views/view.serialized.php', - 'include/MVC/View/views/view.sugarpdf.config.php', - 'include/MVC/View/views/view.sugarpdf.php', - 'include/MVC/View/views/view.vcard.php', - 'include/MVC/View/views/view.xml.php', - ); - $actual = array(); - getFiles($actual, 'include/MVC', '@view@'); - sort($expected); - sort($actual); - $this->assertEquals($expected, $actual); - } - - public function testreadfile_chunked() - { - //execute the method and test if it returns expected values - - $expected = file_get_contents('config.php'); - - //retbytes parameter false - ob_start(); - $actual = readfile_chunked('config.php', false); - $renderedContent = ob_get_contents(); - ob_end_clean(); - - $this->assertTrue($actual); - $this->assertSame($expected, $renderedContent); - - //retbytes parameter true/default - ob_start(); - $actual = readfile_chunked('config.php'); - $renderedContent = ob_get_contents(); - ob_end_clean(); - - $this->assertEquals($actual, strlen($renderedContent)); - $this->assertSame($expected, $renderedContent); - } - - public function testsugar_rename() - { - //execute the method and test if it returns true/success - - $dir = 'vfs://root'; - $file = 'test.txt'; - $vfs = $this->rootFs; - if ($vfs->hasChild($file) != true) { - write_array_to_file('', '', $dir.'/'.$file); - } - - //test with empty file names - $actual = sugar_rename('', ''); - $this->assertFalse($actual); - - //test with valid file names - $actual = sugar_rename($dir.'/'.$file, $dir.'/'.'newtest.txt'); - $this->assertTrue($actual); - - unlink($dir.'/'.'newtest.txt'); - } - - public function testfileToHash() - { - if (isset($_SESSION)) { - $_session = $_SESSION; - } - - //execute the method and test if it returns expected values - - //test with empty filename string - $expected = 'd41d8cd98f00b204e9800998ecf8427e'; - $hash = fileToHash(''); - $this->assertSame($expected, $hash); - $this->assertSame('', $_SESSION['file2Hash'][$hash]); - - //test with valid filename - $expected = '9e5e2527d69c009a81b8ecd730f3957e'; - $hash = fileToHash('config.php'); - $this->assertSame($expected, $hash); - $this->assertSame('config.php', $_SESSION['file2Hash'][$hash]); - - if (isset($_session)) { - $_SESSION = $_session; - } else { - unset($_SESSION); - } - } - - public function testhashToFile() - { - if (isset($_SESSION)) { - $_session = $_SESSION; - } - - //execute the method and test if it returns expected values - - //test with invalid hash. - $actual = hashToFile(''); - $this->assertFalse($actual); - - //test with a newly generated hash - $hash = fileToHash('config.php'); - $actual = hashToFile($hash); - $this->assertSame('config.php', $actual); - - if (isset($_session)) { - $_SESSION = $_session; - } else { - unset($_SESSION); - } - } - - public function testget_file_extension() - { - //execute the method and test if it returns expected values - - $file = ''; // Only variables should be passed by reference in php7 - $this->assertSame('', get_file_extension($file)); - - $file = 'test.txt'; // Only variables should be passed by reference in php7 - $this->assertSame('txt', get_file_extension($file)); - - $file = 'test.ext.Txt'; // Only variables should be passed by reference in php7 - $this->assertSame('Txt', get_file_extension($file, false)); - - $file = 'test.ext.TXT'; // Only variables should be passed by reference in php7 - $this->assertSame('txt', get_file_extension($file, true)); - } - - public function testget_mime_content_type_from_filename() - { - //execute the method and test if it returns expected values - - $this->assertSame('', get_mime_content_type_from_filename('')); - $this->assertSame('application/octet-stream', get_mime_content_type_from_filename('file.tmp')); - $this->assertSame('text/plain', get_mime_content_type_from_filename('file.txt')); - $this->assertSame('application/x-shockwave-flash', get_mime_content_type_from_filename('file.swf')); - $this->assertSame('video/x-flv', get_mime_content_type_from_filename('file.flv')); - } - - public function testcleanFileName() - { - //execute the method and test if it returns expected values - - $this->assertSame('file.txt', cleanFileName('file.txt')); - $this->assertSame('file_1.txt', cleanFileName('file_1.txt')); - $this->assertSame('file.txt', cleanFileName('file.txt')); - } - - public function testcleanDirName() - { - //execute the method and test if it returns expected values - - $this->assertSame('testDir', cleanDirName('./testDir')); - $this->assertSame('testDir', cleanDirName('..\\testDir')); - $this->assertSame('testDir', cleanDirName('\\test/Dir/')); - } -} diff --git a/tests/unit/phpunit/include/utils/layoutUtilsTest.php b/tests/unit/phpunit/include/utils/layoutUtilsTest.php deleted file mode 100644 index 3292d2c7d..000000000 --- a/tests/unit/phpunit/include/utils/layoutUtilsTest.php +++ /dev/null @@ -1,99 +0,0 @@ -assertGreaterThan(0, strlen($html1)); - $this->assertContains('test Header', $html1); - $this->assertContains('test subheader', $html1); - - // help param false - $html2 = get_form_header('new test Header', 'new test subheader', false); - $this->assertGreaterThan(0, strlen($html2)); - $this->assertContains('new test Header', $html2); - $this->assertContains('new test subheader', $html2); - $this->assertGreaterThan(strlen($html2), strlen($html1)); - } - - public function testget_module_title() - { - //execute the method and test if it returns html and contains the values provided in parameters - - //with show_create true, generates more html - $html1 = get_module_title('Users', 'Users Home', true); - $this->assertGreaterThan(0, strlen($html1)); - $this->assertContains('Users', $html1); - $this->assertContains('Users Home', $html1); - - //with show_create false, generates less html - $html2 = get_module_title('Users', 'Users Home', false); - $this->assertGreaterThan(0, strlen($html2)); - $this->assertContains('Users', $html2); - $this->assertContains('Users Home', $html2); - $this->assertGreaterThan(strlen($html2), strlen($html1)); - - //with show_create flase and count > 1, generates more html compared to count =0 - $html3 = get_module_title('Users', 'Users Home', false, 2); - $this->assertGreaterThan(0, strlen($html3)); - $this->assertContains('Users', $html3); - $this->assertContains('Users Home', $html3); - $this->assertGreaterThan(strlen($html2), strlen($html3)); - $this->assertGreaterThan(strlen($html3), strlen($html1)); - } - - public function testgetClassicModuleTitle() - { - //execute the method and test if it returns html and contains the values provided in parameters - - //with show_create false, generates less html - $html1 = getClassicModuleTitle('users', array('Users Home')); - $this->assertGreaterThan(0, strlen($html1)); - $this->assertContains('Users Home', $html1); - - //with show_create true, generates more html - $html2 = getClassicModuleTitle('users', array('Users Home'), true); - $this->assertGreaterThan(0, strlen($html2)); - $this->assertContains('Users Home', $html2); - $this->assertGreaterThan(strlen($html1), strlen($html2)); - } - - public function testinsert_popup_header() - { - //execute the method and test if it returns html/JS - - //with includeJS true, generates more html - ob_start(); - insert_popup_header(); - $renderedContent1 = ob_get_contents(); - ob_end_clean(); - $this->assertGreaterThan(0, strlen($renderedContent1)); - - //with includeJS false, generates less html - ob_start(); - insert_popup_header('', false); - $renderedContent2 = ob_get_contents(); - ob_end_clean(); - $this->assertGreaterThan(0, strlen($renderedContent2)); - - $this->assertGreaterThan(strlen($renderedContent2), strlen($renderedContent1)); - } - - public function testinsert_popup_footer() - { - //execute the method and test if it returns html - - ob_start(); - insert_popup_footer(); - $renderedContent = ob_get_contents(); - ob_end_clean(); - $this->assertGreaterThan(0, strlen($renderedContent)); - } -} diff --git a/tests/unit/phpunit/include/utils/mvcUtilsTest.php b/tests/unit/phpunit/include/utils/mvcUtilsTest.php deleted file mode 100644 index fe41e007d..000000000 --- a/tests/unit/phpunit/include/utils/mvcUtilsTest.php +++ /dev/null @@ -1,99 +0,0 @@ -assertTrue(true); - } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); - } - } - - public function testgetPrintLink() - { - //test without setting REQUEST param - $expected = "javascript:void window.open('index.php?','printwin','menubar=1,status=0,resizable=1,scrollbars=1,toolbar=0,location=1')"; - $actual = getPrintLink(); - $this->assertSame($expected, $actual); - - //test with required REQUEST param set - $_REQUEST['action'] = 'ajaxui'; - $expected = 'javascript:SUGAR.ajaxUI.print();'; - $actual = getPrintLink(); - $this->assertSame($expected, $actual); - } - - public function testajaxBannedModules() - { - //execute the method and test verify it returns true - $result = ajaxBannedModules(); - $this->assertTrue(is_array($result)); - } - - public function testajaxLink() - { - global $sugar_config; - $ajaxUIDisabled = isset($sugar_config['disableAjaxUI']) && $sugar_config['disableAjaxUI']; - - if (!$ajaxUIDisabled) { - $this->assertSame('?action=ajaxui#ajaxUILoc=', ajaxLink('')); - $testModules = array( - 'Calendar', - 'Emails', - 'Campaigns', - 'Documents', - 'DocumentRevisions', - 'Project', - 'ProjectTask', - 'EmailMarketing', - 'CampaignLog', - 'CampaignTrackers', - 'Releases', - 'Groups', - 'EmailMan', - "Administration", - "ModuleBuilder", - 'Schedulers', - 'SchedulersJobs', - 'DynamicFields', - 'EditCustomFields', - 'EmailTemplates', - 'Users', - 'Currencies', - 'Trackers', - 'Connectors', - 'Import_1', - 'Import_2', - 'vCals', - 'CustomFields', - 'Roles', - 'Audit', - 'InboundEmail', - 'SavedSearch', - 'UserPreferences', - 'MergeRecords', - 'EmailAddresses', - 'Relationships', - 'Employees', - 'Import', - 'OAuthKeys' - ); - $bannedModules = ajaxBannedModules(); - foreach ($testModules as $module) { - $uri = "index.php?module=$module&action=detail&record=1"; - if (!in_array($module, $bannedModules)) { - $this->assertSame("?action=ajaxui#ajaxUILoc=" . urlencode($uri), ajaxLink($uri)); - } else { - $this->assertSame($uri, ajaxLink($uri)); - } - } - } - } -} diff --git a/tests/unit/phpunit/include/utils/phpZipUtilsTest.php b/tests/unit/phpunit/include/utils/phpZipUtilsTest.php deleted file mode 100644 index cfd3200be..000000000 --- a/tests/unit/phpunit/include/utils/phpZipUtilsTest.php +++ /dev/null @@ -1,91 +0,0 @@ -assertTrue($result); - - $this->markTestIncomplete('File handling doesnt works in localy'); -// $this->assertFileExists($cache_dir.'/config.php'); -// $this->assertFileExists($cache_dir.'/config_override.php'); - - unlink($cache_dir.'/config.php'); - unlink($cache_dir.'/config_override.php'); - } - - public function testunzip_file() - { - // execute the method and test if it returns true and verify the if unzipped files exist - $cache_dir = rtrim($GLOBALS['sugar_config']['cache_dir'], '/\\'); - $files_list = array('config.php', 'config_override.php'); - $file = $cache_dir.'/zipTest.zip'; - - //create a a zip file first, to unzip - if (!file_exists($file)) { - zip_files_list($file, $files_list); - } - - $result = unzip_file($file, null, $cache_dir); - $this->assertTrue($result); - - $this->markTestIncomplete("File handling doesn't work locally."); -// $this->assertFileExists($cache_dir.'/config.php'); -// $this->assertFileExists($cache_dir.'/config_override.php'); - - unlink($cache_dir.'/config.php'); - unlink($cache_dir.'/config_override.php'); - } - - public function testzip_dir() - { - //execute the method and verify the if zipped file exist - $cache_dir = rtrim($GLOBALS['sugar_config']['cache_dir'], '/\\'); - $file = $cache_dir.'/zipTest.zip'; - - if (file_exists($file)) { - unlink($file); - } - - zip_dir($cache_dir.'/modules', $file); - - $this->assertFileExists($file); - - unlink($file); - } - - public function testzip_files_list() - { - //execute the method and verify the if zipped file exist - $cache_dir = rtrim($GLOBALS['sugar_config']['cache_dir'], '/\\'); - $file = $cache_dir.'/ziplistTest.zip'; - $files_list = array('config.php', 'config_override.php'); - - if (file_exists($file)) { - unlink($file); - } - - $result = zip_files_list($file, $files_list); - - $this->assertTrue($result); - $this->assertFileExists($file); - - unlink($file); - } -} diff --git a/tests/unit/phpunit/include/utils/progressBarUtilsTest.php b/tests/unit/phpunit/include/utils/progressBarUtilsTest.php deleted file mode 100644 index 6d6d11554..000000000 --- a/tests/unit/phpunit/include/utils/progressBarUtilsTest.php +++ /dev/null @@ -1,89 +0,0 @@ -assertTrue(true); - } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); - } - } - - public function testdisplay_flow_bar() - { - //execute the method and test if it doesn't throw an exception. - //this method uses flush so we cannot get and verify content printed - try { - ob_start(); - display_flow_bar('test', 0, 200, false); - ob_end_clean(); - $this->assertTrue(true); - } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); - } - } - - public function teststart_flow_bar() - { - //execute the method and test if it doesn't throw an exception. - //this method uses flush so we cannot get and verify content printed - try { - ob_start(); - start_flow_bar('test', 1, false); - ob_end_clean(); - $this->assertTrue(true); - } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); - } - } - - public function testdestroy_flow_bar() - { - //execute the method and test if it doesn't throw an exception. - //this method uses flush so we cannot get and verify content printed - try { - ob_start(); - destroy_flow_bar('test', false); - ob_end_clean(); - $this->assertTrue(true); - } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); - } - } - - public function testdisplay_progress_bar() - { - //execute the method and test if it doesn't throw an exception. - //this method uses flush so we cannot get and verify content printed - try { - ob_start(); - display_progress_bar('test', 80, 100, false); - ob_end_clean(); - $this->assertTrue(true); - } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); - } - } - - public function testupdate_progress_bar() - { - //execute the method and test if it doesn't throw an exception. - //this method uses flush so we cannot get and verify content printed - try { - ob_start(); - update_progress_bar('test', 80, 100, false); - ob_end_clean(); - $this->assertTrue(true); - } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); - } - } -} diff --git a/tests/unit/phpunit/include/utils/sugarFileUtilsTest.php b/tests/unit/phpunit/include/utils/sugarFileUtilsTest.php deleted file mode 100644 index 8f2fad5ac..000000000 --- a/tests/unit/phpunit/include/utils/sugarFileUtilsTest.php +++ /dev/null @@ -1,170 +0,0 @@ -assertTrue(true, "Needs checking!"); - } - - /* - protected function setUp(): void - { - parent::setUp(); - - $rootFs = org\bovigo\vfs\vfsStream::setup('root'); - $rootFs->addChild(org\bovigo\vfs\vfsStream::newDirectory('testDir')); - $rootFs->addChild(org\bovigo\vfs\vfsStream::newFile('test.txt')->withContent("Hello world!")); - } - - public function testsugar_mkdir() - { - //execute the method and test if it returns true and created dir exists - - $dir = "vfs://root"; - - //non recursive - $result = sugar_mkdir($dir . "/mkdirTest"); - $this->assertFileExists($dir . "/mkdirTest"); - $this->assertTrue($result); - - //recursive - $result = sugar_mkdir($dir . "/mkdirTest/test",null,true); - $this->assertFileExists($dir . "/mkdirTest/test"); - $this->assertTrue($result); - } - - public function testsugar_fopen() - { - //execute the method and test if it doesn't returns false - $result = sugar_fopen('vfs://root/test.txt', 'r'); - $this->assertNotFalse($result); - } - - public function testsugar_file_put_contents() - { - //execute the method and test if it doesn't returns false and returns the number of bytes written - - $dir = "vfs://root"; - $result = sugar_file_put_contents( $dir . '/testfile.txt', 'some test data'); - $this->assertNotFalse($result); - $this->assertEquals(14,$result); - } - - public function testsugar_file_put_contents_atomic() - { - $this->markTestSkipped('Atomic file put cannot be tested with vfsStream'); - //execute the method and test if it returns success(true) - $dir = "vfs://root"; - $result = sugar_file_put_contents_atomic( $dir . '/atomictestfile.txt', 'some test data'); - $this->assertTrue($result); - } - - public function testsugar_file_get_contents() - { - //execute the method and test if it doesn't returns false and returns the expected contents - $dir = "vfs://root"; - $result = file_get_contents( $dir . '/test.txt'); - - $this->assertNotFalse($result); - $this->assertEquals('Hello world!',$result); - } - - - public function testsugar_touch() - { - //execute the method and test if it returns success(true) - - $dir = "vfs://root"; - $test_dt = time() - 3600 ; - $expected = date("m d Y H:i:s", time() - 3600 ); - - //test wihout modified date param - $result = sugar_touch( $dir . '/testfiletouch.txt'); - $this->assertTrue($result); - - //test wih modified date param - $result = sugar_touch( $dir . '/testfiletouch.txt',$test_dt,$test_dt); - $file_dt = date ("m d Y H:i:s", filemtime($dir . '/testfiletouch.txt')) ; - - $this->assertTrue($result); - $this->assertSame($file_dt, $expected ); - } - - public function testsugar_chmod() - { - $this->markTestSkipped('Permissions cannot be tested with vfsStream'); - //execute the method and test if it returns success(true) - $dir = "vfs://test"; - $result = sugar_chmod($dir . '/test.txt',0777); - $this->assertTrue($result); - } - - public function testsugar_chown() - { - $this->markTestSkipped('Permissions cannot be tested with vfsStream'); - //execute the method and test if it returns success(true) - $dir = "vfs://test"; - $result = sugar_chown($dir . '/test.txt'); - $this->assertFalse($result); - - $result = sugar_chown($dir . '/test.txt',org\bovigo\vfs\vfsStream::getCurrentUser()); - $this->assertTrue($result); - - } - - public function testsugar_chgrp() - { - $this->markTestSkipped('Permissions cannot be tested with vfsStream'); - //execute the method and test if it returns success(true) - $dir = "vfs://test"; - $result = sugar_chgrp($dir . '/test.txt'); - $this->assertFalse($result); - - $result = sugar_chgrp($dir . '/test.txt',org\bovigo\vfs\vfsStream::getCurrentGroup()); - $this->assertFalse($result); - } - - public function testget_mode() - { - //test with all mods defined in config - $this->assertSame(1528,get_mode()); - $this->assertSame(1528,get_mode('dir_mode', 10)); - $this->assertSame(493,get_mode('file_mode', 10)); - $this->assertSame('',get_mode('user', 10)); - $this->assertSame('',get_mode('group', 10)); - } - - public function testsugar_is_dir() - { - $dir = "vfs://root"; - - $this->assertFalse(sugar_is_dir('')); //invalid dir - $this->assertFalse(sugar_is_dir($dir."/foo")); //invalid dir - $this->assertTrue(sugar_is_dir($dir."/testDir")); //valid dir - } - - public function testsugar_is_file() - { - $this->assertFalse(sugar_is_file('')); //invalid file - $this->assertFalse(sugar_is_file('vfs://config')); //invalid file - $this->assertTrue(is_file('vfs://root/test.txt')); //valid file - } - - - public function testsugar_cached() - { - $cache_dir = rtrim($GLOBALS['sugar_config']['cache_dir'], '/\\'); - - $this->assertSame($cache_dir . '/', sugar_cached('')); //invalid file - $this->assertSame($cache_dir . '/config', sugar_cached('config')); //valid file - $this->assertSame($cache_dir . '/modules' , sugar_cached('modules')); //valid file - } - */ -} diff --git a/tests/unit/phpunit/include/utils/zipUtilsTest.php b/tests/unit/phpunit/include/utils/zipUtilsTest.php deleted file mode 100644 index d498bc933..000000000 --- a/tests/unit/phpunit/include/utils/zipUtilsTest.php +++ /dev/null @@ -1,27 +0,0 @@ -markTestIncomplete('Can Not be implemented'); - } - - public function testunzip_file() - { -// $this->markTestIncomplete('Can Not be implemented'); - } - - public function testzip_dir() - { -// $this->markTestIncomplete('Can Not be implemented'); - } - - public function testzip_files_list() - { -// $this->markTestIncomplete('Can Not be implemented'); - } -} diff --git a/tests/unit/phpunit/include/ErrorMessageTest.php b/tests/unit/phpunit/includes/ErrorMessageTest.php similarity index 88% rename from tests/unit/phpunit/include/ErrorMessageTest.php rename to tests/unit/phpunit/includes/ErrorMessageTest.php index 79157e256..ff100608b 100644 --- a/tests/unit/phpunit/include/ErrorMessageTest.php +++ b/tests/unit/phpunit/includes/ErrorMessageTest.php @@ -5,7 +5,7 @@ * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. * * SuiteCRM is an extension to SugarCRM Community Edition developed by SalesAgility Ltd. - * Copyright (C) 2011 - 2018 SalesAgility Ltd. + * Copyright (C) 2011 - 2021 SalesAgility Ltd. * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU Affero General Public License version 3 as published by the @@ -38,6 +38,8 @@ * display the words "Powered by SugarCRM" and "Supercharged by SuiteCRM". */ +namespace SuiteCRM\Tests\Unit\includes; + use SuiteCRM\ErrorMessage; use SuiteCRM\ErrorMessageException; use SuiteCRM\Test\SuitePHPUnitFrameworkTestCase; @@ -47,9 +49,8 @@ if (!defined('sugarEntry') || !sugarEntry) { } /** - * ErrorMessageTest - * - * @author gyula + * Class ErrorMessageTest + * @package SuiteCRM\Tests\Unit */ class ErrorMessageTest extends SuitePHPUnitFrameworkTestCase { @@ -77,21 +78,16 @@ class ErrorMessageTest extends SuitePHPUnitFrameworkTestCase include_once __DIR__ . '/../../../../include/LangException.php'; } - protected function tearDown(): void - { - parent::tearDown(); - } - - public function testLog() + public function testLog(): void { try { ErrorMessage::handler('A test error message', 'debug', true, 321); - $this->assertFalse(true, 'Error handler should throw an exception in this scenario.'); + self::assertFalse(true, 'Error handler should throw an exception in this scenario.'); } catch (ErrorMessageException $e) { $message = $e->getMessage(); $code = $e->getCode(); - $this->assertEquals('A test error message', $message, 'Incorrect exception message given.'); - $this->assertEquals(321, $code, 'Incorrect exception code given.'); + self::assertEquals('A test error message', $message, 'Incorrect exception message given.'); + self::assertEquals(321, $code, 'Incorrect exception code given.'); } } } diff --git a/tests/unit/phpunit/include/GoogleSync/GoogleSyncMock.php b/tests/unit/phpunit/includes/GoogleSync/GoogleSyncMock.php similarity index 93% rename from tests/unit/phpunit/include/GoogleSync/GoogleSyncMock.php rename to tests/unit/phpunit/includes/GoogleSync/GoogleSyncMock.php index d6e780874..9dead08fb 100644 --- a/tests/unit/phpunit/include/GoogleSync/GoogleSyncMock.php +++ b/tests/unit/phpunit/includes/GoogleSync/GoogleSyncMock.php @@ -34,7 +34,7 @@ require_once __DIR__ . '/../../../../../include/GoogleSync/GoogleSync.php'; */ class GoogleSyncMock extends GoogleSync { - public function setProperty($key, $value) + public function setProperty($key, $value): void { $this->$key = $value; } @@ -55,7 +55,7 @@ class GoogleSyncMock extends GoogleSync if (!method_exists($this, $name)) { throw new Exception('Method is not exists: ' . $name); } - $ret = call_user_func_array([$this, $name], (array)$params); - return $ret; + + return call_user_func_array([$this, $name], (array)$params); } } diff --git a/tests/unit/phpunit/include/GoogleSync/GoogleSyncTest.php b/tests/unit/phpunit/includes/GoogleSync/GoogleSyncTest.php similarity index 66% rename from tests/unit/phpunit/include/GoogleSync/GoogleSyncTest.php rename to tests/unit/phpunit/includes/GoogleSync/GoogleSyncTest.php index b8db03d62..e28bfc221 100644 --- a/tests/unit/phpunit/include/GoogleSync/GoogleSyncTest.php +++ b/tests/unit/phpunit/includes/GoogleSync/GoogleSyncTest.php @@ -1,29 +1,4 @@ getProperty('timezone'); - $this->assertNotEmpty($timezone); - $this->assertEquals("string", gettype($timezone)); + self::assertNotEmpty($timezone); + self::assertEquals("string", gettype($timezone)); // Test GoogleSync::authJson $authJson = $object->getProperty('authJson'); - $this->assertNotEmpty($authJson); - $this->assertEquals("array", gettype($authJson)); + self::assertNotEmpty($authJson); + self::assertEquals("array", gettype($authJson)); // Test GoogleSync::db $expectedClass = DBManager::class; $actualClass = $object->getProperty('db'); - $this->assertInstanceOf($expectedClass, $actualClass); + self::assertInstanceOf($expectedClass, $actualClass); } /** * * */ - public function testGetAuthJson() + public function testGetAuthJson(): void { // base64 encoded of {"web":"test"} $sugar_config['google_auth_json'] = 'eyJ3ZWIiOiJ0ZXN0In0='; @@ -113,52 +88,52 @@ class GoogleSyncTest extends SuitePHPUnitFrameworkTestCase $expectedAuthJson = json_decode(base64_decode('eyJ3ZWIiOiJ0ZXN0In0'), true); $actualAuthJson = $object->callMethod('getAuthJson', [$this->getFakeSugarConfig('{"web":"test"}')]); - $this->assertEquals($expectedAuthJson, $actualAuthJson); - $this->assertArrayHasKey('web', $actualAuthJson); + self::assertEquals($expectedAuthJson, $actualAuthJson); + self::assertArrayHasKey('web', $actualAuthJson); try { $object->callMethod('getAuthJson', [['google_auth_json' => 'INVALID']]); - $this->assertTrue(false); + self::assertTrue(false); } catch (GoogleSyncException $e) { - $this->assertTrue(true); - $this->assertEquals(GoogleSyncException::JSON_CORRUPT, $e->getCode()); + self::assertTrue(true); + self::assertEquals(GoogleSyncException::JSON_CORRUPT, $e->getCode()); } try { $object->callMethod('getAuthJson', [$this->getFakeSugarConfig('{"foo":"bar"}')]); - $this->assertTrue(false); + self::assertTrue(false); } catch (GoogleSyncException $e) { - $this->assertTrue(true); - $this->assertEquals(GoogleSyncException::JSON_KEY_MISSING, $e->getCode()); + self::assertTrue(true); + self::assertEquals(GoogleSyncException::JSON_KEY_MISSING, $e->getCode()); } $ret = $object->callMethod('getAuthJson', [null]); - $this->assertFalse($ret); + self::assertFalse($ret); } /** * * */ - public function testSetClient() + public function testSetClient(): void { $object = new GoogleSyncMock($this->getFakeSugarConfig('{"web":"test"}')); try { $object->callMethod('setClient', [null]); - $this->assertTrue(false, 'It should throws an exception.'); + self::assertTrue(false, 'It should throws an exception.'); } catch (GoogleSyncException $e) { - $this->assertEquals(GoogleSyncException::INVALID_CLIENT_ID, $e->getCode()); + self::assertEquals(GoogleSyncException::INVALID_CLIENT_ID, $e->getCode()); } } - public function testGetClient() + public function testGetClient(): void { $object = new GoogleSyncMock($this->getFakeSugarConfig('{"web":"test"}')); try { $object->callMethod('getClient', [null]); - $this->assertTrue(false, 'It should throws an exception.'); + self::assertTrue(false, 'It should throws an exception.'); } catch (GoogleSyncException $e) { - $this->assertEquals(GoogleSyncException::INVALID_CLIENT_ID, $e->getCode()); + self::assertEquals(GoogleSyncException::INVALID_CLIENT_ID, $e->getCode()); } } @@ -166,23 +141,23 @@ class GoogleSyncTest extends SuitePHPUnitFrameworkTestCase * * */ - public function testGetGoogleClient() + public function testGetGoogleClient(): void { try { $object = new GoogleSyncMock($this->getFakeSugarConfig('{"web":"test","client_id":"testID"')); - $this->assertTrue(false, 'It should throws an exception.'); + self::assertTrue(false, 'It should throws an exception.'); } catch (GoogleSyncException $e) { - $this->assertEquals(GoogleSyncException::JSON_CORRUPT, $e->getCode(), 'It should throws an exception with code 0.'); - $this->assertEquals('google_auth_json not vaild json', $e->getMessage(), 'It should throws an exception with a proper message.'); + self::assertEquals(GoogleSyncException::JSON_CORRUPT, $e->getCode(), 'It should throws an exception with code 0.'); + self::assertEquals('google_auth_json not vaild json', $e->getMessage(), 'It should throws an exception with a proper message.'); } $object = new GoogleSyncMock($this->getFakeSugarConfig('{"web":"test","client_id":"testID"}')); try { $object->callMethod('getGoogleClient', [null]); - $this->assertTrue(false, 'It should throws an exception.'); + self::assertTrue(false, 'It should throws an exception.'); } catch (GoogleSyncException $e) { - $this->assertEquals(GoogleSyncException::ACCSESS_TOKEN_PARAMETER_MISSING, $e->getCode(), 'It should throws an exception with code 0.'); - $this->assertEquals('Access Token Parameter Missing', $e->getMessage(), 'It should throws an exception with a proper message.'); + self::assertEquals(GoogleSyncException::ACCSESS_TOKEN_PARAMETER_MISSING, $e->getCode(), 'It should throws an exception with code 0.'); + self::assertEquals('Access Token Parameter Missing', $e->getMessage(), 'It should throws an exception with a proper message.'); } } @@ -190,14 +165,14 @@ class GoogleSyncTest extends SuitePHPUnitFrameworkTestCase * * */ - public function testInitUserService() + public function testInitUserService(): void { $object = new GoogleSyncMock($this->getFakeSugarConfig('{"web":"test"}')); try { $object->callMethod('initUserService', [null]); - $this->assertTrue(false, 'It should throws an exception.'); + self::assertTrue(false, 'It should throws an exception.'); } catch (GoogleSyncException $e) { - $this->assertEquals(GoogleSyncException::INVALID_CLIENT_ID, $e->getCode()); + self::assertEquals(GoogleSyncException::INVALID_CLIENT_ID, $e->getCode()); } } @@ -205,7 +180,7 @@ class GoogleSyncTest extends SuitePHPUnitFrameworkTestCase * * */ - public function testGetUserMeetings() + public function testGetUserMeetings(): void { // Create a User $user = BeanFactory::getBean('Users'); @@ -259,79 +234,77 @@ class GoogleSyncTest extends SuitePHPUnitFrameworkTestCase // Test for invalid user id exception handling try { $return = $object->callMethod('getUserMeetings', ['INVALID!+']); - $this->assertTrue(false, 'It should throws an exception.'); + self::assertTrue(false, 'It should throws an exception.'); } catch (GoogleSyncException $e) { - $this->assertEquals(GoogleSyncException::INVALID_USER_ID, $e->getCode()); + self::assertEquals(GoogleSyncException::INVALID_USER_ID, $e->getCode()); } - $this->assertEquals(3, count($return_count)); + self::assertCount(3, $return_count); } /** * * */ - public function testSetUsersGoogleCalendar() + public function testSetUsersGoogleCalendar(): void { $object = new GoogleSyncMock($this->getFakeSugarConfig('{"web":"test"}')); - $this->assertEquals(false, $object->callMethod('setUsersGoogleCalendar')); + self::assertEquals(false, $object->callMethod('setUsersGoogleCalendar')); } /** * * */ - public function testGetSuiteCRMCalendar() + public function testGetSuiteCRMCalendar(): void + { + $result = (new GoogleSyncMock($this->getFakeSugarConfig('{"web":"test"}')))->callMethod('getSuiteCRMCalendar', [new Google_Service_Calendar_CalendarList()]); + self::assertEquals(null, $result); + } + + /** + * + * + */ + public function testGetUserGoogleEvents(): void { $object = new GoogleSyncMock($this->getFakeSugarConfig('{"web":"test"}')); - - $result = $object->callMethod('getSuiteCRMCalendar', [new Google_Service_Calendar_CalendarList()]); - $this->assertEquals(null, $result); + self::assertEquals(false, $object->callMethod('getUserGoogleEvents')); } /** * * */ - public function testGetUserGoogleEvents() + public function testIsServiceExists(): void { $object = new GoogleSyncMock($this->getFakeSugarConfig('{"web":"test"}')); - $this->assertEquals(false, $object->callMethod('getUserGoogleEvents')); + self::assertEquals(false, $object->callMethod('isServiceExists')); } /** * * */ - public function testIsServiceExists() + public function testIsCalendarExists(): void { $object = new GoogleSyncMock($this->getFakeSugarConfig('{"web":"test"}')); - $this->assertEquals(false, $object->callMethod('isServiceExists')); + self::assertEquals(false, $object->callMethod('isCalendarExists')); } /** * * */ - public function testIsCalendarExists() - { - $object = new GoogleSyncMock($this->getFakeSugarConfig('{"web":"test"}')); - $this->assertEquals(false, $object->callMethod('isCalendarExists')); - } - - /** - * - * - */ - public function testGetGoogleEventById() + public function testGetGoogleEventById(): void { $object = new GoogleSyncMock($this->getFakeSugarConfig('{"web":"test"}')); try { $object->callMethod('getGoogleEventById', [null]); - $this->assertTrue(false, 'It should throws an exception.'); + self::assertTrue(false, 'It should throws an exception.'); } catch (GoogleSyncException $e) { - $this->assertEquals(GoogleSyncException::EVENT_ID_IS_EMPTY, $e->getCode()); - $this->assertEquals('event ID is empty', $e->getMessage()); + self::assertEquals(GoogleSyncException::EVENT_ID_IS_EMPTY, $e->getCode()); + self::assertEquals('event ID is empty', $e->getMessage()); } } @@ -339,7 +312,7 @@ class GoogleSyncTest extends SuitePHPUnitFrameworkTestCase * * */ - public function testGetMeetingByEventId() + public function testGetMeetingByEventId(): void { $db = DBManagerFactory::getInstance(); @@ -387,45 +360,45 @@ class GoogleSyncTest extends SuitePHPUnitFrameworkTestCase // Give meeting 1 a gsync_id $sql1 = "UPDATE meetings SET gsync_id = 'valid_gsync_id' WHERE id = '{$meeting1_id}'"; $res1 = $db->query($sql1); - $this->assertEquals(true, $res1); + self::assertEquals(true, $res1); // --- separated test // Give meetings 2 and 3 a duplicate gsync_id $sql2 = "UPDATE meetings SET gsync_id = 'duplicate_gsync_id' WHERE id = '{$meeting2_id}' OR id = '{$meeting3_id}'"; $res2 = $db->query($sql2); - $this->assertEquals(true, $res2); + self::assertEquals(true, $res2); // --- separated test $meeting = $object->callMethod('getMeetingByEventId', ['valid_gsync_id']); - $this->assertEquals($meeting1_id, $meeting->id); + self::assertEquals($meeting1_id, $meeting->id); // --- separated test try { $object->callMethod('getMeetingByEventId', ['duplicate_gsync_id']); - $this->assertTrue(false, 'It should throws an exception.'); + self::assertTrue(false, 'It should throws an exception.'); } catch (GoogleSyncException $e11) { - $this->assertEquals(GoogleSyncException::AMBIGUOUS_MEETING_ID, $e11->getCode()); - $this->assertEquals('More than one meeting matches Google Id!', $e11->getMessage()); + self::assertEquals(GoogleSyncException::AMBIGUOUS_MEETING_ID, $e11->getCode()); + self::assertEquals('More than one meeting matches Google Id!', $e11->getMessage()); } // --- separated test $ret4 = $object->callMethod('getMeetingByEventId', ['NOTHING_MATCHES']); - $this->assertNull($ret4); + self::assertNull($ret4); } /** * * */ - public function testSetGService() + public function testSetGService(): void { $object = new GoogleSyncMock($this->getFakeSugarConfig('{"web":"test"}')); try { $object->callMethod('setGService'); - $this->assertTrue(false); + self::assertTrue(false); } catch (GoogleSyncException $e) { - $this->assertTrue(true); - $this->assertEquals(GoogleSyncException::NO_GCLIENT_SET, $e->getCode()); + self::assertTrue(true); + self::assertEquals(GoogleSyncException::NO_GCLIENT_SET, $e->getCode()); } } @@ -433,15 +406,15 @@ class GoogleSyncTest extends SuitePHPUnitFrameworkTestCase * * */ - public function testPushEvent() + public function testPushEvent(): void { $object = new GoogleSyncMock($this->getFakeSugarConfig('{"web":"test"}')); try { $object->callMethod('pushEvent', [BeanFactory::getBean('Meetings'), null]); - $this->assertTrue(false, 'It should throws an exception.'); + self::assertTrue(false, 'It should throws an exception.'); } catch (GoogleSyncException $e) { - $this->assertEquals(GoogleSyncException::NO_GSERVICE_SET, $e->getCode()); + self::assertEquals(GoogleSyncException::NO_GSERVICE_SET, $e->getCode()); } } @@ -449,7 +422,7 @@ class GoogleSyncTest extends SuitePHPUnitFrameworkTestCase * * */ - public function testReturnExtendedProperties() + public function testReturnExtendedProperties(): void { $object = new GoogleSyncMock($this->getFakeSugarConfig('{"web":"test"}')); @@ -508,24 +481,24 @@ class GoogleSyncTest extends SuitePHPUnitFrameworkTestCase $return = $object->callMethod('returnExtendedProperties', [$Google_Event, $CRM_Meeting]); $returnPrivate = $return->getPrivate(); - $this->assertEquals('FAKE_MEETING_ID', $returnPrivate['suitecrm_id']); - $this->assertEquals('Meeting', $returnPrivate['suitecrm_type']); - $this->assertEquals('VALID', $returnPrivate['remain_unchanged']); + self::assertEquals('FAKE_MEETING_ID', $returnPrivate['suitecrm_id']); + self::assertEquals('Meeting', $returnPrivate['suitecrm_type']); + self::assertEquals('VALID', $returnPrivate['remain_unchanged']); } /** * * */ - public function testPullEvent() + public function testPullEvent(): void { $object = new GoogleSyncMock($this->getFakeSugarConfig('{"web":"test"}')); try { $object->callMethod('pullEvent', [new Google_Service_Calendar_Event(), null]); - $this->assertTrue(false, 'It should throws an exception.'); + self::assertTrue(false, 'It should throws an exception.'); } catch (GoogleSyncException $e) { - $this->assertEquals(GoogleSyncException::NO_REMOVE_EVENT_START_IS_NOT_SET, $e->getCode()); + self::assertEquals(GoogleSyncException::NO_REMOVE_EVENT_START_IS_NOT_SET, $e->getCode()); } } @@ -533,15 +506,15 @@ class GoogleSyncTest extends SuitePHPUnitFrameworkTestCase * * */ - public function testDelMeeting() + public function testDelMeeting(): void { $object = new GoogleSyncMock($this->getFakeSugarConfig('{"web":"test"}')); try { $object->callMethod('delMeeting', [BeanFactory::getBean('Meetings')]); - $this->assertTrue(false, 'It should throws an exception.'); + self::assertTrue(false, 'It should throws an exception.'); } catch (GoogleSyncException $e) { - $this->assertEquals(GoogleSyncException::INCORRECT_WORKING_USER_TYPE, $e->getCode()); + self::assertEquals(GoogleSyncException::INCORRECT_WORKING_USER_TYPE, $e->getCode()); } } @@ -549,15 +522,15 @@ class GoogleSyncTest extends SuitePHPUnitFrameworkTestCase * * */ - public function testDelEvent() + public function testDelEvent(): void { $object = new GoogleSyncMock($this->getFakeSugarConfig('{"web":"test"}')); try { $object->callMethod('delEvent', [new Google_Service_Calendar_Event(), null]); - $this->assertTrue(false); + self::assertTrue(false); } catch (GoogleSyncException $e) { - $this->assertEquals(GoogleSyncException::NO_GSERVICE_SET, $e->getCode()); + self::assertEquals(GoogleSyncException::NO_GSERVICE_SET, $e->getCode()); } @@ -572,16 +545,16 @@ class GoogleSyncTest extends SuitePHPUnitFrameworkTestCase try { $object->callMethod('delEvent', [new Google_Service_Calendar_Event(), null]); - $this->assertTrue(false, 'It should throw an exception.'); + self::assertTrue(false, 'It should throw an exception.'); } catch (GoogleSyncException $e) { - $this->assertEquals(GoogleSyncException::MEETING_ID_IS_EMPTY, $e->getCode()); + self::assertEquals(GoogleSyncException::MEETING_ID_IS_EMPTY, $e->getCode()); } // -- another test try { $object->callMethod('delEvent', [$Google_Event, 'INVALID_ID+!']); - $this->assertTrue(false, 'It should throw an exception.'); + self::assertTrue(false, 'It should throw an exception.'); } catch (GoogleSyncException $e) { - $this->assertEquals(GoogleSyncException::RECORD_VALIDATION_FAILURE, $e->getCode()); + self::assertEquals(GoogleSyncException::RECORD_VALIDATION_FAILURE, $e->getCode()); } } @@ -589,15 +562,15 @@ class GoogleSyncTest extends SuitePHPUnitFrameworkTestCase * * */ - public function testClearPopups() + public function testClearPopups(): void { $object = new GoogleSyncMock($this->getFakeSugarConfig('{"web":"test"}')); try { $object->callMethod('clearPopups', [null]); - $this->assertTrue(false, 'It should throw an exception.'); + self::assertTrue(false, 'It should throw an exception.'); } catch (InvalidArgumentException $e) { - $this->assertTrue(true); - $this->assertEquals(0, $e->getCode()); + self::assertTrue(true); + self::assertEquals(0, $e->getCode()); } $ret = $object->callMethod('clearPopups', '123456'); } @@ -606,7 +579,7 @@ class GoogleSyncTest extends SuitePHPUnitFrameworkTestCase * * */ - public function testCreateSuitecrmMeetingEvent() + public function testCreateSuitecrmMeetingEvent(): void { $object = new GoogleSyncMock($this->getFakeSugarConfig('{"web":"test"}')); @@ -659,29 +632,29 @@ class GoogleSyncTest extends SuitePHPUnitFrameworkTestCase $return = $object->callMethod('createSuitecrmMeetingEvent', [$Google_Event]); - $this->assertEquals('Meeting', get_class($return)); - $this->assertNotNull($return->id); - $this->assertEquals('0', $return->deleted); - $this->assertEquals('Unit Test Event', $return->name); - $this->assertEquals('Unit Test Event', $return->description); - $this->assertEquals('123 Seseme Street', $return->location); - $this->assertEquals('2018-01-01 01:00:00', $return->date_start); - $this->assertEquals('2018-01-01 02:00:00', $return->date_end); - $this->assertEquals('1', $return->duration_hours); - $this->assertEquals('0', $return->duration_minutes); - $this->assertEquals('FAKEUSER', $return->assigned_user_id); + self::assertInstanceOf(\Meeting::class, $return); + self::assertNotNull($return->id); + self::assertEquals('0', $return->deleted); + self::assertEquals('Unit Test Event', $return->name); + self::assertEquals('Unit Test Event', $return->description); + self::assertEquals('123 Seseme Street', $return->location); + self::assertEquals('2018-01-01 01:00:00', $return->date_start); + self::assertEquals('2018-01-01 02:00:00', $return->date_end); + self::assertEquals('1', $return->duration_hours); + self::assertEquals('0', $return->duration_minutes); + self::assertEquals('FAKEUSER', $return->assigned_user_id); } /** * * */ - public function testCreateGoogleCalendarEvent() + public function testCreateGoogleCalendarEvent(): void { $object = new GoogleSyncMock($this->getFakeSugarConfig('{"web":"test"}')); $ret = $object->callMethod('setTimeZone', ['Etc/UTC']); - $this->assertTrue($ret); + self::assertTrue($ret); $testid = create_guid(); $timedate = new TimeDate; @@ -701,57 +674,56 @@ class GoogleSyncTest extends SuitePHPUnitFrameworkTestCase $return = $object->callMethod('createGoogleCalendarEvent', [$CRM_Meeting]); - $this->assertEquals('Google_Service_Calendar_Event', get_class($return)); - $this->assertEquals('Unit Test Event', $return->getSummary()); - $this->assertEquals('Unit Test Event', $return->getDescription()); - $this->assertEquals('123 Sesame Street', $return->getLocation()); + self::assertInstanceOf(\Google_Service_Calendar_Event::class, $return); + self::assertEquals('Unit Test Event', $return->getSummary()); + self::assertEquals('Unit Test Event', $return->getDescription()); + self::assertEquals('123 Sesame Street', $return->getLocation()); $start = $return->getStart(); $end = $return->getEnd(); - $this->assertEquals('2018-01-01T12:00:00+00:00', $start->getDateTime()); - $this->assertEquals('Etc/UTC', $start->getTimeZone()); - $this->assertEquals('2018-01-01T13:00:00+00:00', $end->getDateTime()); - $this->assertEquals('Etc/UTC', $end->getTimeZone()); + self::assertEquals('2018-01-01T12:00:00+00:00', $start->getDateTime()); + self::assertEquals('Etc/UTC', $start->getTimeZone()); + self::assertEquals('2018-01-01T13:00:00+00:00', $end->getDateTime()); + self::assertEquals('Etc/UTC', $end->getTimeZone()); - $props = $return->getExtendedProperties(); - $private = $props->getPrivate(); - $this->assertEquals($testid, $private['suitecrm_id']); - $this->assertEquals('Meeting', $private['suitecrm_type']); + $private = $return->getExtendedProperties()->getPrivate(); + self::assertEquals($testid, $private['suitecrm_id']); + self::assertEquals('Meeting', $private['suitecrm_type']); } /** * * */ - public function testSetTimezone() + public function testSetTimezone(): void { $object = new GoogleSyncMock($this->getFakeSugarConfig('{"web":"test"}')); $property = $object->getProperty('timezone'); - $this->assertEquals('Etc/UTC', $property); + self::assertEquals('Etc/UTC', $property); $expectedTimezone = 'Etc/GMT'; $return = $object->callMethod('setTimezone', [$expectedTimezone]); $property = $object->getProperty('timezone'); - $this->assertTrue($return); - $this->assertEquals($expectedTimezone, $property); - $this->assertEquals($expectedTimezone, date_default_timezone_get()); + self::assertTrue($return); + self::assertEquals($expectedTimezone, $property); + self::assertEquals($expectedTimezone, date_default_timezone_get()); } /** * * */ - public function testSetLastSync() + public function testSetLastSync(): void { $object = new GoogleSyncMock($this->getFakeSugarConfig('{"web":"test"}')); try { $object->callMethod('setLastSync', [BeanFactory::getBean('Meetings'), null]); - $this->assertTrue(false, 'It should throws an exception.'); + self::assertTrue(false, 'It should throws an exception.'); } catch (GoogleSyncException $e) { - $this->assertEquals(GoogleSyncException::INCORRECT_WORKING_USER_TYPE, $e->getCode()); + self::assertEquals(GoogleSyncException::INCORRECT_WORKING_USER_TYPE, $e->getCode()); } } @@ -761,7 +733,7 @@ class GoogleSyncTest extends SuitePHPUnitFrameworkTestCase * * */ - public function testGetTitle() + public function testGetTitle(): void { $object = new GoogleSyncMock($this->getFakeSugarConfig('{"web":"test"}')); @@ -778,42 +750,42 @@ class GoogleSyncTest extends SuitePHPUnitFrameworkTestCase $Google_Event->setSummary('Unit Test Event'); $Google_Event->setDescription('Unit Test Event'); - $this->assertEquals('Unit Test Event / Unit Test Event', $object->callMethod('getTitle', [$CRM_Meeting, $Google_Event])); - $this->assertEquals('Unit Test Event', $object->callMethod('getTitle', [$CRM_Meeting, null])); - $this->assertEquals('Unit Test Event', $object->callMethod('getTitle', [null, $Google_Event])); - $this->assertEquals('Unit Test Event', $object->callMethod('getTitle', [$CRM_Meeting, null])); - $this->assertEquals('UNNAMED RECORD', $object->callMethod('getTitle', [null, null])); + self::assertEquals('Unit Test Event / Unit Test Event', $object->callMethod('getTitle', [$CRM_Meeting, $Google_Event])); + self::assertEquals('Unit Test Event', $object->callMethod('getTitle', [$CRM_Meeting, null])); + self::assertEquals('Unit Test Event', $object->callMethod('getTitle', [null, $Google_Event])); + self::assertEquals('Unit Test Event', $object->callMethod('getTitle', [$CRM_Meeting, null])); + self::assertEquals('UNNAMED RECORD', $object->callMethod('getTitle', [null, null])); } /** * * */ - public function testDoAction() + public function testDoAction(): void { $object = new GoogleSyncMock($this->getFakeSugarConfig('{"web":"test"}')); try { $object->callMethod('doAction', ['INVALID']); - $this->assertTrue(false, 'It should throws an exception.'); + self::assertTrue(false, 'It should throws an exception.'); } catch (GoogleSyncException $e) { - $this->assertEquals(GoogleSyncException::INVALID_ACTION, $e->getCode()); + self::assertEquals(GoogleSyncException::INVALID_ACTION, $e->getCode()); } try { $object->callMethod('doAction', ['push']); - $this->assertTrue(false, 'It should throws an exception.'); + self::assertTrue(false, 'It should throws an exception.'); } catch (InvalidArgumentException $e) { - $this->assertTrue(true, 'It should be an InvalidArgumentException as a first parameter of GoogleSyncBase::pushEvent() should be an instance of meeting but this test implacate that it is null.'); + self::assertTrue(true, 'It should be an InvalidArgumentException as a first parameter of GoogleSyncBase::pushEvent() should be an instance of meeting but this test implacate that it is null.'); } try { $object->callMethod('doAction', ['pull']); - $this->assertTrue(false, 'It should throws an exception.'); + self::assertTrue(false, 'It should throws an exception.'); } catch (InvalidArgumentException $e) { - $this->assertTrue(true, 'It should be an InvalidArgumentException as a first parameter of GoogleSyncBase::pullEvent() should be an instance of Google_Service_Calendar_Event but this test implacate that it is null.'); + self::assertTrue(true, 'It should be an InvalidArgumentException as a first parameter of GoogleSyncBase::pullEvent() should be an instance of Google_Service_Calendar_Event but this test implacate that it is null.'); } $CRM_Meeting = BeanFactory::getBean('Meetings'); @@ -824,35 +796,35 @@ class GoogleSyncTest extends SuitePHPUnitFrameworkTestCase try { $object->callMethod('doAction', ['push_delete', $CRM_Meeting, null]); - $this->assertTrue(false, 'It should throws an exception.'); + self::assertTrue(false, 'It should throws an exception.'); } catch (InvalidArgumentException $e) { - $this->assertTrue(true, 'It should be an InvalidArgumentException as a first parameter of GoogleSyncBase::delEvent() should be an instance of Google_Service_Calendar_Event but this test implacate that it is null.'); + self::assertTrue(true, 'It should be an InvalidArgumentException as a first parameter of GoogleSyncBase::delEvent() should be an instance of Google_Service_Calendar_Event but this test implacate that it is null.'); } try { $object->callMethod('doAction', ['pull_delete']); - $this->assertTrue(false, 'It should throws an exception.'); + self::assertTrue(false, 'It should throws an exception.'); } catch (InvalidArgumentException $e) { - $this->assertTrue(true, 'It should be an InvalidArgumentException as a first parameter of GoogleSyncBase::delMeeting() should be an instance of Meeting but this test implacate that it is null.'); + self::assertTrue(true, 'It should be an InvalidArgumentException as a first parameter of GoogleSyncBase::delMeeting() should be an instance of Meeting but this test implacate that it is null.'); } $return = $object->callMethod('doAction', ['skip']); - $this->assertEquals(true, $return); + self::assertEquals(true, $return); } /** * * */ - public function testDoSync() + public function testDoSync(): void { $object = new GoogleSyncMock($this->getFakeSugarConfig('{"web":"test"}')); try { $object->callMethod('doSync', [null]); - $this->assertTrue(false, 'It should throws an exception.'); + self::assertTrue(false, 'It should throws an exception.'); } catch (GoogleSyncException $e) { - $this->assertEquals(GoogleSyncException::INVALID_CLIENT_ID, $e->getCode()); + self::assertEquals(GoogleSyncException::INVALID_CLIENT_ID, $e->getCode()); } } @@ -860,20 +832,20 @@ class GoogleSyncTest extends SuitePHPUnitFrameworkTestCase * * */ - public function testAddUser() + public function testAddUser(): void { $object = new GoogleSyncMock($this->getFakeSugarConfig('{"web":"test"}')); $return = $object->callMethod('addUser', ['ABC123', 'End User']); - $this->assertTrue($return); - $this->assertArrayHasKey('ABC123', $object->getProperty('users')); + self::assertTrue($return); + self::assertArrayHasKey('ABC123', $object->getProperty('users')); } /** * * */ - public function testPushPullSkip() + public function testPushPullSkip(): void { $object = new GoogleSyncMock($this->getFakeSugarConfig('{"web":"test"}')); @@ -896,22 +868,22 @@ class GoogleSyncTest extends SuitePHPUnitFrameworkTestCase $Google_Event->setStart($startDateTime); // Test with just an active Meeting. Should return 'push' - $this->assertEquals('push', $object->callMethod('pushPullSkip', [$CRM_Meeting, null])); + self::assertEquals('push', $object->callMethod('pushPullSkip', [$CRM_Meeting, null])); // Test with just deleted Meeting. Should return 'skip' $CRM_Meeting->deleted = '1'; - $this->assertEquals('skip', $object->callMethod('pushPullSkip', [$CRM_Meeting, null])); + self::assertEquals('skip', $object->callMethod('pushPullSkip', [$CRM_Meeting, null])); // Test with just an active Google Event. Should return 'pull' - $this->assertEquals('pull', $object->callMethod('pushPullSkip', [null, $Google_Event])); + self::assertEquals('pull', $object->callMethod('pushPullSkip', [null, $Google_Event])); // Test with just a canceled Google Event. Should return 'skip' $Google_Event->status = 'cancelled'; - $this->assertEquals('skip', $object->callMethod('pushPullSkip', [null, $Google_Event])); + self::assertEquals('skip', $object->callMethod('pushPullSkip', [null, $Google_Event])); // Test compare both Meeting & Event, but both deleted. Should return 'skip' - $this->assertEquals('skip', $object->callMethod('pushPullSkip', [$CRM_Meeting, $Google_Event])); + self::assertEquals('skip', $object->callMethod('pushPullSkip', [$CRM_Meeting, $Google_Event])); // Set records to active $CRM_Meeting->deleted = '0'; @@ -921,20 +893,20 @@ class GoogleSyncTest extends SuitePHPUnitFrameworkTestCase $CRM_Meeting->fetched_row['date_modified'] = '2018-01-02 12:00:00'; $CRM_Meeting->fetched_row['gsync_lastsync'] = strtotime('2018-01-01 13:00:00 UTC'); $Google_Event->updated = '2018-01-01 12:00:00 UTC'; - $this->assertEquals('push', $object->callMethod('pushPullSkip', [$CRM_Meeting, $Google_Event])); + self::assertEquals('push', $object->callMethod('pushPullSkip', [$CRM_Meeting, $Google_Event])); // Test with newer Google Event. Should return 'pull' $CRM_Meeting->fetched_row['date_modified'] = '2018-01-01 12:00:00'; $CRM_Meeting->fetched_row['gsync_lastsync'] = strtotime('2018-01-01 13:00:00 UTC'); $Google_Event->updated = '2018-01-02 12:00:00 UTC'; - $this->assertEquals('pull', $object->callMethod('pushPullSkip', [$CRM_Meeting, $Google_Event])); + self::assertEquals('pull', $object->callMethod('pushPullSkip', [$CRM_Meeting, $Google_Event])); // Test with newer, deleted meeting. Should return 'push_delete' $CRM_Meeting->deleted = '1'; $CRM_Meeting->fetched_row['date_modified'] = '2018-01-03 12:00:00'; $CRM_Meeting->fetched_row['gsync_lastsync'] = strtotime('2018-01-02 12:00:00 UTC'); $Google_Event->updated = '2018-01-01 12:00:00 UTC'; - $this->assertEquals('push_delete', $object->callMethod('pushPullSkip', [$CRM_Meeting, $Google_Event])); + self::assertEquals('push_delete', $object->callMethod('pushPullSkip', [$CRM_Meeting, $Google_Event])); $CRM_Meeting->deleted = '0'; // Test with newer, deleted Google Event Should return 'pull_delete' @@ -942,7 +914,7 @@ class GoogleSyncTest extends SuitePHPUnitFrameworkTestCase $CRM_Meeting->fetched_row['date_modified'] = '2018-01-01 12:00:00'; $CRM_Meeting->fetched_row['gsync_lastsync'] = strtotime('2018-01-01 13:00:00 UTC'); $Google_Event->updated = '2018-01-02 12:00:00 UTC'; - $this->assertEquals('pull_delete', $object->callMethod('pushPullSkip', [$CRM_Meeting, $Google_Event])); + self::assertEquals('pull_delete', $object->callMethod('pushPullSkip', [$CRM_Meeting, $Google_Event])); $Google_Event->status = ''; // Set records to active @@ -953,14 +925,14 @@ class GoogleSyncTest extends SuitePHPUnitFrameworkTestCase $CRM_Meeting->fetched_row['date_modified'] = '2018-01-01 12:00:00'; $CRM_Meeting->fetched_row['gsync_lastsync'] = strtotime('2018-01-01 13:00:00 UTC'); $Google_Event->updated = '2018-01-01 12:00:00 UTC'; - $this->assertEquals('skip', $object->callMethod('pushPullSkip', [$CRM_Meeting, $Google_Event])); + self::assertEquals('skip', $object->callMethod('pushPullSkip', [$CRM_Meeting, $Google_Event])); } /** * * */ - public function testSetSyncUsers() + public function testSetSyncUsers(): void { // base64 encoded of {"web":"test"} $json = 'eyJ3ZWIiOiJ0ZXN0In0='; @@ -974,7 +946,7 @@ class GoogleSyncTest extends SuitePHPUnitFrameworkTestCase $cnt = $row['cnt']; break; } - $this->assertEquals(1, $cnt); + self::assertEquals(1, $cnt); $user1 = BeanFactory::getBean('Users'); $user1->last_name = 'UNIT_TESTS1'; @@ -982,7 +954,7 @@ class GoogleSyncTest extends SuitePHPUnitFrameworkTestCase $user1->full_name = 'UNIT_TESTS1'; $user1->save(false); $validator = new SuiteValidator(); - $this->assertTrue($validator->isValidId($id1 = $user1->id)); + self::assertTrue($validator->isValidId($id1 = $user1->id)); $user1->setPreference('GoogleApiToken', $json, false, 'GoogleSync'); $user1->setPreference('syncGCal', 1, 0, 'GoogleSync'); $user1->savePreferencesToDB(); @@ -995,19 +967,19 @@ class GoogleSyncTest extends SuitePHPUnitFrameworkTestCase $cnt = $row['cnt']; break; } - $this->assertEquals(2, $cnt); + self::assertEquals(2, $cnt); $user2 = BeanFactory::getBean('Users'); $user2->last_name = 'UNIT_TESTS2'; $user2->user_name = 'UNIT_TESTS2'; $user2->full_name = 'UNIT_TESTS2'; $user2->save(false); - $this->assertTrue($validator->isValidId($id2 = $user2->id)); + self::assertTrue($validator->isValidId($id2 = $user2->id)); $user2->setPreference('GoogleApiToken', $json, false, 'GoogleSync'); $user2->setPreference('syncGCal', 1, 0, 'GoogleSync'); $user2->savePreferencesToDB(); - $this->assertNotSame($id1, $id2); + self::assertNotSame($id1, $id2); $query = "SELECT COUNT(*) AS cnt FROM users"; $db = DBManagerFactory::getInstance(); @@ -1016,12 +988,12 @@ class GoogleSyncTest extends SuitePHPUnitFrameworkTestCase $cnt = $row['cnt']; break; } - $this->assertEquals(3, $cnt); + self::assertEquals(3, $cnt); $object = new GoogleSyncMock($this->getFakeSugarConfig('{"web":"test"}')); $tempData = []; $countOfSyncUsers = $object->callMethod('setSyncUsers', [&$tempData]); - $this->assertSame([ + self::assertSame([ 'founds' => 3, 'results' => [ ['notEmpty' => false], @@ -1040,19 +1012,18 @@ class GoogleSyncTest extends SuitePHPUnitFrameworkTestCase ], ], $tempData); - $this->assertGreaterThanOrEqual(2, $countOfSyncUsers); // TODO: check how many user should be counted!? + self::assertGreaterThanOrEqual(2, $countOfSyncUsers); // TODO: check how many user should be counted!? } /** * * */ - public function testSyncAllUsers() + public function testSyncAllUsers(): void { - $object = new GoogleSyncMock($this->getFakeSugarConfig('{"web":"test"}')); - $ret = $object->syncAllUsers(); + $ret = (new GoogleSyncMock($this->getFakeSugarConfig('{"web":"test"}')))->syncAllUsers(); // TODO: it needs more test - $this->assertEquals(true, $ret); + self::assertEquals(true, $ret); } //GoogleSyncHelper.php @@ -1061,12 +1032,10 @@ class GoogleSyncTest extends SuitePHPUnitFrameworkTestCase * * */ - public function testSingleEventAction() + public function testSingleEventAction(): void { - $helper = new GoogleSyncHelper; - - $ret1 = $helper->singleEventAction(null, null); - $this->assertEquals(false, $ret1); + $ret1 = (new GoogleSyncHelper)->singleEventAction(null, null); + self::assertEquals(false, $ret1); // The rest of this method is tested by testPushPullSkip } @@ -1074,7 +1043,7 @@ class GoogleSyncTest extends SuitePHPUnitFrameworkTestCase * * */ - public function testGetTimeStrings() + public function testGetTimeStrings(): void { $helper = new GoogleSyncHelper; @@ -1102,34 +1071,16 @@ class GoogleSyncTest extends SuitePHPUnitFrameworkTestCase $ret = $helper->getTimeStrings($CRM_Meeting, $Google_Event); - $this->assertEquals('1514808000', $ret['gModified']); - $this->assertEquals('1514808000', $ret['sModified']); - $this->assertEquals('1514808000', $ret['lastSync']); + self::assertEquals('1514808000', $ret['gModified']); + self::assertEquals('1514808000', $ret['sModified']); + self::assertEquals('1514808000', $ret['lastSync']); } /** * * */ - public function testGetNewestMeetingResponse() - { -// $this->markTestIncomplete('TODO: Implement Tests'); - } - - /** - * - * - */ - public function testCreateSuitecrmReminders() - { -// $this->markTestIncomplete('TODO: Implement Tests'); - } - - /** - * - * - */ - public function testWipeLocalSyncData() + public function testWipeLocalSyncData(): void { // Create a User $user = BeanFactory::getBean('Users'); @@ -1159,8 +1110,8 @@ class GoogleSyncTest extends SuitePHPUnitFrameworkTestCase $query = "SELECT gsync_id, gsync_lastsync FROM meetings WHERE id = {$db->quoted($meeting_id)}"; $result = $db->query($query); $row = $db->fetchByAssoc($result); - $this->assertEquals('GSYNCID', $row['gsync_id']); - $this->assertEquals('1234567890', $row['gsync_lastsync']); + self::assertEquals('GSYNCID', $row['gsync_id']); + self::assertEquals('1234567890', $row['gsync_lastsync']); // Call the tested function to wipe the gsync data $helper = new GoogleSyncHelper; @@ -1169,7 +1120,7 @@ class GoogleSyncTest extends SuitePHPUnitFrameworkTestCase // Check the raw DB values $result = $db->query($query); $row = $db->fetchByAssoc($result); - $this->assertEquals('', $row['gsync_id']); - $this->assertEquals('', $row['gsync_lastsync']); + self::assertEquals('', $row['gsync_id']); + self::assertEquals('', $row['gsync_lastsync']); } } diff --git a/tests/unit/phpunit/include/Imap/ImapHandlerFactoryTest.php b/tests/unit/phpunit/includes/Imap/ImapHandlerFactoryTest.php similarity index 82% rename from tests/unit/phpunit/include/Imap/ImapHandlerFactoryTest.php rename to tests/unit/phpunit/includes/Imap/ImapHandlerFactoryTest.php index 3c39dd802..4462c733d 100644 --- a/tests/unit/phpunit/include/Imap/ImapHandlerFactoryTest.php +++ b/tests/unit/phpunit/includes/Imap/ImapHandlerFactoryTest.php @@ -56,70 +56,70 @@ class ImapHandlerFactoryTest extends SuitePHPUnitFrameworkTestCase /** * FAIL: invalid key argument for save test settings key */ - public function testSaveTestSettingsKeyInvalidKey() + public function testSaveTestSettingsKeyInvalidKey(): void { $factory = new ImapHandlerFactory(); - + try { $factory->saveTestSettingsKey(null); - $this->assertTrue(false); + self::assertTrue(false); } catch (InvalidArgumentException $e) { - $this->assertTrue(true); + self::assertTrue(true); } - + try { $factory->saveTestSettingsKey(123); - $this->assertTrue(false); + self::assertTrue(false); } catch (InvalidArgumentException $e) { - $this->assertTrue(true); + self::assertTrue(true); } - + try { $factory->saveTestSettingsKey(''); - $this->assertTrue(false); + self::assertTrue(false); } catch (InvalidArgumentException $e) { - $this->assertTrue(true); + self::assertTrue(true); } } - + /** * FAIL: when key not found in calls settings file */ - public function testSaveTestSettingsKeyKeyNotFound() + public function testSaveTestSettingsKeyKeyNotFound(): void { $factory = new ImapHandlerFactory(); try { $factory->saveTestSettingsKey('foo'); - $this->assertTrue(false); + self::assertTrue(false); } catch (ImapHandlerException $e) { - $this->assertEquals(ImapHandlerException::ERR_KEY_NOT_FOUND, $e->getCode()); + self::assertEquals(ImapHandlerException::ERR_KEY_NOT_FOUND, $e->getCode()); } } - + /** * OK: should successfully saving a key */ - public function testSaveTestSettingsKeyOK() + public function testSaveTestSettingsKeyOK(): void { $settingsFile = __DIR__ . '/../../../../../include/Imap' . ImapHandlerFactory::SETTINGS_KEY_FILE; $factory = new ImapHandlerFactory(); $existsBefore = file_exists($settingsFile); - $this->assertFalse($existsBefore); + self::assertFalse($existsBefore); $results = $factory->saveTestSettingsKey('testCaseExample'); $existsAfter = file_exists($settingsFile); - $this->assertTrue($existsAfter); - $this->assertTrue($results); + self::assertTrue($existsAfter); + self::assertTrue($results); $factory->deleteTestSettings(); } - + /** * OK: should retrieves an ImapHandler */ - public function testGetImapHandlerOk() + public function testGetImapHandlerOk(): void { $factory = new ImapHandlerFactory(); $results = $factory->getImapHandler(); - $this->assertInstanceOf(ImapHandlerInterface::class, $results); + self::assertInstanceOf(ImapHandlerInterface::class, $results); $factory->deleteTestSettings(); } } diff --git a/tests/unit/phpunit/include/Imap/ImapTestSettingsEntryHandlerTest.php b/tests/unit/phpunit/includes/Imap/ImapTestSettingsEntryHandlerTest.php similarity index 77% rename from tests/unit/phpunit/include/Imap/ImapTestSettingsEntryHandlerTest.php rename to tests/unit/phpunit/includes/Imap/ImapTestSettingsEntryHandlerTest.php index a0eb9884a..0ffe0e675 100644 --- a/tests/unit/phpunit/include/Imap/ImapTestSettingsEntryHandlerTest.php +++ b/tests/unit/phpunit/includes/Imap/ImapTestSettingsEntryHandlerTest.php @@ -53,54 +53,52 @@ require_once __DIR__ . '/../../../../../include/Imap/ImapTestSettingsEntryHandle */ class ImapTestSettingsEntryHandlerTest extends SuitePHPUnitFrameworkTestCase { - + /** * FAIL: sugar_config parameter does not contains imap_test */ - public function testHandleEntryPointRequestWrongConfig() + public function testHandleEntryPointRequestWrongConfig(): void { $handler = new ImapTestSettingsEntryHandler(); try { $handler->handleEntryPointRequest([], []); - $this->assertTrue(false); + self::assertTrue(false); } catch (InvalidArgumentException $e) { - $this->assertTrue(true); + self::assertTrue(true); } } - + /** * FAIL: $_REQUEST does not contains imap_test_settings */ - public function testHandleEntryPointRequestWrongRequest() + public function testHandleEntryPointRequestWrongRequest(): void { $handler = new ImapTestSettingsEntryHandler(); try { $handler->handleEntryPointRequest(['imap_test' => 'foo'], []); - $this->assertTrue(false); + self::assertTrue(false); } catch (InvalidArgumentException $e) { - $this->assertTrue(true); + self::assertTrue(true); } } - + /** * FAIL: Key not found.; key was: "bar" */ - public function testHandleEntryPointRequestWrongKey() + public function testHandleEntryPointRequestWrongKey(): void { - $handler = new ImapTestSettingsEntryHandler(); - $results = $handler->handleEntryPointRequest(['imap_test' => 'foo'], ['imap_test_settings' => 'bar']); - $this->assertEquals('ERROR: Key not found.; key was: "bar".', $results); + $results = (new ImapTestSettingsEntryHandler())->handleEntryPointRequest(['imap_test' => 'foo'], ['imap_test_settings' => 'bar']); + self::assertEquals('ERROR: Key not found.; key was: "bar".', $results); } - + /** * OK: should returns a success output from entry point handling. */ - public function testHandleEntryPointRequest() + public function testHandleEntryPointRequest(): void { $settingsFile = __DIR__ . '/../../../../../include/Imap' . ImapHandlerFactory::SETTINGS_KEY_FILE; - $handler = new ImapTestSettingsEntryHandler(); - $results = $handler->handleEntryPointRequest(['imap_test' => 'foo'], ['imap_test_settings' => 'testCaseExample']); - $this->assertEquals('OK: test settings changed to "testCaseExample"', $results); - $this->assertTrue(unlink($settingsFile)); + $results = (new ImapTestSettingsEntryHandler())->handleEntryPointRequest(['imap_test' => 'foo'], ['imap_test_settings' => 'testCaseExample']); + self::assertEquals('OK: test settings changed to "testCaseExample"', $results); + self::assertTrue(unlink($settingsFile)); } } diff --git a/tests/unit/phpunit/include/APIErrorObjectTest.php b/tests/unit/phpunit/includes/JsonApiErrorObjectTest.php similarity index 90% rename from tests/unit/phpunit/include/APIErrorObjectTest.php rename to tests/unit/phpunit/includes/JsonApiErrorObjectTest.php index 5c057f482..c27b9fe02 100644 --- a/tests/unit/phpunit/include/APIErrorObjectTest.php +++ b/tests/unit/phpunit/includes/JsonApiErrorObjectTest.php @@ -1,12 +1,11 @@ [], ]; $actual = $error->export(); - $this->assertEquals($expected, $actual, 'API Error Object constructor error: Incorrect default state.'); + self::assertEquals($expected, $actual, 'API Error Object constructor error: Incorrect default state.'); global $app_strings; $app_strings['LBL_TEST_LABEL_TITLE'] = 'A title'; @@ -116,10 +112,10 @@ class JsonApiErrorObjectTest extends SuitePHPUnitFrameworkTestCase 'meta' => ['some' => 'meta info'], ]; $actual = $error->export(); - $this->assertEquals($expected, $actual, 'API Error Object constructor error: Incorrect state set.'); + self::assertEquals($expected, $actual, 'API Error Object constructor error: Incorrect state set.'); } - public function testRetrieveFromException() + public function testRetrieveFromException(): void { $error = new JsonApiErrorObject(); @@ -149,6 +145,6 @@ class JsonApiErrorObjectTest extends SuitePHPUnitFrameworkTestCase unset($actual['meta']['debug']); } - $this->assertEquals($expected, $actual, 'API Error Object retrive error from exception.'); + self::assertEquals($expected, $actual, 'API Error Object retrive error from exception.'); } } diff --git a/tests/unit/phpunit/include/LangExceptionTest.php b/tests/unit/phpunit/includes/LangExceptionTest.php similarity index 91% rename from tests/unit/phpunit/include/LangExceptionTest.php rename to tests/unit/phpunit/includes/LangExceptionTest.php index 7387a2307..b6f5aca4f 100644 --- a/tests/unit/phpunit/include/LangExceptionTest.php +++ b/tests/unit/phpunit/includes/LangExceptionTest.php @@ -5,7 +5,7 @@ * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. * * SuiteCRM is an extension to SugarCRM Community Edition developed by SalesAgility Ltd. - * Copyright (C) 2011 - 2018 SalesAgility Ltd. + * Copyright (C) 2011 - 2021 SalesAgility Ltd. * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU Affero General Public License version 3 as published by the @@ -38,6 +38,8 @@ * display the words "Powered by SugarCRM" and "Supercharged by SuiteCRM". */ +namespace SuiteCRM\Tests\Unit\includes; + use SuiteCRM\LangException; use SuiteCRM\LangText; use SuiteCRM\Test\SuitePHPUnitFrameworkTestCase; @@ -46,11 +48,9 @@ if (!defined('sugarEntry') || !sugarEntry) { die('Not A Valid Entry Point'); } - /** - * LangExceptionTest - * - * @author gyula + * Class LangExceptionTest + * @package SuiteCRM\Tests\Unit */ class LangExceptionTest extends SuitePHPUnitFrameworkTestCase { @@ -78,17 +78,12 @@ class LangExceptionTest extends SuitePHPUnitFrameworkTestCase include_once __DIR__ . '/../../../../include/LangException.php'; } - protected function tearDown(): void - { - parent::tearDown(); - } - - public function testGetLangMessage() + public function testGetLangMessage(): void { global $app_strings; $app_strings['LBL_LANG_TEST_LABEL'] = 'Lang text with {variable} in text'; $e = new LangException('Test message', 123, null, new LangText('LBL_LANG_TEST_LABEL', ['variable' => 'foo'])); $langMessage = $e->getLangMessage(); - $this->assertEquals('Lang text with foo in text', $langMessage, 'Incorrect translation for LangException message'); + self::assertEquals('Lang text with foo in text', $langMessage, 'Incorrect translation for LangException message'); } } diff --git a/tests/unit/phpunit/include/LangTextTest.php b/tests/unit/phpunit/includes/LangTextTest.php similarity index 74% rename from tests/unit/phpunit/include/LangTextTest.php rename to tests/unit/phpunit/includes/LangTextTest.php index 301df5538..712935f58 100644 --- a/tests/unit/phpunit/include/LangTextTest.php +++ b/tests/unit/phpunit/includes/LangTextTest.php @@ -1,12 +1,11 @@ 'bar', 'bar' => 'baz'], LangText::USING_APP_STRINGS); $output = $text->getText(); - $this->assertEquals('test app string bar baz', $output, 'Incorrect translation (1)'); + self::assertEquals('test app string bar baz', $output, 'Incorrect translation (1)'); try { $text = new LangText('LBL_TEST_MOD_STRING', ['foo' => 'bar', 'bar' => 'baz'], LangText::USING_APP_STRINGS); $output = $text->getText(); - $this->assertTrue(false, 'Incorrect translation (2) - A language key should not found: [LBL_TEST_MOD_STRING] (1)'); + self::assertTrue(false, 'Incorrect translation (2) - A language key should not found: [LBL_TEST_MOD_STRING] (1)'); } catch (ErrorMessageException $e) { - $this->assertTrue(true, 'Incorrect translation (2) - A language key should not found: [LBL_TEST_MOD_STRING] (2)'); + self::assertTrue(true, 'Incorrect translation (2) - A language key should not found: [LBL_TEST_MOD_STRING] (2)'); } try { $text = new LangText('LBL_TEST_APP_STRING', ['foo' => 'bar', 'bar' => 'baz'], LangText::USING_MOD_STRINGS); $output = $text->getText(); - $this->assertTrue(false, 'Incorrect translation (3) - A language key should not found: [LBL_TEST_APP_STRING] (1)'); + self::assertTrue(false, 'Incorrect translation (3) - A language key should not found: [LBL_TEST_APP_STRING] (1)'); } catch (ErrorMessageException $e) { - $this->assertTrue(true, 'Incorrect translation (3) - A language key should not found: [LBL_TEST_APP_STRING] (2)'); + self::assertTrue(true, 'Incorrect translation (3) - A language key should not found: [LBL_TEST_APP_STRING] (2)'); } $text = new LangText('LBL_TEST_MOD_STRING', ['foo' => 'bar', 'bar' => 'baz'], LangText::USING_MOD_STRINGS); $output = $text->getText(); - $this->assertEquals('test mod string bar baz', $output, 'Incorrect translation (4)'); + self::assertEquals('test mod string bar baz', $output, 'Incorrect translation (4)'); $text = new LangText('LBL_TEST_APP_STRING', ['foo' => 'bar', 'bar' => 'baz'], LangText::USING_ALL_STRINGS); $output = $text->getText(); - $this->assertEquals('test app string bar baz', $output, 'Incorrect translation (5)'); + self::assertEquals('test app string bar baz', $output, 'Incorrect translation (5)'); $text = new LangText('LBL_TEST_MOD_STRING', ['foo' => 'bar', 'bar' => 'baz'], LangText::USING_ALL_STRINGS); $output = $text->getText(); - $this->assertEquals('test mod string bar baz', $output, 'Incorrect translation (6)'); + self::assertEquals('test mod string bar baz', $output, 'Incorrect translation (6)'); $text = new LangText(); $output = $text->getText('LBL_TEST_APP_STRING', ['foo' => 'bar', 'bar' => 'baz'], LangText::USING_APP_STRINGS); - $this->assertEquals('test app string bar baz', $output, 'Incorrect translation (7)'); + self::assertEquals('test app string bar baz', $output, 'Incorrect translation (7)'); try { $text = new LangText(); $output = $text->getText('LBL_TEST_MOD_STRING', ['foo' => 'bar', 'bar' => 'baz'], LangText::USING_APP_STRINGS); - $this->assertTrue(false, 'Incorrect translation (8) - A language key should not found: [LBL_TEST_MOD_STRING] (1)'); + self::assertTrue(false, 'Incorrect translation (8) - A language key should not found: [LBL_TEST_MOD_STRING] (1)'); } catch (ErrorMessageException $e) { - $this->assertTrue(true, 'Incorrect translation (8) - A language key should not found: [LBL_TEST_MOD_STRING] (2)'); + self::assertTrue(true, 'Incorrect translation (8) - A language key should not found: [LBL_TEST_MOD_STRING] (2)'); } try { $text = new LangText(); $output = $text->getText('LBL_TEST_APP_STRING', ['foo' => 'bar', 'bar' => 'baz'], LangText::USING_MOD_STRINGS); - $this->assertTrue(false, 'Incorrect translation (9) - A language key should not found: [LBL_TEST_APP_STRING] (1)'); + self::assertTrue(false, 'Incorrect translation (9) - A language key should not found: [LBL_TEST_APP_STRING] (1)'); } catch (ErrorMessageException $e) { - $this->assertTrue(true, 'Incorrect translation (9) - A language key should not found: [LBL_TEST_APP_STRING] (2)'); + self::assertTrue(true, 'Incorrect translation (9) - A language key should not found: [LBL_TEST_APP_STRING] (2)'); } $text = new LangText(); $output = $text->getText('LBL_TEST_MOD_STRING', ['foo' => 'bar', 'bar' => 'baz'], LangText::USING_MOD_STRINGS); - $this->assertEquals('test mod string bar baz', $output, 'Incorrect translation (10)'); + self::assertEquals('test mod string bar baz', $output, 'Incorrect translation (10)'); $text = new LangText(); $output = $text->getText('LBL_TEST_APP_STRING', ['foo' => 'bar', 'bar' => 'baz'], LangText::USING_ALL_STRINGS); - $this->assertEquals('test app string bar baz', $output, 'Incorrect translation (11)'); + self::assertEquals('test app string bar baz', $output, 'Incorrect translation (11)'); $text = new LangText(); $output = $text->getText('LBL_TEST_MOD_STRING', ['foo' => 'bar', 'bar' => 'baz'], LangText::USING_ALL_STRINGS); - $this->assertEquals('test mod string bar baz', $output, 'Incorrect translation (12)'); + self::assertEquals('test mod string bar baz', $output, 'Incorrect translation (12)'); } } diff --git a/tests/unit/phpunit/include/Localization/LocalizationTest.php b/tests/unit/phpunit/includes/Localization/LocalizationTest.php similarity index 100% rename from tests/unit/phpunit/include/Localization/LocalizationTest.php rename to tests/unit/phpunit/includes/Localization/LocalizationTest.php diff --git a/tests/unit/phpunit/includes/MVC/Controller/ControllerFactoryTest.php b/tests/unit/phpunit/includes/MVC/Controller/ControllerFactoryTest.php new file mode 100644 index 000000000..7135208b1 --- /dev/null +++ b/tests/unit/phpunit/includes/MVC/Controller/ControllerFactoryTest.php @@ -0,0 +1,63 @@ +module; //first test with empty parameter and check for default values being used $SugarController->setup(''); - $this->assertAttributeEquals($default_module, 'module', $SugarController); - $this->assertAttributeEquals(null, 'target_module', $SugarController); + self::assertEquals($default_module, $SugarController->module); + self::assertEquals(null, $SugarController->target_module); //secondly test with module name and check for correct assignment. $SugarController->setup('Users'); - $this->assertAttributeEquals('Users', 'module', $SugarController); - $this->assertAttributeEquals(null, 'target_module', $SugarController); + self::assertEquals('Users', $SugarController->module); + self::assertEquals(null, $SugarController->target_module); } - public function testsetModule() + public function testsetModule(): void { $SugarController = new SugarController(); //first test with empty parameter $SugarController->setModule(''); - $this->assertAttributeEquals('', 'module', $SugarController); + self::assertEquals('', $SugarController->module); //secondly test with module name and check for correct assignment. $SugarController->setModule('Users'); - $this->assertAttributeEquals('Users', 'module', $SugarController); + self::assertEquals('Users', $SugarController->module); } - public function testloadBean() + public function testloadBean(): void { $SugarController = new SugarController(); //first test with empty parameter and check for null. Default is Home but Home has no bean $SugarController->setModule(''); $SugarController->loadBean(); - $this->assertEquals(null, $SugarController->bean); + self::assertEquals(null, $SugarController->bean); //secondly test with module name and check for correct bean class loaded. $SugarController->setModule('Users'); $SugarController->loadBean(); - $this->assertInstanceOf('User', $SugarController->bean); + self::assertInstanceOf('User', $SugarController->bean); } - public function testexecute() + public function testexecute(): void { // suppress output during the test - $this->setOutputCallback(function () {}); + $this->setOutputCallback(function () { + }); // test $SugarController = new SugarController(); @@ -77,7 +115,7 @@ class SugarControllerTest extends SuitePHPUnitFrameworkTestCase try { $SugarController->execute(); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } // change back to original logger @@ -85,10 +123,10 @@ class SugarControllerTest extends SuitePHPUnitFrameworkTestCase $GLOBALS['log'] = $logger; // exam log - $this->assertTrue(true); + self::assertTrue(true); } - public function testprocess() + public function testprocess(): void { $SugarController = new SugarController(); @@ -96,13 +134,13 @@ class SugarControllerTest extends SuitePHPUnitFrameworkTestCase try { $SugarController->process(); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } - $this->assertTrue(true); + self::assertTrue(true); } - public function testpre_save() + public function testpre_save(): void { if (isset($_SESSION)) { $session = $_SESSION; @@ -110,8 +148,7 @@ class SugarControllerTest extends SuitePHPUnitFrameworkTestCase $testUserId = 1; $query = "SELECT date_modified FROM users WHERE id = '$testUserId' LIMIT 1"; - $resource = DBManagerFactory::getInstance()->query($query); - $row = $resource->fetch_assoc(); + $row = DBManagerFactory::getInstance()->query($query)->fetch_assoc(); $testUserDateModified = $row['date_modified']; @@ -125,10 +162,10 @@ class SugarControllerTest extends SuitePHPUnitFrameworkTestCase try { $SugarController->pre_save(); } catch (Exception $e) { - $this->assertStringStartsWith('mysqli_query()', $e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::assertStringStartsWith('mysqli_query()', $e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } - $this->assertTrue(true); + self::assertTrue(true); // cleanup if (isset($session)) { @@ -141,7 +178,7 @@ class SugarControllerTest extends SuitePHPUnitFrameworkTestCase DBManagerFactory::getInstance()->query($query); } - public function testaction_save() + public function testaction_save(): void { if (isset($_SESSION)) { $session = $_SESSION; @@ -149,8 +186,7 @@ class SugarControllerTest extends SuitePHPUnitFrameworkTestCase $testUserId = 1; $query = "SELECT date_modified FROM users WHERE id = '$testUserId' LIMIT 1"; - $resource = DBManagerFactory::getInstance()->query($query); - $row = $resource->fetch_assoc(); + $row = DBManagerFactory::getInstance()->query($query)->fetch_assoc(); $testUserDateModified = $row['date_modified']; $SugarController = new SugarController(); @@ -162,12 +198,12 @@ class SugarControllerTest extends SuitePHPUnitFrameworkTestCase //Fail if it throws any other exception. try { $SugarController->action_save(); - $this->assertTrue(false); + self::assertTrue(false); } catch (Exception $e) { - $this->assertTrue(true); + self::assertTrue(true); } - $this->assertTrue(true); + self::assertTrue(true); // cleanup if (isset($session)) { @@ -180,43 +216,55 @@ class SugarControllerTest extends SuitePHPUnitFrameworkTestCase DBManagerFactory::getInstance()->query($query); } - public function testaction_spot() + public function testaction_spot(): void { $SugarController = new SugarController(); // check with default value of attribute - $this->assertAttributeEquals('classic', 'view', $SugarController); + self::assertEquals('classic', $SugarController->view); // check for attribute value change on method execution. $SugarController->action_spot(); - $this->assertAttributeEquals('spot', 'view', $SugarController); + self::assertEquals('spot', $SugarController->view); } - public function testgetActionFilename() + public function testgetActionFilename(): void { // check with an invalid value $action = SugarController::getActionFilename(''); - $this->assertEquals('', $action); + self::assertEquals('', $action); // check with a valid value $action = SugarController::getActionFilename('editview'); - $this->assertEquals('EditView', $action); + self::assertEquals('EditView', $action); } - public function testcheckEntryPointRequiresAuth() + public function testcheckEntryPointRequiresAuth(): void { $SugarController = new SugarController(); // check with a invalid value $result = $SugarController->checkEntryPointRequiresAuth(''); - $this->assertTrue($result); + self::assertTrue($result); // check with a valid True value $result = $SugarController->checkEntryPointRequiresAuth('download'); - $this->assertTrue($result); + self::assertTrue($result); // check with a valid False value $result = $SugarController->checkEntryPointRequiresAuth('GeneratePassword'); - $this->assertFalse($result); + self::assertFalse($result); + } + + protected function setUp(): void + { + parent::setUp(); + + global $current_user; + $current_user = BeanFactory::newBean('Users'); + get_sugar_config_defaults(); + if (!isset($GLOBALS['app']) || !$GLOBALS['app']) { + $GLOBALS['app'] = new SugarApplication(); + } } } diff --git a/tests/unit/phpunit/include/MVC/SugarApplicationTest.php b/tests/unit/phpunit/includes/MVC/SugarApplicationTest.php similarity index 58% rename from tests/unit/phpunit/include/MVC/SugarApplicationTest.php rename to tests/unit/phpunit/includes/MVC/SugarApplicationTest.php index 060a313ec..5ad24da5b 100644 --- a/tests/unit/phpunit/include/MVC/SugarApplicationTest.php +++ b/tests/unit/phpunit/includes/MVC/SugarApplicationTest.php @@ -1,55 +1,60 @@ markTestIncomplete('Cannot be implemented'); - - // execute the method and test if it works and does not throw an exception other than headers output exception. - // $SugarApplication = new SugarApplication(); - // try { - // $SugarApplication->execute(); - // } catch (Exception $e) { - // print_r($e->getMessage()); - // $this->assertStringStartsWith('Cannot modify header information', $e->getMessage()); - // } - } - - public function testloadUser() - { - $this->markTestIncomplete('Cannot be implemented because the method uses die.'); - - //cannot test this method as it uses die which stops execution of php unit as well - /* - //error_reporting(E_ERROR | E_PARSE); - - $SugarApplication = new SugarApplication(); - $SugarApplication->controller = new SugarController(); - - try { - $SugarApplication->loadUser(); - } - catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); - } - - $this->assertTrue(TRUE); - */ - } - - public function testACLFilter() + public function testACLFilter(): void { if (isset($_SESSION)) { $session = $_SESSION; @@ -61,10 +66,10 @@ class SugarApplicationTest extends SuitePHPUnitFrameworkTestCase try { $SugarApplication->ACLFilter(); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } - $this->assertTrue(true); + self::assertTrue(true); if (isset($session)) { $_SESSION = $session; @@ -73,7 +78,7 @@ class SugarApplicationTest extends SuitePHPUnitFrameworkTestCase } } - public function testsetupResourceManagement() + public function testsetupResourceManagement(): void { $SugarApplication = new SugarApplication(); @@ -81,20 +86,20 @@ class SugarApplicationTest extends SuitePHPUnitFrameworkTestCase try { $SugarApplication->setupResourceManagement(''); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } //execute the method with valid input and test if it works and does not throws an exception. try { $SugarApplication->setupResourceManagement('Users'); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } - $this->assertTrue(true); + self::assertTrue(true); } - public function testsetupPrint() + public function testsetupPrint(): void { $SugarApplication = new SugarApplication(); @@ -102,13 +107,13 @@ class SugarApplicationTest extends SuitePHPUnitFrameworkTestCase try { $SugarApplication->setupPrint(); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } - $this->assertTrue(true); + self::assertTrue(true); } - public function testpreProcess() + public function testpreProcess(): void { if (isset($_SESSION)) { $session = $_SESSION; @@ -121,10 +126,10 @@ class SugarApplicationTest extends SuitePHPUnitFrameworkTestCase try { $SugarApplication->preProcess(); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } - $this->assertTrue(true); + self::assertTrue(true); if (isset($session)) { $_SESSION = $session; @@ -133,7 +138,7 @@ class SugarApplicationTest extends SuitePHPUnitFrameworkTestCase } } - public function testhandleOfflineClient() + public function testhandleOfflineClient(): void { $SugarApplication = new SugarApplication(); @@ -141,13 +146,13 @@ class SugarApplicationTest extends SuitePHPUnitFrameworkTestCase try { $SugarApplication->handleOfflineClient(); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } - $this->assertTrue(true); + self::assertTrue(true); } - public function testhandleAccessControl() + public function testhandleAccessControl(): void { $SugarApplication = new SugarApplication(); $SugarApplication->controller = new SugarController(); @@ -155,28 +160,28 @@ class SugarApplicationTest extends SuitePHPUnitFrameworkTestCase $result = $SugarApplication->handleAccessControl(); //check that it returns Null - $this->assertEquals(null, $result); + self::assertEquals(null, $result); //check that controller->hasAccess is true i-e default setting. - $this->assertEquals(true, $SugarApplication->controller->hasAccess); + self::assertEquals(true, $SugarApplication->controller->hasAccess); } - public function testpreLoadLanguages() + public function testpreLoadLanguages(): void { try { SugarApplication::preLoadLanguages(); //check that method call got the current_language global variable set. - $this->assertTrue(isset($GLOBALS['current_language'])); + self::assertTrue(isset($GLOBALS['current_language'])); //check that method call got the app_strings global variable set. - $this->assertTrue(is_array($GLOBALS['app_strings']) && count($GLOBALS['app_strings']) > 0); + self::assertTrue(is_array($GLOBALS['app_strings']) && count($GLOBALS['app_strings']) > 0); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } } - public function testloadLanguages() + public function testloadLanguages(): void { $SugarApplication = new SugarApplication(); $SugarApplication->controller = new SugarController(); @@ -185,22 +190,22 @@ class SugarApplicationTest extends SuitePHPUnitFrameworkTestCase $SugarApplication->loadLanguages(); //check that method call got the current_language global variable set. - $this->assertTrue(isset($GLOBALS['current_language'])); + self::assertTrue(isset($GLOBALS['current_language'])); //check that method call got the app_strings global variable set. - $this->assertTrue(is_array($GLOBALS['app_strings']) && count($GLOBALS['app_strings']) > 0); + self::assertTrue(is_array($GLOBALS['app_strings']) && count($GLOBALS['app_strings']) > 0); //check that method call got the app_list_strings global variable set. - $this->assertTrue(is_array($GLOBALS['app_list_strings']) && count($GLOBALS['app_list_strings']) > 0); + self::assertTrue(is_array($GLOBALS['app_list_strings']) && count($GLOBALS['app_list_strings']) > 0); //check that method call got the mod_strings global variable set. - $this->assertTrue(is_array($GLOBALS['mod_strings']) && count($GLOBALS['mod_strings']) > 0); + self::assertTrue(is_array($GLOBALS['mod_strings']) && count($GLOBALS['mod_strings']) > 0); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } } - public function testcheckDatabaseVersion() + public function testcheckDatabaseVersion(): void { self::markTestIncomplete('environment dependency'); @@ -214,10 +219,10 @@ class SugarApplicationTest extends SuitePHPUnitFrameworkTestCase $GLOBALS['sugar_db_version'] = $sugar_db_version; $result = $SugarApplication->checkDatabaseVersion(false); - $this->assertTrue($result); + self::assertTrue($result); } - public function testloadDisplaySettings() + public function testloadDisplaySettings(): void { $SugarApplication = new SugarApplication(); @@ -225,13 +230,13 @@ class SugarApplicationTest extends SuitePHPUnitFrameworkTestCase try { $SugarApplication->loadDisplaySettings(); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } - $this->assertTrue(true); + self::assertTrue(true); } - public function testloadLicense() + public function testloadLicense(): void { $SugarApplication = new SugarApplication(); @@ -239,13 +244,13 @@ class SugarApplicationTest extends SuitePHPUnitFrameworkTestCase try { $SugarApplication->loadLicense(); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } - $this->assertTrue(true); + self::assertTrue(true); } - public function testloadGlobals() + public function testloadGlobals(): void { if (isset($_REQUEST)) { $request = $_REQUEST; @@ -258,10 +263,10 @@ class SugarApplicationTest extends SuitePHPUnitFrameworkTestCase try { $SugarApplication->loadGlobals(); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } - $this->assertTrue(true); + self::assertTrue(true); if (isset($request)) { @@ -271,9 +276,7 @@ class SugarApplicationTest extends SuitePHPUnitFrameworkTestCase } } - protected $sessionStartedOk = false; - - public function teststartSession() + public function teststartSession(): void { if (isset($_SESSION)) { $session = $_SESSION; @@ -291,10 +294,10 @@ class SugarApplicationTest extends SuitePHPUnitFrameworkTestCase } catch (Exception $e) { $err = $e->getMessage() . ' ' . $e->getCode() . ' ' . $e->getFile() . ' ' . $e->getLine() . ' ' . $e->getTraceAsString(); var_dump($err); - $this->fail($err); + self::fail($err); } - $this->assertTrue(true); + self::assertTrue(true); // cleanup if (isset($session)) { @@ -304,7 +307,7 @@ class SugarApplicationTest extends SuitePHPUnitFrameworkTestCase } } - public function testendSession() + public function testendSession(): void { $SugarApplication = new SugarApplication(); $SugarApplication->controller = new SugarController(); @@ -317,36 +320,13 @@ class SugarApplicationTest extends SuitePHPUnitFrameworkTestCase } catch (Exception $e) { $err = $e->getMessage() . ' ' . $e->getCode() . ' ' . $e->getFile() . ' ' . $e->getLine() . ' ' . $e->getTraceAsString(); var_dump($err); - $this->fail($err); + self::fail($err); } - $this->assertTrue(true); + self::assertTrue(true); } - public function testredirect() - { - $this->markTestIncomplete('Cannot be implemented due to use of exit().'); - //this method uses exit() which stops execution of phpunit as well so it cannot be tested without additional --process-isolation commandline parameter. - /* - $SugarApplication = new SugarApplication(); - - //execute the method and check if it works and doesn't throws an exception - try { - ob_start(); - - $SugarApplication->redirect(); - - $renderedContent = ob_get_contents(); - ob_end_clean(); - $this->assertGreaterThan(0,strlen($renderedContent)); - - } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); - } - */ - } - - public function testappendErrorMessage() + public function testappendErrorMessage(): void { if (isset($_SESSION)) { $session = $_SESSION; @@ -357,7 +337,7 @@ class SugarApplicationTest extends SuitePHPUnitFrameworkTestCase $_SESSION['user_error_message'] = []; $user_error_message_count = count($_SESSION['user_error_message']); SugarApplication::appendErrorMessage('some error'); - $this->assertGreaterThan($user_error_message_count, count($_SESSION['user_error_message'])); + self::assertGreaterThan($user_error_message_count, count($_SESSION['user_error_message'])); // cleanup if (isset($session)) { @@ -367,21 +347,21 @@ class SugarApplicationTest extends SuitePHPUnitFrameworkTestCase } } - public function testgetErrorMessages() + public function testgetErrorMessages(): void { //execute the method and check if it returns a array. $errorMessages = SugarApplication::getErrorMessages(); - $this->assertTrue(is_array($errorMessages)); + self::assertIsArray($errorMessages); } - public function testsetCookie() + public function testsetCookie(): void { if (isset($_COOKIE)) { $cookie = $_COOKIE; } //execute the method and check that the method adds the key value pair to cookies array. SugarApplication::setCookie('key', 'value'); - $this->assertEquals('value', $_COOKIE['key']); + self::assertEquals('value', $_COOKIE['key']); // cleanup if (isset($cookie)) { @@ -391,7 +371,7 @@ class SugarApplicationTest extends SuitePHPUnitFrameworkTestCase } } - public function testcreateLoginVars() + public function testcreateLoginVars(): void { $SugarApplication = new SugarApplication(); @@ -399,27 +379,32 @@ class SugarApplicationTest extends SuitePHPUnitFrameworkTestCase try { $vars = $SugarApplication->createLoginVars(); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } - $this->assertTrue(true); + self::assertTrue(true); } - public function testgetLoginVars() + public function testgetLoginVars(): void { - $SugarApplication = new SugarApplication(); - //execute the method and test that it returns a array. - $vars = $SugarApplication->getLoginVars(); - $this->assertTrue(is_array($vars)); + $vars = (new SugarApplication())->getLoginVars(); + self::assertIsArray($vars); } - public function testgetLoginRedirect() + public function testgetLoginRedirect(): void { - $SugarApplication = new SugarApplication(); - //execute the method and test that it returns a plus length string - $redirect = $SugarApplication->getLoginRedirect(); - $this->assertGreaterThan(0, strlen($redirect)); + $redirect = (new SugarApplication())->getLoginRedirect(); + self::assertGreaterThan(0, strlen($redirect)); + } + + protected function setUp(): void + { + parent::setUp(); + + global $current_user; + get_sugar_config_defaults(); + $current_user = BeanFactory::newBean('Users'); } } diff --git a/tests/unit/phpunit/includes/MVC/SugarModuleTest.php b/tests/unit/phpunit/includes/MVC/SugarModuleTest.php new file mode 100644 index 000000000..28fbe31e6 --- /dev/null +++ b/tests/unit/phpunit/includes/MVC/SugarModuleTest.php @@ -0,0 +1,100 @@ +getProperty('_moduleName'); + $reflectionProperty->setAccessible(true); + $reflectedValue = $reflectionProperty->getValue(new SugarModule('')); + self::assertEquals(null, $reflectedValue); + + // Test for valid input + $sugarModuleUser = SugarModule::get('User'); + $reflectionProperty = (new ReflectionClass($sugarModuleUser))->getProperty('_moduleName'); + $reflectionProperty->setAccessible(true); + $reflectedValue = $reflectionProperty->getValue(SugarModule::get('User')); + self::assertEquals('User', $reflectedValue); + } + + public function testmoduleImplements(): void + { + // Test for invalid input + $result = (new SugarModule(''))->moduleImplements('Basic'); + self::assertEquals(false, $result); + + // Test for invalid input + $sugarmodule_user = new SugarModule('Users'); + $result = $sugarmodule_user->moduleImplements('SugarModule'); + self::assertFalse($result); + + // Test for valid input + $sugarmodule_user = new SugarModule('Users'); + $result = $sugarmodule_user->moduleImplements('Basic'); + self::assertEquals(true, $result); + } + + public function testloadBean(): void + { + // Test for invalid input + $result = (new SugarModule(''))->loadBean(); + self::assertFalse($result); + + // Test for valid input + $result = (new SugarModule('Users'))->loadBean(); + self::assertInstanceOf('User', $result); + } +} diff --git a/tests/unit/phpunit/includes/MVC/View/SugarViewTest.php b/tests/unit/phpunit/includes/MVC/View/SugarViewTest.php new file mode 100644 index 000000000..ffbee5af4 --- /dev/null +++ b/tests/unit/phpunit/includes/MVC/View/SugarViewTest.php @@ -0,0 +1,303 @@ +init(); + } catch (Exception $e) { + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + } + + self::assertTrue(true); + } + + public function testprocess(): void + { + // test + $SugarView = new SugarView(); + $SugarView->module = 'Users'; + $GLOBALS['app'] = new SugarApplication(); + + //execute the method and check if it works and doesn't throws an exception + //secondly check if it outputs any content to browser + try { + ob_start(); + + $SugarView->process(); + + $renderedContent = ob_get_contents(); + ob_end_clean(); + + self::assertGreaterThan(0, strlen($renderedContent)); + } catch (Exception $e) { + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + } + } + + public function testdisplayErrors(): void + { + $SugarView = new SugarView(); + + //execute the method and check if it works and doesn't throws an exception + try { + $errors = $SugarView->displayErrors(); + self::assertEmpty($errors, print_r($SugarView, true)); + } catch (Exception $e) { + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + } + + self::assertTrue(true); + } + + public function testpreDisplay(): void + { + $SugarView = new SugarView(); + + //execute the method and check if it works and doesn't throws an exception + try { + $SugarView->preDisplay(); + } catch (Exception $e) { + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + } + + self::assertTrue(true); + } + + public function testdisplay(): void + { + $SugarView = new SugarView(); + + //execute the method and check if it works and doesn't throws an exception + try { + $SugarView->display(); + } catch (Exception $e) { + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + } + + self::assertTrue(true); + } + + public function testdisplayHeader(): void + { + $SugarView = new SugarView(); + $SugarView->module = 'Users'; + $GLOBALS['app'] = new SugarApplication(); + + //execute the method and check if it works and doesn't throws an exception + //secondly check if it outputs any content to browser + try { + ob_start(); + + $SugarView->displayHeader(); + + $renderedContent = ob_get_contents(); + ob_end_clean(); + + self::assertGreaterThan(0, strlen($renderedContent)); + } catch (Exception $e) { + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + } + } + + public function testgetModuleMenuHTML(): void + { + $SugarView = new SugarView(); + + //execute the method and check if it works and doesn't throws an exception + try { + $SugarView->getModuleMenuHTML(); + } catch (Exception $e) { + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + } + + self::assertTrue(true); + } + + public function testincludeClassicFile(): void + { + $SugarView = new SugarView(); + + //execute the method and check if it works and doesn't throws an exception + //use any valid file path, we just need to avoid failing require_once + try { + $SugarView->includeClassicFile('config.php'); + } catch (Exception $e) { + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + } + + self::assertTrue(true); + } + + public function testgetJavascriptValidation(): void + { + //check if it returns any text i-e JS code + $js = SugarView::getJavascriptValidation(); + self::assertGreaterThan(0, strlen($js)); + } + + public function testdisplayFooter(): void + { + $SugarView = new SugarView(); + + //execute the method and check if it works and doesn't throws an exception + //secondly check if it outputs any content to browser + try { + ob_start(); + + $SugarView->displayFooter(); + + $renderedContent = ob_get_contents(); + ob_end_clean(); + + self::assertGreaterThan(0, strlen($renderedContent)); + } catch (Exception $e) { + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + } + } + + public function testrenderJavascript(): void + { + $SugarView = new SugarView(); + + //execute the method and check if it works and doesn't throws an exception + //secondly check if it outputs any content to browser + try { + ob_start(); + + $SugarView->renderJavascript(); + + $renderedContent = ob_get_contents(); + ob_end_clean(); + + self::assertGreaterThan(0, strlen($renderedContent)); + } catch (Exception $e) { + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + } + } + + public function testgetMenu(): void + { + // Check with valid value and check if it returns an array. + $menu = (new SugarView())->getMenu('Users'); + self::assertIsArray($menu); + } + + public function testgetModuleTitle(): void + { + $SugarView = new SugarView(); + + //first execute the method with default value + $moduleTitle = $SugarView->getModuleTitle(); + self::assertGreaterThan(0, strlen($moduleTitle)); + + //second execute the method with true value + $moduleTitle = $SugarView->getModuleTitle(true); + self::assertGreaterThan(0, strlen($moduleTitle)); + + //third execute the method with false value + $moduleTitle = $SugarView->getModuleTitle(false); + self::assertGreaterThan(0, strlen($moduleTitle)); + } + + public function testgetMetaDataFile(): void + { + $SugarView = new SugarView(); + + //first execute the method with missing attributes. it should return Null. + $metaDataFile = $SugarView->getMetaDataFile(); + self::assertEquals(null, $metaDataFile); + + //second execute the method with valid attributes set. it should return a file path string. + $SugarView->type = 'detail'; + $SugarView->module = 'Users'; + + $metaDataFile = $SugarView->getMetaDataFile(); + self::assertGreaterThan(0, strlen($metaDataFile)); + } + + public function testgetBrowserTitle(): void + { + //execute the method. it should return a title string. + $browserTitle = (new SugarView())->getBrowserTitle(); + self::assertGreaterThan(0, strlen($browserTitle)); + } + + public function testgetBreadCrumbSymbol(): void + { + //execute the method. it should return a string. + $breadCrumbSymbol = (new SugarView())->getBreadCrumbSymbol(); + self::assertGreaterThan(0, strlen($breadCrumbSymbol)); + } + + public function testcheckPostMaxSizeError(): void + { + //execute the method. it should return False because Request parameters are not available. + $postMaxSizeError = (new SugarView())->checkPostMaxSizeError(); + self::assertFalse($postMaxSizeError); + } + + protected function setUp(): void + { + parent::setUp(); + + global $current_user; + get_sugar_config_defaults(); + $current_user = BeanFactory::newBean('Users'); + } +} diff --git a/tests/unit/phpunit/includes/MVC/View/ViewFactoryTest.php b/tests/unit/phpunit/includes/MVC/View/ViewFactoryTest.php new file mode 100644 index 000000000..efbd7e7ce --- /dev/null +++ b/tests/unit/phpunit/includes/MVC/View/ViewFactoryTest.php @@ -0,0 +1,118 @@ +options; + ViewFactory::_loadConfig($view, 'default'); + self::assertSame($options, $view->options); + + //check with a valid module which does not implement it's own view config. method must not change the view options. + $view = ViewFactory::loadView('detail', 'Users'); + $options = $view->options; + ViewFactory::_loadConfig($view, 'detail'); + self::assertSame($options, $view->options); + + //check with a valid module which implement it's own view config. method still must not change the view options because it needs. + $view = ViewFactory::loadView('area_detail_map', 'jjwg_Areas'); + $view->module = 'jjwg_Areas'; + $options = $view->options; + ViewFactory::_loadConfig($view, 'area_detail_map'); + self::assertSame($options, $view->options); + } + + public function test_buildFromFile(): void + { + //check with valid values and test if it returns correct view instance + $type = 'list'; + $target_module = 'Users'; + $bean = null; + $view = ViewFactory::_buildFromFile('modules/' . $target_module . '/views/view.' . $type . '.php', $bean, + array(), $type, $target_module); + self::assertInstanceOf('UsersViewList', $view); + + //check with valid values and test if it returns correct view instance + $type = 'detail'; + $target_module = 'Users'; + $bean = null; + $view = ViewFactory::_buildFromFile('modules/' . $target_module . '/views/view.' . $type . '.php', $bean, + array(), $type, $target_module); + self::assertInstanceOf('UsersViewDetail', $view); + } + + public function test_buildClass(): void + { + //check with valid values and test if it returns correct view instance + $view = ViewFactory::_buildClass('UsersViewList', null, array()); + self::assertInstanceOf('UsersViewList', $view); + + //check with valid values and test if it returns correct view instance + $view = ViewFactory::_buildClass('UsersViewDetail', null, array()); + self::assertInstanceOf('UsersViewDetail', $view); + } +} diff --git a/tests/unit/phpunit/includes/MVC/View/views/ViewAjaxTest.php b/tests/unit/phpunit/includes/MVC/View/views/ViewAjaxTest.php new file mode 100644 index 000000000..e1057f052 --- /dev/null +++ b/tests/unit/phpunit/includes/MVC/View/views/ViewAjaxTest.php @@ -0,0 +1,70 @@ +options); + } + + protected function setUp(): void + { + parent::setUp(); + + global $current_user; + get_sugar_config_defaults(); + $current_user = BeanFactory::newBean('Users'); + } +} diff --git a/tests/unit/phpunit/includes/MVC/View/views/ViewAjaxUITest.php b/tests/unit/phpunit/includes/MVC/View/views/ViewAjaxUITest.php new file mode 100644 index 000000000..391412814 --- /dev/null +++ b/tests/unit/phpunit/includes/MVC/View/views/ViewAjaxUITest.php @@ -0,0 +1,60 @@ +options); + } +} diff --git a/tests/unit/phpunit/includes/MVC/View/views/ViewClassicTest.php b/tests/unit/phpunit/includes/MVC/View/views/ViewClassicTest.php new file mode 100644 index 000000000..bf604ca64 --- /dev/null +++ b/tests/unit/phpunit/includes/MVC/View/views/ViewClassicTest.php @@ -0,0 +1,119 @@ +type); + + //test with bean parameter; + $bean = BeanFactory::newBean('Users'); + $view = new ViewClassic($bean); + self::assertInstanceOf('ViewClassic', $view); + self::assertInstanceOf('SugarView', $view); + self::assertEquals('', $view->type); + } + + public function testdisplay(): void + { + self::markTestIncomplete("Warning was: Test code or tested code did not (only) close its own output buffers"); + + if (isset($_SESSION)) { + $session = $_SESSION; + } + + //test with a valid module but invalid action. it should return false. + $view = new ViewClassic(); + $view->module = 'Home'; + $view->action = ''; + $ret = $view->display(); + self::assertFalse($ret); + + //test with a valid module and uncustomized action. it should return true + $view = new ViewClassic(); + $view->module = 'Home'; + $view->action = 'About'; + + //test with a valid module and customized action. it should return true + $view = new ViewClassic(); + $view->module = 'Home'; + $view->action = 'index'; + + ob_start(); + $ret = $view->display(); + $renderedContent = ob_get_contents(); + ob_end_clean(); + self::assertGreaterThan(0, strlen($renderedContent)); + self::assertTrue($ret); + + + if (isset($session)) { + $_SESSION = $session; + } else { + unset($_SESSION); + } + } + + protected function setUp(): void + { + parent::setUp(); + + global $current_user; + get_sugar_config_defaults(); + $current_user = BeanFactory::newBean('Users'); + } +} diff --git a/tests/unit/phpunit/includes/MVC/View/views/ViewDetailTest.php b/tests/unit/phpunit/includes/MVC/View/views/ViewDetailTest.php new file mode 100644 index 000000000..879eef02b --- /dev/null +++ b/tests/unit/phpunit/includes/MVC/View/views/ViewDetailTest.php @@ -0,0 +1,113 @@ +type); + } + + public function testpreDisplay(): void + { + //execute the method with required attributes preset, it will initialize the dv(detail view) attribute. + $view = new ViewDetail(); + $view->module = 'Users'; + $view->bean = BeanFactory::newBean('Users'); + $view->ss = new Sugar_Smarty(); + $view->preDisplay(); + self::assertInstanceOf('DetailView2', $view->dv); + self::asserttrue(is_array($view->dv->defs)); + + //execute the method again for a different module with required attributes preset, it will initialize the dv(detail view) attribute. + $view = new ViewDetail(); + $view->module = 'Meetings'; + $view->bean = BeanFactory::newBean('Meetings'); + $view->ss = new Sugar_Smarty(); + $view->preDisplay(); + self::assertInstanceOf('DetailView2', $view->dv); + self::asserttrue(is_array($view->dv->defs)); + } + + public function testdisplay(): void + { + //execute the method with essential parameters set. it should return some html. + $view = new ViewDetail(); + $view->module = 'Users'; + $view->bean = BeanFactory::newBean('Users'); + $view->bean->id = 1; + $view->ss = new Sugar_Smarty(); + $view->preDisplay(); + + ob_start(); + $view->display(); + $renderedContent = ob_get_contents(); + ob_end_clean(); + self::assertGreaterThan(0, strlen($renderedContent)); + } + + protected function setUp(): void + { + parent::setUp(); + global $current_user; + get_sugar_config_defaults(); + $current_user = BeanFactory::newBean('Users'); + } + + protected function tearDown(): void + { + parent::tearDown(); + } +} diff --git a/tests/unit/phpunit/includes/MVC/View/views/ViewEditTest.php b/tests/unit/phpunit/includes/MVC/View/views/ViewEditTest.php new file mode 100644 index 000000000..e02fad039 --- /dev/null +++ b/tests/unit/phpunit/includes/MVC/View/views/ViewEditTest.php @@ -0,0 +1,119 @@ +type); + + self::assertEquals(false, $view->useForSubpanel); + self::assertEquals(false, $view->useModuleQuickCreateTemplate); + self::assertEquals(true, $view->showTitle); + } + + public function testpreDisplay(): void + { + if (isset($_SESSION)) { + $session = $_SESSION; + } + + //execute the method with required attributes preset, it will initialize the ev(edit view) attribute. + $view = new ViewEdit(); + $view->module = 'Users'; + $view->bean = BeanFactory::newBean('Users'); + $view->preDisplay(); + self::assertInstanceOf('EditView', $view->ev); + + //execute the method again for a different module with required attributes preset, it will initialize the ev(edit view) attribute. + $view = new ViewEdit(); + $view->module = 'Meetings'; + $view->bean = BeanFactory::newBean('Meetings'); + $view->preDisplay(); + self::assertInstanceOf('EditView', $view->ev); + + + if (isset($session)) { + $_SESSION = $session; + } else { + unset($_SESSION); + } + } + + public function testdisplay(): void + { + //execute the method with essential parameters set. it should return some html. + $view = new ViewEdit(); + $view->module = 'Users'; + $view->bean = BeanFactory::newBean('Users'); + $view->preDisplay(); + $view->ev->ss = new Sugar_Smarty(); + + ob_start(); + $view->display(); + $renderedContent = ob_get_contents(); + ob_end_clean(); + self::assertGreaterThan(0, strlen($renderedContent)); + } + + protected function setUp(): void + { + parent::setUp(); + + global $current_user; + get_sugar_config_defaults(); + $current_user = BeanFactory::newBean('Users'); + } +} diff --git a/tests/unit/phpunit/includes/MVC/View/views/ViewHtmlTest.php b/tests/unit/phpunit/includes/MVC/View/views/ViewHtmlTest.php new file mode 100644 index 000000000..b649334ab --- /dev/null +++ b/tests/unit/phpunit/includes/MVC/View/views/ViewHtmlTest.php @@ -0,0 +1,82 @@ +display(); + } catch (Exception $e) { + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + } + + self::assertTrue(true); + } + + protected function setUp(): void + { + parent::setUp(); + + global $current_user; + get_sugar_config_defaults(); + $current_user = BeanFactory::newBean('Users'); + } +} diff --git a/tests/unit/phpunit/includes/MVC/View/views/ViewImportvcardTest.php b/tests/unit/phpunit/includes/MVC/View/views/ViewImportvcardTest.php new file mode 100644 index 000000000..c7b2f6e0d --- /dev/null +++ b/tests/unit/phpunit/includes/MVC/View/views/ViewImportvcardTest.php @@ -0,0 +1,88 @@ +type); + } + + public function testdisplay(): void + { + if (isset($_REQUEST)) { + $request = $_REQUEST; + } + + //execute the method with essential parameters set. it should return some html. + $view = new ViewImportvcard(); + $_REQUEST['module'] = 'Users'; + $GLOBALS['mod_strings'] = return_module_language($GLOBALS['current_language'], 'Contacts'); + $view->ss = new Sugar_Smarty(); + + ob_start(); + $view->display(); + $renderedContent = ob_get_contents(); + ob_end_clean(); + self::assertGreaterThan(0, strlen($renderedContent)); + + // cleanup + + if (isset($request)) { + $_REQUEST = $request; + } else { + unset($_REQUEST); + } + } +} diff --git a/tests/unit/phpunit/includes/MVC/View/views/ViewImportvcardsaveTest.php b/tests/unit/phpunit/includes/MVC/View/views/ViewImportvcardsaveTest.php new file mode 100644 index 000000000..496c3d2df --- /dev/null +++ b/tests/unit/phpunit/includes/MVC/View/views/ViewImportvcardsaveTest.php @@ -0,0 +1,60 @@ +type); + } +} diff --git a/tests/unit/phpunit/includes/MVC/View/views/ViewJsonTest.php b/tests/unit/phpunit/includes/MVC/View/views/ViewJsonTest.php new file mode 100644 index 000000000..6fb595f34 --- /dev/null +++ b/tests/unit/phpunit/includes/MVC/View/views/ViewJsonTest.php @@ -0,0 +1,60 @@ +type); + } +} diff --git a/tests/unit/phpunit/include/MVC/View/views/view.listTest.php b/tests/unit/phpunit/includes/MVC/View/views/ViewListTest.php similarity index 63% rename from tests/unit/phpunit/include/MVC/View/views/view.listTest.php rename to tests/unit/phpunit/includes/MVC/View/views/ViewListTest.php index 804b15e5d..b3b5fa424 100644 --- a/tests/unit/phpunit/include/MVC/View/views/view.listTest.php +++ b/tests/unit/phpunit/includes/MVC/View/views/ViewListTest.php @@ -1,19 +1,57 @@ query($query); @@ -42,7 +80,7 @@ class ViewListTest extends SuitePHPUnitFrameworkTestCase $view->listViewProcess(); $renderedContent = ob_get_contents(); ob_end_clean(); - $this->assertGreaterThan(0, strlen($renderedContent)); + self::assertGreaterThan(0, strlen($renderedContent)); DBManagerFactory::getInstance()->query("DELETE FROM email_addresses"); @@ -68,16 +106,16 @@ class ViewListTest extends SuitePHPUnitFrameworkTestCase } } - public function testViewList() + public function testViewList(): void { // Execute the constructor and check for the Object type and type attribute $view = new ViewList(); - $this->assertInstanceOf('ViewList', $view); - $this->assertInstanceOf('SugarView', $view); - $this->assertAttributeEquals('list', 'type', $view); + self::assertInstanceOf('ViewList', $view); + self::assertInstanceOf('SugarView', $view); + self::assertEquals('list', $view->type); } - public function testlistViewPrepare() + public function testlistViewPrepare(): void { //test without setting parameters. it should return some html $view = new ViewList(); @@ -87,7 +125,7 @@ class ViewListTest extends SuitePHPUnitFrameworkTestCase $view->listViewPrepare(); $renderedContent = ob_get_contents(); ob_end_clean(); - $this->assertLessThanOrEqual(0, strlen($renderedContent)); + self::assertLessThanOrEqual(0, strlen($renderedContent)); //test with some REQUEST parameters preset. it should return some html and set the REQUEST key we provided in current_query_by_page REQUEST Param. $view = new ViewList(); @@ -101,17 +139,17 @@ class ViewListTest extends SuitePHPUnitFrameworkTestCase $view->listViewPrepare(); $renderedContent = ob_get_contents(); ob_end_clean(); - $this->assertGreaterThan(0, strlen($renderedContent)); - $this->assertEquals('value', $_REQUEST['key']); + self::assertGreaterThan(0, strlen($renderedContent)); + self::assertEquals('value', $_REQUEST['key']); } - public function testprepareSearchForm() + public function testprepareSearchForm(): void { //test without any REQUEST parameters set. it will set searchform attribute to a searchform object. $view1 = new ViewList(); $view1->module = 'Users'; $view1->prepareSearchForm(); - $this->assertInstanceOf('SearchForm', $view1->searchForm); + self::assertInstanceOf('SearchForm', $view1->searchForm); //test with REQUEST parameters set. it will set searchform attribute to a searchform object. $view2 = new ViewList(); @@ -120,10 +158,10 @@ class ViewListTest extends SuitePHPUnitFrameworkTestCase $_REQUEST['searchFormTab'] = 'advanced_search'; $view2->prepareSearchForm(); - $this->assertInstanceOf('SearchForm', $view2->searchForm); + self::assertInstanceOf('SearchForm', $view2->searchForm); } - public function testprocessSearchForm() + public function testprocessSearchForm(): void { //test without use_old_search. it should return html. $view = new ViewList(); @@ -133,7 +171,7 @@ class ViewListTest extends SuitePHPUnitFrameworkTestCase $view->processSearchForm(); $renderedContent = ob_get_contents(); ob_end_clean(); - $this->assertGreaterThan(0, strlen($renderedContent)); + self::assertGreaterThan(0, strlen($renderedContent)); //test with use_old_search = true. there is a $view variable which is never set so it doesn't returns anything. $view = new ViewList(); @@ -144,18 +182,18 @@ class ViewListTest extends SuitePHPUnitFrameworkTestCase $view->processSearchForm(); $renderedContent = ob_get_contents(); ob_end_clean(); - $this->assertEquals(0, strlen($renderedContent)); + self::assertEquals(0, strlen($renderedContent)); } - public function testpreDisplay() + public function testpreDisplay(): void { //execute the method and test if it sets the lv attribute to ListViewSmarty object. $view = new ViewList(); $view->preDisplay(); - $this->assertInstanceOf('ListViewSmarty', $view->lv); + self::assertInstanceOf('ListViewSmarty', $view->lv); } - public function testdisplay() + public function testdisplay(): void { $query = "SELECT * FROM email_addresses"; $resource = DBManagerFactory::getInstance()->query($query); @@ -172,7 +210,7 @@ class ViewListTest extends SuitePHPUnitFrameworkTestCase $view->display(); $renderedContent1 = ob_get_contents(); ob_end_clean(); - $this->assertGreaterThan(0, strlen($renderedContent1)); + self::assertGreaterThan(0, strlen($renderedContent1)); //test with bean, seed and other arrtibutes set. it shuold return html. $view->bean = BeanFactory::newBean('Users'); @@ -186,7 +224,7 @@ class ViewListTest extends SuitePHPUnitFrameworkTestCase $view->display(); $renderedContent2 = ob_get_contents(); ob_end_clean(); - $this->assertGreaterThan(0, strlen($renderedContent2)); + self::assertGreaterThan(0, strlen($renderedContent2)); DBManagerFactory::getInstance()->query("DELETE FROM email_addresses"); @@ -200,4 +238,13 @@ class ViewListTest extends SuitePHPUnitFrameworkTestCase DBManagerFactory::getInstance()->query($query); } } + + protected function setUp(): void + { + parent::setUp(); + + global $current_user; + get_sugar_config_defaults(); + $current_user = BeanFactory::newBean('Users'); + } } diff --git a/tests/unit/phpunit/include/MVC/View/views/view.metadataTest.php b/tests/unit/phpunit/includes/MVC/View/views/ViewMetadataTest.php similarity index 51% rename from tests/unit/phpunit/include/MVC/View/views/view.metadataTest.php rename to tests/unit/phpunit/includes/MVC/View/views/ViewMetadataTest.php index 960a8cea1..55851a31c 100644 --- a/tests/unit/phpunit/include/MVC/View/views/view.metadataTest.php +++ b/tests/unit/phpunit/includes/MVC/View/views/ViewMetadataTest.php @@ -1,10 +1,56 @@ displayCheckBoxes('test', $values); $renderedContent1 = ob_get_contents(); ob_end_clean(); - $this->assertGreaterThan(0, strlen($renderedContent1)); + self::assertGreaterThan(0, strlen($renderedContent1)); //check with prefilled values array. it should return html sting longer than earlier ob_start(); @@ -22,10 +68,10 @@ class ViewMetadataTest extends SuitePHPUnitFrameworkTestCase $view->displayCheckBoxes('test', $values); $renderedContent2 = ob_get_contents(); ob_end_clean(); - $this->assertGreaterThan(strlen($renderedContent1), strlen($renderedContent2)); + self::assertGreaterThan(strlen($renderedContent1), strlen($renderedContent2)); } - public function testdisplaySelect() + public function testdisplaySelect(): void { $view = new ViewMetadata(); @@ -35,7 +81,7 @@ class ViewMetadataTest extends SuitePHPUnitFrameworkTestCase $view->displaySelect('test', $values); $renderedContent1 = ob_get_contents(); ob_end_clean(); - $this->assertGreaterThan(0, strlen($renderedContent1)); + self::assertGreaterThan(0, strlen($renderedContent1)); //check with prefilled values array. it should return html sting longer than earlier ob_start(); @@ -43,10 +89,10 @@ class ViewMetadataTest extends SuitePHPUnitFrameworkTestCase $view->displaySelect('test', $values); $renderedContent2 = ob_get_contents(); ob_end_clean(); - $this->assertGreaterThan(strlen($renderedContent1), strlen($renderedContent2)); + self::assertGreaterThan(strlen($renderedContent1), strlen($renderedContent2)); } - public function testdisplayTextBoxes() + public function testdisplayTextBoxes(): void { $view = new ViewMetadata(); @@ -56,7 +102,7 @@ class ViewMetadataTest extends SuitePHPUnitFrameworkTestCase $view->displayTextBoxes($values); $renderedContent1 = ob_get_contents(); ob_end_clean(); - $this->assertGreaterThan(0, strlen($renderedContent1)); + self::assertGreaterThan(0, strlen($renderedContent1)); //check with prefilled values array. it should return html sting longer than earlier ob_start(); @@ -64,10 +110,10 @@ class ViewMetadataTest extends SuitePHPUnitFrameworkTestCase $view->displayTextBoxes($values); $renderedContent2 = ob_get_contents(); ob_end_clean(); - $this->assertGreaterThan(strlen($renderedContent1), strlen($renderedContent2)); + self::assertGreaterThan(strlen($renderedContent1), strlen($renderedContent2)); } - public function testprintValue() + public function testprintValue(): void { $view = new ViewMetadata(); @@ -76,20 +122,15 @@ class ViewMetadataTest extends SuitePHPUnitFrameworkTestCase $view->printValue($values); $renderedContent = ob_get_contents(); ob_end_clean(); - $this->assertGreaterThan(0, strlen($renderedContent)); + self::assertGreaterThan(0, strlen($renderedContent)); } - public function testdisplay() + public function testdisplay(): void { if (isset($_REQUEST)) { $request = $_REQUEST; } - - - - - $view = new ViewMetadata(); @@ -98,7 +139,7 @@ class ViewMetadataTest extends SuitePHPUnitFrameworkTestCase $view->display(); $renderedContent = ob_get_contents(); ob_end_clean(); - $this->assertGreaterThan(0, strlen($renderedContent)); + self::assertGreaterThan(0, strlen($renderedContent)); //test with REQUEST parameters set $_REQUEST['modules'] = array('Calls', 'Meetings'); @@ -106,7 +147,7 @@ class ViewMetadataTest extends SuitePHPUnitFrameworkTestCase $view->display(); $renderedContent = ob_get_contents(); ob_end_clean(); - $this->assertGreaterThan(0, strlen($renderedContent)); + self::assertGreaterThan(0, strlen($renderedContent)); if (isset($request)) { $_REQUEST = $request; @@ -115,73 +156,73 @@ class ViewMetadataTest extends SuitePHPUnitFrameworkTestCase } } - public function testgetModules() + public function testgetModules(): void { //execute the method and test if it returns a array. $modules = VardefBrowser::getModules(); - $this->assertTrue(is_array($modules)); + self::assertIsArray($modules); } - public function testfindFieldsWithAttributes() + public function testfindFieldsWithAttributes(): void { //check with emptty attributes array $attributes = array(); $fields1 = VardefBrowser::findFieldsWithAttributes($attributes); - $this->assertTrue(is_array($fields1)); + self::assertIsArray($fields1); //check with a very common attribute $attributes = array('id'); $fields2 = VardefBrowser::findFieldsWithAttributes($attributes); - $this->assertTrue(is_array($fields2)); + self::assertIsArray($fields2); //check with a very specific attribute $attributes = array('category'); $fields3 = VardefBrowser::findFieldsWithAttributes($attributes); - $this->assertTrue(is_array($fields3)); + self::assertIsArray($fields3); //check that all three arrays returned, are not same. - $this->assertNotSame($fields1, $fields2); - $this->assertNotSame($fields1, $fields3); - $this->assertNotSame($fields2, $fields3); + self::assertNotSame($fields1, $fields2); + self::assertNotSame($fields1, $fields3); + self::assertNotSame($fields2, $fields3); } - public function testfindVardefs() + public function testfindVardefs(): void { //check with empty modules array $modules = array(); $defs1 = VardefBrowser::findVardefs($modules); - $this->assertTrue(is_array($defs1)); + self::assertIsArray($defs1); //check with modules array set. $modules = array('Calls'); $defs2 = VardefBrowser::findVardefs($modules); - $this->assertTrue(is_array($defs2)); + self::assertIsArray($defs2); //check that two arrays returned, are not same. - $this->assertNotSame($defs1, $defs2); + self::assertNotSame($defs1, $defs2); } - public function testfindFieldAttributes() + public function testfindFieldAttributes(): void { //check with emptty attributes array $attributes = array(); $fields1 = VardefBrowser::findFieldAttributes(); - $this->assertTrue(is_array($fields1)); + self::assertIsArray($fields1); //check with emptty attributes array and prefilled modules array. $attributes = array(); $modules = array('Users'); $fields2 = VardefBrowser::findFieldAttributes($attributes, $modules, true, true); - $this->assertTrue(is_array($fields2)); + self::assertIsArray($fields2); //check with a very specific attribute and empty modules array. $attributes = array('category'); $fields3 = VardefBrowser::findFieldAttributes($attributes); - $this->assertTrue(is_array($fields3)); + self::assertIsArray($fields3); //check that all three arrays returned, are not same. - $this->assertNotSame($fields1, $fields2); - $this->assertNotSame($fields1, $fields3); - $this->assertNotSame($fields2, $fields3); + self::assertNotSame($fields1, $fields2); + self::assertNotSame($fields1, $fields3); + self::assertNotSame($fields2, $fields3); } } diff --git a/tests/unit/phpunit/includes/MVC/View/views/ViewModulelistmenuTest.php b/tests/unit/phpunit/includes/MVC/View/views/ViewModulelistmenuTest.php new file mode 100644 index 000000000..3867510a5 --- /dev/null +++ b/tests/unit/phpunit/includes/MVC/View/views/ViewModulelistmenuTest.php @@ -0,0 +1,87 @@ +options); + } + + public function testdisplay(): void + { + if (isset($_SESSION)) { + $session = $_SESSION; + } + + //execute the method with required child objects preset. it should return some html. + $view = new ViewModulelistmenu(); + $view->ss = new Sugar_Smarty(); + + ob_start(); + $view->display(); + $renderedContent = ob_get_contents(); + ob_end_clean(); + + self::assertGreaterThan(0, strlen($renderedContent)); + self::assertEquals(false, is_array($renderedContent)); + + if (isset($session)) { + $_SESSION = $session; + } else { + unset($_SESSION); + } + } +} diff --git a/tests/unit/phpunit/includes/MVC/View/views/ViewMultieditTest.php b/tests/unit/phpunit/includes/MVC/View/views/ViewMultieditTest.php new file mode 100644 index 000000000..6d04fd33e --- /dev/null +++ b/tests/unit/phpunit/includes/MVC/View/views/ViewMultieditTest.php @@ -0,0 +1,97 @@ +type); + } + + public function testdisplay(): void + { + //test without action value and modules list in REQUEST object + $view = new ViewMultiedit(); + ob_start(); + $view->display(); + $renderedContent = ob_get_contents(); + ob_end_clean(); + self::assertEquals(0, strlen($renderedContent)); + + //test with valid action value to get link in return + $view = new ViewMultiedit(); + $view->action = 'AjaxFormSave'; + $view->module = 'Users'; + $view->bean = BeanFactory::newBean('Users'); + $view->bean->id = 1; + ob_start(); + $view->display(); + $renderedContent = ob_get_contents(); + ob_end_clean(); + self::assertGreaterThan(0, strlen($renderedContent)); + + //Fails with a fatal error, method creates editview without properly setting it up causing fatal errors. + /* + //test only with modules list in REQUEST object + $view = new ViewMultiedit(); + $GLOBALS['current_language']= 'en_us'; + $_REQUEST['modules']= Array('Calls','Accounts'); + ob_start(); + $view->display(); + $renderedContent = ob_get_contents(); + ob_end_clean(); + $this->assertGreaterThan(0,strlen($renderedContent)); + */ + } +} diff --git a/tests/unit/phpunit/includes/MVC/View/views/ViewNoaccessTest.php b/tests/unit/phpunit/includes/MVC/View/views/ViewNoaccessTest.php new file mode 100644 index 000000000..3ac32a7ea --- /dev/null +++ b/tests/unit/phpunit/includes/MVC/View/views/ViewNoaccessTest.php @@ -0,0 +1,69 @@ +display(); + + $renderedContent = ob_get_contents(); + ob_end_clean(); + + self::assertEquals('noaccess', $view->type); + self::assertGreaterThan(0, strlen($renderedContent)); + + self::assertEquals(false, json_decode($renderedContent)); //check that it doesn't return json. + } +} diff --git a/tests/unit/phpunit/include/MVC/View/views/view.popupTest.php b/tests/unit/phpunit/includes/MVC/View/views/ViewPopupTest.php similarity index 50% rename from tests/unit/phpunit/include/MVC/View/views/view.popupTest.php rename to tests/unit/phpunit/includes/MVC/View/views/ViewPopupTest.php index 4023f24ec..e9b1c94bb 100644 --- a/tests/unit/phpunit/include/MVC/View/views/view.popupTest.php +++ b/tests/unit/phpunit/includes/MVC/View/views/ViewPopupTest.php @@ -1,30 +1,68 @@ assertInstanceOf('ViewPopup', $view); - $this->assertInstanceOf('SugarView', $view); - $this->assertAttributeEquals('list', 'type', $view); + self::assertInstanceOf('ViewPopup', $view); + self::assertInstanceOf('SugarView', $view); + self::assertEquals('list', $view->type); unset($view); } - public function testdisplay() + public function testdisplay(): void { if (isset($_SESSION)) { $session = $_SESSION; @@ -48,7 +86,7 @@ class ViewPopupTest extends SuitePHPUnitFrameworkTestCase } } - public function testdisplayGetModulePopupPickerIfNoListviewsSearchDefs() + public function testdisplayGetModulePopupPickerIfNoListviewsSearchDefs(): void { $view = new ViewPopup(); $view->module = 'Audit'; // Confirms has no listview/searchdefs @@ -59,11 +97,11 @@ class ViewPopupTest extends SuitePHPUnitFrameworkTestCase // test no custom module Popup picker // test module Popup picker exists - $this->assertFileNotExists($customPath); + self::assertFileDoesNotExist($customPath); $result = get_custom_file_if_exists($modulePath); - $this->assertSame($modulePath, $result); + self::assertSame($modulePath, $result); // Now add a custom module Popup picker @@ -77,18 +115,18 @@ class ViewPopupTest extends SuitePHPUnitFrameworkTestCase file_put_contents($customPath, ''); - $this->assertFileExists($customPath); + self::assertFileExists($customPath); $result = get_custom_file_if_exists($modulePath); - $this->assertSame($customPath, $result); + self::assertSame($customPath, $result); // Cleanup unlink($customPath); rmdir($dirname); } - public function testdisplayGetCustomDefaultPopupPickerIdNoModulePopupPicker() + public function testdisplayGetCustomDefaultPopupPickerIdNoModulePopupPicker(): void { $view = new ViewPopup(); $view->module = 'Accounts'; // Confirms has no Popup_picker @@ -104,14 +142,14 @@ class ViewPopupTest extends SuitePHPUnitFrameworkTestCase $result1 = get_custom_file_if_exists($modulePath); $result2 = file_exists($result1); - $this->assertFalse($result2); + self::assertFalse($result2); - $this->assertFileNotExists($customPath); - $this->assertFileExists($defaultPath); + self::assertFileDoesNotExist($customPath); + self::assertFileExists($defaultPath); $result = get_custom_file_if_exists($defaultPath); - $this->assertSame($defaultPath, $result); + self::assertSame($defaultPath, $result); // Now add a custom Popup picker @@ -125,14 +163,23 @@ class ViewPopupTest extends SuitePHPUnitFrameworkTestCase file_put_contents($customPath, ''); - $this->assertFileExists($customPath); + self::assertFileExists($customPath); $result = get_custom_file_if_exists($defaultPath); - $this->assertSame($customPath, $result); + self::assertSame($customPath, $result); // Cleanup unlink($customPath); rmdir($dirname); } + + protected function setUp(): void + { + parent::setUp(); + + global $current_user; + get_sugar_config_defaults(); + $current_user = BeanFactory::newBean('Users'); + } } diff --git a/tests/unit/phpunit/includes/MVC/View/views/ViewQuickTest.php b/tests/unit/phpunit/includes/MVC/View/views/ViewQuickTest.php new file mode 100644 index 000000000..b7870e39e --- /dev/null +++ b/tests/unit/phpunit/includes/MVC/View/views/ViewQuickTest.php @@ -0,0 +1,105 @@ +type); + self::assertIsArray($view->options); + } + + public function testdisplay(): void + { + if (isset($_SESSION)) { + $session = $_SESSION; + } + + $view = new ViewQuick(); + + //execute the method with required child objects preset. it will return some html. + $view->dv = new DetailView2(); + $view->dv->ss = new Sugar_Smarty(); + $view->dv->module = 'Users'; + $view->bean = BeanFactory::newBean('Users'); + $view->bean->id = 1; + + try { + $view->dv->setup('Users', $view->bean); + } catch (Exception $e) { + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + } + + if (isset($session)) { + $_SESSION = $session; + } else { + unset($_SESSION); + } + + self::assertTrue(true); + } + + protected function setUp(): void + { + parent::setUp(); + + global $current_user; + get_sugar_config_defaults(); + $current_user = BeanFactory::newBean('Users'); + } +} diff --git a/tests/unit/phpunit/includes/MVC/View/views/ViewQuickcreateTest.php b/tests/unit/phpunit/includes/MVC/View/views/ViewQuickcreateTest.php new file mode 100644 index 000000000..2ae0f70ef --- /dev/null +++ b/tests/unit/phpunit/includes/MVC/View/views/ViewQuickcreateTest.php @@ -0,0 +1,132 @@ +preDisplay(); + self::assertCount(0, $_REQUEST); + + //check with values preset but without a valid bean id, it sould not change Request parameters + $_REQUEST['source_module'] = 'Users'; + $_REQUEST['module'] = 'Users'; + $_REQUEST['record'] = ''; + $request = $_REQUEST; + + $view->preDisplay(); + self::assertSame($request, $_REQUEST); + + //check with values preset, it sould set some addiiotnal Request parameters + $_REQUEST['record'] = 1; + $view->preDisplay(); + self::assertNotSame($request, $_REQUEST); + + if (isset($_request)) { + $_REQUEST = $_request; + } else { + unset($_REQUEST); + } + } + + public function testdisplay(): void + { + if (isset($_SESSION)) { + $_session = $_SESSION; + } + + if (isset($_REQUEST)) { + $_request = $_REQUEST; + } + + //execute the method with required child objects and parameters preset. it will return some html. + $view = new ViewQuickcreate(); + + $_REQUEST['module'] = 'Accounts'; + $view->bean = BeanFactory::newBean('Accounts'); + + ob_start(); + + $view->display(); + + $renderedContent = ob_get_contents(); + ob_end_clean(); + + self::assertGreaterThan(0, strlen($renderedContent)); + self::assertEquals(false, json_decode($renderedContent)); //check that it doesn't return json. + + if (isset($_session)) { + $_SESSION = $_session; + } else { + unset($_SESSION); + } + + if (isset($_request)) { + $_REQUEST = $_request; + } else { + unset($_REQUEST); + } + } + + protected function setUp(): void + { + parent::setUp(); + + global $current_user; + get_sugar_config_defaults(); + $current_user = BeanFactory::newBean('Users'); + } +} diff --git a/tests/unit/phpunit/includes/MVC/View/views/ViewQuickeditTest.php b/tests/unit/phpunit/includes/MVC/View/views/ViewQuickeditTest.php new file mode 100644 index 000000000..f8a292c51 --- /dev/null +++ b/tests/unit/phpunit/includes/MVC/View/views/ViewQuickeditTest.php @@ -0,0 +1,88 @@ +preDisplay(); + self::assertCount(0, $_REQUEST); + + //check with values preset but without a valid bean id, it sould not change Request parameters + $_REQUEST['source_module'] = 'Users'; + $_REQUEST['module'] = 'Users'; + $_REQUEST['record'] = ''; + $request = $_REQUEST; + + $view->preDisplay(); + self::assertSame($request, $_REQUEST); + + //check with values preset, it sould set some addiiotnal Request parameters + $_REQUEST['record'] = 1; + $view->preDisplay(); + self::assertNotSame($request, $_REQUEST); + + if (isset($_request)) { + $_REQUEST = $_request; + } else { + unset($_REQUEST); + } + } + + protected function setUp(): void + { + parent::setUp(); + } +} diff --git a/tests/unit/phpunit/includes/MVC/View/views/ViewSerializedTest.php b/tests/unit/phpunit/includes/MVC/View/views/ViewSerializedTest.php new file mode 100644 index 000000000..bdf2a0684 --- /dev/null +++ b/tests/unit/phpunit/includes/MVC/View/views/ViewSerializedTest.php @@ -0,0 +1,59 @@ +getMessage(); + self::assertStringStartsWith('Cannot modify header information', $msg, + 'Cannot modify header information? : ' . $msg . "\nTrace\n" . $e->getTraceAsString()); + } + + //execute the method with request parameters and test if it works. + $_REQUEST['sugarpdf'] = 'someValue'; + $view = new ViewSugarpdf(); + $view->module = 'Users'; + self::assertInstanceOf('ViewSugarpdf', $view); + self::assertInstanceOf('SugarView', $view); + self::assertEquals('sugarpdf', $view->type); + self::assertEquals('someValue', $view->sugarpdf); + self::assertEquals(null, $view->sugarpdfBean); + + if (isset($_request)) { + $_REQUEST = $_request; + } else { + unset($_REQUEST); + } + } + + protected function setUp(): void + { + parent::setUp(); + + global $current_user; + get_sugar_config_defaults(); + $current_user = BeanFactory::newBean('Users'); + } +} diff --git a/tests/unit/phpunit/includes/MVC/View/views/ViewVcardTest.php b/tests/unit/phpunit/includes/MVC/View/views/ViewVcardTest.php new file mode 100644 index 000000000..dcceb84a2 --- /dev/null +++ b/tests/unit/phpunit/includes/MVC/View/views/ViewVcardTest.php @@ -0,0 +1,83 @@ +module = 'Contacts'; + $view->bean = BeanFactory::newBean('Contacts'); + $this->expectOutputRegex('/.*BEGIN:VCARD.*/'); + //execute the method and test if it works and does not throws an exception other than headers output exception. + try { + $view->display(); + } catch (Exception $e) { + $msg = $e->getMessage(); + self::assertStringStartsWith('Cannot modify header information', $msg, + $msg . "\nTrace:\n" . $e->getTraceAsString()); + } + + self::assertInstanceOf('ViewVcard', $view); + self::assertInstanceOf('SugarView', $view); + self::assertEquals('detail', $view->type); + } + + protected function setUp(): void + { + parent::setUp(); + + global $current_user; + get_sugar_config_defaults(); + $current_user = BeanFactory::newBean('Users'); + } +} diff --git a/modules/Administration/Search/ajaxSubmit.js b/tests/unit/phpunit/includes/MVC/View/views/ViewXMLTest.php similarity index 60% rename from modules/Administration/Search/ajaxSubmit.js rename to tests/unit/phpunit/includes/MVC/View/views/ViewXMLTest.php index 9eb90ab9f..9ccbae854 100644 --- a/modules/Administration/Search/ajaxSubmit.js +++ b/tests/unit/phpunit/includes/MVC/View/views/ViewXMLTest.php @@ -1,9 +1,11 @@ -/* +type); } - function alertMsg(message) { - var alertMsg = document.createElement("p"); - var classAttr = document.createAttribute("class"); - classAttr.value = "error"; + public function testdisplay(): void + { + //execute the method and check for rexcetions. it should return some html. + $view = new ViewXML(); - alertMsg.setAttributeNode(classAttr); + try { + ob_start(); - var alertContent = document.createTextNode(message); - alertMsg.appendChild(alertContent); + $view->display(); - var pageContent = document.getElementById("pagecontent"); - pageContent.insertBefore(alertMsg, pageContent.firstChild); - } + $renderedContent = ob_get_contents(); + ob_end_clean(); - $.ajax({ - url: action, - type: method.toLowerCase(), - data: data - }).success(function (result) { - if (result.status == 'success') { - window.location.href="index.php?module=Administration&action=index"; - } else { - alertMsg("Error: " + translate("LBL_AJAX_SUBMIT_FAIL")); + self::assertGreaterThan(0, strlen($renderedContent)); + } catch (Exception $e) { + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } - return false; - }).fail(function () { - alertMsg("Error: " + translate("LBL_AJAX_SUBMIT_FAIL")); - return false; - }); -}); + } +} diff --git a/tests/unit/phpunit/include/SubPanel/SubPanelTest.php b/tests/unit/phpunit/includes/SubPanel/SubPanelTest.php similarity index 86% rename from tests/unit/phpunit/include/SubPanel/SubPanelTest.php rename to tests/unit/phpunit/includes/SubPanel/SubPanelTest.php index c08c7a24e..563e66793 100644 --- a/tests/unit/phpunit/include/SubPanel/SubPanelTest.php +++ b/tests/unit/phpunit/includes/SubPanel/SubPanelTest.php @@ -55,7 +55,7 @@ class SubPanelTest extends SuitePHPUnitFrameworkTestCase } } - public function testFaultySubpanelDef() + public function testFaultySubpanelDef(): void { $bean = BeanFactory::newBean('Contacts'); $counter = new SubPanelRowCounter($bean); @@ -63,10 +63,10 @@ class SubPanelTest extends SuitePHPUnitFrameworkTestCase $count = $counter->getSubPanelRowCount($subPanelDefs); - $this->assertEquals(-1, $count); + self::assertEquals(-1, $count); } - public function testSelectQueryToCountQuery() + public function testSelectQueryToCountQuery(): void { $bean = BeanFactory::newBean('Contacts'); $counter = new SubPanelRowCounter($bean); @@ -75,35 +75,35 @@ class SubPanelTest extends SuitePHPUnitFrameworkTestCase $count = $counter->selectQueryToCountQuery($select); $expected = 'SELECT COUNT(id) FROM table LIMIT 1'; - $this->assertEquals($expected, $count); + self::assertEquals($expected, $count); $selectAlias = 'SELECT contact_id id FROM table'; $countAlias = $counter->selectQueryToCountQuery($selectAlias); $expectedAlias = 'SELECT COUNT(contact_id) FROM table LIMIT 1'; - $this->assertEquals($expectedAlias, $countAlias); + self::assertEquals($expectedAlias, $countAlias); $selectAs = 'SELECT contact_id as id FROM table'; $countAs = $counter->selectQueryToCountQuery($selectAs); $expectedAs = 'SELECT COUNT(contact_id) FROM table LIMIT 1'; - $this->assertEquals($expectedAs, $countAs); + self::assertEquals($expectedAs, $countAs); } - public function testMakeFunctionCountQuery() + public function testMakeFunctionCountQuery(): void { $bean = BeanFactory::newBean('Accounts'); $counter = new SubPanelRowCounter($bean); $nonExistantQuery = $counter->makeFunctionCountQuery(''); - $this->assertEquals('', $nonExistantQuery); + self::assertEquals('', $nonExistantQuery); $existantQuery = $counter->makeFunctionCountQuery('function:getProductsServicesPurchasedQuery'); $expectedQueryStart = 'SELECT COUNT(aos_products_quotes.id)'; - $this->assertContains($expectedQueryStart, $existantQuery); + self::assertStringContainsString($expectedQueryStart, $existantQuery); } - public function testMakeSubPanelRowCountQuery() + public function testMakeSubPanelRowCountQuery(): void { $bean = BeanFactory::newBean('Contacts'); $counter = new SubPanelRowCounter($bean); @@ -113,6 +113,6 @@ class SubPanelTest extends SuitePHPUnitFrameworkTestCase $query = $counter->makeSubPanelRowCountQuery(); $expectedQueryStart = 'SELECT COUNT(account_id) FROM accounts_contacts'; - $this->assertContains($expectedQueryStart, $query); + self::assertStringContainsString($expectedQueryStart, $query); } } diff --git a/tests/unit/phpunit/includes/SugarDateTimeTest.php b/tests/unit/phpunit/includes/SugarDateTimeTest.php new file mode 100644 index 000000000..101b2b0c5 --- /dev/null +++ b/tests/unit/phpunit/includes/SugarDateTimeTest.php @@ -0,0 +1,115 @@ +get_day_begin(); + $expected = new SugarDateTime('2019-01-01 00:00:00'); + self::assertEquals($expected, $actual); + } + + public function testget_day_end(): void + { + // Test that the get_day_begin function creates a SugarDateTime + // object where the time is 23:59:59. + $actual = (new SugarDateTime('2019-01-01'))->get_day_end(); + $expected = new SugarDateTime('2019-01-01 23:59:59'); + self::assertEquals($expected, $actual); + } + + public function testasDb(): void + { + // Test that the asDb function returns a string formatted for use in + // the database. + $actual = (new SugarDateTime('2019-1-1'))->asDb(); + $expected = '2019-01-01 00:00:00'; + self::assertEquals($expected, $actual); + } + + public function testasDbDate(): void + { + // Test that the asDbDate function returns a string formatted for use + // in the database. + $actual = (new SugarDateTime('2019-1-1'))->asDbDate(); + $expected = '2019-01-01'; + self::assertEquals($expected, $actual); + } + + public function testget_date_str(): void + { + // Test that the get_date_str function returns a string for use in + // URL parameters. + $actual = (new SugarDateTime('2019-1-1'))->get_date_str(); + $expected = '&year=2019&month=1&day=1&hour=0'; + self::assertEquals($expected, $actual); + } + + public function testget_day_by_index_this_month(): void + { + // Test that the get_day_by_index_this_month function returns a + // SugarDateTime representing the correct day of the month. + $actual = (new SugarDateTime('2019-1-1'))->get_day_by_index_this_month(28); + $expected = new SugarDateTime('2019-01-29'); + self::assertEquals($expected, $actual); + } + + public function testget_day_by_index_this_monthWithExcessiveValue(): void + { + // Test that the get_day_by_index_this_month function returns a + // SugarDateTime representing the correct day of the month, even when + // the index provided is greater than the number of days in the month. + $actual = (new SugarDateTime('2019-1-1'))->get_day_by_index_this_month(32); + $expected = new SugarDateTime('2019-02-02'); + self::assertEquals($expected, $actual); + } +} diff --git a/tests/unit/phpunit/include/SugarEmailAddress/SugarEmailAddressTest.php b/tests/unit/phpunit/includes/SugarEmailAddress/SugarEmailAddressTest.php similarity index 96% rename from tests/unit/phpunit/include/SugarEmailAddress/SugarEmailAddressTest.php rename to tests/unit/phpunit/includes/SugarEmailAddress/SugarEmailAddressTest.php index 24386fb53..2e9191692 100644 --- a/tests/unit/phpunit/include/SugarEmailAddress/SugarEmailAddressTest.php +++ b/tests/unit/phpunit/includes/SugarEmailAddress/SugarEmailAddressTest.php @@ -1,9 +1,8 @@ query($query); @@ -87,7 +86,7 @@ class SugarEmailAddressTest extends SuitePHPUnitFrameworkTestCase /** * Tests for constructor. */ - public function testConstruct() + public function testConstruct(): void { // test $ea = new SugarEmailAddress(); @@ -103,7 +102,7 @@ class SugarEmailAddressTest extends SuitePHPUnitFrameworkTestCase /** * Tests old constructor. */ - public function testSugarEmailAddress() + public function testSugarEmailAddress(): void { // test $ea = new SugarEmailAddress(); @@ -119,7 +118,7 @@ class SugarEmailAddressTest extends SuitePHPUnitFrameworkTestCase /** * Test for handleLegacySave() method. */ - public function testHandleLegacySave() + public function testHandleLegacySave(): void { if (isset($_REQUEST)) { $_request = $_REQUEST; @@ -171,7 +170,7 @@ class SugarEmailAddressTest extends SuitePHPUnitFrameworkTestCase /** * Test for handleLegacyRetrieve() method. */ - public function testHandleLegacyRetrieve() + public function testHandleLegacyRetrieve(): void { $c = BeanFactory::newBean('Contacts'); @@ -190,7 +189,7 @@ class SugarEmailAddressTest extends SuitePHPUnitFrameworkTestCase /** * Test for populateLegacyFields() method. */ - public function testPopulateLegacyFields() + public function testPopulateLegacyFields(): void { $c = BeanFactory::newBean('Contacts'); @@ -222,7 +221,7 @@ class SugarEmailAddressTest extends SuitePHPUnitFrameworkTestCase /** * Test for saveEmail() method. */ - public function testSaveEmail() + public function testSaveEmail(): void { if (isset($_REQUEST)) { $_request = $_REQUEST; @@ -438,7 +437,7 @@ class SugarEmailAddressTest extends SuitePHPUnitFrameworkTestCase /** * Test for getCountEmailAddressByBean() method. */ - public function testGetCountEmailAddressByBean() + public function testGetCountEmailAddressByBean(): void { $query = "SELECT * FROM email_addresses"; $resource = DBManagerFactory::getInstance()->query($query); @@ -516,7 +515,7 @@ class SugarEmailAddressTest extends SuitePHPUnitFrameworkTestCase /** * Test for getRelatedId() method. */ - public function testGetRelatedId() + public function testGetRelatedId(): void { // test $results = $this->ea->getRelatedId('test@email.com', 'Contacts'); @@ -566,7 +565,7 @@ class SugarEmailAddressTest extends SuitePHPUnitFrameworkTestCase /** * Test for getBeansByEmailAddress() method. */ - public function testGetBeansByEmailAddress() + public function testGetBeansByEmailAddress(): void { global $locale, $current_user; @@ -666,9 +665,10 @@ class SugarEmailAddressTest extends SuitePHPUnitFrameworkTestCase } - private function getBeansByEmailAddressDeletedLinksTest($db, $i, $ea_deleted, $bean_deleted) { + private function getBeansByEmailAddressDeletedLinksTest($db, $i, $ea_deleted, $bean_deleted): void + { // must have differing values - self::assertFalse($ea_deleted == $bean_deleted); + self::assertNotEquals($ea_deleted, $bean_deleted); $q = /** @lang sql */ " INSERT INTO email_addr_bean_rel (id, email_address_id, bean_id, bean_module, primary_address, deleted) @@ -699,7 +699,7 @@ class SugarEmailAddressTest extends SuitePHPUnitFrameworkTestCase /** * Test for populateAddresses() method. */ - public function testPopulateAddresses() + public function testPopulateAddresses(): void { $logger = $GLOBALS['log']; $GLOBALS['log'] = new TestLogger(); @@ -922,7 +922,7 @@ class SugarEmailAddressTest extends SuitePHPUnitFrameworkTestCase /** * Test for addAddress() method. */ - public function testAddAddress() + public function testAddAddress(): void { $query = "SELECT * FROM email_addr_bean_rel"; $resource = DBManagerFactory::getInstance()->query($query); @@ -1011,9 +1011,9 @@ class SugarEmailAddressTest extends SuitePHPUnitFrameworkTestCase /** * Test for updateFlags() method. */ - public function testUpdateFlags() + public function testUpdateFlags(): void { - $this->markTestIncomplete('testUpdateFlags'); + self::markTestIncomplete('testUpdateFlags'); // // test // $i = 1; // $q = /** @lang sql */ @@ -1071,7 +1071,7 @@ class SugarEmailAddressTest extends SuitePHPUnitFrameworkTestCase /** * Test for splitEmailAddress() method. */ - public function testSplitEmailAddress() + public function testSplitEmailAddress(): void { $result = $this->ea->splitEmailAddress(null); self::assertSame(array( @@ -1149,7 +1149,7 @@ class SugarEmailAddressTest extends SuitePHPUnitFrameworkTestCase /** * Test for _cleanAddress() method. */ - public function testCleanAddress() + public function testCleanAddress(): void { $result = $this->ea->_cleanAddress(null); self::assertEquals('', $result); @@ -1164,7 +1164,7 @@ class SugarEmailAddressTest extends SuitePHPUnitFrameworkTestCase /** * Test for getEmailGUID() method. */ - public function testGetEmailGUID() + public function testGetEmailGUID(): void { $isValidator = new \SuiteCRM\Utility\SuiteValidator(); @@ -1267,7 +1267,7 @@ class SugarEmailAddressTest extends SuitePHPUnitFrameworkTestCase /** * Test for AddUpdateEmailAddress() method. */ - public function testAddUpdateEmailAddress() + public function testAddUpdateEmailAddress(): void { // test $db = DBManagerFactory::getInstance(); @@ -1314,7 +1314,7 @@ class SugarEmailAddressTest extends SuitePHPUnitFrameworkTestCase /** * Test for getPrimaryAddress() method. */ - public function testGetPrimaryAddress() + public function testGetPrimaryAddress(): void { $db = DBManagerFactory::getInstance(); @@ -1359,7 +1359,7 @@ class SugarEmailAddressTest extends SuitePHPUnitFrameworkTestCase /** * Test for getReplyToAddress() method. */ - public function testGetReplyToAddress() + public function testGetReplyToAddress(): void { $db = DBManagerFactory::getInstance(); @@ -1421,7 +1421,7 @@ class SugarEmailAddressTest extends SuitePHPUnitFrameworkTestCase /** * Test for getAddressesByGUID() method. */ - public function testGetAddressesByGUID() + public function testGetAddressesByGUID(): void { $db = DBManagerFactory::getInstance(); @@ -1468,7 +1468,7 @@ class SugarEmailAddressTest extends SuitePHPUnitFrameworkTestCase /** * Test for getEmailAddressWidgetEditView() method. */ - public function testGetEmailAddressWidgetEditView() + public function testGetEmailAddressWidgetEditView(): void { $query = "SELECT * FROM accounts_cstm"; $resource = DBManagerFactory::getInstance()->query($query); @@ -1485,15 +1485,12 @@ class SugarEmailAddressTest extends SuitePHPUnitFrameworkTestCase $GLOBALS['log'] = new TestLogger(); $env = array(); - /** @noinspection UnSafeIsSetOverArrayInspection */ if (isset($_POST)) { $env['$_POST'] = $_POST; } - /** @noinspection UnSafeIsSetOverArrayInspection */ if (isset($_GET)) { $env['$_GET'] = $_GET; } - /** @noinspection UnSafeIsSetOverArrayInspection */ if (isset($_REQUEST)) { $env['$_REQUEST'] = $_REQUEST; } @@ -1547,7 +1544,7 @@ class SugarEmailAddressTest extends SuitePHPUnitFrameworkTestCase $result = $this->ea->getEmailAddressWidgetEditView('', 'non-exists-module'); - self::assertEquals($result, false); + self::assertEquals(false, $result); if (isset($env['$_REQUEST'])) { $_REQUEST = $env['$_REQUEST']; @@ -1559,7 +1556,7 @@ class SugarEmailAddressTest extends SuitePHPUnitFrameworkTestCase $result = $this->ea->getEmailAddressWidgetEditView('', 'non-exists-module'); - self::assertEquals($result, false); + self::assertEquals(false, $result); $expected = !empty($result) && is_string($result); self::assertNotTrue($expected); @@ -1571,23 +1568,23 @@ class SugarEmailAddressTest extends SuitePHPUnitFrameworkTestCase // test $result = $this->ea->getEmailAddressWidgetEditView('non-exists-id', 'non-exists-module'); - self::assertEquals($result, false); + self::assertEquals(false, $result); // test $_POST['is_converted'] = true; $result = $this->ea->getEmailAddressWidgetEditView('non-exists-id', 'non-exists-module'); - self::assertEquals($result, false); + self::assertEquals(false, $result); $expected = !empty($result) && is_string($result); - self::assertEquals($expected, false); + self::assertEquals(false, $expected); self::assertCount(10, $GLOBALS['log']->calls['fatal']); // test $_POST['is_converted'] = true; $_POST['return_id'] = 'any-non-exists-id'; $result = $this->ea->getEmailAddressWidgetEditView('non-exists-id', 'non-exists-module'); - self::assertEquals($result, false); + self::assertEquals(false, $result); self::assertCount(12, $GLOBALS['log']->calls['fatal']); @@ -1596,35 +1593,35 @@ class SugarEmailAddressTest extends SuitePHPUnitFrameworkTestCase $_POST['return_module'] = 'any-non-exists-module'; $result = $this->ea->getEmailAddressWidgetEditView('non-exists-id', 'non-exists-module'); - self::assertEquals($result, false); + self::assertEquals(false, $result); self::assertCount(13, $GLOBALS['log']->calls['fatal']); // test $result = $this->ea->getEmailAddressWidgetEditView('non-exists-id', 'Users'); - self::assertTrue(is_string($result)); + self::assertIsString($result); // test $_POST['return_id'] = 'test_contact_1'; $_POST['return_module'] = 'Contacts'; $result = $this->ea->getEmailAddressWidgetEditView('test_contact_1', 'Contacts'); - self::assertEquals($result, false); + self::assertEquals(false, $result); self::assertFalse(strpos( $result, '[{"email_address":null,"email_address_caps":"TEST@EMAIL.COM","invalid_email":"0","opt_out":"0","date_created":null,"date_modified":null,"id":"test_email_bean_rel_1","email_address_id":"test_email_1","bean_id":"test_contact_1","bean_module":"Contacts","primary_address":"0","reply_to_address":"0","deleted":"0"},{"email_address":null,"email_address_caps":"TEST@EMAIL.COM","invalid_email":"0","opt_out":"0","date_created":null,"date_modified":null,"id":"","email_address_id":"test_email_1","bean_id":"test_contact_1","bean_module":"Contacts","primary_address":"0","reply_to_address":"1","deleted":"0"}]' )); - self::assertEquals($result, false); + self::assertEquals(false, $result); // test $_POST['return_id'] = 'non-exists-id'; $_POST['return_module'] = 'Contacts'; $result = $this->ea->getEmailAddressWidgetEditView('test_contact_1', 'Contacts'); - self::assertEquals($result, false); + self::assertEquals(false, $result); // test $_REQUEST['full_form'] = true; @@ -1635,7 +1632,7 @@ class SugarEmailAddressTest extends SuitePHPUnitFrameworkTestCase $result = $this->ea->getEmailAddressWidgetEditView('', 'non-exists-module'); - self::assertEquals($result, false); + self::assertEquals(false, $result); if (isset($env['$_REQUEST'])) { $_REQUEST = $env['$_REQUEST']; @@ -1650,7 +1647,7 @@ class SugarEmailAddressTest extends SuitePHPUnitFrameworkTestCase $result = $this->ea->getEmailAddressWidgetEditView('', 'Contacts'); - self::assertEquals($result, false); + self::assertEquals(false, $result); if (isset($env['$_REQUEST'])) { $_REQUEST = $env['$_REQUEST']; @@ -1696,7 +1693,7 @@ class SugarEmailAddressTest extends SuitePHPUnitFrameworkTestCase /** * Test for getEmailAddressWidgetDetailView() method. */ - public function testGetEmailAddressWidgetDetailView() + public function testGetEmailAddressWidgetDetailView(): void { $db = DBManagerFactory::getInstance(); @@ -1757,7 +1754,7 @@ class SugarEmailAddressTest extends SuitePHPUnitFrameworkTestCase /** * Test for getEmailAddressWidgetDuplicatesView() method. */ - public function testGetEmailAddressWidgetDuplicatesView() + public function testGetEmailAddressWidgetDuplicatesView(): void { self::markTestIncomplete('environment dependecy in test'); @@ -1765,15 +1762,12 @@ class SugarEmailAddressTest extends SuitePHPUnitFrameworkTestCase $GLOBALS['log'] = new TestLogger(); $env = array(); - /** @noinspection UnSafeIsSetOverArrayInspection */ if (isset($_POST)) { $env['$_POST'] = $_POST; } - /** @noinspection UnSafeIsSetOverArrayInspection */ if (isset($_GET)) { $env['$_GET'] = $_GET; } - /** @noinspection UnSafeIsSetOverArrayInspection */ if (isset($_REQUEST)) { $env['$_REQUEST'] = $_REQUEST; } @@ -1930,22 +1924,19 @@ class SugarEmailAddressTest extends SuitePHPUnitFrameworkTestCase /** * Test for getFormBaseURL() method. */ - public function testGetFormBaseURL() + public function testGetFormBaseURL(): void { // test $logger = $GLOBALS['log']; $GLOBALS['log'] = new TestLogger(); $env = array(); - /** @noinspection UnSafeIsSetOverArrayInspection */ if (isset($_POST)) { $env['$_POST'] = $_POST; } - /** @noinspection UnSafeIsSetOverArrayInspection */ if (isset($_GET)) { $env['$_GET'] = $_GET; } - /** @noinspection UnSafeIsSetOverArrayInspection */ if (isset($_REQUEST)) { $env['$_REQUEST'] = $_REQUEST; } @@ -2026,7 +2017,7 @@ class SugarEmailAddressTest extends SuitePHPUnitFrameworkTestCase /** * Test for setView() method. */ - public function testSetView() + public function testSetView(): void { $before = $this->ea->view; $this->ea->setView('afterView'); @@ -2038,7 +2029,7 @@ class SugarEmailAddressTest extends SuitePHPUnitFrameworkTestCase /** * Test for getCorrectedModule() method. */ - public function testGetCorrectedModule() + public function testGetCorrectedModule(): void { // test $module = null; @@ -2069,7 +2060,7 @@ class SugarEmailAddressTest extends SuitePHPUnitFrameworkTestCase /** * Test for stash() method. */ - public function testStash() + public function testStash(): void { $db = DBManagerFactory::getInstance(); @@ -2086,7 +2077,7 @@ class SugarEmailAddressTest extends SuitePHPUnitFrameworkTestCase /** * Test for getEmailAddressWidget() function. */ - public function testGetEmailAddressWidget() + public function testGetEmailAddressWidget(): void { self::markTestIncomplete('environment dependecy in test'); @@ -2162,7 +2153,7 @@ class SugarEmailAddressTest extends SuitePHPUnitFrameworkTestCase } - public function testGetOptInStatus() + public function testGetOptInStatus(): void { self::markTestIncomplete('COI_STAT_CONFIRMED_OPT_IN'); @@ -2176,7 +2167,7 @@ class SugarEmailAddressTest extends SuitePHPUnitFrameworkTestCase $emailAddress->email_address = 'test@example.com'; $emailAddress->email_address_caps = 'TEST@EXAMPLE.COM'; - $this->assertEquals( + self::assertEquals( EmailAddress::COI_FLAG_OPT_IN_DISABLED, $emailAddress->getOptInStatus() ); @@ -2187,7 +2178,7 @@ class SugarEmailAddressTest extends SuitePHPUnitFrameworkTestCase $emailAddress->email_address_caps = 'TEST@EXAMPLE.COM'; $emailAddress->confirm_opt_in = SugarEmailAddress::COI_STAT_OPT_IN; - $this->assertEquals( + self::assertEquals( EmailAddress::COI_FLAG_OPT_IN_DISABLED, $emailAddress->getOptInStatus() ); @@ -2200,7 +2191,7 @@ class SugarEmailAddressTest extends SuitePHPUnitFrameworkTestCase $emailAddress->confirm_opt_in_fail_date = '2017-01-01 10:10:00'; $emailAddress->confirm_opt_in_sent_date = '2017-01-01 10:10:00'; - $this->assertEquals( + self::assertEquals( EmailAddress::COI_FLAG_OPT_IN_DISABLED, $emailAddress->getOptInStatus() ); @@ -2213,7 +2204,7 @@ class SugarEmailAddressTest extends SuitePHPUnitFrameworkTestCase $emailAddress->confirm_opt_in_fail_date = '2015-01-01 10:10:00'; $emailAddress->confirm_opt_in_sent_date = '2017-01-01 10:10:00'; - $this->assertEquals( + self::assertEquals( SugarEmailAddress::COI_FLAG_OPT_IN_DISABLED, $emailAddress->getOptInStatus() ); @@ -2228,7 +2219,7 @@ class SugarEmailAddressTest extends SuitePHPUnitFrameworkTestCase $emailAddress->confirm_opt_in_fail_date = '2015-01-01 10:10:00'; $emailAddress->confirm_opt_in_sent_date = '2017-01-01 10:10:00'; - $this->assertEquals( + self::assertEquals( SugarEmailAddress::COI_FLAG_OPT_IN_DISABLED, $emailAddress->getOptInStatus() ); @@ -2245,7 +2236,7 @@ class SugarEmailAddressTest extends SuitePHPUnitFrameworkTestCase $emailAddress->confirm_opt_in_fail_date = ''; $emailAddress->confirm_opt_in_sent_date = ''; - $this->assertEquals( + self::assertEquals( SugarEmailAddress::COI_FLAG_NO_OPT_IN_STATUS, $emailAddress->getOptInStatus() ); @@ -2256,7 +2247,7 @@ class SugarEmailAddressTest extends SuitePHPUnitFrameworkTestCase $emailAddress->email_address_caps = 'TEST@EXAMPLE.COM'; $emailAddress->confirm_opt_in = SugarEmailAddress::COI_STAT_OPT_IN; - $this->assertEquals( + self::assertEquals( SugarEmailAddress::COI_FLAG_OPT_IN, $emailAddress->getOptInStatus() ); @@ -2269,7 +2260,7 @@ class SugarEmailAddressTest extends SuitePHPUnitFrameworkTestCase $emailAddress->confirm_opt_in_fail_date = '2017-01-01 10:10:00'; $emailAddress->confirm_opt_in_sent_date = '2017-01-01 10:10:00'; - $this->assertEquals( + self::assertEquals( EmailAddress::COI_FLAG_OPT_IN, $emailAddress->getOptInStatus() ); @@ -2282,7 +2273,7 @@ class SugarEmailAddressTest extends SuitePHPUnitFrameworkTestCase $emailAddress->confirm_opt_in_fail_date = '2015-01-01 10:10:00'; $emailAddress->confirm_opt_in_sent_date = '2017-01-01 10:10:00'; - $this->assertEquals( + self::assertEquals( EmailAddress::COI_FLAG_OPT_IN, $emailAddress->getOptInStatus() ); @@ -2297,7 +2288,7 @@ class SugarEmailAddressTest extends SuitePHPUnitFrameworkTestCase $emailAddress->confirm_opt_in_fail_date = '2015-01-01 10:10:00'; $emailAddress->confirm_opt_in_sent_date = '2017-01-01 10:10:00'; - $this->assertEquals( + self::assertEquals( SugarEmailAddress::COI_FLAG_OPT_IN, $emailAddress->getOptInStatus() ); @@ -2315,7 +2306,7 @@ class SugarEmailAddressTest extends SuitePHPUnitFrameworkTestCase $emailAddress->confirm_opt_in_fail_date = ''; $emailAddress->confirm_opt_in_sent_date = ''; - $this->assertEquals( + self::assertEquals( SugarEmailAddress::COI_STAT_DISABLED, $emailAddress->getOptInStatus() ); @@ -2326,7 +2317,7 @@ class SugarEmailAddressTest extends SuitePHPUnitFrameworkTestCase $emailAddress->email_address_caps = 'TEST@EXAMPLE.COM'; $emailAddress->confirm_opt_in = SugarEmailAddress::COI_STAT_OPT_IN; - $this->assertEquals( + self::assertEquals( SugarEmailAddress::COI_FLAG_OPT_IN_PENDING_EMAIL_NOT_SENT, $emailAddress->getOptInStatus() ); @@ -2339,7 +2330,7 @@ class SugarEmailAddressTest extends SuitePHPUnitFrameworkTestCase $emailAddress->confirm_opt_in_fail_date = '2017-01-01 10:10:00'; $emailAddress->confirm_opt_in_sent_date = '2017-01-01 10:10:00'; - $this->assertEquals( + self::assertEquals( SugarEmailAddress::COI_FLAG_OPT_IN_PENDING_EMAIL_FAILED, $emailAddress->getOptInStatus() ); @@ -2352,7 +2343,7 @@ class SugarEmailAddressTest extends SuitePHPUnitFrameworkTestCase $emailAddress->confirm_opt_in_fail_date = '2015-01-01 10:10:00'; $emailAddress->confirm_opt_in_sent_date = '2017-01-01 10:10:00'; - $this->assertEquals( + self::assertEquals( SugarEmailAddress::COI_FLAG_OPT_IN_PENDING_EMAIL_SENT, $emailAddress->getOptInStatus() ); @@ -2367,7 +2358,7 @@ class SugarEmailAddressTest extends SuitePHPUnitFrameworkTestCase $emailAddress->confirm_opt_in_fail_date = '2015-01-01 10:10:00'; $emailAddress->confirm_opt_in_sent_date = '2017-01-01 10:10:00'; - $this->assertEquals( + self::assertEquals( SugarEmailAddress::COI_FLAG_OPT_IN_PENDING_EMAIL_CONFIRMED, $emailAddress->getOptInStatus() ); diff --git a/tests/unit/phpunit/include/SugarFolders/SugarFolderTest.php b/tests/unit/phpunit/includes/SugarFolders/SugarFolderTest.php similarity index 85% rename from tests/unit/phpunit/include/SugarFolders/SugarFolderTest.php rename to tests/unit/phpunit/includes/SugarFolders/SugarFolderTest.php index 08355c4a3..3b3c7d6d9 100644 --- a/tests/unit/phpunit/include/SugarFolders/SugarFolderTest.php +++ b/tests/unit/phpunit/includes/SugarFolders/SugarFolderTest.php @@ -56,28 +56,27 @@ class SugarFolderTest extends SuitePHPUnitFrameworkTestCase * * @return void */ - public function testCanGetSugarFolderObject() + public function testCanGetSugarFolderObject(): void { $sugarfolder = new SugarFolder(); - $this->assertTrue(is_object($sugarfolder)); + self::assertIsObject($sugarfolder); } - public function testGenerateArchiveFolderQuery() + public function testGenerateArchiveFolderQuery(): void { $user = BeanFactory::newBean('Users'); $user->id = 1; - $sugarfolder = new SugarFolder($user); - $sql = $sugarfolder->generateArchiveFolderQuery(); + $sql = (new SugarFolder($user))->generateArchiveFolderQuery(); $expected = "SELECT emails.id , emails.name, emails.date_sent_received, emails.status, emails.type, emails.flagged, emails.reply_to_status, emails_text.from_addr, emails_text.to_addrs, 'Emails' polymorphic_module FROM emails JOIN emails_text on emails.id = emails_text.email_id WHERE emails.deleted=0 AND emails.type NOT IN ('out', 'draft')" . " AND emails.status NOT IN ('sent', 'draft') AND emails.id IN (SELECT eear.email_id FROM emails_email_addr_rel eear JOIN email_addr_bean_rel eabr ON eabr.email_address_id=eear.email_address_id AND eabr.bean_id = '1' AND eabr.bean_module = 'Users' WHERE eear.deleted=0)"; - $this->assertEquals($expected, $sql); + self::assertEquals($expected, $sql); } - public function testGenerateSugarsDynamicFolderQuery() + public function testGenerateSugarsDynamicFolderQuery(): void { $user = BeanFactory::newBean('Users'); $user->id = 1; @@ -90,7 +89,7 @@ class SugarFolderTest extends SuitePHPUnitFrameworkTestCase $expected = "SELECT emails.id , emails.name, emails.date_sent_received, emails.status, emails.type, emails.flagged, emails.reply_to_status, emails_text.from_addr, emails_text.to_addrs, 'Emails' polymorphic_module FROM emails JOIN emails_text on emails.id = emails_text.email_id WHERE emails.deleted=0 AND emails.type NOT IN ('out', 'draft')" . " AND emails.status NOT IN ('sent', 'draft') AND emails.id IN (SELECT eear.email_id FROM emails_email_addr_rel eear JOIN email_addr_bean_rel eabr ON eabr.email_address_id=eear.email_address_id AND eabr.bean_id = '1' AND eabr.bean_module = 'Users' WHERE eear.deleted=0)"; - $this->assertEquals($sql, $expected); + self::assertEquals($sql, $expected); $sugarfolder->folder_type = 'sent'; @@ -98,7 +97,7 @@ class SugarFolderTest extends SuitePHPUnitFrameworkTestCase $expected = "SELECT emails.id, emails.name, emails.date_sent_received, emails.status, emails.type, emails.flagged, emails.reply_to_status, emails_text.from_addr, emails_text.to_addrs, 'Emails' polymorphic_module FROM emails JOIN emails_text on emails.id = emails_text.email_id WHERE (type = 'out' OR status = 'sent') AND assigned_user_id = '1' AND emails.deleted = 0 AND emails.status NOT IN ('archived') AND emails.type NOT IN ('archived')"; - $this->assertEquals($sql, $expected); + self::assertEquals($sql, $expected); $sugarfolder->folder_type = 'inbound'; @@ -106,10 +105,10 @@ class SugarFolderTest extends SuitePHPUnitFrameworkTestCase $expected = "SELECT emails.id, emails.name, emails.date_sent_received, emails.status, emails.type, emails.flagged, emails.reply_to_status, emails_text.from_addr, emails_text.to_addrs, 'Emails' polymorphic_module FROM emails JOIN emails_text on emails.id = emails_text.email_id WHERE (type = 'inbound' OR status = 'inbound') AND assigned_user_id = '1' AND emails.deleted = 0 AND emails.status NOT IN ('sent', 'archived', 'draft') AND emails.type NOT IN ('out', 'archived', 'draft')"; - $this->assertEquals($sql, $expected); + self::assertEquals($sql, $expected); } - public function testFolderSubscriptions() + public function testFolderSubscriptions(): void { $user = BeanFactory::newBean('Users'); $user->id = 1; @@ -123,13 +122,13 @@ class SugarFolderTest extends SuitePHPUnitFrameworkTestCase $saved = $sugarfolder->setFolder($fields); - $this->assertTrue($saved); + self::assertTrue($saved); $sugarfolder->insertFolderSubscription($sugarfolder->id, $user->id); $subscriptions = $sugarfolder->getSubscriptions($user); - $this->assertTrue((count($subscriptions) > 0)); + self::assertTrue((count($subscriptions) > 0)); // Access clear with user $sugarfolder->clearSubscriptions($user); @@ -139,7 +138,7 @@ class SugarFolderTest extends SuitePHPUnitFrameworkTestCase $subscriptions = $sugarfolder->getSubscriptions(null); - $this->assertEquals(0, count($subscriptions)); + self::assertCount(0, $subscriptions); // test the add subscription to group folder $sugarfolder->addSubscriptionsToGroupFolder(); @@ -151,7 +150,7 @@ class SugarFolderTest extends SuitePHPUnitFrameworkTestCase // $sugarfolder->clearSubscriptions($user = null) } - public function testClearSubscriptionsForFolder() + public function testClearSubscriptionsForFolder(): void { $user = BeanFactory::newBean('Users'); $user->id = 1; @@ -165,14 +164,14 @@ class SugarFolderTest extends SuitePHPUnitFrameworkTestCase $saved = $sugarfolder->setFolder($fields); - $this->assertTrue($saved); + self::assertTrue($saved); $sugarfolder->insertFolderSubscription($sugarfolder->id, $user->id); $sugarfolder->clearSubscriptionsForFolder($sugarfolder->id); } - public function testGetFoldersForSettings() + public function testGetFoldersForSettings(): void { $user = BeanFactory::newBean('Users'); $user->id = 1; @@ -186,7 +185,7 @@ class SugarFolderTest extends SuitePHPUnitFrameworkTestCase $saved = $sugarfolder->setFolder($fields); - $this->assertTrue($saved); + self::assertTrue($saved); $saved = false; @@ -199,20 +198,20 @@ class SugarFolderTest extends SuitePHPUnitFrameworkTestCase $saved = $childSugarFolder->setFolder($fields); - $this->assertTrue($saved); + self::assertTrue($saved); $sugarfolder->has_child = 1; $ret = $sugarfolder->getFoldersForSettings(); - $this->assertTrue(is_array($ret)); + self::assertIsArray($ret); $ret = $childSugarFolder->getParentIDRecursive($childSugarFolder->id); - $this->assertTrue(in_array($sugarfolder->id, $ret)); + self::assertContains($sugarfolder->id, $ret); } - public function testCrudFolder() + public function testCrudFolder(): void { $user = BeanFactory::newBean('Users'); $user->id = 1; @@ -226,7 +225,7 @@ class SugarFolderTest extends SuitePHPUnitFrameworkTestCase $saved = $sugarfolder->setFolder($fields); - $this->assertTrue($saved); + self::assertTrue($saved); $saved = false; @@ -239,7 +238,7 @@ class SugarFolderTest extends SuitePHPUnitFrameworkTestCase $saved = $childSugarFolder->setFolder($fields); - $this->assertTrue($saved); + self::assertTrue($saved); $sugarfolder->has_child = 1; @@ -251,7 +250,7 @@ class SugarFolderTest extends SuitePHPUnitFrameworkTestCase $ret = $sugarfolder->updateFolder($update); - $this->assertEquals('done', $ret['status']); + self::assertEquals('done', $ret['status']); // Try to update the child with parent @@ -263,23 +262,21 @@ class SugarFolderTest extends SuitePHPUnitFrameworkTestCase $ret = $sugarfolder->updateFolder($update); - $this->assertEquals('failed', $ret['status']); + self::assertEquals('failed', $ret['status']); $deleted = $sugarfolder->delete(); - $this->assertTrue($deleted); + self::assertTrue($deleted); } - public function testCheckFalseIdForDelete() + public function testCheckFalseIdForDelete(): void { - $sugarfolder = new SugarFolder(); + $ret = (new SugarFolder())->delete(); - $ret = $sugarfolder->delete(); - - $this->assertFalse($ret); + self::assertFalse($ret); } - public function testCopyBean() + public function testCopyBean(): void { $user = BeanFactory::newBean('Users'); $user->id = 1; @@ -293,7 +290,7 @@ class SugarFolderTest extends SuitePHPUnitFrameworkTestCase $saved = $parentFolderOne->setFolder($fields); - $this->assertTrue($saved); + self::assertTrue($saved); // reset saved $saved = false; @@ -307,7 +304,7 @@ class SugarFolderTest extends SuitePHPUnitFrameworkTestCase $saved = $parentFolderTwo->setFolder($fields); - $this->assertTrue($saved); + self::assertTrue($saved); $bean = BeanFactory::newBean('Emails'); $bean->save(); @@ -319,13 +316,13 @@ class SugarFolderTest extends SuitePHPUnitFrameworkTestCase $existInFolderOne = $parentFolderOne->checkEmailExistForFolder($bean->id); $existInFolderTwo = $parentFolderTwo->checkEmailExistForFolder($bean->id); - $this->assertTrue($existInFolderOne); + self::assertTrue($existInFolderOne); - $this->assertTrue($existInFolderTwo); + self::assertTrue($existInFolderTwo); } - public function testMoveFolder() + public function testMoveFolder(): void { $user = BeanFactory::newBean('Users'); $user->id = 1; @@ -339,7 +336,7 @@ class SugarFolderTest extends SuitePHPUnitFrameworkTestCase $saved = $parentFolderOne->setFolder($fields); - $this->assertTrue($saved); + self::assertTrue($saved); // reset saved $saved = false; @@ -353,7 +350,7 @@ class SugarFolderTest extends SuitePHPUnitFrameworkTestCase $saved = $parentFolderTwo->setFolder($fields); - $this->assertTrue($saved); + self::assertTrue($saved); // reset saved $saved = false; @@ -367,14 +364,14 @@ class SugarFolderTest extends SuitePHPUnitFrameworkTestCase $saved = $childFolder->setFolder($fields); - $this->assertTrue($saved); + self::assertTrue($saved); $success = $parentFolderOne->move($parentFolderOne->id, $parentFolderTwo->id, $childFolder->id); - $this->assertTrue($success); + self::assertTrue($success); } - public function testGetListItemsForEmailXML() + public function testGetListItemsForEmailXML(): void { $user = BeanFactory::newBean('Users'); $user->id = 1; @@ -383,7 +380,7 @@ class SugarFolderTest extends SuitePHPUnitFrameworkTestCase $sugarFolder->name = 'Parent Folder'; $saved = $sugarFolder->save(); - $this->assertTrue($saved); + self::assertTrue($saved); $saved = false; for ($i = 0; $i < 10; $i++) { @@ -394,7 +391,7 @@ class SugarFolderTest extends SuitePHPUnitFrameworkTestCase } $results = $sugarFolder->getListItemsForEmailXML($sugarFolder->id); - $this->assertTrue(is_array($results)); + self::assertIsArray($results); $results = false; $dynamicSugarFolder = new SugarFolder($user); @@ -405,7 +402,7 @@ class SugarFolderTest extends SuitePHPUnitFrameworkTestCase $dynamicSugarFolder->hrSortLocal = array(); $saved = $dynamicSugarFolder->save(); - $this->assertTrue($saved); + self::assertTrue($saved); for ($i = 0; $i < 10; $i++) { $arrayOfEmailBeans[$i] = BeanFactory::newBean('Emails'); @@ -415,10 +412,10 @@ class SugarFolderTest extends SuitePHPUnitFrameworkTestCase } $results = $dynamicSugarFolder->getListItemsForEmailXML($dynamicSugarFolder->id); - $this->assertTrue(is_array($results)); + self::assertIsArray($results); } - public function testCountOfItems() + public function testCountOfItems(): void { $user = BeanFactory::newBean('Users'); $user->id = 1; @@ -431,7 +428,7 @@ class SugarFolderTest extends SuitePHPUnitFrameworkTestCase ); $saved = $parentFolder->setFolder($fields); - $this->assertTrue($saved); + self::assertTrue($saved); $saved = false; @@ -449,14 +446,14 @@ class SugarFolderTest extends SuitePHPUnitFrameworkTestCase $count = $parentFolder->getCountItems($parentFolder->id); - $this->assertEquals(10, $count); + self::assertEquals(10, $count); // Test getCountNewItems $count = $parentFolder->getCountNewItems($parentFolder->id, false, false); - $this->assertEquals(0, $count); + self::assertEquals(0, $count); $count = $parentFolder->getCountUnread($parentFolder->id); - $this->assertEquals(0, $count); + self::assertEquals(0, $count); // non-existent folder @@ -479,7 +476,7 @@ class SugarFolderTest extends SuitePHPUnitFrameworkTestCase $saved = $parentFolder->save(); - $this->assertTrue($saved); + self::assertTrue($saved); $saved = false; $arrayOfEmailBeans = array(); @@ -492,13 +489,13 @@ class SugarFolderTest extends SuitePHPUnitFrameworkTestCase } $count = $parentFolder->getCountItems($parentFolder->id); - $this->assertEquals(0, $count); + self::assertEquals(0, $count); $count = $parentFolder->getCountUnread($parentFolder->id); - $this->assertEquals(0, $count); + self::assertEquals(0, $count); } - public function testNonExistingRetrieve() + public function testNonExistingRetrieve(): void { $user = BeanFactory::newBean('Users'); $user->id = 1; @@ -509,10 +506,10 @@ class SugarFolderTest extends SuitePHPUnitFrameworkTestCase $ret = $parentFolder->retrieve($randomGuid); - $this->assertFalse($ret); + self::assertFalse($ret); } - public function testDeleteEmailsFromFolder() + public function testDeleteEmailsFromFolder(): void { $user = BeanFactory::newBean('Users'); $user->id = 1; @@ -526,7 +523,7 @@ class SugarFolderTest extends SuitePHPUnitFrameworkTestCase $saved = $parentFolder->setFolder($fields); - $this->assertTrue($saved); + self::assertTrue($saved); $bean = BeanFactory::newBean('Emails'); $bean->save(); @@ -535,13 +532,13 @@ class SugarFolderTest extends SuitePHPUnitFrameworkTestCase $count = $parentFolder->getCountItems($parentFolder->id); - $this->assertEquals(1, $count); + self::assertEquals(1, $count); $parentFolder->deleteEmailFromFolder($bean->id); } - public function testDeleteEmailsFromAllFolders() + public function testDeleteEmailsFromAllFolders(): void { $user = BeanFactory::newBean('Users'); $user->id = 1; @@ -555,7 +552,7 @@ class SugarFolderTest extends SuitePHPUnitFrameworkTestCase $saved = $parentFolderOne->setFolder($fields); - $this->assertTrue($saved); + self::assertTrue($saved); // reset saved $saved = false; @@ -569,7 +566,7 @@ class SugarFolderTest extends SuitePHPUnitFrameworkTestCase $saved = $parentFolderTwo->setFolder($fields); - $this->assertTrue($saved); + self::assertTrue($saved); $bean = BeanFactory::newBean('Emails'); $bean->save(); @@ -581,21 +578,21 @@ class SugarFolderTest extends SuitePHPUnitFrameworkTestCase $existInFolderOne = $parentFolderOne->checkEmailExistForFolder($bean->id); $existInFolderTwo = $parentFolderTwo->checkEmailExistForFolder($bean->id); - $this->assertTrue($existInFolderOne); - $this->assertTrue($existInFolderTwo); + self::assertTrue($existInFolderOne); + self::assertTrue($existInFolderTwo); $parentFolderOne->deleteEmailFromAllFolder($bean->id); $existInFolderOne = $parentFolderOne->checkEmailExistForFolder($bean->id); $existInFolderTwo = $parentFolderTwo->checkEmailExistForFolder($bean->id); - $this->assertFalse($existInFolderOne); - $this->assertFalse($existInFolderTwo); + self::assertFalse($existInFolderOne); + self::assertFalse($existInFolderTwo); } - public function testGetUserFolders() + public function testGetUserFolders(): void { - $this->markTestIncomplete( + self::markTestIncomplete( 'This test requires a review' ); @@ -609,7 +606,7 @@ class SugarFolderTest extends SuitePHPUnitFrameworkTestCase $saved = $parentFolderOne->save(); - $this->assertTrue($saved); + self::assertTrue($saved); $arrayOfEmailBeans = array(); @@ -664,10 +661,10 @@ class SugarFolderTest extends SuitePHPUnitFrameworkTestCase $parentFolderOne->getUserFolders($rootNode, sugar_unserialize($folderOpenState), null, true); - $this->assertTrue(is_object($rootNode)); + self::assertIsObject($rootNode); } - public function testSetSubscriptionWithNoUser() + public function testSetSubscriptionWithNoUser(): void { $user = BeanFactory::newBean('Users'); $user->id = 1; @@ -681,16 +678,16 @@ class SugarFolderTest extends SuitePHPUnitFrameworkTestCase $saved = $parentFolderOne->setFolder($fields); - $this->assertTrue($saved); + self::assertTrue($saved); $subs = array($parentFolderOne->id); $ret = $parentFolderOne->setSubscriptions($subs, 0); - $this->assertFalse($ret); + self::assertFalse($ret); } - public function testUpdateSave() + public function testUpdateSave(): void { $user = BeanFactory::newBean('Users'); $user->id = 1; @@ -704,7 +701,7 @@ class SugarFolderTest extends SuitePHPUnitFrameworkTestCase $saved = $parentFolderOne->setFolder($fields); - $this->assertTrue($saved); + self::assertTrue($saved); $parentFolderOne->new_with_id = true; $parentFolderOne->save(); diff --git a/tests/unit/phpunit/include/SugarLogger/LoggerManagerTest.php b/tests/unit/phpunit/includes/SugarLogger/LoggerManagerTest.php similarity index 60% rename from tests/unit/phpunit/include/SugarLogger/LoggerManagerTest.php rename to tests/unit/phpunit/includes/SugarLogger/LoggerManagerTest.php index 709cf8a42..886842097 100644 --- a/tests/unit/phpunit/include/SugarLogger/LoggerManagerTest.php +++ b/tests/unit/phpunit/includes/SugarLogger/LoggerManagerTest.php @@ -27,36 +27,34 @@ class LoggerManagerTest extends SuitePHPUnitFrameworkTestCase parent::tearDown(); } - public function testLoggerLevels() + public function testLoggerLevels(): void { $loggerManager = self::$loggerManager; $loggerManager::setLevelMapping('test', 125); $loggerLevels = $loggerManager::getLoggerLevels(); - $this->assertArrayHasKey('test', $loggerLevels); + self::assertArrayHasKey('test', $loggerLevels); } - public function testGetLogLevel() + public function testGetLogLevel(): void { - $loggerManager = self::$loggerManager; - $logLevel = $loggerManager::getLogLevel(); - $this->assertEquals('fatal', $logLevel); + $logLevel = self::$loggerManager::getLogLevel(); + self::assertEquals('fatal', $logLevel); } - public function testGetAvailableLoggers() + public function testGetAvailableLoggers(): void { - $loggerManager = self::$loggerManager; - $loggers = $loggerManager::getAvailableLoggers(); + $loggers = self::$loggerManager::getAvailableLoggers(); - $this->assertContains('SugarLogger', $loggers); + self::assertContains('SugarLogger', $loggers); } - public function testSetLoggerLevel() + public function testSetLoggerLevel(): void { $loggerManager = self::$loggerManager; $loggerManager->setLevel('debug'); $logLevel = $loggerManager::getLogLevel(); - $this->assertEquals('debug', $logLevel); + self::assertEquals('debug', $logLevel); } } diff --git a/tests/unit/phpunit/include/SugarObjects/templates/PersonTest.php b/tests/unit/phpunit/includes/SugarObjects/templates/PersonTest.php similarity index 65% rename from tests/unit/phpunit/include/SugarObjects/templates/PersonTest.php rename to tests/unit/phpunit/includes/SugarObjects/templates/PersonTest.php index 76355e738..f3cbf506c 100644 --- a/tests/unit/phpunit/include/SugarObjects/templates/PersonTest.php +++ b/tests/unit/phpunit/includes/SugarObjects/templates/PersonTest.php @@ -48,7 +48,7 @@ class PersonTest extends SuitePHPUnitFrameworkTestCase */ protected $tester; - public function testSetLawfulBasis() + public function testSetLawfulBasis(): void { $person = BeanFactory::newBean('Contacts'); $person->last_name = 'Smith'; @@ -56,58 +56,58 @@ class PersonTest extends SuitePHPUnitFrameworkTestCase // Test when basis is not a string try { $person->setLawfulBasis(1, ''); - $this->assertTrue(false); + self::assertTrue(false); } catch (InvalidArgumentException $ex) { - $this->assertEquals('basis must be a string', $ex->getMessage()); + self::assertEquals('basis must be a string', $ex->getMessage()); } // test when basis does not exist try { $person->setLawfulBasis('Test Invalid Basis', ''); - $this->assertTrue(false); + self::assertTrue(false); } catch (InvalidArgumentException $ex) { - $this->assertEquals('invalid lawful basis', $ex->getMessage()); + self::assertEquals('invalid lawful basis', $ex->getMessage()); } - + // test valid basis - $this->assertEquals(1, $person->setLawfulBasis('', '')); - $this->assertEquals(1, $person->setLawfulBasis('consent', '')); - $this->assertEquals(1, $person->setLawfulBasis('contract', '')); - $this->assertEquals(1, $person->setLawfulBasis('legal_obligation', '')); - $this->assertEquals(1, $person->setLawfulBasis('protection_of_interest', '')); - $this->assertEquals(1, $person->setLawfulBasis('public_interest', '')); - $this->assertEquals(1, $person->setLawfulBasis('legitimate_interest', '')); - $this->assertEquals(1, $person->setLawfulBasis('withdrawn', '')); + self::assertEquals(1, $person->setLawfulBasis('', '')); + self::assertEquals(1, $person->setLawfulBasis('consent', '')); + self::assertEquals(1, $person->setLawfulBasis('contract', '')); + self::assertEquals(1, $person->setLawfulBasis('legal_obligation', '')); + self::assertEquals(1, $person->setLawfulBasis('protection_of_interest', '')); + self::assertEquals(1, $person->setLawfulBasis('public_interest', '')); + self::assertEquals(1, $person->setLawfulBasis('legitimate_interest', '')); + self::assertEquals(1, $person->setLawfulBasis('withdrawn', '')); // test lawful basis has been set $person->setLawfulBasis('consent', ''); - $this->assertEquals($person->lawful_basis, '^consent^'); - + self::assertEquals('^consent^', $person->lawful_basis); + // Test when source is not a string try { $person->setLawfulBasis('', 1); - $this->assertTrue(false); + self::assertTrue(false); } catch (InvalidArgumentException $ex) { - $this->assertEquals('source for lawful basis must be a string', $ex->getMessage()); + self::assertEquals('source for lawful basis must be a string', $ex->getMessage()); } - + // test when source does not exist try { $person->setLawfulBasis('', 'Test Invalid Sources'); - $this->assertTrue(false); + self::assertTrue(false); } catch (InvalidArgumentException $ex) { - $this->assertEquals('invalid lawful basis source', $ex->getMessage()); + self::assertEquals('invalid lawful basis source', $ex->getMessage()); } // test lawful sources - $this->assertEquals(true, $person->setLawfulBasis('', '')); - $this->assertEquals(true, $person->setLawfulBasis('', 'website')); - $this->assertEquals(true, $person->setLawfulBasis('', 'phone')); - $this->assertEquals(true, $person->setLawfulBasis('', 'given_to_user')); - $this->assertEquals(true, $person->setLawfulBasis('', 'email')); - $this->assertEquals(true, $person->setLawfulBasis('', 'third_party')); + self::assertEquals(true, $person->setLawfulBasis('', '')); + self::assertEquals(true, $person->setLawfulBasis('', 'website')); + self::assertEquals(true, $person->setLawfulBasis('', 'phone')); + self::assertEquals(true, $person->setLawfulBasis('', 'given_to_user')); + self::assertEquals(true, $person->setLawfulBasis('', 'email')); + self::assertEquals(true, $person->setLawfulBasis('', 'third_party')); // test that source is being set - $this->assertEquals('third_party', $person->lawful_basis_source); + self::assertEquals('third_party', $person->lawful_basis_source); } } diff --git a/tests/unit/phpunit/includes/SugarTheme/SugarThemeTest.php b/tests/unit/phpunit/includes/SugarTheme/SugarThemeTest.php new file mode 100644 index 000000000..d6213387d --- /dev/null +++ b/tests/unit/phpunit/includes/SugarTheme/SugarThemeTest.php @@ -0,0 +1,15 @@ +getMimeType('svg')); + self::assertEquals('image/gif', $theme->getMimeType('gif')); + self::assertEquals('image/png', $theme->getMimeType('png')); + self::assertEquals(null, $theme->getMimeType('notanextension')); + } +} diff --git a/tests/unit/phpunit/include/TimeDateTest.php b/tests/unit/phpunit/includes/TimeDateTest.php similarity index 54% rename from tests/unit/phpunit/include/TimeDateTest.php rename to tests/unit/phpunit/includes/TimeDateTest.php index 59c8d069d..d9fb61ab5 100644 --- a/tests/unit/phpunit/include/TimeDateTest.php +++ b/tests/unit/phpunit/includes/TimeDateTest.php @@ -1,10 +1,53 @@ setPreference('datef', 'Y-m-d'); - $timeDate = new TimeDate($user); - $actual = $timeDate->get_date_format(); + $actual = (new TimeDate($user))->get_date_format(); $expected = 'Y-m-d'; - $this->assertEquals($expected, $actual); + self::assertEquals($expected, $actual); } - public function testget_time_format() + public function testget_time_format(): void { // Validate that it gets the time format from the user's preferences. $user = BeanFactory::newBean('Users'); @@ -26,13 +68,12 @@ class TimeDateTest extends SuitePHPUnitFrameworkTestCase $userPreference = new UserPreference($user); $userPreference->setPreference('timef', 'H:i:s'); - $timeDate = new TimeDate($user); - $actual = $timeDate->get_time_format(); + $actual = (new TimeDate($user))->get_time_format(); $expected = 'H:i:s'; - $this->assertEquals($expected, $actual); + self::assertEquals($expected, $actual); } - public function testget_date_time_format() + public function testget_date_time_format(): void { // Validate that it gets the date time format from the user's preferences. $user = BeanFactory::newBean('Users'); @@ -41,13 +82,12 @@ class TimeDateTest extends SuitePHPUnitFrameworkTestCase $userPreference->setPreference('datef', 'Y-m-d'); $userPreference->setPreference('timef', 'H:i:s'); - $timeDate = new TimeDate($user); - $actual = $timeDate->get_date_time_format(); + $actual = (new TimeDate($user))->get_date_time_format(); $expected = 'Y-m-d H:i:s'; - $this->assertEquals($expected, $actual); + self::assertEquals($expected, $actual); } - public function testget_first_day_of_week() + public function testget_first_day_of_week(): void { // Validate that it gets the first day of the week from the user's // preferences. @@ -56,33 +96,30 @@ class TimeDateTest extends SuitePHPUnitFrameworkTestCase $userPreference = new UserPreference($user); $userPreference->setPreference('fdow', 1); - $timeDate = new TimeDate($user); - $actual = $timeDate->get_first_day_of_week(); + $actual = (new TimeDate($user))->get_first_day_of_week(); $expected = 1; - $this->assertEquals($expected, $actual); + self::assertEquals($expected, $actual); } - public function testget_first_day_of_week_defaultResponse() + public function testget_first_day_of_week_defaultResponse(): void { // When no user is specified for the TimeDate, // it defaults to 0 aka Sunday. - $timeDate = new TimeDate(); - $actual = $timeDate->get_first_day_of_week(); + $actual = (new TimeDate())->get_first_day_of_week(); $expected = 0; - $this->assertEquals($expected, $actual); + self::assertEquals($expected, $actual); } - public function testmerge_date_time() + public function testmerge_date_time(): void { // Merges the date and time formats given two strings. // Literally just puts a space in between them. - $timeDate = new TimeDate(); - $actual = $timeDate->merge_date_time('Y-m-d', 'H:i:s'); + $actual = (new TimeDate())->merge_date_time('Y-m-d', 'H:i:s'); $expected = 'Y-m-d H:i:s'; - $this->assertEquals($expected, $actual); + self::assertEquals($expected, $actual); } - public function testsplit_date_time() + public function testsplit_date_time(): void { // Splits the date time format into an array of two items when given // a valid string. @@ -91,16 +128,15 @@ class TimeDateTest extends SuitePHPUnitFrameworkTestCase self::assertEquals($expected, $actual); } - public function testhttpTime() + public function testhttpTime(): void { // Returns a timestamp in the format defined by RFC 2616. - $timeDate = new TimeDate(); - $actual = $timeDate->httpTime(1546300800); + $actual = (new TimeDate())::httpTime(1546300800); $expected = 'Tue, 01 Jan 2019 00:00:00 GMT'; - $this->assertEquals($expected, $actual); + self::assertEquals($expected, $actual); } - public function testto_db_time() + public function testto_db_time(): void { // Test that the function returns the time but not the date, even if // a date is provided. @@ -114,14 +150,14 @@ class TimeDateTest extends SuitePHPUnitFrameworkTestCase $actual = $timeDate->to_db_time('2019-01-01 11:00:00'); $expected = '11:00:00'; - $this->assertEquals($expected, $actual); + self::assertEquals($expected, $actual); $actual2 = $timeDate->to_db_time('23:30:00'); $expected2 = '23:30:00'; - $this->assertEquals($expected2, $actual2); + self::assertEquals($expected2, $actual2); } - public function testto_db_date_time() + public function testto_db_date_time(): void { // Test that the function returns the full date time as an array. // We create a user here, but it doesn't actually take the user's @@ -132,14 +168,12 @@ class TimeDateTest extends SuitePHPUnitFrameworkTestCase $userPreference = new UserPreference($user); $userPreference->setPreference('datef', 'Y-m-d'); $userPreference->setPreference('timef', 'H:i:s'); - $timeDate = new TimeDate($user); - - $actual = $timeDate->to_db_date_time('2019-01-01', '11:00:00'); + $actual = (new TimeDate($user))->to_db_date_time('2019-01-01', '11:00:00'); $expected = ['2019-01-01', '11:00:00']; - $this->assertEquals($expected, $actual); + self::assertEquals($expected, $actual); } - public function testsplitTime() + public function testsplitTime(): void { // Split time when the input is only a time represented as a string. $actual = (new TimeDate())->splitTime('11:30:00', 'H:i:s'); diff --git a/tests/unit/phpunit/include/UtilsTest.php b/tests/unit/phpunit/includes/UtilsTest.php similarity index 60% rename from tests/unit/phpunit/include/UtilsTest.php rename to tests/unit/phpunit/includes/UtilsTest.php index 0c1698bec..e9056b603 100644 --- a/tests/unit/phpunit/include/UtilsTest.php +++ b/tests/unit/phpunit/includes/UtilsTest.php @@ -1,11 +1,10 @@ assertTrue(!isset($app_strings['TEST_NONEXISTS_LABEL'])); + self::assertNotTrue(isset($app_strings['TEST_NONEXISTS_LABEL'])); // test if label is not set $result = getAppString('TEST_NONEXISTS_LABEL'); - $this->assertEquals('TEST_NONEXISTS_LABEL', $result); + self::assertEquals('TEST_NONEXISTS_LABEL', $result); // test if label is empty (bool:false) $app_strings['TEST_NONEXISTS_LABEL'] = ''; $result = getAppString('TEST_NONEXISTS_LABEL'); - $this->assertEquals('TEST_NONEXISTS_LABEL', $result); + self::assertEquals('TEST_NONEXISTS_LABEL', $result); // test if it founds $app_strings['TEST_NONEXISTS_LABEL'] = 'Hello test'; $result = getAppString('TEST_NONEXISTS_LABEL'); - $this->assertEquals('Hello test', $result); + self::assertEquals('Hello test', $result); unset($app_strings['TEST_NONEXISTS_LABEL']); } - public function testencodeMultienumValue() + public function testencodeMultienumValue(): void { - $this->assertEquals('', encodeMultienumValue(array())); - $this->assertEquals('^foo^', encodeMultienumValue(array('foo'))); - $this->assertEquals('^foo^,^bar^', encodeMultienumValue(array('foo', 'bar'))); + self::assertEquals('', encodeMultienumValue(array())); + self::assertEquals('^foo^', encodeMultienumValue(array('foo'))); + self::assertEquals('^foo^,^bar^', encodeMultienumValue(array('foo', 'bar'))); } - public function testunencodeMultienum() + public function testunencodeMultienum(): void { - $this->assertEquals(array('foo'), unencodeMultienum('^foo^')); - $this->assertEquals(array('foo', 'bar'), unencodeMultienum('^foo^,^bar^')); + self::assertEquals(array('foo'), unencodeMultienum('^foo^')); + self::assertEquals(array('foo', 'bar'), unencodeMultienum('^foo^,^bar^')); // Will return the same array if given an array. - $this->assertEquals(array('foo', 'bar'), unencodeMultienum(['foo', 'bar'])); + self::assertEquals(array('foo', 'bar'), unencodeMultienum(['foo', 'bar'])); } - public function testget_languages() + public function testget_languages(): void { - $this->assertEquals(['en_us' => 'English (US)'], get_languages()); - $this->assertEquals(['en_us' => 'English (US)'], get_all_languages()); - $this->assertEquals('English (US)', get_language_display('en_us')); + self::assertEquals(['en_us' => 'English (US)'], get_languages()); + self::assertEquals(['en_us' => 'English (US)'], get_all_languages()); + self::assertEquals('English (US)', get_language_display('en_us')); } - public function testget_current_language() + public function testget_current_language(): void { global $sugar_config; $_SESSION['authenticated_user_language'] = 'foo'; - $this->assertEquals('foo', get_current_language()); - $this->assertEquals('foo', get_current_language()); + self::assertEquals('foo', get_current_language()); + self::assertEquals('foo', get_current_language()); $sugar_config['default_language'] = 'bar'; - $this->assertEquals('foo', get_current_language()); + self::assertEquals('foo', get_current_language()); unset($_SESSION['authenticated_user_language']); - $this->assertEquals('bar', get_current_language()); + self::assertEquals('bar', get_current_language()); } - public function testis_admin() + public function testis_admin(): void { // Returns true if the user is an admin. $user = new \User(); $user->is_admin = true; - $this->assertTrue(is_admin($user)); + self::assertTrue(is_admin($user)); // Returns false if the user is not an admin. $user2 = new \User(); $user2->is_admin = false; - $this->assertFalse(is_admin($user2)); + self::assertFalse(is_admin($user2)); // Returns false if no user object is passed. - $this->assertFalse(is_admin(null)); + self::assertFalse(is_admin(null)); } - public function testcheck_php_version() + public function testcheck_php_version(): void { // These are used because the tests would fail if the supported // versions changed, and the constants can't be redefined. So we @@ -142,46 +145,46 @@ class UtilsTest extends SuitePHPUnitFrameworkTestCase $recommendedVersion = '7.1.0'; // Returns -1 when the version is less than the minimum version. - $this->assertEquals(-1, check_php_version("5.4.0", $minimumVersion, $recommendedVersion)); + self::assertEquals(-1, check_php_version("5.4.0", $minimumVersion, $recommendedVersion)); // Returns 0 when the version is above the minimum but below the recommended version. - $this->assertEquals(0, check_php_version("7.0.0", $minimumVersion, $recommendedVersion)); + self::assertEquals(0, check_php_version("7.0.0", $minimumVersion, $recommendedVersion)); // Returns 1 when the version is at or above the recommended version. - $this->assertEquals(1, check_php_version("7.1.0", $minimumVersion, $recommendedVersion)); - $this->assertEquals(1, check_php_version("7.2.0", $minimumVersion, $recommendedVersion)); - $this->assertEquals(1, check_php_version("8.0.0", $minimumVersion, $recommendedVersion)); + self::assertEquals(1, check_php_version("7.1.0", $minimumVersion, $recommendedVersion)); + self::assertEquals(1, check_php_version("7.2.0", $minimumVersion, $recommendedVersion)); + self::assertEquals(1, check_php_version("8.0.0", $minimumVersion, $recommendedVersion)); // Handles versions with a `-dev` suffix correctly. - $this->assertEquals(1, check_php_version("7.4.0-dev", $minimumVersion, $recommendedVersion)); + self::assertEquals(1, check_php_version("7.4.0-dev", $minimumVersion, $recommendedVersion)); } - public function testreturn_bytes() + public function testreturn_bytes(): void { // Test bytes. If you input just '8', it'll output 8. - $this->assertEquals(8, return_bytes('8')); + self::assertEquals(8, return_bytes('8')); // Test kibibytes. - $this->assertEquals(8192, return_bytes('8K')); - $this->assertEquals(8192, return_bytes('8k')); + self::assertEquals(8192, return_bytes('8K')); + self::assertEquals(8192, return_bytes('8k')); // Test mebibytes. // 8M is 8 mebibytes, 1 mebibyte is 1,048,576 bytes or 2^20 bytes. - $this->assertEquals(8388608, return_bytes('8M')); - $this->assertEquals(8388608, return_bytes('8m')); + self::assertEquals(8388608, return_bytes('8M')); + self::assertEquals(8388608, return_bytes('8m')); // Test gibibytes - $this->assertEquals(8589934592, return_bytes('8G')); - $this->assertEquals(8589934592, return_bytes('8g')); + self::assertEquals(8589934592, return_bytes('8G')); + self::assertEquals(8589934592, return_bytes('8g')); // Make sure it also understands strings with whitespace. - $this->assertEquals(8192, return_bytes(' 8K ')); + self::assertEquals(8192, return_bytes(' 8K ')); } - public function testSecureXSS() + public function testSecureXSS(): void { $uncleanString = 'XSS'; $result = securexss($uncleanString); - $this->assertEquals($result, 'XSS'); + self::assertEquals('XSS', $result); } } diff --git a/tests/unit/phpunit/include/database/DBManagerTest.php b/tests/unit/phpunit/includes/database/DBManagerTest.php similarity index 69% rename from tests/unit/phpunit/include/database/DBManagerTest.php rename to tests/unit/phpunit/includes/database/DBManagerTest.php index b8cc4f6da..9edcf1ccf 100644 --- a/tests/unit/phpunit/include/database/DBManagerTest.php +++ b/tests/unit/phpunit/includes/database/DBManagerTest.php @@ -12,7 +12,7 @@ class DBManagerTest extends SuitePHPUnitFrameworkTestCase { // Make sure createPreparedQuery returns the correct SQL query when given // a simple query. - public function testcreatePreparedQueryWithSimpleQuery() + public function testcreatePreparedQueryWithSimpleQuery(): void { $db = DBManagerFactory::getInstance(); @@ -20,15 +20,15 @@ class DBManagerTest extends SuitePHPUnitFrameworkTestCase $stmt = $db->prepareQuery($sql); - $this->assertEquals( - $db->createPreparedQuery($stmt, ["foo"]), - "SELECT foo FROM bar WHERE baz = 'foo';" + self::assertEquals( + "SELECT foo FROM bar WHERE baz = 'foo';", + $db->createPreparedQuery($stmt, ["foo"]) ); } // Make sure createPreparedQuery returns the correct SQL query when given // a slightly more complex query. - public function testcreatePreparedQueryWithMoreComplexQuery() + public function testcreatePreparedQueryWithMoreComplexQuery(): void { $db = DBManagerFactory::getInstance(); @@ -36,15 +36,15 @@ class DBManagerTest extends SuitePHPUnitFrameworkTestCase $stmt = $db->prepareQuery($sql); - $this->assertEquals( - $db->createPreparedQuery($stmt, ["foo", "bar"]), - "SELECT foo FROM bar WHERE baz = 'foo' AND qux = 'bar';" + self::assertEquals( + "SELECT foo FROM bar WHERE baz = 'foo' AND qux = 'bar';", + $db->createPreparedQuery($stmt, ["foo", "bar"]) ); } // Make sure createPreparedQuery returns the correct SQL query when // using '!=' in the input. - public function testcreatePreparedQueryWithNegation() + public function testcreatePreparedQueryWithNegation(): void { $db = DBManagerFactory::getInstance(); @@ -52,15 +52,15 @@ class DBManagerTest extends SuitePHPUnitFrameworkTestCase $stmt = $db->prepareQuery($sql); - $this->assertEquals( - $db->createPreparedQuery($stmt, ["foo"]), - "SELECT foo FROM bar WHERE baz != 'foo';" + self::assertEquals( + "SELECT foo FROM bar WHERE baz != 'foo';", + $db->createPreparedQuery($stmt, ["foo"]) ); } // Make sure createPreparedQuery returns the correct SQL query when // using '\?' in the input. - public function testcreatePreparedQueryWithEscapedToken() + public function testcreatePreparedQueryWithEscapedToken(): void { $db = DBManagerFactory::getInstance(); @@ -69,9 +69,9 @@ class DBManagerTest extends SuitePHPUnitFrameworkTestCase $stmt = $db->prepareQuery($sql); - $this->assertEquals( - $db->createPreparedQuery($stmt, ["foo"]), - "SELECT foo FROM bar WHERE baz = 'foo?';" + self::assertEquals( + "SELECT foo FROM bar WHERE baz = 'foo?';", + $db->createPreparedQuery($stmt, ["foo"]) ); } } diff --git a/tests/unit/phpunit/include/utils/LogicHookTest.php b/tests/unit/phpunit/includes/utils/LogicHookTest.php similarity index 80% rename from tests/unit/phpunit/include/utils/LogicHookTest.php rename to tests/unit/phpunit/includes/utils/LogicHookTest.php index 924ca8cd2..812b7a059 100644 --- a/tests/unit/phpunit/include/utils/LogicHookTest.php +++ b/tests/unit/phpunit/includes/utils/LogicHookTest.php @@ -1,63 +1,97 @@ assertInstanceOf('LogicHook', $LogicHook); + self::assertInstanceOf('LogicHook', $LogicHook); } - public function testLogicHook() + public function testLogicHook(): void { //execute the method and test if it doesn't throw an exception try { $LogicHook = new LogicHook(); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } } - public function testsetBean() + public function testsetBean(): void { //execute the method and test if it returns correct class instances - $LogicHook = new LogicHook(); - $result = $LogicHook->setBean(BeanFactory::newBean('Users')); - $this->assertInstanceOf('LogicHook', $result); - $this->assertInstanceOf('User', $result->bean); + $result = (new LogicHook())->setBean(BeanFactory::newBean('Users')); + self::assertInstanceOf('LogicHook', $result); + self::assertInstanceOf('User', $result->bean); } - public function testgetHooksMap() + public function testgetHooksMap(): void { //execute the method and test if it returns true - $LogicHook = new LogicHook(); - $hook_map = $LogicHook->getHooksMap(); - $this->assertTrue(is_array($hook_map)); + $hook_map = (new LogicHook())->getHooksMap(); + self::assertIsArray($hook_map); } - public function testgetHooksList() + public function testgetHooksList(): void { //execute the method and test if it returns true - $LogicHook = new LogicHook(); - $hookscan = $LogicHook->getHooksList(); - $this->assertTrue(is_array($hookscan)); + $hookscan = (new LogicHook())->getHooksList(); + self::assertIsArray($hookscan); } - public function testscanHooksDir() + public function testscanHooksDir(): void { //execute the method and test if it returns expected contents $expected_hook_map = array( @@ -154,26 +188,26 @@ class LogicHookTest extends SuitePHPUnitFrameworkTestCase if (file_exists('custom/modules/Accounts') && is_dir('custom/modules/Accounts')) { - $this->assertSame($expected_hook_map, $hook_map); - $this->assertSame($expected_hookscan, $hookscan); + self::assertSame($expected_hook_map, $hook_map); + self::assertSame($expected_hookscan, $hookscan); } else { - $this->assertTrue(empty($hook_map)); - $this->assertTrue(empty($hookscan)); + self::assertEmpty($hook_map); + self::assertEmpty($hookscan); } } - public function testrefreshHooks() + public function testrefreshHooks(): void { //execute the method and test if it doesn't throws an exception try { LogicHook::refreshHooks(); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } } - public function testloadHooks() + public function testloadHooks(): void { //execute the method and test if it returns expected contents $expected_accounts = array( @@ -283,9 +317,9 @@ class LogicHookTest extends SuitePHPUnitFrameworkTestCase file_exists("custom/modules/Accounts/logic_hooks.php") || file_exists("custom/modules/Accounts/Ext/LogicHooks/logichooks.ext.php") ) { - $this->assertSame($expected_accounts, $accounts_hooks); + self::assertSame($expected_accounts, $accounts_hooks); } else { - $this->assertTrue(empty($accounts_hooks)); + self::assertEmpty($accounts_hooks); } //test with an invalid module, it will get the application hooks @@ -296,79 +330,11 @@ class LogicHookTest extends SuitePHPUnitFrameworkTestCase ) { //$this->assertSame($expected_default, $default_hooks); } else { - $this->assertTrue(empty($default_hooks)); + self::assertEmpty($default_hooks); } } - /* - public function testloadHooks() - { - //execute the method and test if it returns expected contents - - $expected_accounts = array ( - 'after_ui_frame' => Array (), - 'before_save' => - array ( - array (77, 'updateGeocodeInfo', 'modules/Accounts/AccountsJjwg_MapsLogicHook.php', 'AccountsJjwg_MapsLogicHook', 'updateGeocodeInfo',), - ), - 'after_save' => - array ( - array (77, 'updateRelatedMeetingsGeocodeInfo', 'modules/Accounts/AccountsJjwg_MapsLogicHook.php', 'AccountsJjwg_MapsLogicHook', 'updateRelatedMeetingsGeocodeInfo',), - array (78, 'updateRelatedProjectGeocodeInfo', 'modules/Accounts/AccountsJjwg_MapsLogicHook.php', 'AccountsJjwg_MapsLogicHook', 'updateRelatedProjectGeocodeInfo', ), - array (79, 'updateRelatedOpportunitiesGeocodeInfo', 'modules/Accounts/AccountsJjwg_MapsLogicHook.php', 'AccountsJjwg_MapsLogicHook', 'updateRelatedOpportunitiesGeocodeInfo',), - array (80, 'updateRelatedCasesGeocodeInfo', 'modules/Accounts/AccountsJjwg_MapsLogicHook.php', 'AccountsJjwg_MapsLogicHook', 'updateRelatedCasesGeocodeInfo',), - ), - 'after_relationship_add' => - array ( - array ( 77, 'addRelationship', 'modules/Accounts/AccountsJjwg_MapsLogicHook.php', 'AccountsJjwg_MapsLogicHook', 'addRelationship',), - ), - 'after_relationship_delete' => - array ( - array ( 77, 'deleteRelationship', 'modules/Accounts/AccountsJjwg_MapsLogicHook.php', 'AccountsJjwg_MapsLogicHook', 'deleteRelationship',), - ), - ); - - $expected_default = array ( - 'after_ui_footer' => - array ( - array (10,'popup_onload','modules/SecurityGroups/AssignGroups.php','AssignGroups','popup_onload',), - ), - 'after_ui_frame' => - array ( - array (20, 'mass_assign', 'modules/SecurityGroups/AssignGroups.php', 'AssignGroups', 'mass_assign',), - array ( 1, 'Load Social JS', 'include/social/hooks.php', 'hooks', 'load_js',), - ), - 'after_save' => - array ( - array ( 30,'popup_select', 'modules/SecurityGroups/AssignGroups.php','AssignGroups','popup_select',), - array ( 1, 'AOD Index Changes', 'modules/AOD_Index/AOD_LogicHooks.php', 'AOD_LogicHooks', 'saveModuleChanges',), - array ( 99, 'AOW_Workflow', 'modules/AOW_WorkFlow/AOW_WorkFlow.php', 'AOW_WorkFlow','run_bean_flows',), - ), - 'after_delete' => - array ( - array ( 1, 'AOD Index changes', 'modules/AOD_Index/AOD_LogicHooks.php', 'AOD_LogicHooks','saveModuleDelete',), - ), - 'after_restore' => - array ( - array ( 1, 'AOD Index changes', 'modules/AOD_Index/AOD_LogicHooks.php', 'AOD_LogicHooks', 'saveModuleRestore',), - ), - ); - - - - $LogicHook = new LogicHook(); - - //test with a valid module - $accounts_hooks = $LogicHook->loadHooks('Accounts'); - $this->assertSame($expected_accounts, $accounts_hooks); - - //test with an invalid module, it will get the application hooks - $default_hooks = $LogicHook->loadHooks(''); - $this->assertSame($expected_default, $default_hooks); - - } -*/ - public function testgetHooks() + public function testgetHooks(): void { //execute the method and test if it returns expected contents @@ -445,9 +411,9 @@ class LogicHookTest extends SuitePHPUnitFrameworkTestCase file_exists("custom/modules/Accounts/logic_hooks.php") || file_exists("custom/modules/Accounts/Ext/LogicHooks/logichooks.ext.php") ) { - $this->assertEquals($expected, $hooks); + self::assertEquals($expected, $hooks); } else { - $this->assertTrue(empty($hooks)); + self::assertEmpty($hooks); } //test wit hrefresh true @@ -456,13 +422,13 @@ class LogicHookTest extends SuitePHPUnitFrameworkTestCase file_exists("custom/modules/Accounts/logic_hooks.php") || file_exists("custom/modules/Accounts/Ext/LogicHooks/logichooks.ext.php") ) { - $this->assertSame($expected, $hooks); + self::assertSame($expected, $hooks); } else { - $this->assertTrue(empty($hooks)); + self::assertEmpty($hooks); } } - public function testcall_custom_logic() + public function testcall_custom_logic(): void { //execute the method and test if it doesn't throws an exception $LogicHook = new LogicHook(); @@ -470,13 +436,82 @@ class LogicHookTest extends SuitePHPUnitFrameworkTestCase try { $LogicHook->call_custom_logic('', 'after_ui_footer'); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } } - public function testprocess_hooks() + /* + public function testloadHooks() + { + //execute the method and test if it returns expected contents + + $expected_accounts = array ( + 'after_ui_frame' => Array (), + 'before_save' => + array ( + array (77, 'updateGeocodeInfo', 'modules/Accounts/AccountsJjwg_MapsLogicHook.php', 'AccountsJjwg_MapsLogicHook', 'updateGeocodeInfo',), + ), + 'after_save' => + array ( + array (77, 'updateRelatedMeetingsGeocodeInfo', 'modules/Accounts/AccountsJjwg_MapsLogicHook.php', 'AccountsJjwg_MapsLogicHook', 'updateRelatedMeetingsGeocodeInfo',), + array (78, 'updateRelatedProjectGeocodeInfo', 'modules/Accounts/AccountsJjwg_MapsLogicHook.php', 'AccountsJjwg_MapsLogicHook', 'updateRelatedProjectGeocodeInfo', ), + array (79, 'updateRelatedOpportunitiesGeocodeInfo', 'modules/Accounts/AccountsJjwg_MapsLogicHook.php', 'AccountsJjwg_MapsLogicHook', 'updateRelatedOpportunitiesGeocodeInfo',), + array (80, 'updateRelatedCasesGeocodeInfo', 'modules/Accounts/AccountsJjwg_MapsLogicHook.php', 'AccountsJjwg_MapsLogicHook', 'updateRelatedCasesGeocodeInfo',), + ), + 'after_relationship_add' => + array ( + array ( 77, 'addRelationship', 'modules/Accounts/AccountsJjwg_MapsLogicHook.php', 'AccountsJjwg_MapsLogicHook', 'addRelationship',), + ), + 'after_relationship_delete' => + array ( + array ( 77, 'deleteRelationship', 'modules/Accounts/AccountsJjwg_MapsLogicHook.php', 'AccountsJjwg_MapsLogicHook', 'deleteRelationship',), + ), + ); + + $expected_default = array ( + 'after_ui_footer' => + array ( + array (10,'popup_onload','modules/SecurityGroups/AssignGroups.php','AssignGroups','popup_onload',), + ), + 'after_ui_frame' => + array ( + array (20, 'mass_assign', 'modules/SecurityGroups/AssignGroups.php', 'AssignGroups', 'mass_assign',), + array ( 1, 'Load Social JS', 'include/social/hooks.php', 'hooks', 'load_js',), + ), + 'after_save' => + array ( + array ( 30,'popup_select', 'modules/SecurityGroups/AssignGroups.php','AssignGroups','popup_select',), + array ( 1, 'AOD Index Changes', 'modules/AOD_Index/AOD_LogicHooks.php', 'AOD_LogicHooks', 'saveModuleChanges',), + array ( 99, 'AOW_Workflow', 'modules/AOW_WorkFlow/AOW_WorkFlow.php', 'AOW_WorkFlow','run_bean_flows',), + ), + 'after_delete' => + array ( + array ( 1, 'AOD Index changes', 'modules/AOD_Index/AOD_LogicHooks.php', 'AOD_LogicHooks','saveModuleDelete',), + ), + 'after_restore' => + array ( + array ( 1, 'AOD Index changes', 'modules/AOD_Index/AOD_LogicHooks.php', 'AOD_LogicHooks', 'saveModuleRestore',), + ), + ); + + + + $LogicHook = new LogicHook(); + + //test with a valid module + $accounts_hooks = $LogicHook->loadHooks('Accounts'); + $this->assertSame($expected_accounts, $accounts_hooks); + + //test with an invalid module, it will get the application hooks + $default_hooks = $LogicHook->loadHooks(''); + $this->assertSame($expected_default, $default_hooks); + + } +*/ + + public function testprocess_hooks(): void { // execute the method and test if it doesn't throws an exception $LogicHook = new LogicHook(); @@ -485,9 +520,19 @@ class LogicHookTest extends SuitePHPUnitFrameworkTestCase try { $LogicHook->process_hooks($hooks, 'after_ui_footer', array()); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } } + + protected function setUp(): void + { + parent::setUp(); + } + + protected function tearDown(): void + { + parent::tearDown(); + } } diff --git a/tests/unit/phpunit/includes/utils/SugarAutoLoaderTest.php b/tests/unit/phpunit/includes/utils/SugarAutoLoaderTest.php new file mode 100644 index 000000000..654c1f8de --- /dev/null +++ b/tests/unit/phpunit/includes/utils/SugarAutoLoaderTest.php @@ -0,0 +1,81 @@ +getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + } + } +} diff --git a/tests/unit/phpunit/includes/utils/activity_utilsTest.php b/tests/unit/phpunit/includes/utils/activity_utilsTest.php new file mode 100644 index 000000000..2de563173 --- /dev/null +++ b/tests/unit/phpunit/includes/utils/activity_utilsTest.php @@ -0,0 +1,78 @@ +rel_users_table = 'users_signatures'; + $list = build_related_list_by_user_id($bean, '1', ''); + self::assertIsArray($list); + + //with rel_users_table set by default + $bean = BeanFactory::newBean('Meetings'); + $list = build_related_list_by_user_id($bean, '1', ''); + self::assertIsArray($list); + } + + protected function setUp(): void + { + parent::setUp(); + + global $current_user; + $current_user = BeanFactory::newBean('Users'); + get_sugar_config_defaults(); + } +} diff --git a/tests/unit/phpunit/include/utils/arrayUtilsTest.php b/tests/unit/phpunit/includes/utils/array_utilsTest.php similarity index 68% rename from tests/unit/phpunit/include/utils/arrayUtilsTest.php rename to tests/unit/phpunit/includes/utils/array_utilsTest.php index ac698f2d3..712bf0b3f 100644 --- a/tests/unit/phpunit/include/utils/arrayUtilsTest.php +++ b/tests/unit/phpunit/includes/utils/array_utilsTest.php @@ -1,46 +1,93 @@ 'value1', 'Key2' => 'value2'); $expected = "array (\n 'Key1' => 'value1',\n 'Key2' => 'value2',\n)"; $actual = var_export_helper($tempArray); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } - public function testoverride_value_to_string() + public function testoverride_value_to_string(): void { //execute the method and test if it returns expected values $expected = "\$array_name['value_name'] = 'value';"; $actual = override_value_to_string('array_name', 'value_name', 'value'); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } - public function testadd_blank_option() + public function testadd_blank_option(): void { //execute the method with array not having any blank key value pair. function will return an array with blank key value pair added. $tempArray = array('Key1' => 'value1', 'Key2' => 'value2'); $expected = array('' => '', 'Key1' => 'value1', 'Key2' => 'value2'); $actual = add_blank_option($tempArray); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); //execute the method with array having a blank key value pair. function will return the same array back without any change. $tempArray = array('' => '', 'Key1' => 'value1', 'Key2' => 'value2'); $expected = array('' => '', 'Key1' => 'value1', 'Key2' => 'value2'); $actual = add_blank_option($tempArray); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } - public function testoverride_value_to_string_recursive() + public function testoverride_value_to_string_recursive(): void { //execute the method and test if it returns expected values @@ -48,7 +95,7 @@ class array_utilsTest extends SuitePHPUnitFrameworkTestCase $tempArray = array('Key1' => 'value1', 'Key2' => 'value2'); $expected = "\$tempArray=array (\n 'Key1' => 'value1',\n 'Key2' => 'value2',\n);"; $actual = override_value_to_string_recursive('', 'tempArray', $tempArray); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); //with keys $tempArray = array(); @@ -56,10 +103,10 @@ class array_utilsTest extends SuitePHPUnitFrameworkTestCase $expected = "\$tempArray['key1']['key2']=array (\n 'Key1' => \n array (\n 'Key2' => \n array (\n 'Key3' => 'value',\n 'Key4' => 'value',\n ),\n ),\n);"; $actual = override_value_to_string_recursive(array('key1', 'key2'), 'tempArray', $tempArray); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } - public function testoverride_recursive_helper() + public function testoverride_recursive_helper(): void { //execute the method and test if it returns expected values @@ -67,40 +114,40 @@ class array_utilsTest extends SuitePHPUnitFrameworkTestCase $tempArray = array('Key1' => 'value1', 'Key2' => 'value2'); $expected = "=array (\n 'Key1' => 'value1',\n 'Key2' => 'value2',\n);"; $actual = override_recursive_helper('', 'tempArray', $tempArray); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); //with keys $tempArray = array(); $tempArray['Key1']['Key2'] = array('Key3' => 'value', 'Key4' => 'value'); $expected = "['key1']['key2']=array (\n 'Key1' => \n array (\n 'Key2' => \n array (\n 'Key3' => 'value',\n 'Key4' => 'value',\n ),\n ),\n);"; $actual = override_recursive_helper(array('key1', 'key2'), 'tempArray', $tempArray); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } - public function testoverride_value_to_string_recursive2() + public function testoverride_value_to_string_recursive2(): void { //execute the method and test if it returns expected values //null array $expected = null; $actual = override_value_to_string_recursive2('tempArray', 'key1', '', false); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); //simple array $tempArray = array('Key1' => 'value1', 'Key2' => 'value2'); $expected = "\$['tempArray']['Key1'] = 'value1';\n$['tempArray']['Key2'] = 'value2';\n"; $actual = override_value_to_string_recursive2('', 'tempArray', $tempArray); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); //complex array $tempArray = array(); $tempArray['Key1']['Key2'] = array('Key3' => 'value', 'Key4' => 'value'); $expected = "\$tempArray['key1']['Key2']['Key3'] = 'value';\n\$tempArray['key1']['Key2']['Key4'] = 'value';\n"; $actual = override_value_to_string_recursive2('tempArray', 'key1', $tempArray['Key1']); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } - public function testobject_to_array_recursive() + public function testobject_to_array_recursive(): void { //execute the method and test if it returns expected values @@ -108,17 +155,17 @@ class array_utilsTest extends SuitePHPUnitFrameworkTestCase $obj = ''; $expected = ''; $actual = object_to_array_recursive($obj); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); //test with a valid object $obj = new TimeDate(); $expected = array('dbDayFormat' => 'Y-m-d', 'dbTimeFormat' => 'H:i:s', 'allow_cache' => true); $actual = object_to_array_recursive($obj); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } - public function testdeepArrayDiff() + public function testdeepArrayDiff(): void { //execute the method and test if it returns expected values @@ -127,38 +174,38 @@ class array_utilsTest extends SuitePHPUnitFrameworkTestCase $tempArray2 = array('Key1' => 'value1', 'Key2' => 'value2'); $expected = array(); $actual = deepArrayDiff($tempArray1, $tempArray2); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); //different simple arrays $tempArray1 = array('Key1' => 'value1', 'Key2' => 'value2'); $tempArray2 = array('Key1' => 'value1', 'Key2' => 'value3'); $expected = array('Key2' => 'value2'); $actual = deepArrayDiff($tempArray1, $tempArray2); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); //same complex arrays $tempArray1 = array('Key1' => array('Key2' => 'value2', 'Key3' => 'value3')); $tempArray2 = array('Key1' => array('Key2' => 'value2', 'Key3' => 'value3')); $expected = array(); $actual = deepArrayDiff($tempArray1, $tempArray2); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); //complex arrays with different root node $tempArray1 = array('Key1' => array('Key2' => 'value2', 'Key3' => 'value3')); $tempArray2 = array('Key2' => array('Key2' => 'value2', 'Key3' => 'value3')); $expected = array('Key1' => array('Key2' => 'value2', 'Key3' => 'value3')); $actual = deepArrayDiff($tempArray1, $tempArray2); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); //complex arrays with different child node $tempArray1 = array('Key1' => array('Key2' => 'value2', 'Key3' => 'value3')); $tempArray2 = array('Key1' => array('Key2' => 'value2', 'Key4' => 'value4')); $expected = array('Key1' => array('Key3' => 'value3')); $actual = deepArrayDiff($tempArray1, $tempArray2); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } - public function testsetDeepArrayValue() + public function testsetDeepArrayValue(): void { //execute the method and test if it returns expected values @@ -166,17 +213,17 @@ class array_utilsTest extends SuitePHPUnitFrameworkTestCase $tempArray = array('Key1' => array('Key2' => 'value2', 'Key3' => 'value3')); $expected = array('Key1' => array('Key2' => 'value2', 'Key3' => 'value3'), 'key4' => 'value4'); setDeepArrayValue($tempArray, 'key4', 'value4'); - $this->assertSame($tempArray, $expected); + self::assertSame($tempArray, $expected); //add to empty array $tempArray = array(); $expected = array('key1' => array('key2' => array('key3' => 'value3'))); setDeepArrayValue($tempArray, 'key1_key2_key3', 'value3'); //var_dump($tempArray); - $this->assertSame($tempArray, $expected); + self::assertSame($tempArray, $expected); } - public function testarray_merge_values() + public function testarray_merge_values(): void { //execute the method and test if it returns expected values @@ -184,37 +231,37 @@ class array_utilsTest extends SuitePHPUnitFrameworkTestCase $tempArray1 = array('v1', 'v2', 'v3'); $tempArray2 = array('v4', 'v5'); $actual = array_merge_values($tempArray1, $tempArray2); - $this->assertFalse($actual); + self::assertFalse($actual); //try with same length arrays. $tempArray1 = array('v1', 'v2', 'v3'); $tempArray2 = array('v4', 'v5', 'v6'); $expected = array('v1v4', 'v2v5', 'v3v6'); $actual = array_merge_values($tempArray1, $tempArray2); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } - public function testarray_search_insensitive() + public function testarray_search_insensitive(): void { //execute the method and test if it returns expected value //test with invalid input $tempArray = ''; $actual = array_search_insensitive('', $tempArray); - $this->assertFalse($actual); + self::assertFalse($actual); //test with invalid needle.. $tempArray = array('Key1' => 'value1', 'Key2' => 'value2', 'Key3' => 'value3', 'key4' => 'value4'); $actual = array_search_insensitive('', $tempArray); - $this->assertFalse($actual); + self::assertFalse($actual); //test with valid needle and haystack. $tempArray = array('Key1' => 'value1', 'Key2' => 'value2', 'Key3' => 'value3', 'key4' => 'value4'); $actual = array_search_insensitive('value4', $tempArray); - $this->assertTrue($actual); + self::assertTrue($actual); } - public function testget() + public function testget(): void { //execute the method and test if it returns expected values @@ -222,16 +269,16 @@ class array_utilsTest extends SuitePHPUnitFrameworkTestCase $tempArray = new SugarArray(array('Key1' => array('Key2' => 'value2', 'Key3' => 'value3'), 'key4' => 'value4')); $expected = 'value4'; $actual = $tempArray->get('key4'); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); //test for a child level key with dot notation $tempArray = new SugarArray(array('key1' => array('key2' => 'value2', 'key3' => 'value3'), 'key4' => 'value4')); $expected = 'value3'; $actual = $tempArray->get('key1.key3'); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } - public function teststaticGet() + public function teststaticGet(): void { //execute the method and test if it returns expected values @@ -239,13 +286,13 @@ class array_utilsTest extends SuitePHPUnitFrameworkTestCase $haystack = array('key1' => array('key2' => 'value2', 'key3' => 'value3'), 'key4' => 'value4'); $expected = 'value4'; $actual = SugarArray::staticGet($haystack, 'key4'); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); //test for a child level key with dot notation $haystack = array('key1' => array('key2' => 'value2', 'key3' => 'value3'), 'key4' => 'value4'); $expected = 'value3'; $actual = SugarArray::staticGet($haystack, 'key1.key3'); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } /** @@ -255,7 +302,7 @@ class array_utilsTest extends SuitePHPUnitFrameworkTestCase * After applying fixIndexArrayFormat() to both arrays we compare it as compareVarDefs() function does: * */ - public function testfixIndexArrayFormat() + public function testfixIndexArrayFormat(): void { $index1 = [ 'user_name', @@ -277,7 +324,7 @@ class array_utilsTest extends SuitePHPUnitFrameworkTestCase $index1 = fixIndexArrayFormat($index1); $index2 = fixIndexArrayFormat($index2); - $this->assertTrue(array_map('strtolower', $index1) == array_map('strtolower', $index2)); + self::assertEquals(array_map('strtolower', $index1), array_map('strtolower', $index2)); $index3 = [ 'user_name', @@ -299,6 +346,6 @@ class array_utilsTest extends SuitePHPUnitFrameworkTestCase $index3 = fixIndexArrayFormat($index3); $index4 = fixIndexArrayFormat($index4); - $this->assertFalse(array_map('strtolower', $index3) == array_map('strtolower', $index4)); + self::assertNotEquals(array_map('strtolower', $index3), array_map('strtolower', $index4)); } } diff --git a/tests/unit/phpunit/includes/utils/db_utilsTest.php b/tests/unit/phpunit/includes/utils/db_utilsTest.php new file mode 100644 index 000000000..932850e9f --- /dev/null +++ b/tests/unit/phpunit/includes/utils/db_utilsTest.php @@ -0,0 +1,162 @@ +"; + $expected = ''test'&trial<">'; + $actual = to_html($string); + self::assertSame($expected, $actual); + } + + public function testfrom_html(): void + { + $string = ''; + $expected = ''; + $actual = from_html($string); + self::assertSame($expected, $actual); + + $string = ''test'&trial<">'; + $expected = "'test'&trial<\">"; + $actual = from_html($string); + self::assertSame($expected, $actual); + } + + public function testgetValidDBName(): void + { + $expected = ''; + $actual = getValidDBName(''); + self::assertSame($expected, $actual); + + $expected = 'col'; + $actual = getValidDBName('Col'); + self::assertSame($expected, $actual); + } + + public function testisValidDBName(): void + { + //valid value + $expected = true; + $actual = isValidDBName('suitecrmtest', 'mysql'); + self::assertSame($expected, $actual); + + //invalid value + $expected = false; + $actual = isValidDBName('suite/crm.test', 'mysql'); + self::assertSame($expected, $actual); + } +} diff --git a/tests/unit/phpunit/includes/utils/encryption_utilsTest.php b/tests/unit/phpunit/includes/utils/encryption_utilsTest.php new file mode 100644 index 000000000..86707cbb1 --- /dev/null +++ b/tests/unit/phpunit/includes/utils/encryption_utilsTest.php @@ -0,0 +1,139 @@ +rootFs = vfsStream::setup('root'); + $this->rootFs->addChild(vfsStream::newDirectory('testDir')); + $this->rootFs->addChild(vfsStream::newFile('test.txt')->withContent('Hello world!')); + } + + public function testclean_path(): void + { + //execute the method and test if it returns expected values + + //invalid path + $expected = ''; + $path = ''; + $actual = clean_path($path); + self::assertSame($expected, $actual); + + //a simple valid path + $expected = '/SuiteCRM-develop/include/utils'; + $path = '\SuiteCRM-develop\include\utils'; + $actual = clean_path($path); + self::assertSame($expected, $actual); + + //valid network path + $expected = '//SuiteCRM-develop/include/utils'; + $path = '\\\\/SuiteCRM-develop/include/utils'; + $actual = clean_path($path); + self::assertSame($expected, $actual); + + $expected = '/SuiteCRM-develop/include/utils'; + $path = '/SuiteCRM-develop/./include/utils'; + $actual = clean_path($path); + self::assertSame($expected, $actual); + + $expected = '/SuiteCRM-develop/include/utils'; + $path = '/SuiteCRM-develop//include/utils'; + $actual = clean_path($path); + self::assertSame($expected, $actual); + } + + public function testcreate_cache_directory(): void + { + //execute the method and test if it created file/dir exists + + $cache_dir = rtrim($GLOBALS['sugar_config']['cache_dir'], '/\\'); + $file = 'Test/'; + + if ($this->rootFs->hasChild($file) == true) { + rmdir($cache_dir . '/' . $file); + } + + $actual = create_cache_directory($file); + self::assertFileExists($actual); + + if ($this->rootFs->hasChild($file) == true) { + rmdir($cache_dir . '/' . $file); + } + } + + public function testget_module_dir_list(): void + { + //execute the method and test if it returns expected values + + $expected = array( + 'Accounts' => 'Accounts', + 'ACL' => 'ACL', + 'ACLActions' => 'ACLActions', + 'ACLRoles' => 'ACLRoles', + 'Activities' => 'Activities', + 'Administration' => 'Administration', + 'Alerts' => 'Alerts', + 'AM_ProjectTemplates' => 'AM_ProjectTemplates', + 'AM_TaskTemplates' => 'AM_TaskTemplates', + 'AOBH_BusinessHours' => 'AOBH_BusinessHours', + 'AOD_Index' => 'AOD_Index', + 'AOD_IndexEvent' => 'AOD_IndexEvent', + 'AOK_KnowledgeBase' => 'AOK_KnowledgeBase', + 'AOK_Knowledge_Base_Categories' => 'AOK_Knowledge_Base_Categories', + 'AOP_Case_Events' => 'AOP_Case_Events', + 'AOP_Case_Updates' => 'AOP_Case_Updates', + 'AOR_Charts' => 'AOR_Charts', + 'AOR_Conditions' => 'AOR_Conditions', + 'AOR_Fields' => 'AOR_Fields', + 'AOR_Reports' => 'AOR_Reports', + 'AOR_Scheduled_Reports' => 'AOR_Scheduled_Reports', + 'AOS_Contracts' => 'AOS_Contracts', + 'AOS_Invoices' => 'AOS_Invoices', + 'AOS_Line_Item_Groups' => 'AOS_Line_Item_Groups', + 'AOS_PDF_Templates' => 'AOS_PDF_Templates', + 'AOS_Products' => 'AOS_Products', + 'AOS_Products_Quotes' => 'AOS_Products_Quotes', + 'AOS_Product_Categories' => 'AOS_Product_Categories', + 'AOS_Quotes' => 'AOS_Quotes', + 'AOW_Actions' => 'AOW_Actions', + 'AOW_Conditions' => 'AOW_Conditions', + 'AOW_Processed' => 'AOW_Processed', + 'AOW_WorkFlow' => 'AOW_WorkFlow', + 'Audit' => 'Audit', + 'Bugs' => 'Bugs', + 'Calendar' => 'Calendar', + 'Calls' => 'Calls', + 'Calls_Reschedule' => 'Calls_Reschedule', + 'CampaignLog' => 'CampaignLog', + 'Campaigns' => 'Campaigns', + 'CampaignTrackers' => 'CampaignTrackers', + 'Cases' => 'Cases', + 'Charts' => 'Charts', + 'Configurator' => 'Configurator', + 'Connectors' => 'Connectors', + 'Contacts' => 'Contacts', + 'Currencies' => 'Currencies', + 'Delegates' => 'Delegates', + 'DocumentRevisions' => 'DocumentRevisions', + 'Documents' => 'Documents', + 'DynamicFields' => 'DynamicFields', + 'EAPM' => 'EAPM', + 'EmailAddresses' => 'EmailAddresses', + 'EmailMan' => 'EmailMan', + 'EmailMarketing' => 'EmailMarketing', + 'Emails' => 'Emails', + 'EmailTemplates' => 'EmailTemplates', + 'EmailText' => 'EmailText', + 'Employees' => 'Employees', + 'Favorites' => 'Favorites', + 'FP_events' => 'FP_events', + 'FP_Event_Locations' => 'FP_Event_Locations', + 'Groups' => 'Groups', + 'Help' => 'Help', + 'History' => 'History', + 'Home' => 'Home', + 'iCals' => 'iCals', + 'Import' => 'Import', + 'InboundEmail' => 'InboundEmail', + 'jjwg_Address_Cache' => 'jjwg_Address_Cache', + 'jjwg_Areas' => 'jjwg_Areas', + 'jjwg_Maps' => 'jjwg_Maps', + 'jjwg_Markers' => 'jjwg_Markers', + 'LabelEditor' => 'LabelEditor', + 'Leads' => 'Leads', + 'MailMerge' => 'MailMerge', + 'Meetings' => 'Meetings', + 'MergeRecords' => 'MergeRecords', + 'ModuleBuilder' => 'ModuleBuilder', + 'MySettings' => 'MySettings', + 'Notes' => 'Notes', + 'OAuth2Clients' => 'OAuth2Clients', + 'OAuth2Tokens' => 'OAuth2Tokens', + 'OAuthKeys' => 'OAuthKeys', + 'OAuthTokens' => 'OAuthTokens', + 'Opportunities' => 'Opportunities', + 'OptimisticLock' => 'OptimisticLock', + 'OutboundEmailAccounts' => 'OutboundEmailAccounts', + 'Project' => 'Project', + 'ProjectTask' => 'ProjectTask', + 'ProspectLists' => 'ProspectLists', + 'Prospects' => 'Prospects', + 'Relationships' => 'Relationships', + 'Reminders' => 'Reminders', + 'Reminders_Invitees' => 'Reminders_Invitees', + 'ResourceCalendar' => 'ResourceCalendar', + 'Releases' => 'Releases', + 'Roles' => 'Roles', + 'SavedSearch' => 'SavedSearch', + 'Schedulers' => 'Schedulers', + 'SchedulersJobs' => 'SchedulersJobs', + 'SecurityGroups' => 'SecurityGroups', + 'Spots' => 'Spots', + 'Studio' => 'Studio', + 'SugarFeed' => 'SugarFeed', + 'SurveyQuestionOptions' => 'SurveyQuestionOptions', + 'SurveyQuestionResponses' => 'SurveyQuestionResponses', + 'SurveyQuestions' => 'SurveyQuestions', + 'SurveyResponses' => 'SurveyResponses', + 'Surveys' => 'Surveys', + 'Tasks' => 'Tasks', + 'Trackers' => 'Trackers', + 'TemplateSectionLine' => 'TemplateSectionLine', + 'UpgradeWizard' => 'UpgradeWizard', + 'UserPreferences' => 'UserPreferences', + 'Users' => 'Users', + 'vCals' => 'vCals', + ); + + $actual = get_module_dir_list(); + sort($actual); + sort($expected); + self::assertSame($expected, $actual); + } + + public function testremove_file_extension(): void + { + //execute the method and test if it returns expected values + + //no file extension + $expected = ''; + $actual = remove_file_extension('fileNoExt'); + self::assertSame($expected, $actual); + + //simple file extension + $expected = 'file1'; + $actual = remove_file_extension('file1.txt'); + self::assertSame($expected, $actual); + + //complex filename + $expected = 'file2.ext1'; + $actual = remove_file_extension('file2.ext1.ext2'); + self::assertSame($expected, $actual); + } + + public function testwrite_encoded_file(): void + { + //execute the method and test if it created file exists + + $cache_dir = 'vfs://root'; + + //without filename + $tempArray = array( + 'filename' => 'soap_array.txt', + 'md5' => '523ef67de860fc54794f27117dba4fac', + 'data' => 'some soap data' + ); + $actual = write_encoded_file($tempArray, $cache_dir, ''); + self::assertFileExists($actual); + unlink($actual); + + //with filename + $tempArray = array('md5' => '523ef67de860fc54794f27117dba4fac', 'data' => 'some soap data'); + $actual = write_encoded_file($tempArray, $cache_dir, 'soap_array.txt'); + self::assertFileExists($actual); + unlink($actual); + } + + public function testcreate_custom_directory(): void + { + //execute the method and test if it created file/dir exists + + $file = 'Test/'; + + $vfs = $this->rootFs; + if ($vfs->hasChild($file) == true) { + rmdir('custom/' . $file); + } + + $actual = create_custom_directory($file); + self::assertFileExists($actual); + + if ($vfs->hasChild($file) == true) { + rmdir('custom/' . $file); + } + } + + public function testmd5DirCompare(): void + { + //execute the method and test if it returns expected values + + $expected = array(); + + $actual = md5DirCompare('include/MVC/', 'include/MVC/', array('views')); + self::assertSame($expected, $actual); + } + + public function testgetFiles(): void + { + //execute the method and test if it returns expected values + + //test without pattern + $expected = array( + 'include/MVC/Controller/ControllerFactory.php', + 'include/MVC/Controller/file_access_control_map.php', + 'include/MVC/Controller/action_file_map.php', + 'include/MVC/Controller/action_view_map.php', + 'include/MVC/Controller/entry_point_registry.php', + 'include/MVC/Controller/SugarController.php', + ); + $actual = array(); + getFiles($actual, 'include/MVC/Controller'); + sort($actual); + sort($expected); + self::assertSame($expected, $actual); + + //test with pattern + $expected = array( + 'include/MVC/Controller/action_view_map.php', + 'include/MVC/View/views/view.ajax.php', + 'include/MVC/View/views/view.ajaxui.php', + 'include/MVC/View/views/view.classic.config.php', + 'include/MVC/View/views/view.classic.php', + 'include/MVC/View/views/view.config.php', + 'include/MVC/View/views/view.detail.config.php', + 'include/MVC/View/views/view.detail.php', + 'include/MVC/View/views/view.edit.php', + 'include/MVC/View/views/view.favorites.php', + 'include/MVC/View/views/view.html.php', + 'include/MVC/View/views/view.importvcard.php', + 'include/MVC/View/views/view.importvcardsave.php', + 'include/MVC/View/views/view.json.php', + 'include/MVC/View/views/view.list.php', + 'include/MVC/View/views/view.metadata.php', + 'include/MVC/View/views/view.modulelistmenu.php', + 'include/MVC/View/views/view.multiedit.php', + 'include/MVC/View/views/view.noaccess.php', + 'include/MVC/View/views/view.popup.php', + 'include/MVC/View/views/view.quick.php', + 'include/MVC/View/views/view.quickcreate.php', + 'include/MVC/View/views/view.quickedit.php', + 'include/MVC/View/views/view.serialized.php', + 'include/MVC/View/views/view.sugarpdf.config.php', + 'include/MVC/View/views/view.sugarpdf.php', + 'include/MVC/View/views/view.vcard.php', + 'include/MVC/View/views/view.xml.php', + ); + $actual = array(); + getFiles($actual, 'include/MVC', '@view@'); + sort($expected); + sort($actual); + self::assertEquals($expected, $actual); + } + + public function testreadfile_chunked(): void + { + //execute the method and test if it returns expected values + + $expected = file_get_contents('config.php'); + + //retbytes parameter false + ob_start(); + $actual = readfile_chunked('config.php', false); + $renderedContent = ob_get_contents(); + ob_end_clean(); + + self::assertTrue($actual); + self::assertSame($expected, $renderedContent); + + //retbytes parameter true/default + ob_start(); + $actual = readfile_chunked('config.php'); + $renderedContent = ob_get_contents(); + ob_end_clean(); + + self::assertEquals($actual, strlen($renderedContent)); + self::assertSame($expected, $renderedContent); + } + + public function testsugar_rename(): void + { + //execute the method and test if it returns true/success + + $dir = 'vfs://root'; + $file = 'test.txt'; + $vfs = $this->rootFs; + if ($vfs->hasChild($file) != true) { + write_array_to_file('', '', $dir . '/' . $file); + } + + //test with empty file names + $actual = sugar_rename('', ''); + self::assertFalse($actual); + + //test with valid file names + $actual = sugar_rename($dir . '/' . $file, $dir . '/' . 'newtest.txt'); + self::assertTrue($actual); + + unlink($dir . '/' . 'newtest.txt'); + } + + public function testfileToHash(): void + { + if (isset($_SESSION)) { + $_session = $_SESSION; + } + + //execute the method and test if it returns expected values + + //test with empty filename string + $expected = 'd41d8cd98f00b204e9800998ecf8427e'; + $hash = fileToHash(''); + self::assertSame($expected, $hash); + self::assertSame('', $_SESSION['file2Hash'][$hash]); + + //test with valid filename + $expected = '9e5e2527d69c009a81b8ecd730f3957e'; + $hash = fileToHash('config.php'); + self::assertSame($expected, $hash); + self::assertSame('config.php', $_SESSION['file2Hash'][$hash]); + + if (isset($_session)) { + $_SESSION = $_session; + } else { + unset($_SESSION); + } + } + + public function testhashToFile(): void + { + if (isset($_SESSION)) { + $_session = $_SESSION; + } + + //execute the method and test if it returns expected values + + //test with invalid hash. + $actual = hashToFile(''); + self::assertFalse($actual); + + //test with a newly generated hash + $hash = fileToHash('config.php'); + $actual = hashToFile($hash); + self::assertSame('config.php', $actual); + + if (isset($_session)) { + $_SESSION = $_session; + } else { + unset($_SESSION); + } + } + + public function testget_file_extension(): void + { + //execute the method and test if it returns expected values + + $file = ''; // Only variables should be passed by reference in php7 + self::assertSame('', get_file_extension($file)); + + $file = 'test.txt'; // Only variables should be passed by reference in php7 + self::assertSame('txt', get_file_extension($file)); + + $file = 'test.ext.Txt'; // Only variables should be passed by reference in php7 + self::assertSame('Txt', get_file_extension($file, false)); + + $file = 'test.ext.TXT'; // Only variables should be passed by reference in php7 + self::assertSame('txt', get_file_extension($file, true)); + } + + public function testget_mime_content_type_from_filename(): void + { + //execute the method and test if it returns expected values + + self::assertSame('', get_mime_content_type_from_filename('')); + self::assertSame('application/octet-stream', get_mime_content_type_from_filename('file.tmp')); + self::assertSame('text/plain', get_mime_content_type_from_filename('file.txt')); + self::assertSame('application/x-shockwave-flash', get_mime_content_type_from_filename('file.swf')); + self::assertSame('video/x-flv', get_mime_content_type_from_filename('file.flv')); + } + + public function testcleanFileName(): void + { + //execute the method and test if it returns expected values + + self::assertSame('file.txt', cleanFileName('file.txt')); + self::assertSame('file_1.txt', cleanFileName('file_1.txt')); + self::assertSame('file.txt', cleanFileName('file.txt')); + } + + public function testcleanDirName(): void + { + //execute the method and test if it returns expected values + + self::assertSame('testDir', cleanDirName('./testDir')); + self::assertSame('testDir', cleanDirName('..\\testDir')); + self::assertSame('testDir', cleanDirName('\\test/Dir/')); + } +} diff --git a/tests/unit/phpunit/includes/utils/layout_utilsTest.php b/tests/unit/phpunit/includes/utils/layout_utilsTest.php new file mode 100644 index 000000000..1e33bc741 --- /dev/null +++ b/tests/unit/phpunit/includes/utils/layout_utilsTest.php @@ -0,0 +1,144 @@ + 1, generates more html compared to count =0 + $html3 = get_module_title('Users', 'Users Home', false, 2); + self::assertGreaterThan(0, strlen($html3)); + self::assertStringContainsString('Users', $html3); + self::assertStringContainsString('Users Home', $html3); + self::assertGreaterThan(strlen($html2), strlen($html3)); + self::assertGreaterThan(strlen($html3), strlen($html1)); + } + + public function testgetClassicModuleTitle(): void + { + //execute the method and test if it returns html and contains the values provided in parameters + + //with show_create false, generates less html + $html1 = getClassicModuleTitle('users', array('Users Home')); + self::assertGreaterThan(0, strlen($html1)); + self::assertStringContainsString('Users Home', $html1); + + //with show_create true, generates more html + $html2 = getClassicModuleTitle('users', array('Users Home'), true); + self::assertGreaterThan(0, strlen($html2)); + self::assertStringContainsString('Users Home', $html2); + self::assertGreaterThan(strlen($html1), strlen($html2)); + } + + public function testinsert_popup_header(): void + { + //execute the method and test if it returns html/JS + + //with includeJS true, generates more html + ob_start(); + insert_popup_header(); + $renderedContent1 = ob_get_contents(); + ob_end_clean(); + self::assertGreaterThan(0, strlen($renderedContent1)); + + //with includeJS false, generates less html + ob_start(); + insert_popup_header('', false); + $renderedContent2 = ob_get_contents(); + ob_end_clean(); + self::assertGreaterThan(0, strlen($renderedContent2)); + + self::assertGreaterThan(strlen($renderedContent2), strlen($renderedContent1)); + } + + public function testinsert_popup_footer(): void + { + //execute the method and test if it returns html + + ob_start(); + insert_popup_footer(); + $renderedContent = ob_get_contents(); + ob_end_clean(); + self::assertGreaterThan(0, strlen($renderedContent)); + } +} diff --git a/tests/unit/phpunit/include/utils/logicUtilsTest.php b/tests/unit/phpunit/includes/utils/logic_utilsTest.php similarity index 70% rename from tests/unit/phpunit/include/utils/logicUtilsTest.php rename to tests/unit/phpunit/includes/utils/logic_utilsTest.php index 04ae50cae..3491d7a8d 100644 --- a/tests/unit/phpunit/include/utils/logicUtilsTest.php +++ b/tests/unit/phpunit/includes/utils/logic_utilsTest.php @@ -1,18 +1,63 @@ assertTrue(is_array($AccountsHooks)); + self::assertIsArray($AccountsHooks); } //test with an invalid array. it will throw an file include exception. @@ -22,10 +67,21 @@ class logic_utilsTest extends SuitePHPUnitFrameworkTestCase } catch (Exception $e) { } - $this->assertFalse(is_array($BugsHooks)); + self::assertIsNotArray($BugsHooks); } - private function getTestHook() + public function check_existing_elementProvider(): array + { + $hook_array = $this->getTestHook(); + + return [ + [$hook_array, 'after_save', [0, 'popup_select'], true], + [$hook_array, 'after_save', [0, 'foo'], false], + [$hook_array, 'foo', [0, 'popup_select'], false], + ]; + } + + private function getTestHook(): array { //array containing hooks array to test @@ -88,38 +144,25 @@ class logic_utilsTest extends SuitePHPUnitFrameworkTestCase return $hook_array; } - public function check_existing_elementProvider() - { - //provide test cases dataset to validate - - $hook_array = $this->getTestHook(); - - return array( - array($hook_array, 'after_save', array(0, 'popup_select'), true), - array($hook_array, 'after_save', array(0, 'foo'), false), - array($hook_array, 'foo', array(0, 'popup_select'), false), - ); - } - /** * @dataProvider check_existing_elementProvider */ - public function testcheck_existing_element($hook_array, $event, $action_array, $expected) + public function testcheck_existing_element($hook_array, $event, $action_array, $expected): void { //test with dataset containing valid and invalid cases - $this->assertSame(check_existing_element($hook_array, $event, $action_array), $expected); + self::assertSame(check_existing_element($hook_array, $event, $action_array), $expected); } - public function testreplace_or_add_logic_type() + public function testreplace_or_add_logic_type(): void { //execute the method and test if it returns expected values $hook_array = $this->getTestHook(); $expected = ""; - $this->assertEquals($expected, replace_or_add_logic_type($hook_array)); + self::assertEquals($expected, replace_or_add_logic_type($hook_array)); } - public function testwrite_logic_file() + public function testwrite_logic_file(): void { //execute the method and test if it returns expected values, //check if file is created and contains expected contents @@ -135,26 +178,26 @@ class logic_utilsTest extends SuitePHPUnitFrameworkTestCase write_logic_file('TEST_Test', $expectedContents); //Check file created - $this->assertFileExists('custom/modules/TEST_Test/logic_hooks.php'); + self::assertFileExists('custom/modules/TEST_Test/logic_hooks.php'); $actualContents = file_get_contents('custom/modules/TEST_Test/logic_hooks.php'); - $this->assertSame($expectedContents, $actualContents); + self::assertSame($expectedContents, $actualContents); $expectedArray = $this->getTestHook(); $actualArray = get_hook_array('TEST_Test'); - $this->assertSame($expectedArray, $actualArray); + self::assertSame($expectedArray, $actualArray); unlink('custom/modules/TEST_Test/logic_hooks.php'); rmdir('custom/modules/TEST_Test'); } - public function testbuild_logic_file() + public function testbuild_logic_file(): void { //execute the method and test if it returns expected values $hook_array = $this->getTestHook(); $expected = "// Do not store anything in this file that is not part of the array or the hook version. This file will \n// be automatically rebuilt in the future. \n \$hook_version = 1; \n\$hook_array = Array(); \n// position, file, function \n\$hook_array['after_ui_footer'] = Array(); \n\$hook_array['after_ui_footer'][] = Array(10, 'popup_onload', 'modules/SecurityGroups/AssignGroups.php','AssignGroups', 'popup_onload'); \n\$hook_array['after_ui_frame'] = Array(); \n\$hook_array['after_ui_frame'][] = Array(20, 'mass_assign', 'modules/SecurityGroups/AssignGroups.php','AssignGroups', 'mass_assign'); \n\$hook_array['after_ui_frame'][] = Array(1, 'Load Social JS', 'custom/include/social/hooks.php','hooks', 'load_js'); \n\$hook_array['after_save'] = Array(); \n\$hook_array['after_save'][] = Array(30, 'popup_select', 'modules/SecurityGroups/AssignGroups.php','AssignGroups', 'popup_select'); \n\$hook_array['after_save'][] = Array(1, 'AOD Index Changes', 'modules/AOD_Index/AOD_LogicHooks.php','AOD_LogicHooks', 'saveModuleChanges'); \n\$hook_array['after_delete'] = Array(); \n\$hook_array['after_delete'][] = Array(1, 'AOD Index changes', 'modules/AOD_Index/AOD_LogicHooks.php','AOD_LogicHooks', 'saveModuleDelete'); \n\$hook_array['after_restore'] = Array(); \n\$hook_array['after_restore'][] = Array(1, 'AOD Index changes', 'modules/AOD_Index/AOD_LogicHooks.php','AOD_LogicHooks', 'saveModuleRestore'); \n\n\n"; - $this->assertEquals($expected, build_logic_file($hook_array)); + self::assertEquals($expected, build_logic_file($hook_array)); } } diff --git a/tests/unit/phpunit/includes/utils/mvc_utilsTest.php b/tests/unit/phpunit/includes/utils/mvc_utilsTest.php new file mode 100644 index 000000000..9ce8b4af7 --- /dev/null +++ b/tests/unit/phpunit/includes/utils/mvc_utilsTest.php @@ -0,0 +1,145 @@ +getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + } + } + + public function testgetPrintLink(): void + { + //test without setting REQUEST param + $expected = "javascript:void window.open('index.php?','printwin','menubar=1,status=0,resizable=1,scrollbars=1,toolbar=0,location=1')"; + $actual = getPrintLink(); + self::assertSame($expected, $actual); + + //test with required REQUEST param set + $_REQUEST['action'] = 'ajaxui'; + $expected = 'javascript:SUGAR.ajaxUI.print();'; + $actual = getPrintLink(); + self::assertSame($expected, $actual); + } + + public function testajaxBannedModules(): void + { + //execute the method and test verify it returns true + $result = ajaxBannedModules(); + self::assertIsArray($result); + } + + public function testajaxLink(): void + { + global $sugar_config; + $ajaxUIDisabled = isset($sugar_config['disableAjaxUI']) && $sugar_config['disableAjaxUI']; + + if (!$ajaxUIDisabled) { + self::assertSame('?action=ajaxui#ajaxUILoc=', ajaxLink('')); + $testModules = array( + 'Calendar', + 'Emails', + 'Campaigns', + 'Documents', + 'DocumentRevisions', + 'Project', + 'ProjectTask', + 'EmailMarketing', + 'CampaignLog', + 'CampaignTrackers', + 'Releases', + 'Groups', + 'EmailMan', + "Administration", + "ModuleBuilder", + 'Schedulers', + 'SchedulersJobs', + 'DynamicFields', + 'EditCustomFields', + 'EmailTemplates', + 'Users', + 'Currencies', + 'Trackers', + 'Connectors', + 'Import_1', + 'Import_2', + 'vCals', + 'CustomFields', + 'Roles', + 'Audit', + 'InboundEmail', + 'SavedSearch', + 'UserPreferences', + 'MergeRecords', + 'EmailAddresses', + 'Relationships', + 'Employees', + 'Import', + 'OAuthKeys' + ); + $bannedModules = ajaxBannedModules(); + foreach ($testModules as $module) { + $uri = "index.php?module=$module&action=detail&record=1"; + if (!in_array($module, $bannedModules)) { + self::assertSame("?action=ajaxui#ajaxUILoc=" . urlencode($uri), ajaxLink($uri)); + } else { + self::assertSame($uri, ajaxLink($uri)); + } + } + } + } +} diff --git a/tests/unit/phpunit/includes/utils/php_zip_utilsTest.php b/tests/unit/phpunit/includes/utils/php_zip_utilsTest.php new file mode 100644 index 000000000..fcd6c8aab --- /dev/null +++ b/tests/unit/phpunit/includes/utils/php_zip_utilsTest.php @@ -0,0 +1,136 @@ +assertFileExists($cache_dir.'/config.php'); +// $this->assertFileExists($cache_dir.'/config_override.php'); + + unlink($cache_dir . '/config.php'); + unlink($cache_dir . '/config_override.php'); + } + + public function testunzip_file(): void + { + // execute the method and test if it returns true and verify the if unzipped files exist + $cache_dir = rtrim($GLOBALS['sugar_config']['cache_dir'], '/\\'); + $files_list = array('config.php', 'config_override.php'); + $file = $cache_dir . '/zipTest.zip'; + + //create a a zip file first, to unzip + if (!file_exists($file)) { + zip_files_list($file, $files_list); + } + + $result = unzip_file($file, null, $cache_dir); + self::assertTrue($result); + + self::markTestIncomplete("File handling doesn't work locally."); +// $this->assertFileExists($cache_dir.'/config.php'); +// $this->assertFileExists($cache_dir.'/config_override.php'); + + unlink($cache_dir . '/config.php'); + unlink($cache_dir . '/config_override.php'); + } + + public function testzip_dir(): void + { + //execute the method and verify the if zipped file exist + $cache_dir = rtrim($GLOBALS['sugar_config']['cache_dir'], '/\\'); + $file = $cache_dir . '/zipTest.zip'; + + if (file_exists($file)) { + unlink($file); + } + + zip_dir($cache_dir . '/modules', $file); + + self::assertFileExists($file); + + unlink($file); + } + + public function testzip_files_list(): void + { + //execute the method and verify the if zipped file exist + $cache_dir = rtrim($GLOBALS['sugar_config']['cache_dir'], '/\\'); + $file = $cache_dir . '/ziplistTest.zip'; + $files_list = array('config.php', 'config_override.php'); + + if (file_exists($file)) { + unlink($file); + } + + $result = zip_files_list($file, $files_list); + + self::assertTrue($result); + self::assertFileExists($file); + + unlink($file); + } +} diff --git a/tests/unit/phpunit/includes/utils/progress_bar_utilsTest.php b/tests/unit/phpunit/includes/utils/progress_bar_utilsTest.php new file mode 100644 index 000000000..78fe22ae3 --- /dev/null +++ b/tests/unit/phpunit/includes/utils/progress_bar_utilsTest.php @@ -0,0 +1,135 @@ +getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + } + } + + public function testdisplay_flow_bar(): void + { + //execute the method and test if it doesn't throw an exception. + //this method uses flush so we cannot get and verify content printed + try { + ob_start(); + display_flow_bar('test', 0, 200, false); + ob_end_clean(); + self::assertTrue(true); + } catch (Exception $e) { + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + } + } + + public function teststart_flow_bar(): void + { + //execute the method and test if it doesn't throw an exception. + //this method uses flush so we cannot get and verify content printed + try { + ob_start(); + start_flow_bar('test', 1, false); + ob_end_clean(); + self::assertTrue(true); + } catch (Exception $e) { + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + } + } + + public function testdestroy_flow_bar(): void + { + //execute the method and test if it doesn't throw an exception. + //this method uses flush so we cannot get and verify content printed + try { + ob_start(); + destroy_flow_bar('test', false); + ob_end_clean(); + self::assertTrue(true); + } catch (Exception $e) { + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + } + } + + public function testdisplay_progress_bar(): void + { + //execute the method and test if it doesn't throw an exception. + //this method uses flush so we cannot get and verify content printed + try { + ob_start(); + display_progress_bar('test', 80, 100, false); + ob_end_clean(); + self::assertTrue(true); + } catch (Exception $e) { + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + } + } + + public function testupdate_progress_bar(): void + { + //execute the method and test if it doesn't throw an exception. + //this method uses flush so we cannot get and verify content printed + try { + ob_start(); + update_progress_bar('test', 80, 100, false); + ob_end_clean(); + self::assertTrue(true); + } catch (Exception $e) { + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + } + } +} diff --git a/tests/unit/phpunit/include/utils/securityUtilsTest.php b/tests/unit/phpunit/includes/utils/security_utilsTest.php similarity index 55% rename from tests/unit/phpunit/include/utils/securityUtilsTest.php rename to tests/unit/phpunit/includes/utils/security_utilsTest.php index f115a6485..eb0d535f3 100644 --- a/tests/unit/phpunit/include/utils/securityUtilsTest.php +++ b/tests/unit/phpunit/includes/utils/security_utilsTest.php @@ -1,20 +1,58 @@ assertSame($expected, $actual); + self::assertSame($expected, $actual); } - public function testquery_user_has_roles() + public function testquery_user_has_roles(): void { // execute the method and test it returns 1 role // if the test suite run runs RolesTest first. @@ -73,19 +111,19 @@ class security_utilsTest extends SuitePHPUnitFrameworkTestCase $expected = '0'; $actual = query_user_has_roles('1'); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } - public function testget_user_allowed_modules() + public function testget_user_allowed_modules(): void { //execute the method and test it it returns expected contents $expected = array(); $actual = get_user_allowed_modules('1'); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } - public function testget_user_disallowed_modules() + public function testget_user_disallowed_modules(): void { self::markTestIncomplete('Test fails only in travis and php7, Test has environment specific issue.'); @@ -103,31 +141,40 @@ class security_utilsTest extends SuitePHPUnitFrameworkTestCase $allowed = query_module_access_list(new User('1')); $actual = get_user_disallowed_modules('1', $allowed); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } - public function testquery_client_ip() + public function testquery_client_ip(): void { //test without setting any server parameters - $this->assertSame(null, query_client_ip()); + self::assertNull(query_client_ip()); //test with server params set $_SERVER['REMOTE_ADDR'] = '1.1.1.3'; - $this->assertSame('1.1.1.3', query_client_ip()); + self::assertSame('1.1.1.3', query_client_ip()); $_SERVER['HTTP_FROM'] = '1.1.1.2'; - $this->assertSame('1.1.1.2', query_client_ip()); + self::assertSame('1.1.1.2', query_client_ip()); $_SERVER['HTTP_CLIENT_IP'] = '1.1.1.1'; - $this->assertSame('1.1.1.1', query_client_ip()); + self::assertSame('1.1.1.1', query_client_ip()); } - public function testget_val_array() + public function testget_val_array(): void { //execute the method and test it it returns expected contents $tempArray = array('key1' => 'val1', 'key2' => 'val2', 'key3' => 'val3'); $expected = array('key1' => 'key1', 'key2' => 'key2', 'key3' => 'key3'); $actual = get_val_array($tempArray); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); + } + + protected function setUp(): void + { + parent::setUp(); + + global $current_user; + get_sugar_config_defaults(); + $current_user = BeanFactory::newBean('Users'); } } diff --git a/tests/unit/phpunit/lib/Exception/ExceptionTest.php b/tests/unit/phpunit/lib/Exception/ExceptionTest.php index 58ebf2710..31c901cb8 100644 --- a/tests/unit/phpunit/lib/Exception/ExceptionTest.php +++ b/tests/unit/phpunit/lib/Exception/ExceptionTest.php @@ -1,38 +1,55 @@ assertEquals( + self::assertEquals( 'SuiteCRM has encountered an exception which has not been handled', self::$exception->getDetail() ); } - public function testGetLogLevel() + public function testGetLogLevel(): void { - $this->assertEquals( + self::assertEquals( LogLevel::CRITICAL, self::$exception->getLogLevel() ); diff --git a/tests/unit/phpunit/lib/PDF/MPDF/MPDFEngineTest.php b/tests/unit/phpunit/lib/PDF/MPDF/MPDFEngineTest.php new file mode 100644 index 000000000..81b164d56 --- /dev/null +++ b/tests/unit/phpunit/lib/PDF/MPDF/MPDFEngineTest.php @@ -0,0 +1,159 @@ +pdf = PDFWrapper::getPDFEngine(); + } + + public function testWriteFooter(): void + { + $this->pdf->writeFooter('{TEST_FOOTER}'); + $footerDetails = $this->pdf->pdf->footerDetails; + $expected = '{TEST_FOOTER}'; + + self::assertIsArray($footerDetails); + + $odd = $footerDetails['odd']['R']['content']; + $even = $footerDetails['even']['L']['content']; + + self::assertEquals($expected, $odd); + self::assertEquals($expected, $even); + } + + public function testWriteHeader(): void + { + $this->pdf->writeHeader('{TEST_HEADER}'); + $headerDetails = $this->pdf->pdf->headerDetails; + $expected = '{TEST_HEADER}'; + + self::assertIsArray($headerDetails); + + $odd = $headerDetails['odd']['R']['content']; + $even = $headerDetails['even']['L']['content']; + + self::assertEquals($expected, $odd); + self::assertEquals($expected, $even); + } + + public function testConfigurePDF(): void + { + $this->pdf->configurePDF([ + 'font' => 'DejaVuSansCondensed', + ]); + $actual = $this->pdf->pdf->original_default_font; + + self::assertEquals('dejavusanscondensed', $actual); + } + + public function testWriteHTML(): void + { + $stylesheet = file_get_contents(SugarThemeRegistry::current()->getCSSURL( + 'style.css', false + )); + $this->pdf->configurePDF([ + 'mode' => 'en', + 'font' => 'DejaVuSansCondensed', + ]); + $this->pdf->writeHTML($stylesheet, 1); + $defaultCSS = $this->pdf->pdf->defaultCSS; + + $actual = $defaultCSS['BODY']['BACKGROUND-COLOR']; + + self::assertEquals('#FFFFFF', $actual); + } + + public function test__construct(): void + { + $engine = new MPDFEngine(); + $mpdfEngine = $engine->pdf; + + self::assertInstanceOf(PDFEngine::class, $engine); + self::assertInstanceOf(mPDF::class, $mpdfEngine); + } + + public function testOutputPDF(): void + { + $stylesheet = file_get_contents(SugarThemeRegistry::current()->getCSSURL( + 'style.css', false) + ); + + try { + $this->pdf = PDFWrapper::getPDFEngine(); + $this->pdf->configurePDF([ + 'mode' => 'en', + 'font' => 'DejaVuSansCondensed', + ]); + $this->pdf->writeHTML($stylesheet, 1); + @$actual = $this->pdf->outputPDF('TEST_PDF.pdf', 'S'); + } catch (PDFException $e) { + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + } + + self::assertIsString($actual); + } +} diff --git a/tests/unit/phpunit/lib/PDF/PDFWrapperTest.php b/tests/unit/phpunit/lib/PDF/PDFWrapperTest.php new file mode 100644 index 000000000..99971c2df --- /dev/null +++ b/tests/unit/phpunit/lib/PDF/PDFWrapperTest.php @@ -0,0 +1,90 @@ + 'MPDFEngine' + ]; + + self::assertEquals($expected, $actual); + } + + public function testGetDefaultEngine(): void + { + $actual = PDFWrapper::getDefaultEngine(); + $expected = 'MPDFEngine'; + + self::assertEquals($expected, $actual); + } + + public function testAddEngine(): void + { + PDFWrapper::addEngine('TestPDFEngine', 'TestPDFEngine.php', 'TestPDFEngine'); + $engines = PDFWrapper::getEngines(); + $testEngine = $engines[1]; + + self::assertEquals('TestPDFEngine', $testEngine); + } + + public function testGetPDFEngine(): void + { + $actual = PDFWrapper::getPDFEngine(); + + self::assertInstanceOf(MPDFEngine::class, $actual); + } +} diff --git a/tests/unit/phpunit/lib/Search/UI/SearchResultsControllerTest.php b/tests/unit/phpunit/lib/Search/UI/SearchResultsControllerTest.php index 92492f516..4f11952e8 100644 --- a/tests/unit/phpunit/lib/Search/UI/SearchResultsControllerTest.php +++ b/tests/unit/phpunit/lib/Search/UI/SearchResultsControllerTest.php @@ -55,17 +55,17 @@ if (!defined('sugarEntry') || !sugarEntry) { */ class SearchResultsControllerTest extends SuitePHPUnitFrameworkTestCase { - public function testDisplayFoundOnePage() + public function testDisplayFoundOnePage(): void { $ids = []; for ($i=0; $i<15; $i++) { $account = BeanFactory::getBean('Accounts'); $account->name = 'test account ' . $i; $ok = $account->save(); - $this->assertTrue((bool)$ok); + self::assertTrue((bool)$ok); $ids[] = $account->id; } - $this->assertEquals(15, count($ids)); + self::assertCount(15, $ids); $request = [ 'search-query-string' => 'test account', @@ -89,19 +89,19 @@ class SearchResultsControllerTest extends SuitePHPUnitFrameworkTestCase $searchResultsController->display(); $content = ob_get_contents(); ob_end_clean(); - $this->assertContains('Total result(s): 15', $content); - $this->assertContains('Page 1 of 2', $content); - + self::assertStringContainsString('Total result(s): 15', $content); + self::assertStringContainsString('Page 1 of 2', $content); + // add 5 more.. for ($i=15; $i<20; $i++) { $account = BeanFactory::getBean('Accounts'); $account->name = 'test account ' . $i; $ok = $account->save(); - $this->assertTrue((bool)$ok); + self::assertTrue((bool)$ok); $ids[] = $account->id; } - $this->assertEquals(20, count($ids)); - + self::assertCount(20, $ids); + $request = [ 'search-query-string' => 'test account', 'query_string' => 'test account', @@ -124,16 +124,16 @@ class SearchResultsControllerTest extends SuitePHPUnitFrameworkTestCase $searchResultsController->display(); $content = ob_get_contents(); ob_end_clean(); - $this->assertContains('Total result(s): 20', $content); - $this->assertContains('Page 2 of 2', $content); + self::assertStringContainsString('Total result(s): 20', $content); + self::assertStringContainsString('Page 2 of 2', $content); } - - public function testDisplayFoundOne() + + public function testDisplayFoundOne(): void { $account = BeanFactory::getBean('Accounts'); $account->name = 'test account 1'; $ok = $account->save(); - $this->assertTrue((bool)$ok); + self::assertTrue((bool)$ok); $request = [ 'search-query-string' => 'test account', @@ -157,10 +157,10 @@ class SearchResultsControllerTest extends SuitePHPUnitFrameworkTestCase $searchResultsController->display(); $content = ob_get_contents(); ob_end_clean(); - $this->assertContains('test account 1', $content); + self::assertStringContainsString('test account 1', $content); } - - public function testDisplayNotFound() + + public function testDisplayNotFound(): void { $request = [ 'search-query-string' => 'test query string (not found)', @@ -182,6 +182,6 @@ class SearchResultsControllerTest extends SuitePHPUnitFrameworkTestCase $searchResultsController->display(); $content = ob_get_contents(); ob_end_clean(); - $this->assertContains('No results matching your search criteria. Try broadening your search.', $content); + self::assertStringContainsString('No results matching your search criteria. Try broadening your search.', $content); } } diff --git a/tests/unit/phpunit/lib/SuiteCRM/Log/CliLoggerHandlerTest.php b/tests/unit/phpunit/lib/SuiteCRM/Log/CliLoggerHandlerTest.php index caf8fa1e7..5fb87a7b8 100644 --- a/tests/unit/phpunit/lib/SuiteCRM/Log/CliLoggerHandlerTest.php +++ b/tests/unit/phpunit/lib/SuiteCRM/Log/CliLoggerHandlerTest.php @@ -4,7 +4,7 @@ * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. * * SuiteCRM is an extension to SugarCRM Community Edition developed by SalesAgility Ltd. - * Copyright (C) 2011 - 2018 SalesAgility Ltd. + * Copyright (C) 2011 - 2021 SalesAgility Ltd. * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU Affero General Public License version 3 as published by the @@ -37,8 +37,6 @@ * display the words "Powered by SugarCRM" and "Supercharged by SuiteCRM". */ -/** @noinspection PhpUnhandledExceptionInspection */ - use Monolog\Logger; use SuiteCRM\Log\CliLoggerHandler; use SuiteCRM\Test\SuitePHPUnitFrameworkTestCase; @@ -53,9 +51,9 @@ class CliLoggerHandlerTest extends SuitePHPUnitFrameworkTestCase /** @var Logger */ private $logger; - public function testLogging() + public function testLogging(): void { - $this->logger->debug("\n"); + $output = $this->logger->debug("\n"); $this->logger->debug('DEBUG'); $this->logger->info("INFO"); $this->logger->notice('NOTICE'); @@ -64,7 +62,7 @@ class CliLoggerHandlerTest extends SuitePHPUnitFrameworkTestCase $this->logger->critical('CRITICAL'); $this->logger->emergency('EMERGENCY'); - $this->logger->emergency(new RuntimeException("Exception!")); + self::assertTrue($output); } protected function setUp(): void diff --git a/tests/unit/phpunit/lib/SuiteCRM/Robo/Commands/CodeCoverageCommandsTest.php b/tests/unit/phpunit/lib/SuiteCRM/Robo/Commands/CodeCoverageCommandsTest.php index c468705d9..383f23686 100644 --- a/tests/unit/phpunit/lib/SuiteCRM/Robo/Commands/CodeCoverageCommandsTest.php +++ b/tests/unit/phpunit/lib/SuiteCRM/Robo/Commands/CodeCoverageCommandsTest.php @@ -22,10 +22,9 @@ class CodeCoverageCommandsTest extends SuitePHPUnitFrameworkTestCase } } - public function testIsEnvironmentTravisCI() + public function testIsEnvironmentTravisCI(): void { - $reflection = new ReflectionClass(CodeCoverageCommands::class); - $method = $reflection->getMethod('isEnvironmentTravisCI'); + $method = (new ReflectionClass(CodeCoverageCommands::class))->getMethod('isEnvironmentTravisCI'); $method->setAccessible(true); $actual = $method->invoke( @@ -33,13 +32,12 @@ class CodeCoverageCommandsTest extends SuitePHPUnitFrameworkTestCase ); $returnType = is_string($actual) || is_array($actual) || is_bool($actual); - $this->assertTrue($returnType); + self::assertTrue($returnType); } - public function testGetCommitRangeForTravisCi() + public function testGetCommitRangeForTravisCi(): void { - $reflection = new ReflectionClass(CodeCoverageCommands::class); - $method = $reflection->getMethod('getCommitRangeForTravisCi'); + $method = (new ReflectionClass(CodeCoverageCommands::class))->getMethod('getCommitRangeForTravisCi'); $method->setAccessible(true); $actual = $method->invoke( @@ -47,21 +45,20 @@ class CodeCoverageCommandsTest extends SuitePHPUnitFrameworkTestCase ); $returnType = is_string($actual) || is_array($actual) || is_bool($actual); - $this->assertTrue($returnType); + self::assertTrue($returnType); } - public function testGetCodeCoverageCommand() + public function testGetCodeCoverageCommand(): void { $commandExpected = './vendor/bin/phpunit --configuration ./tests/phpunit.xml.dist --coverage-clover ./tests/_output/coverage.xml ./tests/unit/phpunit'; // Run tests - $reflection = new ReflectionClass(CodeCoverageCommands::class); - $method = $reflection->getMethod('getCodeCoverageCommand'); + $method = (new ReflectionClass(CodeCoverageCommands::class))->getMethod('getCodeCoverageCommand'); $method->setAccessible(true); $actual = $method->invoke( self::$testClass ); - $this->assertEquals($commandExpected, $actual); + self::assertEquals($commandExpected, $actual); } } diff --git a/tests/unit/phpunit/lib/SuiteCRM/Search/AbstractDocumentifierMock.php b/tests/unit/phpunit/lib/SuiteCRM/Search/AbstractDocumentifierMock.php index 37ae0eb3a..ec0479353 100644 --- a/tests/unit/phpunit/lib/SuiteCRM/Search/AbstractDocumentifierMock.php +++ b/tests/unit/phpunit/lib/SuiteCRM/Search/AbstractDocumentifierMock.php @@ -4,7 +4,7 @@ * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. * * SuiteCRM is an extension to SugarCRM Community Edition developed by SalesAgility Ltd. - * Copyright (C) 2011 - 2018 SalesAgility Ltd. + * Copyright (C) 2011 - 2021 SalesAgility Ltd. * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU Affero General Public License version 3 as published by the @@ -37,20 +37,25 @@ * display the words "Powered by SugarCRM" and "Supercharged by SuiteCRM". */ -namespace SuiteCRM\Test; +namespace SuiteCRM\Tests\Unit\lib\SuiteCRM\Search; +use SugarBean; use SuiteCRM\Search\Index\Documentify\AbstractDocumentifier; -class AbstractDocumentifierMock extends \SuiteCRM\Search\Index\Documentify\AbstractDocumentifier +/** + * Class AbstractDocumentifierMock + * @package SuiteCRM\Tests\Unit\lib\SuiteCRM\Search + */ +class AbstractDocumentifierMock extends AbstractDocumentifier { /** * Converts a bean to a document-friendly associative array. * - * @param \SugarBean $bean - * + * @param SugarBean $bean * @return array + * @noinspection UnusedFunctionResultInspection */ - public function documentify(\SugarBean $bean) + public function documentify(SugarBean $bean): array { parent::documentify($bean); } diff --git a/tests/unit/phpunit/lib/SuiteCRM/Search/AbstractDocumentifierTest.php b/tests/unit/phpunit/lib/SuiteCRM/Search/AbstractDocumentifierTest.php index 39bc45f22..faf7ec1fb 100644 --- a/tests/unit/phpunit/lib/SuiteCRM/Search/AbstractDocumentifierTest.php +++ b/tests/unit/phpunit/lib/SuiteCRM/Search/AbstractDocumentifierTest.php @@ -4,7 +4,7 @@ * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. * * SuiteCRM is an extension to SugarCRM Community Edition developed by SalesAgility Ltd. - * Copyright (C) 2011 - 2018 SalesAgility Ltd. + * Copyright (C) 2011 - 2021 SalesAgility Ltd. * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU Affero General Public License version 3 as published by the @@ -37,23 +37,23 @@ * display the words "Powered by SugarCRM" and "Supercharged by SuiteCRM". */ - -namespace SuiteCRM\Test; +namespace SuiteCRM\Tests\Unit\lib\SuiteCRM\Search; use SuiteCRM\Search\Index\Documentify\AbstractDocumentifier; -use SuiteCRM\Search\SearchTestAbstract; - require_once __DIR__ . "/AbstractDocumentifierMock.php"; require_once __DIR__ . "/SearchTestAbstract.php"; - +/** + * Class AbstractDocumentifierTest + * @package SuiteCRM\Tests\Unit\lib\SuiteCRM\Search + */ class AbstractDocumentifierTest extends SearchTestAbstract { /** @var AbstractDocumentifier */ private $documentifier; - public function testSanitizePhone() + public function testSanitizePhone(): void { $data1 = "(+44) 012321323"; $expe1 = "+44012321323"; @@ -69,7 +69,7 @@ class AbstractDocumentifierTest extends SearchTestAbstract self::assertEquals($expe3, $this->documentifier->sanitizePhone($data3)); } - public function testFixPhone() + public function testFixPhone(): void { $document = [ 'name' => 'foo', diff --git a/tests/unit/phpunit/lib/SuiteCRM/Search/AbstractIndexerTest.php b/tests/unit/phpunit/lib/SuiteCRM/Search/AbstractIndexerTest.php index 896734a3e..d8b43c251 100644 --- a/tests/unit/phpunit/lib/SuiteCRM/Search/AbstractIndexerTest.php +++ b/tests/unit/phpunit/lib/SuiteCRM/Search/AbstractIndexerTest.php @@ -7,7 +7,7 @@ * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. * * SuiteCRM is an extension to SugarCRM Community Edition developed by SalesAgility Ltd. - * Copyright (C) 2011 - 2018 SalesAgility Ltd. + * Copyright (C) 2011 - 2021 SalesAgility Ltd. * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU Affero General Public License version 3 as published by the @@ -44,21 +44,22 @@ use Mockery as m; use SuiteCRM\Search\Index\AbstractIndexer; use SuiteCRM\Search\Index\Documentify\JsonSerializerDocumentifier; use SuiteCRM\Search\Index\Documentify\SearchDefsDocumentifier; +use SuiteCRM\Tests\Unit\lib\SuiteCRM\Search\SearchTestAbstract; /** * Class AbstractIndexerTest * * @see AbstractIndexer */ -class AbstractIndexerTest extends \SuiteCRM\Search\SearchTestAbstract +class AbstractIndexerTest extends SearchTestAbstract { - public function testConstruct() + public function testConstruct(): void { $indexer = $this->getIndexerMock(); self::assertInstanceOf(AbstractIndexer::class, $indexer); } - public function testGettersAndSetters() + public function testGettersAndSetters(): void { $differential = true; $doc = new SearchDefsDocumentifier(); @@ -90,7 +91,7 @@ class AbstractIndexerTest extends \SuiteCRM\Search\SearchTestAbstract try { $indexer->setModulesToIndex(null); - $this->fail('Null should not be accepted'); + self::fail('Null should not be accepted'); } catch (Exception $throwable) { // All good! } catch (Throwable $throwable) { @@ -98,7 +99,7 @@ class AbstractIndexerTest extends \SuiteCRM\Search\SearchTestAbstract } } - public function testAddModulesToIndex() + public function testAddModulesToIndex(): void { $indexer = $this->getIndexerMock(); $indexer->addModulesToIndex('Foo'); @@ -120,7 +121,7 @@ class AbstractIndexerTest extends \SuiteCRM\Search\SearchTestAbstract } } - public function testGetDocumentifierName() + public function testGetDocumentifierName(): void { $indexer = $this->getIndexerMock(); $doc1 = new JsonSerializerDocumentifier(); @@ -135,7 +136,7 @@ class AbstractIndexerTest extends \SuiteCRM\Search\SearchTestAbstract self::assertEquals($doc2Exp, $indexer->getDocumentifierName()); } - public function testGetIndexerName() + public function testGetIndexerName(): void { $indexer = $this->getIndexerMock(); @@ -145,7 +146,7 @@ class AbstractIndexerTest extends \SuiteCRM\Search\SearchTestAbstract self::assertEquals($expected, $actual, "Indexer name does not match"); } - public function testLogger() + public function testLogger(): void { $indexer = $this->getIndexerMock(); @@ -159,7 +160,6 @@ class AbstractIndexerTest extends \SuiteCRM\Search\SearchTestAbstract */ private function getIndexerMock() { - $indexer = m::mock(AbstractIndexer::class)->makePartial(); - return $indexer; + return m::mock(AbstractIndexer::class)->makePartial(); } } diff --git a/tests/unit/phpunit/lib/SuiteCRM/Search/ElasticSearch/ElasticSearchClientBuilderTest.php b/tests/unit/phpunit/lib/SuiteCRM/Search/ElasticSearch/ElasticSearchClientBuilderTest.php index 09fe019a7..928617f40 100644 --- a/tests/unit/phpunit/lib/SuiteCRM/Search/ElasticSearch/ElasticSearchClientBuilderTest.php +++ b/tests/unit/phpunit/lib/SuiteCRM/Search/ElasticSearch/ElasticSearchClientBuilderTest.php @@ -1,10 +1,11 @@ invokeMethod($builder, 'loadFromFile', [__DIR__ . '/TestData/ElasticsearchServerConfig.json']); $expected = [ [ 'host' => 'foo.com', @@ -70,10 +72,10 @@ class ElasticSearchClientBuilderTest extends SearchTestAbstract } // Tests if the default configs are returned when the config file is not found - public function testLoadConfigFileNotThere() + public function testLoadConfigFileNotThere(): void { $builder = new ElasticSearchClientBuilder(); - $config = self::invokeMethod($builder, 'loadFromFile', [__DIR__ . '/TestData/NopeNotHere.json']); + $config = $this->invokeMethod($builder, 'loadFromFile', [__DIR__ . '/TestData/NopeNotHere.json']); $expected = [ ['host' => '127.0.0.1'] ]; @@ -81,7 +83,7 @@ class ElasticSearchClientBuilderTest extends SearchTestAbstract self::assertEquals($expected, $config); } - public function testLoadSugarConfig() + public function testLoadSugarConfig(): void { global $sugar_config; @@ -101,7 +103,7 @@ class ElasticSearchClientBuilderTest extends SearchTestAbstract self::assertEquals($expected, $actual); } - public function testLoadSugarConfig2() + public function testLoadSugarConfig2(): void { global $sugar_config; @@ -123,7 +125,7 @@ class ElasticSearchClientBuilderTest extends SearchTestAbstract } - public function testLoadSugarConfig3() + public function testLoadSugarConfig3(): void { global $sugar_config; @@ -145,16 +147,18 @@ class ElasticSearchClientBuilderTest extends SearchTestAbstract private function loadFromSugarConfig() { $builder = new ElasticSearchClientBuilder(); - return self::invokeMethod($builder, 'loadFromSugarConfig'); + + return $this->invokeMethod($builder, 'loadFromSugarConfig'); } private function sanitizeHost(array $host) { $builder = new ElasticSearchClientBuilder(); - return self::invokeMethod($builder, 'sanitizeHost', [$host]); + + return $this->invokeMethod($builder, 'sanitizeHost', [$host]); } - public function testUrlParser1() + public function testUrlParser1(): void { $data = [ 'host' => 'www.example.com' @@ -169,7 +173,7 @@ class ElasticSearchClientBuilderTest extends SearchTestAbstract self::assertEquals($expected, $actual); } - public function testUrlParser2() + public function testUrlParser2(): void { $data = [ 'host' => 'https://www.example.com', @@ -187,7 +191,7 @@ class ElasticSearchClientBuilderTest extends SearchTestAbstract self::assertEquals($expected, $actual); } - public function testUrlParser3() + public function testUrlParser3(): void { $data = [ 'host' => 'https://www.example.com:42', @@ -208,7 +212,7 @@ class ElasticSearchClientBuilderTest extends SearchTestAbstract self::assertEquals($expected, $actual); } - public function testUrlParser4() + public function testUrlParser4(): void { $data = [ 'host' => 'bar:pass@mydomain.server.com:9201', @@ -227,57 +231,40 @@ class ElasticSearchClientBuilderTest extends SearchTestAbstract self::assertEquals($expected, $actual); } - public function testUrlParser5() + public function testUrlParser5(): void { $data = [ 'user' => 'foo', ]; - try { - $this->sanitizeHost($data); - } catch (InvalidArgumentException $e) { - return; - } - - $this->fail('Exception not thrown!'); + $this->expectException(InvalidArgumentException::class); + $this->sanitizeHost($data); } - public function testUrlParser6() + public function testUrlParser6(): void { $data = [ 'host' => 0.5, 'user' => 'foo', ]; - try { - $this->sanitizeHost($data); - } catch (InvalidArgumentException $e) { - return; - } + $this->expectException(InvalidArgumentException::class); + $this->sanitizeHost($data); } - public function testUrlParserBadUrls() + public function testUrlParserBadUrls(): void { $url1 = ['host' => 'http:///example.com']; $url2 = ['host' => 'http://:80']; $url3 = ['host' => 'http://user@:80']; - try { - $this->sanitizeHost($url1); - $this->fail('Exception not thrown!'); - } catch (InvalidArgumentException $e) { - } + $this->expectException(InvalidArgumentException::class); + $this->sanitizeHost($url1); - try { - $this->sanitizeHost($url2); - $this->fail('Exception not thrown!'); - } catch (InvalidArgumentException $e) { - } + $this->expectException(InvalidArgumentException::class); + $this->sanitizeHost($url2); - try { - $this->sanitizeHost($url3); - $this->fail('Exception not thrown!'); - } catch (InvalidArgumentException $e) { - } + $this->expectException(InvalidArgumentException::class); + $this->sanitizeHost($url3); } } diff --git a/tests/unit/phpunit/lib/SuiteCRM/Search/ElasticSearch/ElasticSearchEngineTest.php b/tests/unit/phpunit/lib/SuiteCRM/Search/ElasticSearch/ElasticSearchEngineTest.php index b11495b16..450947be5 100644 --- a/tests/unit/phpunit/lib/SuiteCRM/Search/ElasticSearch/ElasticSearchEngineTest.php +++ b/tests/unit/phpunit/lib/SuiteCRM/Search/ElasticSearch/ElasticSearchEngineTest.php @@ -1,11 +1,10 @@ getSearchString()); } - public function testCreateSearchParams1() + public function testCreateSearchParams1(): void { global $sugar_config; @@ -88,10 +96,10 @@ class ElasticSearchEngineTest extends \SuiteCRM\Search\SearchTestAbstract $params = $this->invokeMethod($engine, 'createSearchParams', [$query]); - $this->assertEquals($expectedParams, $params); + self::assertEquals($expectedParams, $params); } - public function testCreateSearchParams2() + public function testCreateSearchParams2(): void { global $sugar_config; @@ -121,10 +129,10 @@ class ElasticSearchEngineTest extends \SuiteCRM\Search\SearchTestAbstract $params = $this->invokeMethod($engine, 'createSearchParams', [$query]); - $this->assertEquals($expectedParams, $params); + self::assertEquals($expectedParams, $params); } - public function testRunElasticSearch() + public function testRunElasticSearch(): void { $query = SearchQuery::fromString("a"); @@ -133,8 +141,8 @@ class ElasticSearchEngineTest extends \SuiteCRM\Search\SearchTestAbstract $client = $this->getMockedClient($mockedResults); $engine = new ElasticSearchEngine($client); - - $results = $params = $this->invokeMethod($engine, 'runElasticSearch', [$query]); + $searchQuery = $this->getSearchQuery($engine, $query); + $results = $this->invokeMethod($engine, 'runElasticSearch', [$searchQuery]); self::assertEquals($mockedResults, $results); } @@ -142,11 +150,11 @@ class ElasticSearchEngineTest extends \SuiteCRM\Search\SearchTestAbstract /** * @return array */ - private function getMockedHits() + private function getMockedHits(): array { global $sugar_config; - $mockedResults = [ + return [ 'took' => 5, 'timed_out' => false, '_shards' => @@ -186,18 +194,16 @@ class ElasticSearchEngineTest extends \SuiteCRM\Search\SearchTestAbstract ] ], ]; - return $mockedResults; } /** * @param $mockedResults - * @return \Mockery\MockInterface + * @return MockInterface */ - private function getMockedClient($mockedResults) + private function getMockedClient($mockedResults): MockInterface { - $client = Mockery::mock('Elasticsearch\Client'); + $client = Mockery::mock(Client::class); - /** @noinspection PhpMethodParametersCountMismatchInspection */ $client ->shouldReceive('search') ->once() @@ -206,7 +212,7 @@ class ElasticSearchEngineTest extends \SuiteCRM\Search\SearchTestAbstract return $client; } - public function testParseHits() + public function testParseHits(): void { $engine = new ElasticSearchEngine(); @@ -214,7 +220,7 @@ class ElasticSearchEngineTest extends \SuiteCRM\Search\SearchTestAbstract $expectedResults = $this->getExpectedResultsForMockedHits(); - $results = $params = $this->invokeMethod($engine, 'parseHits', [$mockedHits]); + $results = $this->invokeMethod($engine, 'parseHits', [$mockedHits]); self::assertEquals($expectedResults, $results); } @@ -222,9 +228,9 @@ class ElasticSearchEngineTest extends \SuiteCRM\Search\SearchTestAbstract /** * @return array */ - private function getExpectedResultsForMockedHits() + private function getExpectedResultsForMockedHits(): array { - $expectedResults = [ + return [ 'Accounts' => [ 'id1', 'id2' @@ -233,11 +239,9 @@ class ElasticSearchEngineTest extends \SuiteCRM\Search\SearchTestAbstract 'id3', ] ]; - - return $expectedResults; } - public function testParseEmptyHits() + public function testParseEmptyHits(): void { $engine = new ElasticSearchEngine(); @@ -245,12 +249,12 @@ class ElasticSearchEngineTest extends \SuiteCRM\Search\SearchTestAbstract $expectedResults = []; - $results = $params = $this->invokeMethod($engine, 'parseHits', [$mockedHits]); + $results = $this->invokeMethod($engine, 'parseHits', [$mockedHits]); self::assertEquals($expectedResults, $results); } - private function getMockedHitsEmpty() + private function getMockedHitsEmpty(): array { return [ 'took' => 1, @@ -270,7 +274,7 @@ class ElasticSearchEngineTest extends \SuiteCRM\Search\SearchTestAbstract ]; } - public function testSearch() + public function testSearch(): void { $mockedClient = $this->getMockedClient($this->getMockedHits()); $engine = new ElasticSearchEngine($mockedClient); @@ -281,11 +285,11 @@ class ElasticSearchEngineTest extends \SuiteCRM\Search\SearchTestAbstract self::assertEquals($expectedResults, $results->getHits()); self::assertEquals(258, $results->getTotal()); - self::assertTrue(is_float($results->getSearchTime())); + self::assertIsFloat($results->getSearchTime()); self::assertGreaterThan(0, $results->getSearchTime()); } - public function testGetIndex() + public function testGetIndex(): void { global $sugar_config; @@ -299,4 +303,17 @@ class ElasticSearchEngineTest extends \SuiteCRM\Search\SearchTestAbstract self::assertEquals($expected, $actual); } + + /** + * @param ElasticSearchEngine $engine + * @param SearchQuery $query + * @return array + * @throws ReflectionException + */ + private function getSearchQuery(ElasticSearchEngine $engine, SearchQuery $query): array + { + $this->invokeMethod($engine, 'validateQuery', [&$query]); + + return $this->invokeMethod($engine, 'createSearchParams', [&$query]); + } } diff --git a/tests/unit/phpunit/lib/SuiteCRM/Search/ElasticSearch/ElasticSearchIndexerTest.php b/tests/unit/phpunit/lib/SuiteCRM/Search/ElasticSearch/ElasticSearchIndexerTest.php index 2f7023e2d..f8268e08d 100644 --- a/tests/unit/phpunit/lib/SuiteCRM/Search/ElasticSearch/ElasticSearchIndexerTest.php +++ b/tests/unit/phpunit/lib/SuiteCRM/Search/ElasticSearch/ElasticSearchIndexerTest.php @@ -1,5 +1,4 @@ getModulesToIndex(); - $modules = $indexer->getModulesToIndex(); - - self::assertTrue(is_array($modules), "Result is not an array."); + self::assertIsArray($modules, "Result is not an array."); self::assertTrue(count($modules) > 0, "The array is empty."); - self::assertTrue(in_array('Contacts', $modules), "Contacts was not found in the list of modules to index"); + self::assertContains('Contacts', $modules, "Contacts was not found in the list of modules to index"); } - public function testIndexBeans() + public function testIndexBeans(): void { $client = m::mock('\Elasticsearch\Client'); @@ -107,7 +105,7 @@ class ElasticSearchIndexerTest extends SearchTestAbstract self::assertEquals(9, $i->getIndexedFieldsCount(), "Wrong number of fields indexed"); } - public function testGettersAndSetters() + public function testGettersAndSetters(): void { $batchSize = 20; $index = 'test1'; @@ -128,7 +126,7 @@ class ElasticSearchIndexerTest extends SearchTestAbstract self::assertEquals($index, $i->getIndex()); } - public function testIndexBean() + public function testIndexBean(): void { $bean = $this->getTestBean(); $client = m::mock('\Elasticsearch\Client'); @@ -139,20 +137,24 @@ class ElasticSearchIndexerTest extends SearchTestAbstract $indexer = new ElasticSearchIndexer($client); - $indexer->indexBean($bean); + try { + $indexer->indexBean($bean); + self::assertTrue(true); + } catch (Exception $e) { + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + } } /** * @return SugarBean */ - private function getTestBean() + private function getTestBean(): \SugarBean { /** @var SugarBean $bean */ - $bean = new BeanMock(__DIR__ . '/../../Utility/BeanJsonSerializerTestData/ContactBean.json'); - return $bean; + return new BeanMock(__DIR__ . '/../../Utility/BeanJsonSerializerTestData/ContactBean.json'); } - public function testMakeIndexParamsFromBean() + public function testMakeIndexParamsFromBean(): void { $bean = $this->getTestBean(); $expected = $this->getExpectedHeader(); @@ -160,7 +162,7 @@ class ElasticSearchIndexerTest extends SearchTestAbstract $indexer = new ElasticSearchIndexer(null); - $actual = self::invokeMethod($indexer, 'makeIndexParamsFromBean', [$bean]); + $actual = $this->invokeMethod($indexer, 'makeIndexParamsFromBean', [$bean]); self::assertEquals($expected, $actual); } @@ -168,24 +170,23 @@ class ElasticSearchIndexerTest extends SearchTestAbstract /** * @return array */ - private function getExpectedHeader() + private function getExpectedHeader(): array { global $sugar_config; - $expected = [ + return [ 'index' => $sugar_config['unique_key'], 'type' => 'Contacts', 'id' => '00000000-0000-0000-0000-000000000000', ]; - return $expected; } /** * @return array */ - private function getExpectedBody() + private function getExpectedBody(): array { - $expected = [ + return [ 'meta' => [ 'created' => @@ -244,20 +245,19 @@ class ElasticSearchIndexerTest extends SearchTestAbstract 0 => 'kid79@example.co.jp', ], ]; - return $expected; } - public function testMakeIndexParamsBodyFromBean1() + public function testMakeIndexParamsBodyFromBean1(): void { $bean = $this->getTestBean(); $indexer = new ElasticSearchIndexer(null); $expected = $this->getExpectedBody(); - $actual = self::invokeMethod($indexer, 'makeIndexParamsBodyFromBean', [$bean]); + $actual = $this->invokeMethod($indexer, 'makeIndexParamsBodyFromBean', [$bean]); self::assertEquals($expected, $actual); } - public function testMakeIndexParamsBodyFromBean2() + public function testMakeIndexParamsBodyFromBean2(): void { $bean = $this->getTestBean(); $indexer = new ElasticSearchIndexer(null); @@ -305,12 +305,12 @@ class ElasticSearchIndexerTest extends SearchTestAbstract 'lead_source' => 'Web Site', ]; - $actual = self::invokeMethod($indexer, 'makeIndexParamsBodyFromBean', [$bean]); + $actual = $this->invokeMethod($indexer, 'makeIndexParamsBodyFromBean', [$bean]); self::assertEquals($expected, $actual); } - public function testRemoveBeans() + public function testRemoveBeans(): void { global $sugar_config; @@ -346,10 +346,15 @@ class ElasticSearchIndexerTest extends SearchTestAbstract $indexer = new ElasticSearchIndexer($mock); - $indexer->removeBeans($beans, true); + try { + $indexer->removeBeans($beans, true); + self::assertTrue(true); + } catch (Exception $e) { + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + } } - public function testRemoveBean() + public function testRemoveBean(): void { global $sugar_config; @@ -369,27 +374,31 @@ class ElasticSearchIndexerTest extends SearchTestAbstract $indexer = new ElasticSearchIndexer($mock); - $indexer->removeBean($bean); + try { + $indexer->removeBean($bean); + self::assertTrue(true); + } catch (Exception $e) { + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + } } - public function testMakeParamsHeaderFromBean() + public function testMakeParamsHeaderFromBean(): void { - /** @var SugarBean $bean */ $bean = $this->getTestBean(); $expected = $this->getExpectedHeader(); $indexer = new ElasticSearchIndexer(null); - $actual = self::invokeMethod($indexer, 'makeParamsHeaderFromBean', [$bean]); + $actual = $this->invokeMethod($indexer, 'makeParamsHeaderFromBean', [$bean]); self::assertEquals($expected, $actual); } - public function testRemoveIndex() + public function testRemoveIndex(): void { global $sugar_config; - list($mockClient, $mockIndices) = $this->getMockIndices(); + [$mockClient, $mockIndices] = $this->getMockIndices(); $mockIndices ->shouldReceive('delete') @@ -398,13 +407,18 @@ class ElasticSearchIndexerTest extends SearchTestAbstract $indexer = new ElasticSearchIndexer($mockClient); - $indexer->removeIndex(); + try { + $indexer->removeIndex(); + self::assertTrue(true); + } catch (Exception $e) { + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + } } /** * @return array(\Elasticsearch\Client, \Elasticsearch\Namespaces\IndicesNamespace) */ - public function getMockIndices() + public function getMockIndices(): array { $mockClient = m::mock('Elasticsearch\Client'); $mockIndices = m::mock('Elasticsearch\Namespaces\IndicesNamespace'); @@ -417,10 +431,10 @@ class ElasticSearchIndexerTest extends SearchTestAbstract return [$mockClient, $mockIndices]; } - public function testRemoveIndex2() + public function testRemoveIndex2(): void { $index = uniqid(); - list($mockClient, $mockIndices) = $this->getMockIndices(); + [$mockClient, $mockIndices] = $this->getMockIndices(); $mockIndices ->shouldReceive('delete') @@ -428,12 +442,18 @@ class ElasticSearchIndexerTest extends SearchTestAbstract ->with(['index' => $index, 'client' => ['ignore' => [404]]]); $indexer = new ElasticSearchIndexer($mockClient); - $indexer->removeIndex($index); + + try { + $indexer->removeIndex($index); + self::assertTrue(true); + } catch (Exception $e) { + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + } } - public function testDeleteAllIndexes() + public function testDeleteAllIndexes(): void { - list($mockClient, $mockIndices) = $this->getMockIndices(); + [$mockClient, $mockIndices] = $this->getMockIndices(); $mockIndices ->shouldReceive('delete') @@ -441,12 +461,18 @@ class ElasticSearchIndexerTest extends SearchTestAbstract ->with(['index' => '_all']); $indexer = new ElasticSearchIndexer($mockClient); - $indexer->removeAllIndices(); + + try { + $indexer->removeAllIndices(); + self::assertTrue(true); + } catch (Exception $e) { + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + } } - public function testDeleteAllIndexes2() + public function testDeleteAllIndexes2(): void { - list($mockClient, $mockIndices) = $this->getMockIndices(); + [$mockClient, $mockIndices] = $this->getMockIndices(); $mockIndices ->shouldReceive('delete') @@ -455,9 +481,13 @@ class ElasticSearchIndexerTest extends SearchTestAbstract ->andThrow('\Elasticsearch\Common\Exceptions\Missing404Exception'); $indexer = new ElasticSearchIndexer($mockClient); - $indexer->removeAllIndices(); - // no exception should appear here, as the 404 has to be caught. + try { + $indexer->removeAllIndices(); + self::assertTrue(true); + } catch (Exception $e) { + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + } } protected function tearDown(): void @@ -466,7 +496,7 @@ class ElasticSearchIndexerTest extends SearchTestAbstract parent::tearDown(); } - public function testPing() + public function testPing(): void { $mockClient = m::mock('\Elasticsearch\Client'); @@ -476,12 +506,11 @@ class ElasticSearchIndexerTest extends SearchTestAbstract ->once() ->andReturnFalse(); - $indexer = new ElasticSearchIndexer($mockClient); - $actual = $indexer->ping(); + $actual = (new ElasticSearchIndexer($mockClient))->ping(); self::assertFalse($actual); } - public function testPing2() + public function testPing2(): void { $mockClient = m::mock('\Elasticsearch\Client'); @@ -491,13 +520,12 @@ class ElasticSearchIndexerTest extends SearchTestAbstract ->once() ->andReturnTrue(); - $indexer = new ElasticSearchIndexer($mockClient); - $actual = $indexer->ping(); + $actual = (new ElasticSearchIndexer($mockClient))->ping(); self::assertNotFalse($actual); - self::assertTrue(is_numeric($actual)); + self::assertIsNumeric($actual); } - public function testPutMappings() + public function testPutMappings(): void { $meta = ['foo' => 'bar']; $module = 'Accounts'; @@ -509,7 +537,7 @@ class ElasticSearchIndexerTest extends SearchTestAbstract 'body' => ['_meta' => $meta] ]; - list($client, $indices) = $this->getMockIndices(); + [$client, $indices] = $this->getMockIndices(); $indices ->shouldReceive('putMapping') @@ -517,12 +545,17 @@ class ElasticSearchIndexerTest extends SearchTestAbstract ->once(); $i = new i($client); - $i->setIndex($index); - $i->putMeta($module, $meta); + try { + $i->setIndex($index); + $i->putMeta($module, $meta); + self::assertTrue(true); + } catch (Exception $e) { + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + } } - public function testGetMeta() + public function testGetMeta(): void { $meta = ['foo' => 'bar']; $module = 'Accounts'; @@ -531,7 +564,7 @@ class ElasticSearchIndexerTest extends SearchTestAbstract $params = ['index' => $index, 'filter_path' => "$index.mappings.$module._meta"]; $response = [$index => ['mappings' => [$module => ['_meta' => $meta]]]]; - list($client, $indices) = $this->getMockIndices(); + [$client, $indices] = $this->getMockIndices(); $indices ->shouldReceive('getMapping') @@ -548,12 +581,12 @@ class ElasticSearchIndexerTest extends SearchTestAbstract self::assertEquals($meta, $actual); } - public function testCreateIndex() + public function testCreateIndex(): void { $index = 'test'; $params = ['index' => $index]; - list($client, $indices) = $this->getMockIndices(); + [$client, $indices] = $this->getMockIndices(); $indices ->shouldReceive('create') @@ -562,16 +595,21 @@ class ElasticSearchIndexerTest extends SearchTestAbstract $i = new i($client); - $i->createIndex($index); + try { + $i->createIndex($index); + self::assertTrue(true); + } catch (Exception $e) { + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + } } - public function testCreateIndexWithBody() + public function testCreateIndexWithBody(): void { $index = 'test'; $body = ["mappings" => ['my_type' => ['_source' => ['enabled' => true]]]]; $params = ['index' => $index, 'body' => $body]; - list($client, $indices) = $this->getMockIndices(); + [$client, $indices] = $this->getMockIndices(); $indices ->shouldReceive('create') @@ -580,6 +618,11 @@ class ElasticSearchIndexerTest extends SearchTestAbstract $i = new i($client); - $i->createIndex($index, $body); + try { + $i->createIndex($index, $body); + self::assertTrue(true); + } catch (Exception $e) { + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + } } } diff --git a/tests/unit/phpunit/lib/SuiteCRM/Search/ElasticSearch/ElasticSearchInstallTest.php b/tests/unit/phpunit/lib/SuiteCRM/Search/ElasticSearch/ElasticSearchInstallTest.php index ad53ee347..6805e60ca 100644 --- a/tests/unit/phpunit/lib/SuiteCRM/Search/ElasticSearch/ElasticSearchInstallTest.php +++ b/tests/unit/phpunit/lib/SuiteCRM/Search/ElasticSearch/ElasticSearchInstallTest.php @@ -4,7 +4,7 @@ * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. * * SuiteCRM is an extension to SugarCRM Community Edition developed by SalesAgility Ltd. - * Copyright (C) 2011 - 2018 SalesAgility Ltd. + * Copyright (C) 2011 - 2021 SalesAgility Ltd. * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU Affero General Public License version 3 as published by the @@ -37,7 +37,7 @@ * display the words "Powered by SugarCRM" and "Supercharged by SuiteCRM". */ -use SuiteCRM\Search\SearchTestAbstract; +use SuiteCRM\Tests\Unit\lib\SuiteCRM\Search\SearchTestAbstract; require_once 'include/utils/LogicHook.php'; require_once 'modules/Schedulers/Scheduler.php'; @@ -47,10 +47,9 @@ class ElasticSearchInstallTest extends SearchTestAbstract /** * Asserts if the after_save and after_delete logic hooks for ElasticSearchIndexer are correctly loaded. */ - public function testHooksPresent() + public function testHooksPresent(): void { - $LogicHook = new LogicHook(); - $default_hooks = $LogicHook->loadHooks(''); + $default_hooks = (new LogicHook())->loadHooks(''); $afterSave = $default_hooks['after_save']; $afterDelete = $default_hooks['after_delete']; @@ -84,24 +83,10 @@ class ElasticSearchInstallTest extends SearchTestAbstract self::assertEquals(1, $found, 'Found the wrong number of Elasticsearch after_delete hooks.'); } - /** - * Asserts if the ElasticSearchIndexer scheduler is correctly loaded - */ - public function testSchedulerPresent() - { -// self::markTestIncomplete('environment dependency'); -// -// $scheduler = new Scheduler(); -// -// $jobs = $scheduler->getJobsList(); -// -// self::assertArrayHasKey('function::runElasticSearchIndexerScheduler', $jobs); - } - /** * Asserts that the configuration for the ElasticSearch are present in the global config array. */ - public function testConfigPresent() + public function testConfigPresent(): void { global $sugar_config; diff --git a/tests/unit/phpunit/lib/SuiteCRM/Search/ElasticSearch/ElasticSearchIntegrationTest.php b/tests/unit/phpunit/lib/SuiteCRM/Search/ElasticSearch/ElasticSearchIntegrationTest.php index 69cbacac3..c52caf74e 100644 --- a/tests/unit/phpunit/lib/SuiteCRM/Search/ElasticSearch/ElasticSearchIntegrationTest.php +++ b/tests/unit/phpunit/lib/SuiteCRM/Search/ElasticSearch/ElasticSearchIntegrationTest.php @@ -4,7 +4,7 @@ * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. * * SuiteCRM is an extension to SugarCRM Community Edition developed by SalesAgility Ltd. - * Copyright (C) 2011 - 2019 SalesAgility Ltd. + * Copyright (C) 2011 - 2021 SalesAgility Ltd. * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU Affero General Public License version 3 as published by the @@ -37,19 +37,20 @@ * display the words "Powered by SugarCRM" and "Supercharged by SuiteCRM". */ +use SuiteCRM\Search\ElasticSearch\ElasticSearchEngine; use SuiteCRM\Search\ElasticSearch\ElasticSearchIndexer; use SuiteCRM\Search\Index\Documentify\JsonSerializerDocumentifier; use SuiteCRM\Search\Index\Documentify\SearchDefsDocumentifier; use SuiteCRM\Search\SearchQuery; use SuiteCRM\Search\SearchWrapper; - +use SuiteCRM\Tests\Unit\lib\SuiteCRM\Search\SearchTestAbstract; /** @noinspection PhpIncludeInspection */ require_once 'lib/Search/ElasticSearch/ElasticSearchEngine.php'; -class ElasticSearchIntegrationTest extends SuiteCRM\Search\SearchTestAbstract +class ElasticSearchIntegrationTest extends SearchTestAbstract { - const LOCK_FILE = 'cache/ElasticSearchIndex.lock'; + public const LOCK_FILE = 'cache/ElasticSearchIndex.lock'; /** @var ElasticSearchIndexer */ private $indexer; /** @var ElasticSearchEngine */ @@ -78,20 +79,20 @@ class ElasticSearchIntegrationTest extends SuiteCRM\Search\SearchTestAbstract parent::tearDown(); } - private function restore() + private function restore(): void { $this->indexer->removeIndex('test'); } - public function testPing() + public function testPing(): void { $result = $this->indexer->ping(); self::assertNotFalse($result); - self::assertTrue(is_numeric($result)); + self::assertIsNumeric($result); } - public function testWithoutSearchdefs() + public function testWithoutSearchdefs(): void { $this->indexer->setDocumentifier(new JsonSerializerDocumentifier()); $this->indexRunner(); @@ -100,7 +101,7 @@ class ElasticSearchIntegrationTest extends SuiteCRM\Search\SearchTestAbstract /** * Starts indexing using the indexer stored as a field. */ - private function indexRunner() + private function indexRunner(): void { /** @var Contact $bean */ $bean = BeanFactory::newBean('Contacts'); @@ -211,19 +212,19 @@ class ElasticSearchIntegrationTest extends SuiteCRM\Search\SearchTestAbstract * The indexing on Elasticsearch is scheduled each second. * No results will be available before that time. **/ - private function waitForIndexing() + private function waitForIndexing(): void { sleep(1); } - public function testWithSearchdefs() + public function testWithSearchdefs(): void { $this->indexer->setDocumentifier(new SearchDefsDocumentifier()); $this->indexRunner(); } - public function testDifferentialIndexing() + public function testDifferentialIndexing(): void { global $timedate; $timedate->allow_cache = false; @@ -323,7 +324,7 @@ class ElasticSearchIntegrationTest extends SuiteCRM\Search\SearchTestAbstract self::assertEmpty($results->getHits(), 'There should be no search results, as the record was deleted'); } - private function populateContactsTable() + private function populateContactsTable(): void { /** @var Contact $bean */ $bean = BeanFactory::newBean('Contacts'); @@ -336,7 +337,7 @@ class ElasticSearchIntegrationTest extends SuiteCRM\Search\SearchTestAbstract $bean->save(); } - public function testMeta() + public function testMeta(): void { $module = "TestModule"; $meta1 = ['foo' => 'baz']; diff --git a/tests/unit/phpunit/lib/SuiteCRM/Search/SearchDefsDocumentifierTest.php b/tests/unit/phpunit/lib/SuiteCRM/Search/SearchDefsDocumentifierTest.php index c3690e49c..62ec43c15 100644 --- a/tests/unit/phpunit/lib/SuiteCRM/Search/SearchDefsDocumentifierTest.php +++ b/tests/unit/phpunit/lib/SuiteCRM/Search/SearchDefsDocumentifierTest.php @@ -4,7 +4,7 @@ * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. * * SuiteCRM is an extension to SugarCRM Community Edition developed by SalesAgility Ltd. - * Copyright (C) 2011 - 2018 SalesAgility Ltd. + * Copyright (C) 2011 - 2021 SalesAgility Ltd. * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU Affero General Public License version 3 as published by the @@ -39,7 +39,7 @@ use Mockery as m; use SuiteCRM\Search\Index\Documentify\SearchDefsDocumentifier; -use SuiteCRM\Search\SearchTestAbstract; +use SuiteCRM\Tests\Unit\lib\SuiteCRM\Search\SearchTestAbstract; class SearchDefsDocumentifierTest extends SearchTestAbstract { diff --git a/tests/unit/phpunit/lib/SuiteCRM/Search/SearchEngineMock.php b/tests/unit/phpunit/lib/SuiteCRM/Search/SearchEngineMock.php index b9178aaaa..83c1f3044 100644 --- a/tests/unit/phpunit/lib/SuiteCRM/Search/SearchEngineMock.php +++ b/tests/unit/phpunit/lib/SuiteCRM/Search/SearchEngineMock.php @@ -4,7 +4,7 @@ * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. * * SuiteCRM is an extension to SugarCRM Community Edition developed by SalesAgility Ltd. - * Copyright (C) 2011 - 2018 SalesAgility Ltd. + * Copyright (C) 2011 - 2021 SalesAgility Ltd. * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU Affero General Public License version 3 as published by the @@ -39,24 +39,46 @@ use SuiteCRM\Search\SearchEngine; use SuiteCRM\Search\SearchQuery; +use SuiteCRM\Search\SearchResults; +/** + * Class SearchEngineMock + */ class SearchEngineMock extends SearchEngine { - public function search(SearchQuery $query) + /** + * @param SearchQuery $query + * @return SearchResults + * @throws \SuiteCRM\Exception\InvalidArgumentException + */ + public function search(SearchQuery $query): SearchResults { - if ($query->getSearchString() == 'foo') { - return 'bar'; + $start = microtime(true); + $results = []; + $hits = 0; + + if ($query->getSearchString() === 'foo') { + $results = ['bar']; + $hits++; } - if ($query->getSearchString() == 'fooz') { - return 'barz'; + if ($query->getSearchString() === 'fooz') { + $results = ['barz']; + $hits++; } - return false; + $end = microtime(true); + $elapsed = $end - $start; + + return new SearchResults($results, false, $elapsed, $hits); } - public function searchAndDisplay(SearchQuery $query) + /** + * @param SearchQuery $query + * @throws \SuiteCRM\Exception\InvalidArgumentException + */ + public function searchAndDisplay(SearchQuery $query): void { - echo $this->search($query); + echo $this->search($query)->getTotal(); } } diff --git a/tests/unit/phpunit/lib/SuiteCRM/Search/SearchInstallTest.php b/tests/unit/phpunit/lib/SuiteCRM/Search/SearchInstallTest.php index a502b3bd2..af5b8f290 100644 --- a/tests/unit/phpunit/lib/SuiteCRM/Search/SearchInstallTest.php +++ b/tests/unit/phpunit/lib/SuiteCRM/Search/SearchInstallTest.php @@ -4,7 +4,7 @@ * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. * * SuiteCRM is an extension to SugarCRM Community Edition developed by SalesAgility Ltd. - * Copyright (C) 2011 - 2018 SalesAgility Ltd. + * Copyright (C) 2011 - 2021 SalesAgility Ltd. * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU Affero General Public License version 3 as published by the @@ -37,11 +37,11 @@ * display the words "Powered by SugarCRM" and "Supercharged by SuiteCRM". */ -use SuiteCRM\Search\SearchTestAbstract; +use SuiteCRM\Tests\Unit\lib\SuiteCRM\Search\SearchTestAbstract; class SearchInstallTest extends SearchTestAbstract { - public function testConfiguredSuccessfully() + public function testConfiguredSuccessfully(): void { global $sugar_config; diff --git a/tests/unit/phpunit/lib/SuiteCRM/Search/SearchQueryTest.php b/tests/unit/phpunit/lib/SuiteCRM/Search/SearchQueryTest.php index 48341b9d1..b535689ea 100644 --- a/tests/unit/phpunit/lib/SuiteCRM/Search/SearchQueryTest.php +++ b/tests/unit/phpunit/lib/SuiteCRM/Search/SearchQueryTest.php @@ -4,7 +4,7 @@ * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. * * SuiteCRM is an extension to SugarCRM Community Edition developed by SalesAgility Ltd. - * Copyright (C) 2011 - 2018 SalesAgility Ltd. + * Copyright (C) 2011 - 2021 SalesAgility Ltd. * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU Affero General Public License version 3 as published by the @@ -38,11 +38,14 @@ */ use SuiteCRM\Search\SearchQuery; -use SuiteCRM\Search\SearchTestAbstract; +use SuiteCRM\Tests\Unit\lib\SuiteCRM\Search\SearchTestAbstract; +/** + * Class SearchQueryTest + */ class SearchQueryTest extends SearchTestAbstract { - public function testFromString() + public function testFromString(): void { $searchString = 'hello test'; $size = 20; @@ -60,7 +63,7 @@ class SearchQueryTest extends SearchTestAbstract self::assertEquals('bar', $query->getOption('foo')); } - public function testIsEmpty() + public function testIsEmpty(): void { $nonEmptyQuery = SearchQuery::fromString('foo'); $emptyQuery = SearchQuery::fromString(''); @@ -69,7 +72,7 @@ class SearchQueryTest extends SearchTestAbstract self::assertTrue($emptyQuery->isEmpty()); } - public function testTrim() + public function testTrim(): void { $string = ' hello test world '; $query = SearchQuery::fromString($string); @@ -79,7 +82,7 @@ class SearchQueryTest extends SearchTestAbstract } - public function testToLowerCase() + public function testToLowerCase(): void { $string = ' HelLo tEsT WorLD '; $expected = ' hello test world '; @@ -90,7 +93,7 @@ class SearchQueryTest extends SearchTestAbstract self::assertEquals($expected, $query->getSearchString()); } - public function testReplace() + public function testReplace(): void { $string = '-HELLO_WOR-LD-'; $expString = 'HELLO_WORLD'; @@ -101,7 +104,7 @@ class SearchQueryTest extends SearchTestAbstract self::assertEquals($expString, $query->getSearchString()); } - public function testStripSlashes() + public function testStripSlashes(): void { $string = "Is your name O\'reilly? :\\\\"; $expected = "Is your name O'reilly? :\\"; @@ -112,7 +115,7 @@ class SearchQueryTest extends SearchTestAbstract self::assertEquals($expected, $query->getSearchString()); } - public function testEscapeRegex() + public function testEscapeRegex(): void { $string = '$40 for a g3/400'; $expected = '\$40 for a g3\/400'; @@ -123,7 +126,7 @@ class SearchQueryTest extends SearchTestAbstract self::assertEquals($expected, $query->getSearchString()); } - public function testConvertEncoding() + public function testConvertEncoding(): void { $string = 'Foo © bar 𝌆 baz ☃ qux'; $expected = 'Foo © bar 𝌆 baz ☃ qux'; @@ -134,7 +137,7 @@ class SearchQueryTest extends SearchTestAbstract self::assertEquals($expected, $query->getSearchString()); } - public function testFromRequestArray() + public function testFromRequestArray(): void { $request = $this->getRequest(); @@ -143,7 +146,7 @@ class SearchQueryTest extends SearchTestAbstract $this->assertRequest($query); } - public function testFromRequestArray2() + public function testFromRequestArray2(): void { $request = [ 'query_string' => 'FOO', @@ -152,15 +155,15 @@ class SearchQueryTest extends SearchTestAbstract $query = SearchQuery::fromRequestArray($request); - self::assertEquals($query->getSearchString(), 'FOO'); - self::assertEquals($query->getSize(), 10); - self::assertEquals($query->getFrom(), 0); - self::assertNull($query->getEngine()); - self::assertEquals($query->getOptions(), ['foo' => 'bar']); - self::assertEquals($query->getOption('foo'), 'bar'); + self::assertEquals('FOO', $query->getSearchString()); + self::assertEquals(10, $query->getSize()); + self::assertEquals(0, $query->getFrom()); + self::assertEquals('BasicSearchEngine', $query->getEngine()); + self::assertEquals(['foo' => 'bar'], $query->getOptions()); + self::assertEquals('bar', $query->getOption('foo')); } - public function testFromGetRequest() + public function testFromGetRequest(): void { $old = $_GET; @@ -176,28 +179,27 @@ class SearchQueryTest extends SearchTestAbstract /** * @return array */ - private function getRequest() + private function getRequest(): array { - $request = [ + return [ 'search-query-string' => 'FOO', 'search-query-size' => '123', 'search-query-from' => 3, 'search-engine' => 'TestEngine', 'foo' => 'bar', ]; - return $request; } /** * @param SearchQuery $query */ - private function assertRequest(SearchQuery $query) + private function assertRequest(SearchQuery $query): void { - self::assertEquals($query->getSearchString(), 'FOO'); - self::assertEquals($query->getSize(), 123); - self::assertEquals($query->getFrom(), 3); - self::assertEquals($query->getEngine(), 'TestEngine'); - self::assertEquals($query->getOptions(), ['foo' => 'bar']); - self::assertEquals($query->getOption('foo'), 'bar'); + self::assertEquals('FOO', $query->getSearchString()); + self::assertEquals(123, $query->getSize()); + self::assertEquals(3, $query->getFrom()); + self::assertEquals('TestEngine', $query->getEngine()); + self::assertEquals(['foo' => 'bar'], $query->getOptions()); + self::assertEquals('bar', $query->getOption('foo')); } } diff --git a/tests/unit/phpunit/lib/SuiteCRM/Search/SearchTestAbstract.php b/tests/unit/phpunit/lib/SuiteCRM/Search/SearchTestAbstract.php index 07fcd7aa0..238b9f3b1 100644 --- a/tests/unit/phpunit/lib/SuiteCRM/Search/SearchTestAbstract.php +++ b/tests/unit/phpunit/lib/SuiteCRM/Search/SearchTestAbstract.php @@ -1,37 +1,53 @@ getMethod($methodName); + $method = (new ReflectionClass(get_class($object)))->getMethod($methodName); $method->setAccessible(true); return $method->invokeArgs($object, $parameters); @@ -61,10 +76,9 @@ abstract class SearchTestAbstract extends SuitePHPUnitFrameworkTestCase * @param mixed $value value of the property. * @throws ReflectionException */ - public function setValue(&$object, $property, $value) + public function setValue(object $object, string $property, $value): void { - $reflection = new ReflectionClass(get_class($object)); - $property = $reflection->getProperty($property); + $property = (new ReflectionClass(get_class($object)))->getProperty($property); $property->setAccessible(true); $property->setValue($object, $value); } diff --git a/tests/unit/phpunit/lib/SuiteCRM/Search/SearchWrapperTest.php b/tests/unit/phpunit/lib/SuiteCRM/Search/SearchWrapperTest.php index f623be4e1..87e7adad7 100644 --- a/tests/unit/phpunit/lib/SuiteCRM/Search/SearchWrapperTest.php +++ b/tests/unit/phpunit/lib/SuiteCRM/Search/SearchWrapperTest.php @@ -1,112 +1,134 @@ invokeMethod($search, 'fetchEngine', ['ElasticSearchEngine']); - $this->assertInstanceOf('ElasticSearchEngine', $searchEngine); + self::assertInstanceOf(ElasticSearchEngine::class, $searchEngine); } catch (ReflectionException $exception) { - $this->fail("Failed to use reflection!"); + self::fail("Failed to use reflection!"); } } - public function testFetchEngineNonExisting() + public function testFetchEngineNonExisting(): void { $search = new SearchWrapper(); - $this->setValue($search, 'customEnginePath', __DIR__ . '/TestCustomEngines/'); + $this->setValue($search, 'customEnginePath', $this->customEngines); - try { - $this->invokeMethod($search, 'fetchEngine', ['VeryFakeEngine']); - $this->fail("Exception should be thrown here!"); - } catch (ReflectionException $exception) { - $this->fail("Failed to use reflection!"); - } catch (SearchEngineNotFoundException $exception) { - // All good! - } + $this->expectException(SearchEngineNotFoundException::class); + $this->invokeMethod($search, 'fetchEngine', ['VeryFakeEngine']); } - public function testFetchEngineCustom() + public function testFetchEngineCustom(): void { $search = new SearchWrapper(); - $this->setValue($search, 'customEnginePath', __DIR__ . '/TestCustomEngines/'); + $this->setValue($search, 'customEnginePath', $this->customEngines); $engine = $this->invokeMethod($search, 'fetchEngine', ['MockSearch']); self::assertInstanceOf(SearchEngine::class, $engine); } - public function testFetchEngineCustomBad() + public function testFetchEngineCustomBad(): void { $search = new SearchWrapper(); - $this->setValue($search, 'customEnginePath', __DIR__ . '/TestCustomEngines/'); + $this->setValue($search, 'customEnginePath', $this->customEngines); - try { - $this->invokeMethod($search, 'fetchEngine', ['BadMockSearch']); - $this->fail("Exception should be thrown here!"); - } catch (SearchEngineNotFoundException $exception) { - echo $exception->getMessage(); - } + $this->expectException(SearchEngineNotFoundException::class); + $this->invokeMethod($search, 'fetchEngine', ['BadMockSearch']); } - public function testGetEngines() + public function testGetEngines(): void { $expected = [ 0 => 'ElasticSearchEngine', - 1 => 'BadMockSearch', - 2 => 'MockSearch', + 1 => 'BasicSearchEngine', + 2 => 'LuceneSearchEngine', + 3 => 'VeryFakeEngine', + 4 => 'MockSearch', + 5 => 'BadMockSearch', + 6 => 'BadMockSearch', + 7 => 'MockSearch', ]; $actual = SearchWrapper::getEngines(); self::assertEquals($actual, $expected); } - public function testSearchAndDisplayCustom() + public function testSearchAndDisplayCustom(): void { $search = new SearchWrapper(); - $this->setValue($search, 'customEnginePath', __DIR__ . '/TestCustomEngines/'); + $this->setValue($search, 'customEnginePath', $this->customEngines); $query = SearchQuery::fromString('bar', null, null, 'MockSearch'); @@ -114,12 +136,12 @@ class SearchWrapperTest extends SearchTestAbstract $search::searchAndDisplay($query); $output = ob_get_flush(); - self::assertEquals('bar', $output); + self::assertEquals(1, $output); } - public function testSearchAndDisplayBuiltIn() + public function testSearchAndDisplayBuiltIn(): void { - SearchWrapper::addEngine('SearchEngineMock', __DIR__ . '/SearchEngineMock.php'); + SearchWrapper::addEngine('SearchEngineMock', $this->searchEngineMock, SearchEngineMock::class); $query = SearchQuery::fromString('foo', null, null, 'SearchEngineMock'); @@ -127,25 +149,28 @@ class SearchWrapperTest extends SearchTestAbstract SearchWrapper::searchAndDisplay($query); $output = ob_get_flush(); - self::assertEquals('bar', $output); + self::assertEquals(1, $output); } - public function testFakeSearch() + public function testFakeSearch(): void { - SearchWrapper::addEngine('SearchEngineMock', __DIR__ . '/SearchEngineMock.php'); + SearchWrapper::addEngine('SearchEngineMock', $this->searchEngineMock, SearchEngineMock::class); $result = SearchWrapper::search('SearchEngineMock', SearchQuery::fromString('foo')); - self::assertEquals('bar', $result, "Wrong mocked search result!"); + $hits = $result->getHits(); + + self::assertEquals('bar', $hits[0]); $result = SearchWrapper::search('SearchEngineMock', SearchQuery::fromString('fooz')); - self::assertEquals('barz', $result, "Wrong mocked search result!"); + $hits = $result->getHits(); + + self::assertEquals('barz', $hits[0]); } - public function testSearch2() + public function testSearchCustomEngine(): void { - // this time try passing a custom engine $mockEngine = Mockery::mock(SearchEngine::class); $query = SearchQuery::fromString("Test"); @@ -154,37 +179,25 @@ class SearchWrapperTest extends SearchTestAbstract ->once() ->with($query); - SearchWrapper::search($mockEngine, $query); - - Mockery::close(); - } - - public function testSearch3() - { - // this time check if the validation works - - $mockEngine = Mockery::mock(SearchWrapper::class); // just an object that shouldn't be passed - $query = SearchQuery::fromString("Test"); - try { SearchWrapper::search($mockEngine, $query); - self::fail("Exception should have been thrown!"); - } catch (SearchEngineNotFoundException $exception) { - // All good! + self::assertTrue(true); + } catch (SearchEngineNotFoundException $e) { + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } Mockery::close(); } - public function testGetModules() + public function testGetModules(): void { $actual = SearchWrapper::getModules(); - self::assertTrue(is_array($actual)); + self::assertIsArray($actual); self::assertGreaterThan(1, count($actual)); } - public function testGetDefaultEngine() + public function testGetDefaultEngine(): void { global $sugar_config; @@ -193,7 +206,7 @@ class SearchWrapperTest extends SearchTestAbstract self::assertEquals('foo', SearchWrapper::getDefaultEngine()); } - public function testGetController() + public function testGetController(): void { global $sugar_config; diff --git a/tests/unit/phpunit/lib/SuiteCRM/Search/TestCustomEngines/MockSearch.php b/tests/unit/phpunit/lib/SuiteCRM/Search/TestCustomEngines/MockSearch.php index 6e11151e8..4db2769d3 100644 --- a/tests/unit/phpunit/lib/SuiteCRM/Search/TestCustomEngines/MockSearch.php +++ b/tests/unit/phpunit/lib/SuiteCRM/Search/TestCustomEngines/MockSearch.php @@ -1,42 +1,79 @@ getSearchString() === 'bar') { + $results = ['foo']; + $hits++; + } + + $end = microtime(true); + $elapsed = $end - $start; + + return new SearchResults($results, false, $elapsed, $hits); } - public function searchAndDisplay(SearchQuery $query) + /** + * @param SearchQuery $query + * @throws \SuiteCRM\Exception\InvalidArgumentException + */ + public function searchAndDisplay(SearchQuery $query): void { - echo $query->getSearchString(); + echo $this->search($query)->getTotal(); } } diff --git a/tests/unit/phpunit/lib/SuiteCRM/Utility/ArrayMapperTest.php b/tests/unit/phpunit/lib/SuiteCRM/Utility/ArrayMapperTest.php index c779f432f..55dad5133 100644 --- a/tests/unit/phpunit/lib/SuiteCRM/Utility/ArrayMapperTest.php +++ b/tests/unit/phpunit/lib/SuiteCRM/Utility/ArrayMapperTest.php @@ -42,7 +42,7 @@ use SuiteCRM\Utility\ArrayMapper; class ArrayMapperTest extends SuitePHPUnitFrameworkTestCase { - public function test() + public function test(): void { $array = [ 'object' => (object)[ diff --git a/tests/unit/phpunit/lib/SuiteCRM/Utility/BeanJsonSerializerTest.php b/tests/unit/phpunit/lib/SuiteCRM/Utility/BeanJsonSerializerTest.php index f149835c5..7a32e0ab3 100644 --- a/tests/unit/phpunit/lib/SuiteCRM/Utility/BeanJsonSerializerTest.php +++ b/tests/unit/phpunit/lib/SuiteCRM/Utility/BeanJsonSerializerTest.php @@ -4,7 +4,7 @@ * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. * * SuiteCRM is an extension to SugarCRM Community Edition developed by SalesAgility Ltd. - * Copyright (C) 2011 - 2018 SalesAgility Ltd. + * Copyright (C) 2011 - 2021 SalesAgility Ltd. * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU Affero General Public License version 3 as published by the @@ -38,12 +38,12 @@ */ use SuiteCRM\Utility\BeanJsonSerializer; -use SuiteCRM\Utility\BeanJsonSerializerTestData\BeanMock; +use SuiteCRM\Tests\Unit\lib\SuiteCRM\Utility\BeanJsonSerializerTestData\BeanMock; use SuiteCRM\Test\SuitePHPUnitFrameworkTestCase; class BeanJsonSerializerTest extends SuitePHPUnitFrameworkTestCase { - public function testToArrayContact() + public function testToArrayContact(): void { $mockBean = new BeanMock(__DIR__ . '/BeanJsonSerializerTestData/ContactBean.json'); $expected = json_decode(file_get_contents(__DIR__ . '/BeanJsonSerializerTestData/ContactBean.expected.json'), true); @@ -52,7 +52,7 @@ class BeanJsonSerializerTest extends SuitePHPUnitFrameworkTestCase self::assertEquals($expected, $actual); } - public function testToArrayAccount() + public function testToArrayAccount(): void { $mockBean = new BeanMock(__DIR__ . '/BeanJsonSerializerTestData/AccountBean.json'); $expected = json_decode(file_get_contents(__DIR__ . '/BeanJsonSerializerTestData/AccountBean.expected.json'), true); @@ -61,7 +61,7 @@ class BeanJsonSerializerTest extends SuitePHPUnitFrameworkTestCase self::assertEquals($expected, $actual); } - public function testSerializeContact() + public function testSerializeContact(): void { $mockBean = new BeanMock(__DIR__ . '/BeanJsonSerializerTestData/ContactBean.json'); $actual = BeanJsonSerializer::make()->serialize($mockBean, false, true); @@ -72,7 +72,7 @@ class BeanJsonSerializerTest extends SuitePHPUnitFrameworkTestCase ); } - public function testSerializeAccount() + public function testSerializeAccount(): void { $mockBean = new BeanMock(__DIR__ . '/BeanJsonSerializerTestData/AccountBean.json'); $actual = BeanJsonSerializer::make()->serialize($mockBean, false, true); diff --git a/tests/unit/phpunit/lib/SuiteCRM/Utility/BeanJsonSerializerTestData/BeanMock.php b/tests/unit/phpunit/lib/SuiteCRM/Utility/BeanJsonSerializerTestData/BeanMock.php index 06d18ac44..871d8b12b 100644 --- a/tests/unit/phpunit/lib/SuiteCRM/Utility/BeanJsonSerializerTestData/BeanMock.php +++ b/tests/unit/phpunit/lib/SuiteCRM/Utility/BeanJsonSerializerTestData/BeanMock.php @@ -4,7 +4,7 @@ * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. * * SuiteCRM is an extension to SugarCRM Community Edition developed by SalesAgility Ltd. - * Copyright (C) 2011 - 2018 SalesAgility Ltd. + * Copyright (C) 2011 - 2021 SalesAgility Ltd. * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU Affero General Public License version 3 as published by the @@ -37,8 +37,12 @@ * display the words "Powered by SugarCRM" and "Supercharged by SuiteCRM". */ -namespace SuiteCRM\Utility\BeanJsonSerializerTestData; +namespace SuiteCRM\Tests\Unit\lib\SuiteCRM\Utility\BeanJsonSerializerTestData; +/** + * Class BeanMock + * @package SuiteCRM\Tests\Unit\lib\SuiteCRM\Utility\BeanJsonSerializerTestData + */ class BeanMock extends \SugarBean { public $fetched_rel_row = []; @@ -50,13 +54,14 @@ class BeanMock extends \SugarBean /** @noinspection PhpMissingParentConstructorInspection */ public function __construct($file) { - $array = json_decode(file_get_contents($file), true); - - foreach ($array as $key => $item) { + foreach (json_decode(file_get_contents($file), true) as $key => $item) { $this->$key = $item; } } + /** + * @noinspection ReturnTypeCanBeDeclaredInspection + */ public function load_relationships() { echo "load_relationships() has been called on the mocked class!"; diff --git a/tests/unit/phpunit/lib/SuiteCRM/Utility/CurrentLanguageTest.php b/tests/unit/phpunit/lib/SuiteCRM/Utility/CurrentLanguageTest.php index 1a52becac..7a48968f7 100644 --- a/tests/unit/phpunit/lib/SuiteCRM/Utility/CurrentLanguageTest.php +++ b/tests/unit/phpunit/lib/SuiteCRM/Utility/CurrentLanguageTest.php @@ -23,9 +23,9 @@ class CurrentLanguageTest extends SuitePHPUnitFrameworkTestCase } } - public function testGetCurrentLanguage() + public function testGetCurrentLanguage(): void { $language = self::$language->getCurrentLanguage(); - $this->assertNotEmpty($language); + self::assertNotEmpty($language); } } diff --git a/tests/unit/phpunit/lib/SuiteCRM/Utility/ModuleLanguageTest.php b/tests/unit/phpunit/lib/SuiteCRM/Utility/ModuleLanguageTest.php index 465f49d48..4af9edff5 100644 --- a/tests/unit/phpunit/lib/SuiteCRM/Utility/ModuleLanguageTest.php +++ b/tests/unit/phpunit/lib/SuiteCRM/Utility/ModuleLanguageTest.php @@ -23,10 +23,10 @@ class ModuleLanguageTest extends SuitePHPUnitFrameworkTestCase } } - public function testGetCurrentLanguage() + public function testGetCurrentLanguage(): void { $language = self::$language->getModuleLanguageStrings(new \SuiteCRM\Utility\CurrentLanguage(), 'Accounts'); - $this->assertNotEmpty($language); - $this->assertArrayHasKey('LBL_MODULE_NAME', $language); + self::assertNotEmpty($language); + self::assertArrayHasKey('LBL_MODULE_NAME', $language); } } diff --git a/tests/unit/phpunit/lib/SuiteCRM/Utility/PathsTest.php b/tests/unit/phpunit/lib/SuiteCRM/Utility/PathsTest.php index 3a1ad68c0..acab700df 100644 --- a/tests/unit/phpunit/lib/SuiteCRM/Utility/PathsTest.php +++ b/tests/unit/phpunit/lib/SuiteCRM/Utility/PathsTest.php @@ -31,24 +31,24 @@ class PathsTest extends SuitePHPUnitFrameworkTestCase } } - public function testGetProjectPath() + public function testGetProjectPath(): void { $expected = self::$projectPath; $actual = self::$paths->getProjectPath(); - $this->assertEquals($expected, $actual); + self::assertEquals($expected, $actual); } - public function testGetLibraryPath() + public function testGetLibraryPath(): void { $expected = self::$projectPath.'/lib'; $actual = self::$paths->getLibraryPath(); - $this->assertEquals($expected, $actual); + self::assertEquals($expected, $actual); } - public function testGetContainersPath() + public function testGetContainersPath(): void { $expected = self::$projectPath.'/lib/API/core/containers.php'; $actual = self::$paths->getContainersFilePath(); - $this->assertEquals($expected, $actual); + self::assertEquals($expected, $actual); } } diff --git a/tests/unit/phpunit/lib/SuiteCRM/Utility/StringValidatorTest.php b/tests/unit/phpunit/lib/SuiteCRM/Utility/StringValidatorTest.php index ace90b576..4e3a8db64 100644 --- a/tests/unit/phpunit/lib/SuiteCRM/Utility/StringValidatorTest.php +++ b/tests/unit/phpunit/lib/SuiteCRM/Utility/StringValidatorTest.php @@ -10,17 +10,17 @@ class StringValidatorTest extends SuitePHPUnitFrameworkTestCase */ protected $tester; - public function testStartsWith() + public function testStartsWith(): void { $testString = 'foobarbaz'; - $this->assertTrue(StringValidator::startsWith($testString, 'foo')); - $this->assertFalse(StringValidator::startsWith($testString, 'bar')); + self::assertTrue(StringValidator::startsWith($testString, 'foo')); + self::assertFalse(StringValidator::startsWith($testString, 'bar')); } - public function testEndsWith() + public function testEndsWith(): void { $testString = 'foobarbaz'; - $this->assertTrue(StringValidator::endsWith($testString, 'baz')); - $this->assertFalse(StringValidator::endsWith($testString, 'bar')); + self::assertTrue(StringValidator::endsWith($testString, 'baz')); + self::assertFalse(StringValidator::endsWith($testString, 'bar')); } } diff --git a/tests/unit/phpunit/lib/SuiteCRM/Utility/SuiteLoggerTest.php b/tests/unit/phpunit/lib/SuiteCRM/Utility/SuiteLoggerTest.php index 13e409b0c..ee86e0c85 100644 --- a/tests/unit/phpunit/lib/SuiteCRM/Utility/SuiteLoggerTest.php +++ b/tests/unit/phpunit/lib/SuiteCRM/Utility/SuiteLoggerTest.php @@ -1,4 +1,41 @@ emergency('test'); $lastLine = $this->getLastLogMessage(); preg_match('/\[EMERGENCY\] test/', $lastLine, $matches); - $this->assertNotEmpty($matches); + self::assertNotEmpty($matches); } - public function testLogAlert() + public function testLogAlert(): void { self::$logger->alert('test'); $lastLine = $this->getLastLogMessage(); preg_match('/\[ALERT\] test/', $lastLine, $matches); - $this->assertNotEmpty($matches); + self::assertNotEmpty($matches); } - public function testLogCritical() + public function testLogCritical(): void { self::$logger->critical('test'); $lastLine = $this->getLastLogMessage(); preg_match('/\[CRITICAL\] test/', $lastLine, $matches); - $this->assertNotEmpty($matches); + self::assertNotEmpty($matches); } - public function testLogError() + public function testLogError(): void { self::$logger->error('test'); $lastLine = $this->getLastLogMessage(); preg_match('/\[ERROR\] test/', $lastLine, $matches); - $this->assertNotEmpty($matches); + self::assertNotEmpty($matches); } - public function testLogWarning() + public function testLogWarning(): void { self::$logger->warning('test'); $lastLine = $this->getLastLogMessage(); preg_match('/\[WARNING\] test/', $lastLine, $matches); - $this->assertNotEmpty($matches); + self::assertNotEmpty($matches); } - public function testLogNotice() + public function testLogNotice(): void { self::$logger->notice('test'); $lastLine = $this->getLastLogMessage(); preg_match('/\[NOTICE\] test/', $lastLine, $matches); - $this->assertNotEmpty($matches); + self::assertNotEmpty($matches); } - public function testLogInfo() + public function testLogInfo(): void { self::$logger->info('test'); $lastLine = $this->getLastLogMessage(); preg_match('/\[INFO\] test/', $lastLine, $matches); - $this->assertNotEmpty($matches); + self::assertNotEmpty($matches); } - public function testLogDebug() + public function testLogDebug(): void { self::$logger->debug('test'); $lastLine = $this->getLastLogMessage(); preg_match('/\[DEBUG\] test/', $lastLine, $matches); - $this->assertNotEmpty($matches); + self::assertNotEmpty($matches); } - public function testInterpolate() + public function testInterpolate(): void { self::$logger->error('test {a}', ['a' => 'apple']); $lastLine = $this->getLastLogMessage(); preg_match('/\[ERROR\] test apple/', $lastLine, $matches); - $this->assertNotEmpty($matches); + self::assertNotEmpty($matches); } - /** - * @expectedException InvalidArgumentException - */ - public function testInvalidLevel() + public function testInvalidLevel(): void { + $this->expectException(InvalidArgumentException::class); self::$logger->log('invalid', 'test'); } diff --git a/tests/unit/phpunit/modules/ACLActions/ACLActionTest.php b/tests/unit/phpunit/modules/ACLActions/ACLActionTest.php index a2749b6b4..53b5b7e08 100644 --- a/tests/unit/phpunit/modules/ACLActions/ACLActionTest.php +++ b/tests/unit/phpunit/modules/ACLActions/ACLActionTest.php @@ -77,19 +77,6 @@ class ACLActionTest extends SuitePHPUnitFrameworkTestCase } } - public function testgetUserActions() - { - self::markTestIncomplete('Need to implement: verify that all three results returned are different.'); - // $result1 = ACLAction::getUserActions('1'); - // $result2 = ACLAction::getUserActions('1', false, 'Accounts'); - // $result3 = ACLAction::getUserActions('1', false, 'Accounts', 'list'); - - //verify that all three results returned are different - //$this->assertNotSame($result1, $result2); - //$this->assertNotSame($result1, $result3); - //$this->assertNotSame($result2, $result3); - } - public function testhasAccess() { $this->assertFalse(ACLAction::hasAccess()); //check with defaults @@ -108,51 +95,6 @@ class ACLActionTest extends SuitePHPUnitFrameworkTestCase 'list')); //test with valid module and action } - public function testuserHasAccess() - { - self::markTestIncomplete('Need to fix checking user access. Hint: session is a system state perhaps its failing because the user session'); - - // Test with empty module and action - $this->assertFalse(ACLAction::userHasAccess('', '', '')); - // Test with empty user and valid module and action - $this->assertTrue(ACLAction::userHasAccess('', 'Accounts', - 'list')); - // Test with valid User, module and action - $this->assertTrue(ACLAction::userHasAccess('1', 'Accounts', 'list')); - // Test with valid User, module and action - $this->assertTrue(ACLAction::userHasAccess('1', 'SecurityGroups', - 'list')); - // Test with valid User, module and action - $this->assertTrue(ACLAction::userHasAccess('1', 'Users', 'list')); - } - - public function testgetUserAccessLevel() - { - self::markTestIncomplete('Need to fix checking user access. Hint: session is a system state perhaps its failing because the user session'); - - //tes for accoounts module with two different actions - $this->assertEquals(90, ACLAction::getUserAccessLevel('1', 'Accounts', 'list')); - $this->assertEquals(89, ACLAction::getUserAccessLevel('1', 'Accounts', 'access')); - - //tes for users module with two different actions - $this->assertEquals(90, ACLAction::getUserAccessLevel('1', 'Users', 'list')); - $this->assertEquals(89, ACLAction::getUserAccessLevel('1', 'Users', 'access')); - } - - public function testuserNeedsOwnership() - { - self::markTestIncomplete('Need to fix checking user access. Hint: session is a system state perhaps its failing because the user session'); - - //test with invalid values - $this->assertFalse(ACLAction::userNeedsOwnership('', '', '')); - - //test with valid values for different module and action combination - $this->assertFalse(ACLAction::userNeedsOwnership('1', 'Accounts', 'list')); - $this->assertFalse(ACLAction::userNeedsOwnership('1', 'Accounts', 'delete')); - $this->assertFalse(ACLAction::userNeedsOwnership('1', 'Users', 'delete')); - $this->assertFalse(ACLAction::userNeedsOwnership('1', 'Users', 'list')); - } - public function testsetupCategoriesMatrix() { //preset required data diff --git a/tests/unit/phpunit/modules/ACLRoles/ACLRoleTest.php b/tests/unit/phpunit/modules/ACLRoles/ACLRoleTest.php index 2bb5cd5dd..48a9e2851 100644 --- a/tests/unit/phpunit/modules/ACLRoles/ACLRoleTest.php +++ b/tests/unit/phpunit/modules/ACLRoles/ACLRoleTest.php @@ -13,23 +13,22 @@ class ACLRoleTest extends SuitePHPUnitFrameworkTestCase $current_user = BeanFactory::newBean('Users'); } - public function testACLRole() + public function testACLRole(): void { // Execute the constructor and check for the Object type and type attribute $aclRole = BeanFactory::newBean('ACLRoles'); - $this->assertInstanceOf('ACLRole', $aclRole); - $this->assertInstanceOf('SugarBean', $aclRole); + self::assertInstanceOf('ACLRole', $aclRole); + self::assertInstanceOf('SugarBean', $aclRole); - $this->assertAttributeEquals('ACLRoles', 'module_dir', $aclRole); - $this->assertAttributeEquals('ACLRole', 'object_name', $aclRole); - $this->assertAttributeEquals('acl_roles', 'table_name', $aclRole); - $this->assertAttributeEquals(true, 'new_schema', $aclRole); - $this->assertAttributeEquals(true, 'disable_row_level_security', $aclRole); - $this->assertAttributeEquals(true, 'disable_custom_fields', $aclRole); - $this->assertAttributeEquals(array('user_id' => 'users'), 'relationship_fields', $aclRole); + self::assertEquals('ACLRoles', $aclRole->module_dir); + self::assertEquals('ACLRole', $aclRole->object_name); + self::assertEquals('acl_roles', $aclRole->table_name); + self::assertEquals(true, $aclRole->new_schema); + self::assertEquals(true, $aclRole->disable_row_level_security); + self::assertEquals(true, $aclRole->disable_custom_fields); } - public function testget_summary_text() + public function testget_summary_text(): void { $aclRole = BeanFactory::newBean('ACLRoles'); @@ -37,10 +36,10 @@ class ACLRoleTest extends SuitePHPUnitFrameworkTestCase //it works only if name attribute is preset, throws exception otherwise $aclRole->name = 'test role'; $name = $aclRole->get_summary_text(); - $this->assertEquals('test role', $name); + self::assertEquals('test role', $name); } - public function testsetAction() + public function testsetAction(): void { $aclRole = BeanFactory::newBean('ACLRoles'); @@ -49,10 +48,10 @@ class ACLRoleTest extends SuitePHPUnitFrameworkTestCase $aclRole->setAction('1', '1', '90'); $final_count = count($aclRole->retrieve_relationships('acl_roles_actions', array('role_id' => '1', 'action_id' => '1', 'access_override' => '90'), 'role_id')); - $this->assertGreaterThanOrEqual($initial_count, $final_count, "values were: [$initial_count], [$final_count]"); + self::assertGreaterThanOrEqual($initial_count, $final_count, "values were: [$initial_count], [$final_count]"); } - public function testmark_relationships_deleted() + public function testmark_relationships_deleted(): void { $aclRole = BeanFactory::newBean('ACLRoles'); @@ -61,55 +60,55 @@ class ACLRoleTest extends SuitePHPUnitFrameworkTestCase $aclRole->mark_relationships_deleted('1'); $final_count = count($aclRole->retrieve_relationships('acl_roles_actions', array('role_id' => '1', 'action_id' => '1', 'access_override' => '90'), 'role_id')); - $this->assertLessThanOrEqual($initial_count, $final_count, "values were: [$initial_count], [$final_count]"); + self::assertLessThanOrEqual($initial_count, $final_count, "values were: [$initial_count], [$final_count]"); } - public function testgetUserRoles() + public function testgetUserRoles(): void { $aclRole = BeanFactory::newBean('ACLRoles'); //test with default/true getAsNameArray param value $result = $aclRole->getUserRoles('1'); - $this->assertTrue(is_array($result)); + self::assertIsArray($result); //test with flase getAsNameArray param value $result = $aclRole->getUserRoles('1', false); - $this->assertTrue(is_array($result)); + self::assertIsArray($result); } - public function testgetUserRoleNames() + public function testgetUserRoleNames(): void { $aclRole = BeanFactory::newBean('ACLRoles'); //test with empty value $result = $aclRole->getUserRoleNames(''); - $this->assertTrue(is_array($result)); + self::assertIsArray($result); //test with non empty but non existing role id value $result = $aclRole->getUserRoleNames('1'); - $this->assertTrue(is_array($result)); + self::assertIsArray($result); } - public function testgetAllRoles() + public function testgetAllRoles(): void { $aclRole = BeanFactory::newBean('ACLRoles'); //test with returnAsArray default/flase $result = $aclRole->getAllRoles(); - $this->assertTrue(is_array($result)); + self::assertIsArray($result); //test with returnAsArray true $result = $aclRole->getAllRoles(true); - $this->assertTrue(is_array($result)); + self::assertIsArray($result); } - public function testgetRoleActions() + public function testgetRoleActions(): void { $aclRole = BeanFactory::newBean('ACLRoles'); //test with empty value $result = $aclRole->getRoleActions(''); - $this->assertInternalType('array', $result); + self::assertIsArray($result); $exp = [ 'Accounts', 'Alerts', @@ -168,22 +167,22 @@ class ACLRoleTest extends SuitePHPUnitFrameworkTestCase 'Users', 'AOW_WorkFlow', ]; - $this->assertEquals($exp, array_keys($result)); + self::assertEquals($exp, array_keys($result)); //test with non empty but non existing role id value, initially no roles exist. $result = $aclRole->getRoleActions('1'); - $this->assertInternalType('array', $result); - $this->assertEquals($exp, array_keys($result)); + self::assertIsArray($result); + self::assertEquals($exp, array_keys($result)); } - public function testtoArray() + public function testtoArray(): void { $aclRole = BeanFactory::newBean('ACLRoles'); //wihout any fields set $expected = array('id' => '', 'name' => '', 'description' => ''); $actual = $aclRole->toArray(); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); //with fileds pre populated $aclRole->id = '1'; @@ -192,10 +191,10 @@ class ACLRoleTest extends SuitePHPUnitFrameworkTestCase $expected = array('id' => '1', 'name' => 'test', 'description' => 'some description text'); $actual = $aclRole->toArray(); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } - public function testfromArray() + public function testfromArray(): void { $aclRole = BeanFactory::newBean('ACLRoles'); @@ -203,8 +202,8 @@ class ACLRoleTest extends SuitePHPUnitFrameworkTestCase $aclRole->fromArray($arr); //verify that it sets the object attributes correctly - $this->assertSame($aclRole->id, '1'); - $this->assertSame($aclRole->name, 'test'); - $this->assertSame($aclRole->description, 'some description text'); + self::assertSame($aclRole->id, '1'); + self::assertSame($aclRole->name, 'test'); + self::assertSame($aclRole->description, 'some description text'); } } diff --git a/tests/unit/phpunit/modules/AM_ProjectTemplates/AM_ProjectTemplatesTest.php b/tests/unit/phpunit/modules/AM_ProjectTemplates/AM_ProjectTemplatesTest.php index e8291dd1b..fa6889963 100644 --- a/tests/unit/phpunit/modules/AM_ProjectTemplates/AM_ProjectTemplatesTest.php +++ b/tests/unit/phpunit/modules/AM_ProjectTemplates/AM_ProjectTemplatesTest.php @@ -4,19 +4,19 @@ use SuiteCRM\Test\SuitePHPUnitFrameworkTestCase; class AM_ProjectTemplatesTest extends SuitePHPUnitFrameworkTestCase { - public function testAM_ProjectTemplates() + public function testAM_ProjectTemplates(): void { // Execute the constructor and check for the Object type and type attribute $am_projectTemplate = BeanFactory::newBean('AM_ProjectTemplates'); - $this->assertInstanceOf('AM_ProjectTemplates', $am_projectTemplate); - $this->assertInstanceOf('Basic', $am_projectTemplate); - $this->assertInstanceOf('SugarBean', $am_projectTemplate); + self::assertInstanceOf('AM_ProjectTemplates', $am_projectTemplate); + self::assertInstanceOf('Basic', $am_projectTemplate); + self::assertInstanceOf('SugarBean', $am_projectTemplate); - $this->assertAttributeEquals('AM_ProjectTemplates', 'module_dir', $am_projectTemplate); - $this->assertAttributeEquals('AM_ProjectTemplates', 'object_name', $am_projectTemplate); - $this->assertAttributeEquals('am_projecttemplates', 'table_name', $am_projectTemplate); - $this->assertAttributeEquals(true, 'new_schema', $am_projectTemplate); - $this->assertAttributeEquals(true, 'disable_row_level_security', $am_projectTemplate); - $this->assertAttributeEquals(true, 'importable', $am_projectTemplate); + self::assertEquals('AM_ProjectTemplates', $am_projectTemplate->module_dir); + self::assertEquals('AM_ProjectTemplates', $am_projectTemplate->object_name); + self::assertEquals('am_projecttemplates', $am_projectTemplate->table_name); + self::assertEquals(true, $am_projectTemplate->new_schema); + self::assertEquals(true, $am_projectTemplate->disable_row_level_security); + self::assertEquals(true, $am_projectTemplate->importable); } } diff --git a/tests/unit/phpunit/modules/AM_TaskTemplates/AM_TaskTemplatesTest.php b/tests/unit/phpunit/modules/AM_TaskTemplates/AM_TaskTemplatesTest.php index db0e850a5..76382d8c0 100644 --- a/tests/unit/phpunit/modules/AM_TaskTemplates/AM_TaskTemplatesTest.php +++ b/tests/unit/phpunit/modules/AM_TaskTemplates/AM_TaskTemplatesTest.php @@ -4,19 +4,19 @@ use SuiteCRM\Test\SuitePHPUnitFrameworkTestCase; class AM_TaskTemplatesTest extends SuitePHPUnitFrameworkTestCase { - public function testAM_TaskTemplates() + public function testAM_TaskTemplates(): void { // Execute the constructor and check for the Object type and type attribute $am_taskTemplates = BeanFactory::newBean('AM_TaskTemplates'); - $this->assertInstanceOf('AM_TaskTemplates', $am_taskTemplates); - $this->assertInstanceOf('Basic', $am_taskTemplates); - $this->assertInstanceOf('SugarBean', $am_taskTemplates); + self::assertInstanceOf('AM_TaskTemplates', $am_taskTemplates); + self::assertInstanceOf('Basic', $am_taskTemplates); + self::assertInstanceOf('SugarBean', $am_taskTemplates); - $this->assertAttributeEquals('AM_TaskTemplates', 'module_dir', $am_taskTemplates); - $this->assertAttributeEquals('AM_TaskTemplates', 'object_name', $am_taskTemplates); - $this->assertAttributeEquals('am_tasktemplates', 'table_name', $am_taskTemplates); - $this->assertAttributeEquals(true, 'new_schema', $am_taskTemplates); - $this->assertAttributeEquals(true, 'disable_row_level_security', $am_taskTemplates); - $this->assertAttributeEquals(false, 'importable', $am_taskTemplates); + self::assertEquals('AM_TaskTemplates', $am_taskTemplates->module_dir); + self::assertEquals('AM_TaskTemplates', $am_taskTemplates->object_name); + self::assertEquals('am_tasktemplates', $am_taskTemplates->table_name); + self::assertEquals(true, $am_taskTemplates->new_schema); + self::assertEquals(true, $am_taskTemplates->disable_row_level_security); + self::assertEquals(false, $am_taskTemplates->importable); } } diff --git a/tests/unit/phpunit/modules/AOD_Index/AOD_IndexTest.php b/tests/unit/phpunit/modules/AOD_Index/AOD_IndexTest.php index 2489c519a..bd8684be4 100644 --- a/tests/unit/phpunit/modules/AOD_Index/AOD_IndexTest.php +++ b/tests/unit/phpunit/modules/AOD_Index/AOD_IndexTest.php @@ -4,122 +4,74 @@ use SuiteCRM\Test\SuitePHPUnitFrameworkTestCase; class AOD_IndexTest extends SuitePHPUnitFrameworkTestCase { - public function testAOD_Index() + public function testAOD_Index(): void { // Execute the constructor and check for the Object type and type attribute $aod_index = BeanFactory::newBean('AOD_Index'); - $this->assertInstanceOf('AOD_Index', $aod_index); - $this->assertInstanceOf('Basic', $aod_index); - $this->assertInstanceOf('SugarBean', $aod_index); + self::assertInstanceOf('AOD_Index', $aod_index); + self::assertInstanceOf('Basic', $aod_index); + self::assertInstanceOf('SugarBean', $aod_index); - $this->assertAttributeEquals('AOD_Index', 'module_dir', $aod_index); - $this->assertAttributeEquals('AOD_Index', 'object_name', $aod_index); - $this->assertAttributeEquals('aod_index', 'table_name', $aod_index); - $this->assertAttributeEquals(true, 'new_schema', $aod_index); - $this->assertAttributeEquals(true, 'disable_row_level_security', $aod_index); - $this->assertAttributeEquals(false, 'importable', $aod_index); - $this->assertAttributeEquals(false, 'tracker_visibility', $aod_index); + self::assertEquals('AOD_Index', $aod_index->module_dir); + self::assertEquals('AOD_Index', $aod_index->object_name); + self::assertEquals('aod_index', $aod_index->table_name); + self::assertEquals(true, $aod_index->new_schema); + self::assertEquals(true, $aod_index->disable_row_level_security); + self::assertEquals(false, $aod_index->importable); + self::assertEquals(false, $aod_index->tracker_visibility); } - public function testisEnabled() + public function testisEnabled(): void { - $aod_index = BeanFactory::newBean('AOD_Index'); - // execute the method and verify that it returns true - $result = $aod_index->isEnabled(); - $this->assertTrue($result); + $result = BeanFactory::newBean('AOD_Index')->isEnabled(); + self::assertTrue($result); } - public function testfind() - { - self::markTestIncomplete('[Zend_Search_Lucene_Exception] File \'modules/AOD_Index/Index/Index/segments_31\' is not readable.'); - $aod_index = BeanFactory::newBean('AOD_Index'); - - $aod_index->id = 1; - $aod_index->location = 'modules/AOD_Index/Index/Index'; - - //execute the method with parameters and verify that it returns true - $hits = $aod_index->find('/'); - $this->assertTrue(is_array($hits)); - } - - public function testoptimise() - { - self::markTestIncomplete('[Zend_Search_Lucene_Exception] File \'modules/AOD_Index/Index/Index/segments_31\' is not readable.'); - - // test - $aod_index = BeanFactory::newBean('AOD_Index'); - $aod_index->id = 1; - $aod_index->location = 'modules/AOD_Index/Index/Index'; - $last_optimized = $aod_index->last_optimised; - - //execute the method and test if the last optimized date is changed to a later date/time. - $aod_index->optimise(); - $this->assertGreaterThan($last_optimized, $aod_index->last_optimised); - } - - public function testgetIndex() + public function testgetIndex(): void { $aod_index = BeanFactory::newBean('AOD_Index'); $result = $aod_index->getIndex(); //execute the method and verify it returns a different instance of samme type - $this->assertInstanceOf('AOD_Index', $result); - $this->assertNotSame($aod_index, $result); + self::assertInstanceOf('AOD_Index', $result); + self::assertNotSame($aod_index, $result); } - public function testgetDocumentForBean() + public function testgetDocumentForBean(): void { $user = new User(1); - $aod_index = BeanFactory::newBean('AOD_Index'); - $result = $aod_index->getDocumentForBean($user); + $result = BeanFactory::newBean('AOD_Index')->getDocumentForBean($user); //execute the method and verify that it returns an array - $this->assertTrue(is_array($result)); + self::assertIsArray($result); //verify that returned array has a valid Zend_Search_Lucene_Document instance - $this->assertInstanceOf('Zend_Search_Lucene_Document', $result['document']); + self::assertInstanceOf('Zend_Search_Lucene_Document', $result['document']); } - public function testcommit() - { - self::markTestIncomplete('File \'modules/AOD_Index/Index/Index/segments_31\' is not readable.'); - - $aod_index = BeanFactory::newBean('AOD_Index'); - $aod_index->id = 1; - $aod_index->location = 'modules/AOD_Index/Index/Index'; - - // Execute the method and test that it works and doesn't throw an exception. - try { - $aod_index->commit(); - $this->assertTrue(true); - } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); - } - } - - public function testisModuleSearchable() + public function testisModuleSearchable(): void { //test with an invalid module - $this->assertFalse(AOD_Index::isModuleSearchable('', '')); + self::assertFalse(AOD_Index::isModuleSearchable('', '')); //test for modules that are searchable - $this->assertTrue(AOD_Index::isModuleSearchable('DocumentRevisions', 'DocumentRevision')); - $this->assertTrue(AOD_Index::isModuleSearchable('Cases', 'Case')); - $this->assertTrue(AOD_Index::isModuleSearchable('Accounts', 'Account')); + self::assertTrue(AOD_Index::isModuleSearchable('DocumentRevisions', 'DocumentRevision')); + self::assertTrue(AOD_Index::isModuleSearchable('Cases', 'Case')); + self::assertTrue(AOD_Index::isModuleSearchable('Accounts', 'Account')); //test for modules that are not searchable - $this->assertFalse(AOD_Index::isModuleSearchable('AOD_IndexEvent', 'AOD_IndexEvent')); - $this->assertFalse(AOD_Index::isModuleSearchable('AOD_Index', 'AOD_Index')); - $this->assertFalse(AOD_Index::isModuleSearchable('AOW_Actions', 'AOW_Action')); - $this->assertFalse(AOD_Index::isModuleSearchable('AOW_Conditions', 'AOW_Condition')); - $this->assertFalse(AOD_Index::isModuleSearchable('AOW_Processed', 'AOW_Processed')); - $this->assertFalse(AOD_Index::isModuleSearchable('SchedulersJobs', 'SchedulersJob')); - $this->assertFalse(AOD_Index::isModuleSearchable('Users', 'User')); + self::assertFalse(AOD_Index::isModuleSearchable('AOD_IndexEvent', 'AOD_IndexEvent')); + self::assertFalse(AOD_Index::isModuleSearchable('AOD_Index', 'AOD_Index')); + self::assertFalse(AOD_Index::isModuleSearchable('AOW_Actions', 'AOW_Action')); + self::assertFalse(AOD_Index::isModuleSearchable('AOW_Conditions', 'AOW_Condition')); + self::assertFalse(AOD_Index::isModuleSearchable('AOW_Processed', 'AOW_Processed')); + self::assertFalse(AOD_Index::isModuleSearchable('SchedulersJobs', 'SchedulersJob')); + self::assertFalse(AOD_Index::isModuleSearchable('Users', 'User')); } - public function testindex() + public function testindex(): void { $aod_index = BeanFactory::newBean('AOD_Index'); $aod_index->id = 1; @@ -127,31 +79,14 @@ class AOD_IndexTest extends SuitePHPUnitFrameworkTestCase //test with a not searchable module, it will return false $result = $aod_index->index('Users', 1); - $this->assertFalse($result); + self::assertFalse($result); //test with a searchable module but invalid bean id, it will still index it $result = $aod_index->index('Accounts', 1); - $this->assertEquals(null, $result); + self::assertEquals(null, $result); } - public function testremove() - { - self::markTestIncomplete('File \'modules/AOD_Index/Index/Index/segments_31\' is not readable.'); - - $aod_index = BeanFactory::newBean('AOD_Index'); - $aod_index->id = 1; - $aod_index->location = 'modules/AOD_Index/Index/Index'; - - // Execute the method and test that it works and doesn't throw an exception. - try { - $aod_index->remove('Accounts', 1); - $this->assertTrue(true); - } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); - } - } - - public function testgetIndexableModules() + public function testgetIndexableModules(): void { $expected = array( 'AM_ProjectTemplates' => 'AM_ProjectTemplates', @@ -194,10 +129,8 @@ class AOD_IndexTest extends SuitePHPUnitFrameworkTestCase 'Tasks' => 'Task' ); - $aod_index = BeanFactory::newBean('AOD_Index'); - //execute the method and verify that it retunrs expected results - $actual = $aod_index->getIndexableModules(); - $this->assertSame($expected, $actual); + $actual = BeanFactory::newBean('AOD_Index')->getIndexableModules(); + self::assertSame($expected, $actual); } } diff --git a/tests/unit/phpunit/modules/AOD_IndexEvent/AOD_IndexEventTest.php b/tests/unit/phpunit/modules/AOD_IndexEvent/AOD_IndexEventTest.php index d15493efb..caa65d6ad 100644 --- a/tests/unit/phpunit/modules/AOD_IndexEvent/AOD_IndexEventTest.php +++ b/tests/unit/phpunit/modules/AOD_IndexEvent/AOD_IndexEventTest.php @@ -4,20 +4,20 @@ use SuiteCRM\Test\SuitePHPUnitFrameworkTestCase; class AOD_IndexEventTest extends SuitePHPUnitFrameworkTestCase { - public function testAOD_IndexEvent() + public function testAOD_IndexEvent(): void { // Execute the constructor and check for the Object type and type attribute $aod_indexEvent = BeanFactory::newBean('AOD_IndexEvent'); - $this->assertInstanceOf('AOD_IndexEvent', $aod_indexEvent); - $this->assertInstanceOf('Basic', $aod_indexEvent); - $this->assertInstanceOf('SugarBean', $aod_indexEvent); + self::assertInstanceOf('AOD_IndexEvent', $aod_indexEvent); + self::assertInstanceOf('Basic', $aod_indexEvent); + self::assertInstanceOf('SugarBean', $aod_indexEvent); - $this->assertAttributeEquals('AOD_IndexEvent', 'module_dir', $aod_indexEvent); - $this->assertAttributeEquals('AOD_IndexEvent', 'object_name', $aod_indexEvent); - $this->assertAttributeEquals('aod_indexevent', 'table_name', $aod_indexEvent); - $this->assertAttributeEquals(true, 'new_schema', $aod_indexEvent); - $this->assertAttributeEquals(true, 'disable_row_level_security', $aod_indexEvent); - $this->assertAttributeEquals(false, 'importable', $aod_indexEvent); - $this->assertAttributeEquals(false, 'tracker_visibility', $aod_indexEvent); + self::assertEquals('AOD_IndexEvent', $aod_indexEvent->module_dir); + self::assertEquals('AOD_IndexEvent', $aod_indexEvent->object_name); + self::assertEquals('aod_indexevent', $aod_indexEvent->table_name); + self::assertEquals(true, $aod_indexEvent->new_schema); + self::assertEquals(true, $aod_indexEvent->disable_row_level_security); + self::assertEquals(false, $aod_indexEvent->importable); + self::assertEquals(false, $aod_indexEvent->tracker_visibility); } } diff --git a/tests/unit/phpunit/modules/AOK_KnowledgeBase/AOK_KnowledgeBaseTest.php b/tests/unit/phpunit/modules/AOK_KnowledgeBase/AOK_KnowledgeBaseTest.php index ce8acab00..b9afb620e 100644 --- a/tests/unit/phpunit/modules/AOK_KnowledgeBase/AOK_KnowledgeBaseTest.php +++ b/tests/unit/phpunit/modules/AOK_KnowledgeBase/AOK_KnowledgeBaseTest.php @@ -4,19 +4,19 @@ use SuiteCRM\Test\SuitePHPUnitFrameworkTestCase; class AOK_KnowledgeBaseTest extends SuitePHPUnitFrameworkTestCase { - public function testAOK_KnowledgeBase() + public function testAOK_KnowledgeBase(): void { // Execute the constructor and check for the Object type and type attribute $aok_KnowledgeBase = BeanFactory::newBean('AOK_KnowledgeBase'); - $this->assertInstanceOf('AOK_KnowledgeBase', $aok_KnowledgeBase); - $this->assertInstanceOf('Basic', $aok_KnowledgeBase); - $this->assertInstanceOf('SugarBean', $aok_KnowledgeBase); + self::assertInstanceOf('AOK_KnowledgeBase', $aok_KnowledgeBase); + self::assertInstanceOf('Basic', $aok_KnowledgeBase); + self::assertInstanceOf('SugarBean', $aok_KnowledgeBase); - $this->assertAttributeEquals('AOK_KnowledgeBase', 'module_dir', $aok_KnowledgeBase); - $this->assertAttributeEquals('AOK_KnowledgeBase', 'object_name', $aok_KnowledgeBase); - $this->assertAttributeEquals('aok_knowledgebase', 'table_name', $aok_KnowledgeBase); - $this->assertAttributeEquals(true, 'new_schema', $aok_KnowledgeBase); - $this->assertAttributeEquals(true, 'disable_row_level_security', $aok_KnowledgeBase); - $this->assertAttributeEquals(false, 'importable', $aok_KnowledgeBase); + self::assertEquals('AOK_KnowledgeBase', $aok_KnowledgeBase->module_dir); + self::assertEquals('AOK_KnowledgeBase', $aok_KnowledgeBase->object_name); + self::assertEquals('aok_knowledgebase', $aok_KnowledgeBase->table_name); + self::assertEquals(true, $aok_KnowledgeBase->new_schema); + self::assertEquals(true, $aok_KnowledgeBase->disable_row_level_security); + self::assertEquals(false, $aok_KnowledgeBase->importable); } } diff --git a/tests/unit/phpunit/modules/AOK_Knowledge_Base_Categories/AOK_Knowledge_Base_CategoriesTest.php b/tests/unit/phpunit/modules/AOK_Knowledge_Base_Categories/AOK_Knowledge_Base_CategoriesTest.php index a926cc5a1..bccd93af1 100644 --- a/tests/unit/phpunit/modules/AOK_Knowledge_Base_Categories/AOK_Knowledge_Base_CategoriesTest.php +++ b/tests/unit/phpunit/modules/AOK_Knowledge_Base_Categories/AOK_Knowledge_Base_CategoriesTest.php @@ -4,19 +4,19 @@ use SuiteCRM\Test\SuitePHPUnitFrameworkTestCase; class AOK_Knowledge_Base_CategoriesTest extends SuitePHPUnitFrameworkTestCase { - public function testAOK_Knowledge_Base_Categories() + public function testAOK_Knowledge_Base_Categories(): void { // Execute the constructor and check for the Object type and type attribute $aok_KBCategories = BeanFactory::newBean('AOK_Knowledge_Base_Categories'); - $this->assertInstanceOf('AOK_Knowledge_Base_Categories', $aok_KBCategories); - $this->assertInstanceOf('Basic', $aok_KBCategories); - $this->assertInstanceOf('SugarBean', $aok_KBCategories); + self::assertInstanceOf('AOK_Knowledge_Base_Categories', $aok_KBCategories); + self::assertInstanceOf('Basic', $aok_KBCategories); + self::assertInstanceOf('SugarBean', $aok_KBCategories); - $this->assertAttributeEquals('AOK_Knowledge_Base_Categories', 'module_dir', $aok_KBCategories); - $this->assertAttributeEquals('AOK_Knowledge_Base_Categories', 'object_name', $aok_KBCategories); - $this->assertAttributeEquals('aok_knowledge_base_categories', 'table_name', $aok_KBCategories); - $this->assertAttributeEquals(true, 'new_schema', $aok_KBCategories); - $this->assertAttributeEquals(true, 'disable_row_level_security', $aok_KBCategories); - $this->assertAttributeEquals(false, 'importable', $aok_KBCategories); + self::assertEquals('AOK_Knowledge_Base_Categories', $aok_KBCategories->module_dir); + self::assertEquals('AOK_Knowledge_Base_Categories', $aok_KBCategories->object_name); + self::assertEquals('aok_knowledge_base_categories', $aok_KBCategories->table_name); + self::assertEquals(true, $aok_KBCategories->new_schema); + self::assertEquals(true, $aok_KBCategories->disable_row_level_security); + self::assertEquals(false, $aok_KBCategories->importable); } } diff --git a/tests/unit/phpunit/modules/AOP_Case_Events/AOP_Case_EventsTest.php b/tests/unit/phpunit/modules/AOP_Case_Events/AOP_Case_EventsTest.php index c359ea87e..12669ac91 100644 --- a/tests/unit/phpunit/modules/AOP_Case_Events/AOP_Case_EventsTest.php +++ b/tests/unit/phpunit/modules/AOP_Case_Events/AOP_Case_EventsTest.php @@ -4,20 +4,20 @@ use SuiteCRM\Test\SuitePHPUnitFrameworkTestCase; class AOP_Case_EventsTest extends SuitePHPUnitFrameworkTestCase { - public function testAOP_Case_Events() + public function testAOP_Case_Events(): void { // Execute the constructor and check for the Object type and type attribute $aopCaseEvents = BeanFactory::newBean('AOP_Case_Events'); - $this->assertInstanceOf('AOP_Case_Events', $aopCaseEvents); - $this->assertInstanceOf('Basic', $aopCaseEvents); - $this->assertInstanceOf('SugarBean', $aopCaseEvents); + self::assertInstanceOf('AOP_Case_Events', $aopCaseEvents); + self::assertInstanceOf('Basic', $aopCaseEvents); + self::assertInstanceOf('SugarBean', $aopCaseEvents); - $this->assertAttributeEquals('AOP_Case_Events', 'module_dir', $aopCaseEvents); - $this->assertAttributeEquals('AOP_Case_Events', 'object_name', $aopCaseEvents); - $this->assertAttributeEquals('aop_case_events', 'table_name', $aopCaseEvents); - $this->assertAttributeEquals(true, 'new_schema', $aopCaseEvents); - $this->assertAttributeEquals(true, 'disable_row_level_security', $aopCaseEvents); - $this->assertAttributeEquals(false, 'importable', $aopCaseEvents); - $this->assertAttributeEquals(false, 'tracker_visibility', $aopCaseEvents); + self::assertEquals('AOP_Case_Events', $aopCaseEvents->module_dir); + self::assertEquals('AOP_Case_Events', $aopCaseEvents->object_name); + self::assertEquals('aop_case_events', $aopCaseEvents->table_name); + self::assertEquals(true, $aopCaseEvents->new_schema); + self::assertEquals(true, $aopCaseEvents->disable_row_level_security); + self::assertEquals(false, $aopCaseEvents->importable); + self::assertEquals(false, $aopCaseEvents->tracker_visibility); } } diff --git a/tests/unit/phpunit/modules/AOP_Case_Updates/AOP_Case_UpdatesTest.php b/tests/unit/phpunit/modules/AOP_Case_Updates/AOP_Case_UpdatesTest.php index 3dc223d1b..b1ac0f8b1 100644 --- a/tests/unit/phpunit/modules/AOP_Case_Updates/AOP_Case_UpdatesTest.php +++ b/tests/unit/phpunit/modules/AOP_Case_Updates/AOP_Case_UpdatesTest.php @@ -13,24 +13,24 @@ class AOP_Case_UpdatesTest extends SuitePHPUnitFrameworkTestCase $current_user = BeanFactory::newBean('Users'); } - public function testAOP_Case_Updates() + public function testAOP_Case_Updates(): void { // Execute the constructor and check for the Object type and attributes $aopCaseUpdates = BeanFactory::newBean('AOP_Case_Updates'); - $this->assertInstanceOf('AOP_Case_Updates', $aopCaseUpdates); - $this->assertInstanceOf('Basic', $aopCaseUpdates); - $this->assertInstanceOf('SugarBean', $aopCaseUpdates); + self::assertInstanceOf('AOP_Case_Updates', $aopCaseUpdates); + self::assertInstanceOf('Basic', $aopCaseUpdates); + self::assertInstanceOf('SugarBean', $aopCaseUpdates); - $this->assertAttributeEquals('AOP_Case_Updates', 'module_dir', $aopCaseUpdates); - $this->assertAttributeEquals('AOP_Case_Updates', 'object_name', $aopCaseUpdates); - $this->assertAttributeEquals('aop_case_updates', 'table_name', $aopCaseUpdates); - $this->assertAttributeEquals(true, 'new_schema', $aopCaseUpdates); - $this->assertAttributeEquals(true, 'disable_row_level_security', $aopCaseUpdates); - $this->assertAttributeEquals(false, 'importable', $aopCaseUpdates); - $this->assertAttributeEquals(false, 'tracker_visibility', $aopCaseUpdates); + self::assertEquals('AOP_Case_Updates', $aopCaseUpdates->module_dir); + self::assertEquals('AOP_Case_Updates', $aopCaseUpdates->object_name); + self::assertEquals('aop_case_updates', $aopCaseUpdates->table_name); + self::assertEquals(true, $aopCaseUpdates->new_schema); + self::assertEquals(true, $aopCaseUpdates->disable_row_level_security); + self::assertEquals(false, $aopCaseUpdates->importable); + self::assertEquals(false, $aopCaseUpdates->tracker_visibility); } - public function testsave() + public function testsave(): void { self::markTestIncomplete('environment dependency'); @@ -43,60 +43,52 @@ class AOP_Case_UpdatesTest extends SuitePHPUnitFrameworkTestCase $aopCaseUpdates->save(); //test for record ID to verify that record is saved - $this->assertEquals(36, strlen($aopCaseUpdates->id)); + self::assertEquals(36, strlen($aopCaseUpdates->id)); //mark the record as deleted for cleanup $aopCaseUpdates->mark_deleted($aopCaseUpdates->id); } - public function testgetCase() + public function testgetCase(): void { - $aopCaseUpdates = BeanFactory::newBean('AOP_Case_Updates'); - //execute the method and verify that it returns a Case object - $result = $aopCaseUpdates->getCase(); + $result = BeanFactory::newBean('AOP_Case_Updates')->getCase(); - $this->assertInstanceOf('aCase', $result); + self::assertInstanceOf('aCase', $result); } - public function testgetContacts() + public function testgetContacts(): void { - $aopCaseUpdates = BeanFactory::newBean('AOP_Case_Updates'); - //execute the method and verify that it returns an array - $result = $aopCaseUpdates->getContacts(); - $this->assertTrue(is_array($result)); + $result = BeanFactory::newBean('AOP_Case_Updates')->getContacts(); + self::assertIsArray($result); } - public function testgetUpdateContact() + public function testgetUpdateContact(): void { $aopCaseUpdates = BeanFactory::newBean('AOP_Case_Updates'); //execute the method without contact_id and verify that it returns null $result = $aopCaseUpdates->getUpdateContact(); - $this->assertEquals(null, $result); + self::assertEquals(null, $result); //execute the method without contact_id and verify that it returns false $aopCaseUpdates->contact_id = 1; $result = $aopCaseUpdates->getUpdateContact(); - $this->assertEquals(false, $result); + self::assertEquals(false, $result); } - public function testgetUser() + public function testgetUser(): void { - $aopCaseUpdates = BeanFactory::newBean('AOP_Case_Updates'); - //execute the method and verify that it returns an instance of User - $result = $aopCaseUpdates->getUser(); - $this->assertInstanceOf('User', $result); + $result = BeanFactory::newBean('AOP_Case_Updates')->getUser(); + self::assertInstanceOf('User', $result); } - public function testgetUpdateUser() + public function testgetUpdateUser(): void { - $aopCaseUpdates = BeanFactory::newBean('AOP_Case_Updates'); - //execute the method and verify that it returns an instance of User - $result = $aopCaseUpdates->getUpdateUser(); - $this->assertInstanceOf('User', $result); + $result = BeanFactory::newBean('AOP_Case_Updates')->getUpdateUser(); + self::assertInstanceOf('User', $result); } } diff --git a/tests/unit/phpunit/modules/AOR_Charts/AOR_ChartTest.php b/tests/unit/phpunit/modules/AOR_Charts/AOR_ChartTest.php index b678aa412..e7f0cedd5 100644 --- a/tests/unit/phpunit/modules/AOR_Charts/AOR_ChartTest.php +++ b/tests/unit/phpunit/modules/AOR_Charts/AOR_ChartTest.php @@ -5,27 +5,27 @@ use SuiteCRM\Test\SuitePHPUnitFrameworkTestCase; class AOR_ChartTest extends SuitePHPUnitFrameworkTestCase { - public function testAOR_Chart() + public function testAOR_Chart(): void { - $this->markTestSkipped('Skipping AOR Charts Tests'); + self::markTestSkipped('Skipping AOR Charts Tests'); // Execute the constructor and check for the Object type and attributes $aorChart = BeanFactory::newBean('AOR_Charts'); - $this->assertInstanceOf('AOR_Chart', $aorChart); - $this->assertInstanceOf('Basic', $aorChart); - $this->assertInstanceOf('SugarBean', $aorChart); + self::assertInstanceOf('AOR_Chart', $aorChart); + self::assertInstanceOf('Basic', $aorChart); + self::assertInstanceOf('SugarBean', $aorChart); - $this->assertAttributeEquals('AOR_Charts', 'module_dir', $aorChart); - $this->assertAttributeEquals('AOR_Chart', 'object_name', $aorChart); - $this->assertAttributeEquals('aor_charts', 'table_name', $aorChart); - $this->assertAttributeEquals(true, 'new_schema', $aorChart); - $this->assertAttributeEquals(true, 'disable_row_level_security', $aorChart); - $this->assertAttributeEquals(true, 'importable', $aorChart); + self::assertEquals('AOR_Charts', $aorChart->module_dir); + self::assertEquals('AOR_Chart', $aorChart->object_name); + self::assertEquals('aor_charts', $aorChart->table_name); + self::assertEquals(true, $aorChart->new_schema); + self::assertEquals(true, $aorChart->disable_row_level_security); + self::assertEquals(true, $aorChart->importable); } - public function testsave_lines() + public function testsave_lines(): void { - $this->markTestSkipped('Skipping AOR Charts Tests'); - + self::markTestSkipped('Skipping AOR Charts Tests'); + $aorChart = BeanFactory::newBean('AOR_Charts'); //preset the required data @@ -43,16 +43,16 @@ class AOR_ChartTest extends SuitePHPUnitFrameworkTestCase // Execute the method and test that it works and doesn't throw an exception. try { $result = $aorChart->save_lines($post, $bean, $postKey); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } } - public function testbuildChartImageBar() + public function testbuildChartImageBar(): void { - $this->markTestSkipped('Skipping AOR Charts Tests'); - + self::markTestSkipped('Skipping AOR Charts Tests'); + $aorChart = BeanFactory::newBean('AOR_Charts'); $chartData = new pData(); @@ -62,21 +62,21 @@ class AOR_ChartTest extends SuitePHPUnitFrameworkTestCase //execute with recordImageMap true and verify that the chartPicture is changed $chartPicture = new pImage(700, 700, $chartData); $aorChart->buildChartImageBar($chartPicture, true); - $this->assertNotEquals($chartPicture, new pImage(700, 700, $chartData)); + self::assertNotEquals($chartPicture, new pImage(700, 700, $chartData)); //execute with recordImageMap false and verify that the chartPicture is changed $chartPicture = new pImage(700, 700, $chartData); $aorChart->buildChartImageBar($chartPicture, false); - $this->assertNotEquals($chartPicture, new pImage(700, 700, $chartData)); + self::assertNotEquals($chartPicture, new pImage(700, 700, $chartData)); unset($chartData); unset($chartPicture); } - public function testbuildChartImagePie() + public function testbuildChartImagePie(): void { - $this->markTestSkipped('Skipping AOR Charts Tests'); - + self::markTestSkipped('Skipping AOR Charts Tests'); + $aorChart = BeanFactory::newBean('AOR_Charts'); $chartData = new pData(); @@ -86,21 +86,21 @@ class AOR_ChartTest extends SuitePHPUnitFrameworkTestCase //execute with recordImageMap false and verify that the chartPicture is changed $chartPicture = new pImage(700, 700, $chartData); $aorChart->buildChartImagePie($chartPicture, $chartData, array(array('x' => 10), array('x' => 20)), 700, 700, 'x', false); - $this->assertNotEquals($chartPicture, new pImage(700, 700, $chartData)); + self::assertNotEquals($chartPicture, new pImage(700, 700, $chartData)); //execute with recordImageMap true and verify that the chartPicture is changed $chartPicture = new pImage(700, 700, $chartData); $aorChart->buildChartImagePie($chartPicture, $chartData, array(array('x' => 10), array('x' => 20)), 700, 700, 'x', true); - $this->assertNotEquals($chartPicture, new pImage(700, 700, $chartData)); + self::assertNotEquals($chartPicture, new pImage(700, 700, $chartData)); unset($chartData); unset($chartPicture); } - public function testbuildChartImageLine() + public function testbuildChartImageLine(): void { - $this->markTestSkipped('Skipping AOR Charts Tests'); - + self::markTestSkipped('Skipping AOR Charts Tests'); + $aorChart = BeanFactory::newBean('AOR_Charts'); $chartData = new pData(); @@ -110,21 +110,21 @@ class AOR_ChartTest extends SuitePHPUnitFrameworkTestCase //execute with recordImageMap true and verify that the chartPicture is changed $chartPicture = new pImage(700, 700, $chartData); $aorChart->buildChartImageLine($chartPicture, true); - $this->assertNotEquals($chartPicture, new pImage(700, 700, $chartData)); + self::assertNotEquals($chartPicture, new pImage(700, 700, $chartData)); //execute with recordImageMap false and verify that the chartPicture is changed $chartPicture = new pImage(700, 700, $chartData); $aorChart->buildChartImageLine($chartPicture, false); - $this->assertNotEquals($chartPicture, new pImage(700, 700, $chartData)); + self::assertNotEquals($chartPicture, new pImage(700, 700, $chartData)); unset($chartData); unset($chartPicture); } - public function testbuildChartImageRadar() + public function testbuildChartImageRadar(): void { - $this->markTestSkipped('Skipping AOR Charts Tests'); - + self::markTestSkipped('Skipping AOR Charts Tests'); + $aorChart = BeanFactory::newBean('AOR_Charts'); //preset the required objects and properties @@ -145,21 +145,21 @@ class AOR_ChartTest extends SuitePHPUnitFrameworkTestCase $chartPicture = new pImage($imageWidth, $imageHeight, $chartData); $chartPicture->setGraphArea(60, 60, $imageWidth - 60, $imageHeight - 100); $aorChart->buildChartImageRadar($chartPicture, $chartData, true); - $this->assertNotEquals($chartPicture, new pImage(700, 700, $chartData)); + self::assertNotEquals($chartPicture, new pImage(700, 700, $chartData)); //execute with recordImageMap false and verify that the chartPicture is changed $chartPicture = new pImage(700, 700, $chartData); $chartPicture->setGraphArea(60, 60, $imageWidth - 60, $imageHeight - 100); $aorChart->buildChartImageRadar($chartPicture, $chartData, false); - $this->assertNotEquals($chartPicture, new pImage(700, 700, $chartData)); + self::assertNotEquals($chartPicture, new pImage(700, 700, $chartData)); unset($chartData); unset($chartPicture); } - public function testbuildChartImage() + public function testbuildChartImage(): void { - $this->markTestSkipped('Skipping testing chart image'); + self::markTestSkipped('Skipping testing chart image'); global $current_user; @@ -181,27 +181,27 @@ class AOR_ChartTest extends SuitePHPUnitFrameworkTestCase //execute the method and verify it returns expected results $aorChart->type = 'bar'; $result = $aorChart->buildChartImage($reportData, $fields); - $this->assertEquals('data:image/png;base64,', $result); + self::assertEquals('data:image/png;base64,', $result); //execute the method and verify it returns expected results $aorChart->type = 'Line'; $result = $aorChart->buildChartImage($reportData, $fields); - $this->assertEquals('', $result); + self::assertEquals('', $result); //execute the method and verify it returns expected results $aorChart->type = 'pie'; $result = $aorChart->buildChartImage($reportData, $fields); - $this->assertEquals('data:image/png;base64,', $result); + self::assertEquals('data:image/png;base64,', $result); //execute the method and verify it returns expected results $aorChart->type = 'radar'; $result = $aorChart->buildChartImage($reportData, $fields, true); - $this->assertEquals('data:image/png;base64,', $result); + self::assertEquals('data:image/png;base64,', $result); } - public function testbuildChartHTML() + public function testbuildChartHTML(): void { - $this->markTestSkipped('Skipping testing chart HTML'); + self::markTestSkipped('Skipping testing chart HTML'); $aorChart = BeanFactory::newBean('AOR_Charts'); //preset the required objects and properties @@ -219,11 +219,11 @@ class AOR_ChartTest extends SuitePHPUnitFrameworkTestCase //test with type CHART_TYPE_PCHART and verify it returns expected results $expected = ""; $result = $aorChart->buildChartHTML($reportData, $fields); - $this->assertSame($expected, $result); + self::assertSame($expected, $result); //test with type CHART_TYPE_CHARTJS verify it returns expected results $expected = "

"; $result = $aorChart->buildChartHTML($reportData, $fields, 0, AOR_Report::CHART_TYPE_CHARTJS); - $this->assertSame($expected, $result); + self::assertSame($expected, $result); } } diff --git a/tests/unit/phpunit/modules/AOR_Conditions/AOR_ConditionTest.php b/tests/unit/phpunit/modules/AOR_Conditions/AOR_ConditionTest.php index 8a20c2202..45bc2ee4e 100644 --- a/tests/unit/phpunit/modules/AOR_Conditions/AOR_ConditionTest.php +++ b/tests/unit/phpunit/modules/AOR_Conditions/AOR_ConditionTest.php @@ -4,24 +4,24 @@ use SuiteCRM\Test\SuitePHPUnitFrameworkTestCase; class AOR_ConditionTest extends SuitePHPUnitFrameworkTestCase { - public function testAOR_Condition() + public function testAOR_Condition(): void { // Execute the constructor and check for the Object type and attributes $aor_Condition = BeanFactory::newBean('AOR_Conditions'); - $this->assertInstanceOf('AOR_Condition', $aor_Condition); - $this->assertInstanceOf('Basic', $aor_Condition); - $this->assertInstanceOf('SugarBean', $aor_Condition); + self::assertInstanceOf('AOR_Condition', $aor_Condition); + self::assertInstanceOf('Basic', $aor_Condition); + self::assertInstanceOf('SugarBean', $aor_Condition); - $this->assertAttributeEquals('AOR_Conditions', 'module_dir', $aor_Condition); - $this->assertAttributeEquals('AOR_Condition', 'object_name', $aor_Condition); - $this->assertAttributeEquals('aor_conditions', 'table_name', $aor_Condition); - $this->assertAttributeEquals(true, 'new_schema', $aor_Condition); - $this->assertAttributeEquals(true, 'disable_row_level_security', $aor_Condition); - $this->assertAttributeEquals(true, 'importable', $aor_Condition); - $this->assertAttributeEquals(false, 'tracker_visibility', $aor_Condition); + self::assertEquals('AOR_Conditions', $aor_Condition->module_dir); + self::assertEquals('AOR_Condition', $aor_Condition->object_name); + self::assertEquals('aor_conditions', $aor_Condition->table_name); + self::assertEquals(true, $aor_Condition->new_schema); + self::assertEquals(true, $aor_Condition->disable_row_level_security); + self::assertEquals(true, $aor_Condition->importable); + self::assertEquals(false, $aor_Condition->tracker_visibility); } - public function testsave_lines() + public function testsave_lines(): void { $aor_Condition = BeanFactory::newBean('AOR_Conditions'); @@ -37,9 +37,9 @@ class AOR_ConditionTest extends SuitePHPUnitFrameworkTestCase // Execute the method and test that it works and doesn't throw an exception. try { $aor_Condition->save_lines($post_data, BeanFactory::newBean('AOR_Reports')); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } } } diff --git a/tests/unit/phpunit/modules/AOR_Fields/AOR_FieldTest.php b/tests/unit/phpunit/modules/AOR_Fields/AOR_FieldTest.php index 11384d9a3..998520b60 100644 --- a/tests/unit/phpunit/modules/AOR_Fields/AOR_FieldTest.php +++ b/tests/unit/phpunit/modules/AOR_Fields/AOR_FieldTest.php @@ -4,24 +4,24 @@ use SuiteCRM\Test\SuitePHPUnitFrameworkTestCase; class AOR_FieldTest extends SuitePHPUnitFrameworkTestCase { - public function testAOR_Field() + public function testAOR_Field(): void { // Execute the constructor and check for the Object type and attributes $aor_Field = BeanFactory::newBean('AOR_Fields'); - $this->assertInstanceOf('AOR_Field', $aor_Field); - $this->assertInstanceOf('Basic', $aor_Field); - $this->assertInstanceOf('SugarBean', $aor_Field); + self::assertInstanceOf('AOR_Field', $aor_Field); + self::assertInstanceOf('Basic', $aor_Field); + self::assertInstanceOf('SugarBean', $aor_Field); - $this->assertAttributeEquals('AOR_Fields', 'module_dir', $aor_Field); - $this->assertAttributeEquals('AOR_Field', 'object_name', $aor_Field); - $this->assertAttributeEquals('aor_fields', 'table_name', $aor_Field); - $this->assertAttributeEquals(true, 'new_schema', $aor_Field); - $this->assertAttributeEquals(true, 'disable_row_level_security', $aor_Field); - $this->assertAttributeEquals(true, 'importable', $aor_Field); - $this->assertAttributeEquals(false, 'tracker_visibility', $aor_Field); + self::assertEquals('AOR_Fields', $aor_Field->module_dir); + self::assertEquals('AOR_Field', $aor_Field->object_name); + self::assertEquals('aor_fields', $aor_Field->table_name); + self::assertEquals(true, $aor_Field->new_schema); + self::assertEquals(true, $aor_Field->disable_row_level_security); + self::assertEquals(true, $aor_Field->importable); + self::assertEquals(false, $aor_Field->tracker_visibility); } - public function testsave_lines() + public function testsave_lines(): void { $aor_Field = BeanFactory::newBean('AOR_Fields'); @@ -42,9 +42,9 @@ class AOR_FieldTest extends SuitePHPUnitFrameworkTestCase // Execute the method and test that it works and doesn't throw an exception. try { $aor_Field->save_lines($post_data, BeanFactory::newBean('AOR_Reports')); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } } } diff --git a/tests/unit/phpunit/modules/AOR_Reports/AOR_ReportTest.php b/tests/unit/phpunit/modules/AOR_Reports/AOR_ReportTest.php index 065295809..aed132a83 100644 --- a/tests/unit/phpunit/modules/AOR_Reports/AOR_ReportTest.php +++ b/tests/unit/phpunit/modules/AOR_Reports/AOR_ReportTest.php @@ -4,32 +4,32 @@ use SuiteCRM\Test\SuitePHPUnitFrameworkTestCase; class AOR_ReportTest extends SuitePHPUnitFrameworkTestCase { - public function testAOR_Report() + public function testAOR_Report(): void { // Execute the constructor and check for the Object type and attributes $aor_Report = BeanFactory::newBean('AOR_Reports'); - $this->assertInstanceOf('AOR_Report', $aor_Report); - $this->assertInstanceOf('Basic', $aor_Report); - $this->assertInstanceOf('SugarBean', $aor_Report); + self::assertInstanceOf('AOR_Report', $aor_Report); + self::assertInstanceOf('Basic', $aor_Report); + self::assertInstanceOf('SugarBean', $aor_Report); - $this->assertAttributeEquals('AOR_Reports', 'module_dir', $aor_Report); - $this->assertAttributeEquals('AOR_Report', 'object_name', $aor_Report); - $this->assertAttributeEquals('aor_reports', 'table_name', $aor_Report); - $this->assertAttributeEquals(true, 'new_schema', $aor_Report); - $this->assertAttributeEquals(true, 'disable_row_level_security', $aor_Report); - $this->assertAttributeEquals(true, 'importable', $aor_Report); + self::assertEquals('AOR_Reports', $aor_Report->module_dir); + self::assertEquals('AOR_Report', $aor_Report->object_name); + self::assertEquals('aor_reports', $aor_Report->table_name); + self::assertEquals(true, $aor_Report->new_schema); + self::assertEquals(true, $aor_Report->disable_row_level_security); + self::assertEquals(true, $aor_Report->importable); } - public function testbean_implements() + public function testbean_implements(): void { $aor_Report = BeanFactory::newBean('AOR_Reports'); - $this->assertEquals(false, $aor_Report->bean_implements('')); //test with blank value - $this->assertEquals(false, $aor_Report->bean_implements('test')); //test with invalid value - $this->assertEquals(true, $aor_Report->bean_implements('ACL')); //test with valid value + self::assertEquals(false, $aor_Report->bean_implements('')); //test with blank value + self::assertEquals(false, $aor_Report->bean_implements('test')); //test with invalid value + self::assertEquals(true, $aor_Report->bean_implements('ACL')); //test with valid value } - public function testsave() + public function testsave(): void { $aor_Report = BeanFactory::newBean('AOR_Reports'); @@ -60,8 +60,8 @@ class AOR_ReportTest extends SuitePHPUnitFrameworkTestCase $aor_Report->save(); //test for record ID to verify that record is saved - $this->assertTrue(isset($aor_Report->id)); - $this->assertEquals(36, strlen($aor_Report->id)); + self::assertTrue(isset($aor_Report->id)); + self::assertEquals(36, strlen($aor_Report->id)); //mark the record as deleted for cleanup $aor_Report->mark_deleted($aor_Report->id); @@ -69,28 +69,27 @@ class AOR_ReportTest extends SuitePHPUnitFrameworkTestCase unset($aor_Report); } - public function testload_report_beans() + public function testload_report_beans(): void { $aor_Report = BeanFactory::newBean('AOR_Reports'); // Execute the method and test that it works and doesn't throw an exception. try { $aor_Report->load_report_beans(); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } } - public function testgetReportFields() + public function testgetReportFields(): void { //execute the method and verify that it returns an array - $aor_Report = BeanFactory::newBean('AOR_Reports'); - $result = $aor_Report->getReportFields(); - $this->assertTrue(is_array($result)); + $result = BeanFactory::newBean('AOR_Reports')->getReportFields(); + self::assertIsArray($result); } - public function testbuild_report_chart() + public function testbuild_report_chart(): void { $aor_Report = BeanFactory::newBean('AOR_Reports'); $aor_Report->report_module = 'Accounts'; @@ -101,7 +100,7 @@ class AOR_ReportTest extends SuitePHPUnitFrameworkTestCase //execute the method and verify that it returns chart display script. strings returned vary due to included chart id. $result = $aor_Report->build_report_chart(); foreach ($charts as $chart) { - $this->assertContains($chart->id, $result); + self::assertContains($chart->id, $result); } unset($GLOBALS['_SESSION']); @@ -115,7 +114,7 @@ class AOR_ReportTest extends SuitePHPUnitFrameworkTestCase unset($GLOBALS['currentModule']); } - public function testbuild_group_report() + public function testbuild_group_report(): void { $aor_Report = BeanFactory::newBean('AOR_Reports'); $aor_Report->report_module = 'Accounts'; @@ -123,45 +122,45 @@ class AOR_ReportTest extends SuitePHPUnitFrameworkTestCase //execute the method without any parameters and verify it returns html string $html1 = $aor_Report->build_group_report(); - $this->assertGreaterThan(0, strlen($html1)); + self::assertGreaterThan(0, strlen($html1)); //execute the method wit offset parameter and verify it returns html string $html2 = $aor_Report->build_group_report(1); - $this->assertGreaterThan(0, strlen($html2)); + self::assertGreaterThan(0, strlen($html2)); //execute the method with both parameters and verify it returns html string $html3 = $aor_Report->build_group_report(0, false); - $this->assertGreaterThan(0, strlen($html3)); + self::assertGreaterThan(0, strlen($html3)); //verify that all three html strings are different. - $this->assertNotEquals($html1, $html2); - $this->assertNotEquals($html1, $html3); - $this->assertNotEquals($html2, $html3); + self::assertNotEquals($html1, $html2); + self::assertNotEquals($html1, $html3); + self::assertNotEquals($html2, $html3); } - public function testbuild_report_html() + public function testbuild_report_html(): void { $aor_Report = BeanFactory::newBean('AOR_Reports'); $aor_Report->report_module = 'Accounts'; //execute the method without any parameters and verify it returns html string $html1 = $aor_Report->build_report_html(); - $this->assertGreaterThan(0, strlen($html1)); + self::assertGreaterThan(0, strlen($html1)); //execute the method with both parameters and verify it returns html string $html2 = $aor_Report->build_report_html(0, false); - $this->assertGreaterThan(0, strlen($html2)); + self::assertGreaterThan(0, strlen($html2)); //execute the method with group and identifier parameters and verify it returns html string $html3 = $aor_Report->build_report_html(1, false, 'grouptest', 'testidentifier'); - $this->assertGreaterThan(0, strlen($html3)); + self::assertGreaterThan(0, strlen($html3)); //verify that group and identifier exist in the strings - $this->assertContains('grouptest', $html3); - $this->assertContains('testidentifier', $html3); + self::assertStringContainsString('grouptest', $html3); + self::assertStringContainsString('testidentifier', $html3); } - public function testGetTotalHTML() + public function testGetTotalHTML(): void { //execute the method with required data preset and verify it returns expected result $fields = [ @@ -180,50 +179,38 @@ class AOR_ReportTest extends SuitePHPUnitFrameworkTestCase $reportBean = BeanFactory::newBean('AOR_Reports'); $actual = $reportBean->getTotalHTML($fields, $totals); - $this->assertContains('sugar_field', $actual); - $this->assertContains('duration_hours', $actual); + self::assertStringContainsString('sugar_field', $actual); + self::assertStringContainsString('duration_hours', $actual); } - public function testcalculateTotal() + public function testcalculateTotal(): void { //execute the method with data preset and verify it returns expected result $totals = array(10, 20, 30); $aor_Report = BeanFactory::newBean('AOR_Reports'); - $this->assertEquals('', $aor_Report->calculateTotal('', $totals)); - $this->assertEquals(60, $aor_Report->calculateTotal('SUM', $totals)); - $this->assertEquals(3, $aor_Report->calculateTotal('COUNT', $totals)); - $this->assertEquals(20, $aor_Report->calculateTotal('AVG', $totals)); + self::assertEquals('', $aor_Report->calculateTotal('', $totals)); + self::assertEquals(60, $aor_Report->calculateTotal('SUM', $totals)); + self::assertEquals(3, $aor_Report->calculateTotal('COUNT', $totals)); + self::assertEquals(20, $aor_Report->calculateTotal('AVG', $totals)); } - public function testbuild_report_csv() - { - //this method uses exit so it cannot be tested - - /*$aor_Report = BeanFactory::newBean('AOR_Reports'); - $aor_Report->report_module = "Accounts"; - $aor_Report->build_report_csv(); - */ - - $this->markTestIncomplete('Can Not be implemented'); - } - - public function testbuild_report_query() + public function testbuild_report_query(): void { $aor_Report = BeanFactory::newBean('AOR_Reports'); $aor_Report->report_module = 'Accounts'; //execute the method without any parameters and verify that it returns a non empty string $actual = $aor_Report->build_report_query(); - $this->assertGreaterThanOrEqual(0, strlen($actual)); + self::assertGreaterThanOrEqual(0, strlen($actual)); //execute the method with parameter and verify that it returns a non empty string $actual = $aor_Report->build_report_query('name'); - $this->assertGreaterThanOrEqual(0, strlen($actual)); + self::assertGreaterThanOrEqual(0, strlen($actual)); } - public function testbuild_report_query_select() + public function testbuild_report_query_select(): void { $aor_Report = BeanFactory::newBean('AOR_Reports'); $aor_Report->report_module = 'Accounts'; @@ -231,10 +218,10 @@ class AOR_ReportTest extends SuitePHPUnitFrameworkTestCase //execute the method with parameters and verify that it returns an array. $actual = $aor_Report->build_report_query_select($query_array, 'name'); - $this->assertTrue(is_array($actual)); + self::assertIsArray($actual); } - public function testbuild_report_query_join() + public function testbuild_report_query_join(): void { $aor_Report = BeanFactory::newBean('AOR_Reports'); $aor_Report->report_module = 'Accounts'; @@ -249,7 +236,7 @@ class AOR_ReportTest extends SuitePHPUnitFrameworkTestCase 'custom', array() ); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); //test with type relationship and verify that it retunrs expected results $expected = array( @@ -265,23 +252,23 @@ class AOR_ReportTest extends SuitePHPUnitFrameworkTestCase 'relationship', array() ); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } - public function testbuild_report_access_query() + public function testbuild_report_access_query(): void { $aor_Report = BeanFactory::newBean('AOR_Reports'); //test without alias and verify that it retunrs expected results $result = $aor_Report->build_report_access_query(BeanFactory::newBean('AOR_Reports'), ''); - $this->assertEquals('', $result); + self::assertEquals('', $result); //test with alias and verify that it retunrs expected results $result = $aor_Report->build_report_access_query(BeanFactory::newBean('AOR_Reports'), 'rep'); - $this->assertEquals('', $result); + self::assertEquals('', $result); } - public function testbuild_report_query_where() + public function testbuild_report_query_where(): void { $aor_Report = BeanFactory::newBean('AOR_Reports'); $aor_Report->report_module = 'Accounts'; @@ -289,6 +276,6 @@ class AOR_ReportTest extends SuitePHPUnitFrameworkTestCase //execute the method and verify that it retunrs expected results $expected = array('where' => array('accounts.deleted = 0 ')); $actual = $aor_Report->build_report_query_where(); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } } diff --git a/tests/unit/phpunit/modules/AOR_Scheduled_Reports/AOR_Scheduled_ReportsTest.php b/tests/unit/phpunit/modules/AOR_Scheduled_Reports/AOR_Scheduled_ReportsTest.php index ed1b27dcd..999c34f94 100644 --- a/tests/unit/phpunit/modules/AOR_Scheduled_Reports/AOR_Scheduled_ReportsTest.php +++ b/tests/unit/phpunit/modules/AOR_Scheduled_Reports/AOR_Scheduled_ReportsTest.php @@ -13,7 +13,7 @@ class AOR_Scheduled_ReportsTest extends SuitePHPUnitFrameworkTestCase $current_user = BeanFactory::newBean('Users'); } - public function testSaveAndGet_email_recipients() + public function testSaveAndGet_email_recipients(): void { $aorScheduledReports = BeanFactory::newBean('AOR_Scheduled_Reports'); $aorScheduledReports->name = "test"; @@ -23,8 +23,8 @@ class AOR_Scheduled_ReportsTest extends SuitePHPUnitFrameworkTestCase //test save and test for record ID to verify that record is saved $aorScheduledReports->save(); - $this->assertTrue(isset($aorScheduledReports->id)); - $this->assertEquals(36, strlen($aorScheduledReports->id)); + self::assertTrue(isset($aorScheduledReports->id)); + self::assertEquals(36, strlen($aorScheduledReports->id)); @@ -33,31 +33,32 @@ class AOR_Scheduled_ReportsTest extends SuitePHPUnitFrameworkTestCase $aorScheduledReports->retrieve($aorScheduledReports->id); $emails = $aorScheduledReports->get_email_recipients(); - $this->assertTrue(is_array($emails)); - $this->assertEquals('test@test.com', $emails[0]); + self::assertIsArray($emails); + self::assertEquals('test@test.com', $emails[0]); $aorScheduledReports->mark_deleted($aorScheduledReports->id); unset($aorScheduledReports); } - public function testAOR_Scheduled_Reports() + public function testAOR_Scheduled_Reports(): void { // Execute the constructor and check for the Object type and attributes $aorScheduledReports = BeanFactory::newBean('AOR_Scheduled_Reports'); - $this->assertInstanceOf('AOR_Scheduled_Reports', $aorScheduledReports); - $this->assertInstanceOf('Basic', $aorScheduledReports); - $this->assertInstanceOf('SugarBean', $aorScheduledReports); + self::assertInstanceOf('AOR_Scheduled_Reports', $aorScheduledReports); + self::assertInstanceOf('Basic', $aorScheduledReports); + self::assertInstanceOf('SugarBean', $aorScheduledReports); - $this->assertAttributeEquals('AOR_Scheduled_Reports', 'module_dir', $aorScheduledReports); - $this->assertAttributeEquals('AOR_Scheduled_Reports', 'object_name', $aorScheduledReports); - $this->assertAttributeEquals('aor_scheduled_reports', 'table_name', $aorScheduledReports); - $this->assertAttributeEquals(true, 'new_schema', $aorScheduledReports); - $this->assertAttributeEquals(true, 'disable_row_level_security', $aorScheduledReports); - $this->assertAttributeEquals(false, 'importable', $aorScheduledReports); + self::assertEquals('AOR_Scheduled_Reports', $aorScheduledReports->module_dir); + self::assertEquals('AOR_Scheduled_Reports', $aorScheduledReports->object_name); + self::assertEquals('aor_scheduled_reports', $aorScheduledReports->table_name); + self::assertEquals(true, $aorScheduledReports->new_schema); + self::assertEquals(true, $aorScheduledReports->disable_row_level_security); + self::assertEquals(false, $aorScheduledReports->importable); } - public function test_ReportRelation() { + public function test_ReportRelation(): void + { $_POST['aor_fields_field'] = []; $report = BeanFactory::newBean('AOR_Reports'); $report->name = "Foobar"; @@ -68,19 +69,19 @@ class AOR_Scheduled_ReportsTest extends SuitePHPUnitFrameworkTestCase $aorScheduledReports->load_relationships(); $aorScheduledReports->aor_report->add($report); $aorScheduledReports->retrieve($aorScheduledReports->id); - $this->assertEquals($report->name, $aorScheduledReports->aor_report_name); - $this->assertEquals($report->id, $aorScheduledReports->aor_report_id); + self::assertEquals($report->name, $aorScheduledReports->aor_report_name); + self::assertEquals($report->id, $aorScheduledReports->aor_report_id); } - public function testbean_implements() + public function testbean_implements(): void { $aorScheduledReports = BeanFactory::newBean('AOR_Scheduled_Reports'); - $this->assertEquals(false, $aorScheduledReports->bean_implements('')); //test with blank value - $this->assertEquals(false, $aorScheduledReports->bean_implements('test')); //test with invalid value - $this->assertEquals(true, $aorScheduledReports->bean_implements('ACL')); //test with valid value + self::assertEquals(false, $aorScheduledReports->bean_implements('')); //test with blank value + self::assertEquals(false, $aorScheduledReports->bean_implements('test')); //test with invalid value + self::assertEquals(true, $aorScheduledReports->bean_implements('ACL')); //test with valid value } - public function testshouldRun() + public function testshouldRun(): void { $aorScheduledReports = BeanFactory::newBean('AOR_Scheduled_Reports'); $aorScheduledReports->schedule = " 8 * * * *"; @@ -91,11 +92,11 @@ class AOR_Scheduled_ReportsTest extends SuitePHPUnitFrameworkTestCase //test without a older last_run date $aorScheduledReports->last_run = date("d-m-y H:i:s", mktime(0, 0, 0, 10, 3, 2014)); - $this->assertTrue($aorScheduledReports->shouldRun(new DateTime())); + self::assertTrue($aorScheduledReports->shouldRun(new DateTime())); //test without a current last_run date $aorScheduledReports->last_run = new DateTime(); - $this->assertFalse($aorScheduledReports->shouldRun(new DateTime())); + self::assertFalse($aorScheduledReports->shouldRun(new DateTime())); } } diff --git a/tests/unit/phpunit/modules/AOS_Contracts/AOS_ContractsTest.php b/tests/unit/phpunit/modules/AOS_Contracts/AOS_ContractsTest.php index b0c1862b9..ff7f57bf5 100644 --- a/tests/unit/phpunit/modules/AOS_Contracts/AOS_ContractsTest.php +++ b/tests/unit/phpunit/modules/AOS_Contracts/AOS_ContractsTest.php @@ -13,25 +13,25 @@ class AOS_ContractsTest extends SuitePHPUnitFrameworkTestCase $current_user = BeanFactory::newBean('Users'); } - public function testAOS_Contracts() + public function testAOS_Contracts(): void { // Execute the constructor and check for the Object type and attributes $aosContracts = BeanFactory::newBean('AOS_Contracts'); - $this->assertInstanceOf('AOS_Contracts', $aosContracts); - $this->assertInstanceOf('Basic', $aosContracts); - $this->assertInstanceOf('SugarBean', $aosContracts); + self::assertInstanceOf('AOS_Contracts', $aosContracts); + self::assertInstanceOf('Basic', $aosContracts); + self::assertInstanceOf('SugarBean', $aosContracts); - $this->assertAttributeEquals('AOS_Contracts', 'module_dir', $aosContracts); - $this->assertAttributeEquals('AOS_Contracts', 'object_name', $aosContracts); - $this->assertAttributeEquals('aos_contracts', 'table_name', $aosContracts); - $this->assertAttributeEquals(true, 'new_schema', $aosContracts); - $this->assertAttributeEquals(true, 'disable_row_level_security', $aosContracts); - $this->assertAttributeEquals(true, 'importable', $aosContracts); + self::assertEquals('AOS_Contracts', $aosContracts->module_dir); + self::assertEquals('AOS_Contracts', $aosContracts->object_name); + self::assertEquals('aos_contracts', $aosContracts->table_name); + self::assertEquals(true, $aosContracts->new_schema); + self::assertEquals(true, $aosContracts->disable_row_level_security); + self::assertEquals(true, $aosContracts->importable); - $this->assertTrue(isset($aosContracts->renewal_reminder_date)); + self::assertTrue(isset($aosContracts->renewal_reminder_date)); } - public function testsaveAndDelete() + public function testsaveAndDelete(): void { $aosContracts = BeanFactory::newBean('AOS_Contracts'); $aosContracts->name = 'test'; @@ -39,16 +39,16 @@ class AOS_ContractsTest extends SuitePHPUnitFrameworkTestCase $aosContracts->save(); //test for record ID to verify that record is saved - $this->assertTrue(isset($aosContracts->id)); - $this->assertEquals(36, strlen($aosContracts->id)); + self::assertTrue(isset($aosContracts->id)); + self::assertEquals(36, strlen($aosContracts->id)); //mark the record as deleted and verify that this record cannot be retrieved anymore. $aosContracts->mark_deleted($aosContracts->id); $result = $aosContracts->retrieve($aosContracts->id); - $this->assertEquals(null, $result); + self::assertEquals(null, $result); } - public function testCreateReminderAndCreateLinkAndDeleteCall() + public function testCreateReminderAndCreateLinkAndDeleteCall(): void { $call = new call(); @@ -59,21 +59,21 @@ class AOS_ContractsTest extends SuitePHPUnitFrameworkTestCase $aosContracts->createReminder(); //verify record ID to check that record is saved - $this->assertTrue(isset($aosContracts->call_id)); - $this->assertEquals(36, strlen($aosContracts->call_id)); + self::assertTrue(isset($aosContracts->call_id)); + self::assertEquals(36, strlen($aosContracts->call_id)); //verify the parent_type value set by createReminder() $call->retrieve($aosContracts->call_id); - $this->assertAttributeEquals('AOS_Contracts', 'parent_type', $call); + self::assertEquals('AOS_Contracts', $call->parent_type); //test createLink() and verify the parent_type value $aosContracts->createLink(); $call->retrieve($aosContracts->call_id); - $this->assertAttributeEquals('Accounts', 'parent_type', $call); + self::assertEquals('Accounts', $call->parent_type); //delete the call and verify that this record cannot be retrieved anymore. $aosContracts->deleteCall(); $result = $call->retrieve($aosContracts->call_id); - $this->assertEquals(null, $result); + self::assertEquals(null, $result); } } diff --git a/tests/unit/phpunit/modules/AOS_Invoices/AOS_InvoicesTest.php b/tests/unit/phpunit/modules/AOS_Invoices/AOS_InvoicesTest.php index 594c10902..39156d9c5 100644 --- a/tests/unit/phpunit/modules/AOS_Invoices/AOS_InvoicesTest.php +++ b/tests/unit/phpunit/modules/AOS_Invoices/AOS_InvoicesTest.php @@ -13,23 +13,23 @@ class AOS_InvoicesTest extends SuitePHPUnitFrameworkTestCase $current_user = BeanFactory::newBean('Users'); } - public function testAOS_Invoices() + public function testAOS_Invoices(): void { // Execute the constructor and check for the Object type and attributes $aosInvoices = BeanFactory::newBean('AOS_Invoices'); - $this->assertInstanceOf('AOS_Invoices', $aosInvoices); - $this->assertInstanceOf('Basic', $aosInvoices); - $this->assertInstanceOf('SugarBean', $aosInvoices); + self::assertInstanceOf('AOS_Invoices', $aosInvoices); + self::assertInstanceOf('Basic', $aosInvoices); + self::assertInstanceOf('SugarBean', $aosInvoices); - $this->assertAttributeEquals('AOS_Invoices', 'module_dir', $aosInvoices); - $this->assertAttributeEquals('AOS_Invoices', 'object_name', $aosInvoices); - $this->assertAttributeEquals('aos_invoices', 'table_name', $aosInvoices); - $this->assertAttributeEquals(true, 'new_schema', $aosInvoices); - $this->assertAttributeEquals(true, 'disable_row_level_security', $aosInvoices); - $this->assertAttributeEquals(true, 'importable', $aosInvoices); + self::assertEquals('AOS_Invoices', $aosInvoices->module_dir); + self::assertEquals('AOS_Invoices', $aosInvoices->object_name); + self::assertEquals('aos_invoices', $aosInvoices->table_name); + self::assertEquals(true, $aosInvoices->new_schema); + self::assertEquals(true, $aosInvoices->disable_row_level_security); + self::assertEquals(true, $aosInvoices->importable); } - public function testSaveAndMark_deleted() + public function testSaveAndMark_deleted(): void { $aosInvoices = BeanFactory::newBean('AOS_Invoices'); $aosInvoices->name = 'test'; @@ -37,13 +37,13 @@ class AOS_InvoicesTest extends SuitePHPUnitFrameworkTestCase $aosInvoices->save(); //test for record ID to verify that record is saved - $this->assertTrue(isset($aosInvoices->id)); - $this->assertEquals(36, strlen($aosInvoices->id)); - $this->assertGreaterThan(0, $aosInvoices->number); + self::assertTrue(isset($aosInvoices->id)); + self::assertEquals(36, strlen($aosInvoices->id)); + self::assertGreaterThan(0, $aosInvoices->number); //mark the record as deleted and verify that this record cannot be retrieved anymore. $aosInvoices->mark_deleted($aosInvoices->id); $result = $aosInvoices->retrieve($aosInvoices->id); - $this->assertEquals(null, $result); + self::assertEquals(null, $result); } } diff --git a/tests/unit/phpunit/modules/AOS_Line_Item_Groups/AOS_Line_Item_GroupsTest.php b/tests/unit/phpunit/modules/AOS_Line_Item_Groups/AOS_Line_Item_GroupsTest.php index c1477435e..684b83a31 100644 --- a/tests/unit/phpunit/modules/AOS_Line_Item_Groups/AOS_Line_Item_GroupsTest.php +++ b/tests/unit/phpunit/modules/AOS_Line_Item_Groups/AOS_Line_Item_GroupsTest.php @@ -13,24 +13,24 @@ class AOS_Line_Item_GroupsTest extends SuitePHPUnitFrameworkTestCase $current_user = BeanFactory::newBean('Users'); } - public function testAOS_Line_Item_Groups() + public function testAOS_Line_Item_Groups(): void { // Execute the constructor and check for the Object type and attributes $aosLineItemGroup = BeanFactory::newBean('AOS_Line_Item_Groups'); - $this->assertInstanceOf('AOS_Line_Item_Groups', $aosLineItemGroup); - $this->assertInstanceOf('Basic', $aosLineItemGroup); - $this->assertInstanceOf('SugarBean', $aosLineItemGroup); + self::assertInstanceOf('AOS_Line_Item_Groups', $aosLineItemGroup); + self::assertInstanceOf('Basic', $aosLineItemGroup); + self::assertInstanceOf('SugarBean', $aosLineItemGroup); - $this->assertAttributeEquals('AOS_Line_Item_Groups', 'module_dir', $aosLineItemGroup); - $this->assertAttributeEquals('AOS_Line_Item_Groups', 'object_name', $aosLineItemGroup); - $this->assertAttributeEquals('aos_line_item_groups', 'table_name', $aosLineItemGroup); - $this->assertAttributeEquals(true, 'new_schema', $aosLineItemGroup); - $this->assertAttributeEquals(true, 'disable_row_level_security', $aosLineItemGroup); - $this->assertAttributeEquals(true, 'importable', $aosLineItemGroup); - $this->assertAttributeEquals(false, 'tracker_visibility', $aosLineItemGroup); + self::assertEquals('AOS_Line_Item_Groups', $aosLineItemGroup->module_dir); + self::assertEquals('AOS_Line_Item_Groups', $aosLineItemGroup->object_name); + self::assertEquals('aos_line_item_groups', $aosLineItemGroup->table_name); + self::assertEquals(true, $aosLineItemGroup->new_schema); + self::assertEquals(true, $aosLineItemGroup->disable_row_level_security); + self::assertEquals(true, $aosLineItemGroup->importable); + self::assertEquals(false, $aosLineItemGroup->tracker_visibility); } - public function testsave_groups() + public function testsave_groups(): void { $aosLineItemGroup = BeanFactory::newBean('AOS_Line_Item_Groups'); @@ -56,7 +56,7 @@ class AOS_Line_Item_GroupsTest extends SuitePHPUnitFrameworkTestCase } } - public function testsave() + public function testsave(): void { $aosLineItemGroup = BeanFactory::newBean('AOS_Line_Item_Groups'); $aosLineItemGroup->name = 'test'; @@ -66,12 +66,12 @@ class AOS_Line_Item_GroupsTest extends SuitePHPUnitFrameworkTestCase $aosLineItemGroup->save(); //test for record ID to verify that record is saved - $this->assertTrue(isset($aosLineItemGroup->id)); - $this->assertEquals(36, strlen($aosLineItemGroup->id)); + self::assertTrue(isset($aosLineItemGroup->id)); + self::assertEquals(36, strlen($aosLineItemGroup->id)); //mark the record as deleted and verify that this record cannot be retrieved anymore. $aosLineItemGroup->mark_deleted($aosLineItemGroup->id); $result = $aosLineItemGroup->retrieve($aosLineItemGroup->id); - $this->assertEquals(null, $result); + self::assertEquals(null, $result); } } diff --git a/tests/unit/phpunit/modules/AOS_PDF_Templates/AOS_PDF_TemplatesTest.php b/tests/unit/phpunit/modules/AOS_PDF_Templates/AOS_PDF_TemplatesTest.php index a8f7674ec..84b0a2886 100644 --- a/tests/unit/phpunit/modules/AOS_PDF_Templates/AOS_PDF_TemplatesTest.php +++ b/tests/unit/phpunit/modules/AOS_PDF_Templates/AOS_PDF_TemplatesTest.php @@ -13,19 +13,19 @@ class AOS_PDF_TemplatesTest extends SuitePHPUnitFrameworkTestCase $current_user = BeanFactory::newBean('Users'); } - public function testAOS_PDF_Templates() + public function testAOS_PDF_Templates(): void { // Execute the constructor and check for the Object type and attributes $aosPdfTemplates = BeanFactory::newBean('AOS_PDF_Templates'); - $this->assertInstanceOf('AOS_PDF_Templates', $aosPdfTemplates); - $this->assertInstanceOf('Basic', $aosPdfTemplates); - $this->assertInstanceOf('SugarBean', $aosPdfTemplates); + self::assertInstanceOf('AOS_PDF_Templates', $aosPdfTemplates); + self::assertInstanceOf('Basic', $aosPdfTemplates); + self::assertInstanceOf('SugarBean', $aosPdfTemplates); - $this->assertAttributeEquals('AOS_PDF_Templates', 'module_dir', $aosPdfTemplates); - $this->assertAttributeEquals('AOS_PDF_Templates', 'object_name', $aosPdfTemplates); - $this->assertAttributeEquals('aos_pdf_templates', 'table_name', $aosPdfTemplates); - $this->assertAttributeEquals(true, 'new_schema', $aosPdfTemplates); - $this->assertAttributeEquals(true, 'disable_row_level_security', $aosPdfTemplates); - $this->assertAttributeEquals(true, 'importable', $aosPdfTemplates); + self::assertEquals('AOS_PDF_Templates', $aosPdfTemplates->module_dir); + self::assertEquals('AOS_PDF_Templates', $aosPdfTemplates->object_name); + self::assertEquals('aos_pdf_templates', $aosPdfTemplates->table_name); + self::assertEquals(true, $aosPdfTemplates->new_schema); + self::assertEquals(true, $aosPdfTemplates->disable_row_level_security); + self::assertEquals(true, $aosPdfTemplates->importable); } } diff --git a/tests/unit/phpunit/modules/AOS_Product_Categories/AOS_Product_CategoriesTest.php b/tests/unit/phpunit/modules/AOS_Product_Categories/AOS_Product_CategoriesTest.php index 054961fe3..01360a62f 100644 --- a/tests/unit/phpunit/modules/AOS_Product_Categories/AOS_Product_CategoriesTest.php +++ b/tests/unit/phpunit/modules/AOS_Product_Categories/AOS_Product_CategoriesTest.php @@ -13,23 +13,23 @@ class AOS_Product_CategoriesTest extends SuitePHPUnitFrameworkTestCase $current_user = BeanFactory::newBean('Users'); } - public function testAOS_Product_Categories() + public function testAOS_Product_Categories(): void { // Execute the constructor and check for the Object type and attributes $aosProductCategories = BeanFactory::newBean('AOS_Product_Categories'); - $this->assertInstanceOf('AOS_Product_Categories', $aosProductCategories); - $this->assertInstanceOf('Basic', $aosProductCategories); - $this->assertInstanceOf('SugarBean', $aosProductCategories); + self::assertInstanceOf('AOS_Product_Categories', $aosProductCategories); + self::assertInstanceOf('Basic', $aosProductCategories); + self::assertInstanceOf('SugarBean', $aosProductCategories); - $this->assertAttributeEquals('AOS_Product_Categories', 'module_dir', $aosProductCategories); - $this->assertAttributeEquals('AOS_Product_Categories', 'object_name', $aosProductCategories); - $this->assertAttributeEquals('aos_product_categories', 'table_name', $aosProductCategories); - $this->assertAttributeEquals(true, 'new_schema', $aosProductCategories); - $this->assertAttributeEquals(true, 'disable_row_level_security', $aosProductCategories); - $this->assertAttributeEquals(true, 'importable', $aosProductCategories); + self::assertEquals('AOS_Product_Categories', $aosProductCategories->module_dir); + self::assertEquals('AOS_Product_Categories', $aosProductCategories->object_name); + self::assertEquals('aos_product_categories', $aosProductCategories->table_name); + self::assertEquals(true, $aosProductCategories->new_schema); + self::assertEquals(true, $aosProductCategories->disable_row_level_security); + self::assertEquals(true, $aosProductCategories->importable); } - public function testsave() + public function testsave(): void { $aosProductCategories = BeanFactory::newBean('AOS_Product_Categories'); $aosProductCategories->name = 'test'; @@ -38,12 +38,12 @@ class AOS_Product_CategoriesTest extends SuitePHPUnitFrameworkTestCase $aosProductCategories->save(); //test for record ID to verify that record is saved - $this->assertTrue(isset($aosProductCategories->id)); - $this->assertEquals(36, strlen($aosProductCategories->id)); + self::assertTrue(isset($aosProductCategories->id)); + self::assertEquals(36, strlen($aosProductCategories->id)); //mark the record as deleted and verify that this record cannot be retrieved anymore. $aosProductCategories->mark_deleted($aosProductCategories->id); $result = $aosProductCategories->retrieve($aosProductCategories->id); - $this->assertEquals(null, $result); + self::assertEquals(null, $result); } } diff --git a/tests/unit/phpunit/modules/AOS_Products/AOS_ProductsTest.php b/tests/unit/phpunit/modules/AOS_Products/AOS_ProductsTest.php index 6fce771a5..ea95a0068 100644 --- a/tests/unit/phpunit/modules/AOS_Products/AOS_ProductsTest.php +++ b/tests/unit/phpunit/modules/AOS_Products/AOS_ProductsTest.php @@ -13,23 +13,23 @@ class AOS_ProductsTest extends SuitePHPUnitFrameworkTestCase $current_user = BeanFactory::newBean('Users'); } - public function testAOS_Products() + public function testAOS_Products(): void { // Execute the constructor and check for the Object type and attributes $aosProducts = BeanFactory::newBean('AOS_Products'); - $this->assertInstanceOf('AOS_Products', $aosProducts); - $this->assertInstanceOf('Basic', $aosProducts); - $this->assertInstanceOf('SugarBean', $aosProducts); + self::assertInstanceOf('AOS_Products', $aosProducts); + self::assertInstanceOf('Basic', $aosProducts); + self::assertInstanceOf('SugarBean', $aosProducts); - $this->assertAttributeEquals('AOS_Products', 'module_dir', $aosProducts); - $this->assertAttributeEquals('AOS_Products', 'object_name', $aosProducts); - $this->assertAttributeEquals('aos_products', 'table_name', $aosProducts); - $this->assertAttributeEquals(true, 'new_schema', $aosProducts); - $this->assertAttributeEquals(true, 'disable_row_level_security', $aosProducts); - $this->assertAttributeEquals(true, 'importable', $aosProducts); + self::assertEquals('AOS_Products', $aosProducts->module_dir); + self::assertEquals('AOS_Products', $aosProducts->object_name); + self::assertEquals('aos_products', $aosProducts->table_name); + self::assertEquals(true, $aosProducts->new_schema); + self::assertEquals(true, $aosProducts->disable_row_level_security); + self::assertEquals(true, $aosProducts->importable); } - public function testsave() + public function testsave(): void { $aosProducts = BeanFactory::newBean('AOS_Products'); @@ -41,17 +41,17 @@ class AOS_ProductsTest extends SuitePHPUnitFrameworkTestCase $aosProducts->save(); //test for record ID to verify that record is saved - $this->assertTrue(isset($aosProducts->id)); - $this->assertEquals(36, strlen($aosProducts->id)); - $this->assertEquals('', $aosProducts->product_image); + self::assertTrue(isset($aosProducts->id)); + self::assertEquals(36, strlen($aosProducts->id)); + self::assertEquals('', $aosProducts->product_image); //mark the record as deleted and verify that this record cannot be retrieved anymore. $aosProducts->mark_deleted($aosProducts->id); $result = $aosProducts->retrieve($aosProducts->id); - $this->assertEquals(null, $result); + self::assertEquals(null, $result); } - public function testgetCustomersPurchasedProductsQuery() + public function testgetCustomersPurchasedProductsQuery(): void { self::markTestIncomplete('environment dependency'); @@ -80,6 +80,6 @@ class AOS_ProductsTest extends SuitePHPUnitFrameworkTestCase GROUP BY accounts.id ) AS aos_quotes"; $actual = $aosProducts->getCustomersPurchasedProductsQuery(); - $this->assertSame(trim($expected), trim($actual)); + self::assertSame(trim($expected), trim($actual)); } } diff --git a/tests/unit/phpunit/modules/AOS_Products_Quotes/AOS_Products_QuotesTest.php b/tests/unit/phpunit/modules/AOS_Products_Quotes/AOS_Products_QuotesTest.php index fb8b8a522..e16249090 100644 --- a/tests/unit/phpunit/modules/AOS_Products_Quotes/AOS_Products_QuotesTest.php +++ b/tests/unit/phpunit/modules/AOS_Products_Quotes/AOS_Products_QuotesTest.php @@ -13,7 +13,7 @@ class AOS_Products_QuotesTest extends SuitePHPUnitFrameworkTestCase $current_user = BeanFactory::newBean('Users'); } - public function testsave() + public function testsave(): void { $aosProductsQuotes = BeanFactory::newBean('AOS_Products_Quotes'); @@ -24,16 +24,16 @@ class AOS_Products_QuotesTest extends SuitePHPUnitFrameworkTestCase $aosProductsQuotes->save(); //test for record ID to verify that record is saved - $this->assertTrue(isset($aosProductsQuotes->id)); - $this->assertEquals(36, strlen($aosProductsQuotes->id)); + self::assertTrue(isset($aosProductsQuotes->id)); + self::assertEquals(36, strlen($aosProductsQuotes->id)); //mark the record as deleted and verify that this record cannot be retrieved anymore. $aosProductsQuotes->mark_deleted($aosProductsQuotes->id); $result = $aosProductsQuotes->retrieve($aosProductsQuotes->id); - $this->assertEquals(null, $result); + self::assertEquals(null, $result); } - public function testsave_lines() + public function testsave_lines(): void { DBManagerFactory::getInstance()->query('DELETE FROM aos_products_quotes'); @@ -54,26 +54,26 @@ class AOS_Products_QuotesTest extends SuitePHPUnitFrameworkTestCase //get the linked beans and verify if records created $product_quote_lines = $aosQuote->get_linked_beans('aos_products_quotes', $aosQuote->object_name); - $this->assertEquals(count($post_data['name']), count($product_quote_lines)); + self::assertCount(count($post_data['name']), $product_quote_lines); } - public function testAOS_Products_Quotes() + public function testAOS_Products_Quotes(): void { // Execute the constructor and check for the Object type and attributes $aosProductsQuotes = BeanFactory::newBean('AOS_Products_Quotes'); - $this->assertInstanceOf('AOS_Products_Quotes', $aosProductsQuotes); - $this->assertInstanceOf('Basic', $aosProductsQuotes); - $this->assertInstanceOf('SugarBean', $aosProductsQuotes); + self::assertInstanceOf('AOS_Products_Quotes', $aosProductsQuotes); + self::assertInstanceOf('Basic', $aosProductsQuotes); + self::assertInstanceOf('SugarBean', $aosProductsQuotes); - $this->assertAttributeEquals('AOS_Products_Quotes', 'module_dir', $aosProductsQuotes); - $this->assertAttributeEquals('AOS_Products_Quotes', 'object_name', $aosProductsQuotes); - $this->assertAttributeEquals('aos_products_quotes', 'table_name', $aosProductsQuotes); - $this->assertAttributeEquals(true, 'new_schema', $aosProductsQuotes); - $this->assertAttributeEquals(true, 'disable_row_level_security', $aosProductsQuotes); - $this->assertAttributeEquals(true, 'importable', $aosProductsQuotes); + self::assertEquals('AOS_Products_Quotes', $aosProductsQuotes->module_dir); + self::assertEquals('AOS_Products_Quotes', $aosProductsQuotes->object_name); + self::assertEquals('aos_products_quotes', $aosProductsQuotes->table_name); + self::assertEquals(true, $aosProductsQuotes->new_schema); + self::assertEquals(true, $aosProductsQuotes->disable_row_level_security); + self::assertEquals(true, $aosProductsQuotes->importable); } - public function testmark_lines_deleted() + public function testmark_lines_deleted(): void { $aosProductsQuotes = BeanFactory::newBean('AOS_Products_Quotes'); @@ -95,6 +95,6 @@ class AOS_Products_QuotesTest extends SuitePHPUnitFrameworkTestCase $product_quote_lines = $aosQuote->get_linked_beans('aos_products_quotes', $aosQuote->object_name); $actual = count($product_quote_lines); - $this->assertLessThanOrEqual($expected, $actual); + self::assertLessThanOrEqual($expected, $actual); } } diff --git a/tests/unit/phpunit/modules/AOS_Quotes/AOS_QuotesTest.php b/tests/unit/phpunit/modules/AOS_Quotes/AOS_QuotesTest.php index 644da6af0..9dbb763f9 100644 --- a/tests/unit/phpunit/modules/AOS_Quotes/AOS_QuotesTest.php +++ b/tests/unit/phpunit/modules/AOS_Quotes/AOS_QuotesTest.php @@ -13,24 +13,24 @@ class AOS_QuotesTest extends SuitePHPUnitFrameworkTestCase $current_user = BeanFactory::newBean('Users'); } - public function testAOS_Quotes() + public function testAOS_Quotes(): void { // Execute the constructor and check for the Object type and attributes $aosQuotes = BeanFactory::newBean('AOS_Quotes'); - $this->assertInstanceOf('AOS_Quotes', $aosQuotes); - $this->assertInstanceOf('Basic', $aosQuotes); - $this->assertInstanceOf('SugarBean', $aosQuotes); + self::assertInstanceOf('AOS_Quotes', $aosQuotes); + self::assertInstanceOf('Basic', $aosQuotes); + self::assertInstanceOf('SugarBean', $aosQuotes); - $this->assertAttributeEquals('AOS_Quotes', 'module_dir', $aosQuotes); - $this->assertAttributeEquals('AOS_Quotes', 'object_name', $aosQuotes); - $this->assertAttributeEquals('aos_quotes', 'table_name', $aosQuotes); - $this->assertAttributeEquals(true, 'new_schema', $aosQuotes); - $this->assertAttributeEquals(true, 'disable_row_level_security', $aosQuotes); - $this->assertAttributeEquals(true, 'importable', $aosQuotes); - $this->assertAttributeEquals(true, 'lineItems', $aosQuotes); + self::assertEquals('AOS_Quotes', $aosQuotes->module_dir); + self::assertEquals('AOS_Quotes', $aosQuotes->object_name); + self::assertEquals('aos_quotes', $aosQuotes->table_name); + self::assertEquals(true, $aosQuotes->new_schema); + self::assertEquals(true, $aosQuotes->disable_row_level_security); + self::assertEquals(true, $aosQuotes->importable); + self::assertEquals(true, $aosQuotes->lineItems); } - public function testSaveAndMark_deleted() + public function testSaveAndMark_deleted(): void { $aosQuotes = BeanFactory::newBean('AOS_Quotes'); @@ -41,12 +41,12 @@ class AOS_QuotesTest extends SuitePHPUnitFrameworkTestCase $aosQuotes->save(); //test for record ID to verify that record is saved - $this->assertTrue(isset($aosQuotes->id)); - $this->assertEquals(36, strlen($aosQuotes->id)); + self::assertTrue(isset($aosQuotes->id)); + self::assertEquals(36, strlen($aosQuotes->id)); //mark the record as deleted and verify that this record cannot be retrieved anymore. $aosQuotes->mark_deleted($aosQuotes->id); $result = $aosQuotes->retrieve($aosQuotes->id); - $this->assertEquals(null, $result); + self::assertEquals(null, $result); } } diff --git a/tests/unit/phpunit/modules/AOW_Actions/AOW_ActionTest.php b/tests/unit/phpunit/modules/AOW_Actions/AOW_ActionTest.php index 6ed1511c2..306600cf7 100644 --- a/tests/unit/phpunit/modules/AOW_Actions/AOW_ActionTest.php +++ b/tests/unit/phpunit/modules/AOW_Actions/AOW_ActionTest.php @@ -13,24 +13,24 @@ class AOW_ActionTest extends SuitePHPUnitFrameworkTestCase $current_user = BeanFactory::newBean('Users'); } - public function testAOW_Action() + public function testAOW_Action(): void { // Execute the constructor and check for the Object type and attributes $aowAction = BeanFactory::newBean('AOW_Actions'); - $this->assertInstanceOf('AOW_Action', $aowAction); - $this->assertInstanceOf('Basic', $aowAction); - $this->assertInstanceOf('SugarBean', $aowAction); + self::assertInstanceOf('AOW_Action', $aowAction); + self::assertInstanceOf('Basic', $aowAction); + self::assertInstanceOf('SugarBean', $aowAction); - $this->assertAttributeEquals('AOW_Actions', 'module_dir', $aowAction); - $this->assertAttributeEquals('AOW_Action', 'object_name', $aowAction); - $this->assertAttributeEquals('aow_actions', 'table_name', $aowAction); - $this->assertAttributeEquals(true, 'new_schema', $aowAction); - $this->assertAttributeEquals(true, 'disable_row_level_security', $aowAction); - $this->assertAttributeEquals(false, 'importable', $aowAction); - $this->assertAttributeEquals(false, 'tracker_visibility', $aowAction); + self::assertEquals('AOW_Actions', $aowAction->module_dir); + self::assertEquals('AOW_Action', $aowAction->object_name); + self::assertEquals('aow_actions', $aowAction->table_name); + self::assertEquals(true, $aowAction->new_schema); + self::assertEquals(true, $aowAction->disable_row_level_security); + self::assertEquals(false, $aowAction->importable); + self::assertEquals(false, $aowAction->tracker_visibility); } - public function testsave_lines() + public function testsave_lines(): void { $aowAction = BeanFactory::newBean('AOW_Actions'); @@ -48,7 +48,7 @@ class AOW_ActionTest extends SuitePHPUnitFrameworkTestCase //get the linked beans and verify if records created $aow_actions = $aowWorkFlow->get_linked_beans('aow_actions', $aowWorkFlow->object_name); - $this->assertEquals(count($post_data['action']), count($aow_actions)); + self::assertCount(count($post_data['action']), $aow_actions); //cleanup afterwards foreach ($aow_actions as $lineItem) { @@ -56,11 +56,11 @@ class AOW_ActionTest extends SuitePHPUnitFrameworkTestCase } } - public function testbean_implements() + public function testbean_implements(): void { $aowAction = BeanFactory::newBean('AOW_Actions'); - $this->assertEquals(false, $aowAction->bean_implements('')); //test with blank value - $this->assertEquals(false, $aowAction->bean_implements('test')); //test with invalid value - $this->assertEquals(false, $aowAction->bean_implements('ACL')); //test with valid value + self::assertEquals(false, $aowAction->bean_implements('')); //test with blank value + self::assertEquals(false, $aowAction->bean_implements('test')); //test with invalid value + self::assertEquals(false, $aowAction->bean_implements('ACL')); //test with valid value } } diff --git a/tests/unit/phpunit/modules/AOW_Conditions/AOW_ConditionTest.php b/tests/unit/phpunit/modules/AOW_Conditions/AOW_ConditionTest.php index abc1fdac2..0b536e02b 100644 --- a/tests/unit/phpunit/modules/AOW_Conditions/AOW_ConditionTest.php +++ b/tests/unit/phpunit/modules/AOW_Conditions/AOW_ConditionTest.php @@ -13,32 +13,32 @@ class AOW_ConditionTest extends SuitePHPUnitFrameworkTestCase $current_user = BeanFactory::newBean('Users'); } - public function testAOW_Condition() + public function testAOW_Condition(): void { // Execute the constructor and check for the Object type and attributes $aowCondition = BeanFactory::newBean('AOW_Conditions'); - $this->assertInstanceOf('AOW_Condition', $aowCondition); - $this->assertInstanceOf('Basic', $aowCondition); - $this->assertInstanceOf('SugarBean', $aowCondition); + self::assertInstanceOf('AOW_Condition', $aowCondition); + self::assertInstanceOf('Basic', $aowCondition); + self::assertInstanceOf('SugarBean', $aowCondition); - $this->assertAttributeEquals('AOW_Conditions', 'module_dir', $aowCondition); - $this->assertAttributeEquals('AOW_Condition', 'object_name', $aowCondition); - $this->assertAttributeEquals('aow_conditions', 'table_name', $aowCondition); - $this->assertAttributeEquals(true, 'new_schema', $aowCondition); - $this->assertAttributeEquals(true, 'disable_row_level_security', $aowCondition); - $this->assertAttributeEquals(false, 'importable', $aowCondition); - $this->assertAttributeEquals(false, 'tracker_visibility', $aowCondition); + self::assertEquals('AOW_Conditions', $aowCondition->module_dir); + self::assertEquals('AOW_Condition', $aowCondition->object_name); + self::assertEquals('aow_conditions', $aowCondition->table_name); + self::assertEquals(true, $aowCondition->new_schema); + self::assertEquals(true, $aowCondition->disable_row_level_security); + self::assertEquals(false, $aowCondition->importable); + self::assertEquals(false, $aowCondition->tracker_visibility); } - public function testbean_implements() + public function testbean_implements(): void { $aowCondition = BeanFactory::newBean('AOW_Conditions'); - $this->assertEquals(false, $aowCondition->bean_implements('')); //test with blank value - $this->assertEquals(false, $aowCondition->bean_implements('test')); //test with invalid value - $this->assertEquals(false, $aowCondition->bean_implements('ACL')); //test with valid value + self::assertEquals(false, $aowCondition->bean_implements('')); //test with blank value + self::assertEquals(false, $aowCondition->bean_implements('test')); //test with invalid value + self::assertEquals(false, $aowCondition->bean_implements('ACL')); //test with valid value } - public function testsave_lines() + public function testsave_lines(): void { $aowCondition = BeanFactory::newBean('AOW_Conditions'); @@ -58,7 +58,7 @@ class AOW_ConditionTest extends SuitePHPUnitFrameworkTestCase //get the linked beans and verify if records created $aow_conditions = $aowWorkFlow->get_linked_beans('aow_conditions', $aowWorkFlow->object_name); - $this->assertEquals(count($post_data['field']), count($aow_conditions)); + self::assertCount(count($post_data['field']), $aow_conditions); //cleanup afterwards foreach ($aow_conditions as $lineItem) { diff --git a/tests/unit/phpunit/modules/AOW_Processed/AOW_ProcessedTest.php b/tests/unit/phpunit/modules/AOW_Processed/AOW_ProcessedTest.php index 37b7dc64d..225049cfb 100644 --- a/tests/unit/phpunit/modules/AOW_Processed/AOW_ProcessedTest.php +++ b/tests/unit/phpunit/modules/AOW_Processed/AOW_ProcessedTest.php @@ -13,27 +13,27 @@ class AOW_ProcessedTest extends SuitePHPUnitFrameworkTestCase $current_user = BeanFactory::newBean('Users'); } - public function testAOW_Processed() + public function testAOW_Processed(): void { // Execute the constructor and check for the Object type and attributes $aowProcessed = BeanFactory::newBean('AOW_Processed'); - $this->assertInstanceOf('AOW_Processed', $aowProcessed); - $this->assertInstanceOf('Basic', $aowProcessed); - $this->assertInstanceOf('SugarBean', $aowProcessed); + self::assertInstanceOf('AOW_Processed', $aowProcessed); + self::assertInstanceOf('Basic', $aowProcessed); + self::assertInstanceOf('SugarBean', $aowProcessed); - $this->assertAttributeEquals('AOW_Processed', 'module_dir', $aowProcessed); - $this->assertAttributeEquals('AOW_Processed', 'object_name', $aowProcessed); - $this->assertAttributeEquals('aow_processed', 'table_name', $aowProcessed); - $this->assertAttributeEquals(true, 'new_schema', $aowProcessed); - $this->assertAttributeEquals(true, 'disable_row_level_security', $aowProcessed); - $this->assertAttributeEquals(false, 'importable', $aowProcessed); + self::assertEquals('AOW_Processed', $aowProcessed->module_dir); + self::assertEquals('AOW_Processed', $aowProcessed->object_name); + self::assertEquals('aow_processed', $aowProcessed->table_name); + self::assertEquals(true, $aowProcessed->new_schema); + self::assertEquals(true, $aowProcessed->disable_row_level_security); + self::assertEquals(false, $aowProcessed->importable); } - public function testbean_implements() + public function testbean_implements(): void { $aowProcessed = BeanFactory::newBean('AOW_Processed'); - $this->assertEquals(false, $aowProcessed->bean_implements('')); //test with blank value - $this->assertEquals(false, $aowProcessed->bean_implements('test')); //test with invalid value - $this->assertEquals(true, $aowProcessed->bean_implements('ACL')); //test with valid value + self::assertEquals(false, $aowProcessed->bean_implements('')); //test with blank value + self::assertEquals(false, $aowProcessed->bean_implements('test')); //test with invalid value + self::assertEquals(true, $aowProcessed->bean_implements('ACL')); //test with valid value } } diff --git a/tests/unit/phpunit/modules/AOW_WorkFlow/AOW_WorkFlowTest.php b/tests/unit/phpunit/modules/AOW_WorkFlow/AOW_WorkFlowTest.php index 1597b8ea8..aa0b4ef43 100644 --- a/tests/unit/phpunit/modules/AOW_WorkFlow/AOW_WorkFlowTest.php +++ b/tests/unit/phpunit/modules/AOW_WorkFlow/AOW_WorkFlowTest.php @@ -13,31 +13,31 @@ class AOW_WorkFlowTest extends SuitePHPUnitFrameworkTestCase $current_user = BeanFactory::newBean('Users'); } - public function testAOW_WorkFlow() + public function testAOW_WorkFlow(): void { // Execute the constructor and check for the Object type and attributes $aowWorkFlow = BeanFactory::newBean('AOW_WorkFlow'); - $this->assertInstanceOf('AOW_WorkFlow', $aowWorkFlow); - $this->assertInstanceOf('Basic', $aowWorkFlow); - $this->assertInstanceOf('SugarBean', $aowWorkFlow); + self::assertInstanceOf('AOW_WorkFlow', $aowWorkFlow); + self::assertInstanceOf('Basic', $aowWorkFlow); + self::assertInstanceOf('SugarBean', $aowWorkFlow); - $this->assertAttributeEquals('AOW_WorkFlow', 'module_dir', $aowWorkFlow); - $this->assertAttributeEquals('AOW_WorkFlow', 'object_name', $aowWorkFlow); - $this->assertAttributeEquals('aow_workflow', 'table_name', $aowWorkFlow); - $this->assertAttributeEquals(true, 'new_schema', $aowWorkFlow); - $this->assertAttributeEquals(true, 'disable_row_level_security', $aowWorkFlow); - $this->assertAttributeEquals(false, 'importable', $aowWorkFlow); + self::assertEquals('AOW_WorkFlow', $aowWorkFlow->module_dir); + self::assertEquals('AOW_WorkFlow', $aowWorkFlow->object_name); + self::assertEquals('aow_workflow', $aowWorkFlow->table_name); + self::assertEquals(true, $aowWorkFlow->new_schema); + self::assertEquals(true, $aowWorkFlow->disable_row_level_security); + self::assertEquals(false, $aowWorkFlow->importable); } - public function testbean_implements() + public function testbean_implements(): void { $aowWorkFlow = BeanFactory::newBean('AOW_WorkFlow'); - $this->assertEquals(false, $aowWorkFlow->bean_implements('')); //test with blank value - $this->assertEquals(false, $aowWorkFlow->bean_implements('test')); //test with invalid value - $this->assertEquals(true, $aowWorkFlow->bean_implements('ACL')); //test with valid value + self::assertEquals(false, $aowWorkFlow->bean_implements('')); //test with blank value + self::assertEquals(false, $aowWorkFlow->bean_implements('test')); //test with invalid value + self::assertEquals(true, $aowWorkFlow->bean_implements('ACL')); //test with valid value } - public function testmark_delete_related() + public function testmark_delete_related(): void { // Create a workflow and a related condition $aowWorkFlow = BeanFactory::newBean('AOW_WorkFlow'); @@ -50,20 +50,20 @@ class AOW_WorkFlowTest extends SuitePHPUnitFrameworkTestCase $condition->save(); $linked = $aowWorkFlow->get_linked_beans('aow_conditions'); - $this->assertCount(1, $linked); + self::assertCount(1, $linked); $conditionID = $linked[0]->id; // Deleting the workflow should delete also the condition BeanFactory::unregisterBean('AOW_Conditions', $conditionID); $cond = BeanFactory::getBean('AOW_Conditions', $conditionID); - $this->assertNotEmpty($cond); + self::assertNotEmpty($cond); $aowWorkFlow->mark_deleted($aowWorkFlow->id); BeanFactory::unregisterBean('AOW_Conditions', $conditionID); $cond = BeanFactory::getBean('AOW_Conditions', $conditionID); - $this->assertEmpty($cond); + self::assertEmpty($cond); } - public function testsave() + public function testsave(): void { $aowWorkFlow = BeanFactory::newBean('AOW_WorkFlow'); @@ -73,73 +73,71 @@ class AOW_WorkFlowTest extends SuitePHPUnitFrameworkTestCase $aowWorkFlow->save(); //test for record ID to verify that record is saved - $this->assertTrue(isset($aowWorkFlow->id)); - $this->assertEquals(36, strlen($aowWorkFlow->id)); + self::assertTrue(isset($aowWorkFlow->id)); + self::assertEquals(36, strlen($aowWorkFlow->id)); //mark the record as deleted and verify that this record cannot be retrieved anymore. $aowWorkFlow->mark_deleted($aowWorkFlow->id); $result = $aowWorkFlow->retrieve($aowWorkFlow->id); - $this->assertEquals(null, $result); + self::assertEquals(null, $result); } - public function testload_flow_beans() + public function testload_flow_beans(): void { $aowWorkFlow = BeanFactory::newBean('AOW_WorkFlow'); // Execute the method and test that it works and doesn't throw an exception. try { $aowWorkFlow->load_flow_beans(); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } } - public function testrun_flows() + public function testrun_flows(): void { - $aowWorkFlow = BeanFactory::newBean('AOW_WorkFlow'); - - $result = $aowWorkFlow->run_flows(); - $this->assertTrue($result); + $result = BeanFactory::newBean('AOW_WorkFlow')->run_flows(); + self::assertTrue($result); } - public function testrun_flow() + public function testrun_flow(): void { $aowWorkFlow = BeanFactory::newBean('AOW_WorkFlow'); // Execute the method and test that it works and doesn't throw an exception. try { $aowWorkFlow->run_flow(); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } } - public function testrun_bean_flows() + public function testrun_bean_flows(): void { $aowWorkFlow = BeanFactory::newBean('AOW_WorkFlow'); //test with different modules. it always returns true $result = $aowWorkFlow->run_bean_flows(BeanFactory::newBean('AOS_Quotes')); - $this->assertTrue($result); + self::assertTrue($result); $result = $aowWorkFlow->run_bean_flows(BeanFactory::newBean('Calls')); - $this->assertTrue($result); + self::assertTrue($result); } - public function testget_flow_beans() + public function testget_flow_beans(): void { $aowWorkFlow = BeanFactory::newBean('AOW_WorkFlow'); //test for AOS_Quotes. it will return null as no test data is available $aowWorkFlow->flow_module = 'AOS_Quotes'; $result = $aowWorkFlow->get_flow_beans(); - $this->assertGreaterThanOrEqual(0, count((array)$result)); + self::assertGreaterThanOrEqual(0, count((array)$result)); } - public function testbuild_flow_query_join() + public function testbuild_flow_query_join(): void { $aowWorkFlow = BeanFactory::newBean('AOW_WorkFlow'); $query = array(); @@ -147,7 +145,7 @@ class AOW_WorkFlowTest extends SuitePHPUnitFrameworkTestCase //test with type custom $expected = array('join' => array('c' => 'LEFT JOIN calls_cstm c ON calls.id = c.id_c ')); $result = $aowWorkFlow->build_flow_custom_query_join('calls', 'c', BeanFactory::newBean('Calls'), array()); - $this->assertSame($expected, $result); + self::assertSame($expected, $result); //test with type relationship $expected = array( @@ -155,17 +153,17 @@ class AOW_WorkFlowTest extends SuitePHPUnitFrameworkTestCase 'select' => array("aos_products_quotes.id AS 'aos_products_quotes_id'"), ); $result = $aowWorkFlow->build_flow_relationship_query_join('aos_products_quotes', BeanFactory::newBean('AOS_Quotes'), array()); - $this->assertSame($expected, $result); + self::assertSame($expected, $result); } - public function testbuild_flow_query_where() + public function testbuild_flow_query_where(): void { $aowWorkFlow = BeanFactory::newBean('AOW_WorkFlow'); //test without presetting required object attributes $expected = array(); $query = $aowWorkFlow->build_flow_query_where(); - $this->assertSame($expected, $query); + self::assertSame($expected, $query); //test with module required attributes set $aowWorkFlow->id = '1'; @@ -175,7 +173,7 @@ class AOW_WorkFlowTest extends SuitePHPUnitFrameworkTestCase 'calls.deleted = 0 ', ), ); $query = $aowWorkFlow->build_flow_query_where(); - $this->assertSame($expected, $query); + self::assertSame($expected, $query); //test with flow_run_on and multiple_runs attributes set $expected = array( @@ -184,10 +182,10 @@ class AOW_WorkFlowTest extends SuitePHPUnitFrameworkTestCase $aowWorkFlow->flow_run_on = 'New_Records'; $aowWorkFlow->multiple_runs = 1; $query = $aowWorkFlow->build_flow_query_where(); - $this->assertSame($expected, $query); + self::assertSame($expected, $query); } - public function testbuild_query_where() + public function testbuild_query_where(): void { self::markTestIncomplete('[PHPUnit_Framework_Exception] unserialize(): Error at offset 0 of 5 bytes'); $aowWorkFlow = BeanFactory::newBean('AOW_WorkFlow'); @@ -207,7 +205,7 @@ class AOW_WorkFlowTest extends SuitePHPUnitFrameworkTestCase 'where' => array(".name LIKE CONCAT('%', 'testval' ,'%')"), ); $query = $aowWorkFlow->build_query_where($aowCondition, $call); - $this->assertEquals($expected, $query); + self::assertEquals($expected, $query); //test for starts with operator $aowCondition->operator = 'Starts_With'; @@ -217,7 +215,7 @@ class AOW_WorkFlowTest extends SuitePHPUnitFrameworkTestCase 'where' => array(".name LIKE CONCAT('testval' ,'%')"), ); $query = $aowWorkFlow->build_query_where($aowCondition, $call); - $this->assertEquals($expected, $query); + self::assertEquals($expected, $query); //test for Equal_To operator $aowCondition->operator = 'Equal_To'; @@ -227,7 +225,7 @@ class AOW_WorkFlowTest extends SuitePHPUnitFrameworkTestCase 'where' => array(".name = 'testval'"), ); $query = $aowWorkFlow->build_query_where($aowCondition, $call); - $this->assertEquals($expected, $query); + self::assertEquals($expected, $query); //test with value type Date $aowCondition->operator = 'Equal_To'; @@ -239,7 +237,7 @@ class AOW_WorkFlowTest extends SuitePHPUnitFrameworkTestCase $query = $aowWorkFlow->build_query_where($aowCondition, $call); - $this->assertEquals($expected, $query); + self::assertEquals($expected, $query); //test with value type Field $aowCondition->operator = 'Equal_To'; @@ -250,10 +248,10 @@ class AOW_WorkFlowTest extends SuitePHPUnitFrameworkTestCase ); $query = $aowWorkFlow->build_query_where($aowCondition, $call); - $this->assertEquals($expected, $query); + self::assertEquals($expected, $query); } - public function testcheck_valid_bean() + public function testcheck_valid_bean(): void { $aowWorkFlow = BeanFactory::newBean('AOW_WorkFlow'); $aowWorkFlow->flow_run_on = 'New_Records'; @@ -261,46 +259,46 @@ class AOW_WorkFlowTest extends SuitePHPUnitFrameworkTestCase $aosQuotes = BeanFactory::newBean('AOS_Quotes'); $result = $aowWorkFlow->check_valid_bean($aosQuotes); - $this->assertTrue($result); + self::assertTrue($result); } - public function testcompare_condition() + public function testcompare_condition(): void { $aowWorkFlow = BeanFactory::newBean('AOW_WorkFlow'); //execute the method and verify that it returns valid values for all operators - $this->assertTrue($aowWorkFlow->compare_condition(1, 1)); - $this->assertTrue($aowWorkFlow->compare_condition(1, 2, 'Not_Equal_To')); - $this->assertTrue($aowWorkFlow->compare_condition(2, 1, 'Greater_Than')); - $this->assertTrue($aowWorkFlow->compare_condition(1, 2, 'Less_Than')); - $this->assertTrue($aowWorkFlow->compare_condition(5, 4, 'Greater_Than_or_Equal_To')); - $this->assertTrue($aowWorkFlow->compare_condition(2, 3, 'Less_Than_or_Equal_To')); - $this->assertTrue($aowWorkFlow->compare_condition('', '', 'is_null')); - $this->assertTrue($aowWorkFlow->compare_condition('test2', array('test1', 'test2'), 'One_of')); - $this->assertTrue($aowWorkFlow->compare_condition('test', array('test1', 'test2'), 'Not_One_of')); + self::assertTrue($aowWorkFlow->compare_condition(1, 1)); + self::assertTrue($aowWorkFlow->compare_condition(1, 2, 'Not_Equal_To')); + self::assertTrue($aowWorkFlow->compare_condition(2, 1, 'Greater_Than')); + self::assertTrue($aowWorkFlow->compare_condition(1, 2, 'Less_Than')); + self::assertTrue($aowWorkFlow->compare_condition(5, 4, 'Greater_Than_or_Equal_To')); + self::assertTrue($aowWorkFlow->compare_condition(2, 3, 'Less_Than_or_Equal_To')); + self::assertTrue($aowWorkFlow->compare_condition('', '', 'is_null')); + self::assertTrue($aowWorkFlow->compare_condition('test2', array('test1', 'test2'), 'One_of')); + self::assertTrue($aowWorkFlow->compare_condition('test', array('test1', 'test2'), 'Not_One_of')); //These do not return bool but 'strpos' result //$this->assertNotFalse($aowWorkFlow->compare_condition('test1', 'test', 'Contains')); - $this->assertEquals(0, $aowWorkFlow->compare_condition('test1', 'test', 'Contains')); + self::assertEquals(0, $aowWorkFlow->compare_condition('test1', 'test', 'Contains')); //$this->assertNotFalse($aowWorkFlow->compare_condition('test1', 'test', 'Starts_With')); - $this->assertEquals(0, $aowWorkFlow->compare_condition('test1', 'test', 'Starts_With')); + self::assertEquals(0, $aowWorkFlow->compare_condition('test1', 'test', 'Starts_With')); //$this->assertNotFalse($aowWorkFlow->compare_condition('test1', '1', 'Ends_With')); - $this->assertEquals(4, $aowWorkFlow->compare_condition('test1', '1', 'Ends_With')); + self::assertEquals(4, $aowWorkFlow->compare_condition('test1', '1', 'Ends_With')); } - public function testcheck_in_group() + public function testcheck_in_group(): void { $aowWorkFlow = BeanFactory::newBean('AOW_WorkFlow'); //test with two different modules - $this->assertFalse($aowWorkFlow->check_in_group(1, 'Users', 1)); - $this->assertFalse($aowWorkFlow->check_in_group(1, 'Calls', 1)); + self::assertFalse($aowWorkFlow->check_in_group(1, 'Users', 1)); + self::assertFalse($aowWorkFlow->check_in_group(1, 'Calls', 1)); } - public function testrun_actions() + public function testrun_actions(): void { $aowWorkFlow = BeanFactory::newBean('AOW_WorkFlow'); @@ -318,12 +316,12 @@ class AOW_WorkFlowTest extends SuitePHPUnitFrameworkTestCase $processed->retrieve_by_string_fields(array('aow_workflow_id' => 1, 'parent_id' => 1)); //test for record ID to verify that record is saved - $this->assertTrue(isset($processed->id)); - $this->assertEquals(36, strlen($processed->id)); + self::assertTrue(isset($processed->id)); + self::assertEquals(36, strlen($processed->id)); //mark the record as deleted and verify that this record cannot be retrieved anymore. $processed->mark_deleted($processed->id); $result = $processed->retrieve($processed->id); - $this->assertEquals(null, $result); + self::assertEquals(null, $result); } } diff --git a/tests/unit/phpunit/modules/Accounts/AccountTest.php b/tests/unit/phpunit/modules/Accounts/AccountTest.php index 5f63e02dd..b4fb24c15 100644 --- a/tests/unit/phpunit/modules/Accounts/AccountTest.php +++ b/tests/unit/phpunit/modules/Accounts/AccountTest.php @@ -13,7 +13,7 @@ class AccountTest extends SuitePHPUnitFrameworkTestCase $current_user = BeanFactory::newBean('Users'); } - public function testgetProductsServicesPurchasedQuery() + public function testgetProductsServicesPurchasedQuery(): void { $Account = BeanFactory::newBean('Accounts'); @@ -28,7 +28,7 @@ class AccountTest extends SuitePHPUnitFrameworkTestCase "; $actual = $Account->getProductsServicesPurchasedQuery(); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); //with account id $expected = " @@ -42,93 +42,82 @@ class AccountTest extends SuitePHPUnitFrameworkTestCase "; $Account->id = '1234'; $actual = $Account->getProductsServicesPurchasedQuery(); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } - public function testAccount() + public function testAccount(): void { // Execute the constructor and check for the Object type and type attribute $Account = BeanFactory::newBean('Accounts'); - $this->assertInstanceOf('Account', $Account); - $this->assertInstanceOf('Company', $Account); - $this->assertInstanceOf('SugarBean', $Account); - $this->assertTrue(is_array($Account->field_name_map)); - $this->assertTrue(is_array($Account->field_defs)); + self::assertInstanceOf('Account', $Account); + self::assertInstanceOf('Company', $Account); + self::assertInstanceOf('SugarBean', $Account); + self::assertIsArray($Account->field_name_map); + self::assertIsArray($Account->field_defs); } - public function testget_summary_text() + public function testget_summary_text(): void { //test without name setting attribute $Account = BeanFactory::newBean('Accounts'); $name = $Account->get_summary_text(); - $this->assertEquals(null, $name); + self::assertEquals(null, $name); //test with name attribute set $Account->name = 'test account'; $name = $Account->get_summary_text(); - $this->assertEquals('test account', $name); + self::assertEquals('test account', $name); } - public function testget_contacts() + public function testget_contacts(): void { - $Account = new Account(''); - //execute the method and verify that it returns an array - $contacts = $Account->get_contacts(); - $this->assertTrue(is_array($contacts)); + $contacts = (new Account(''))->get_contacts(); + self::assertIsArray($contacts); } - public function testclear_account_case_relationship() - { - $this->markTestIncomplete('Can Not be implemented - Query has a wrong column name which makes the function to die'); - //This method cannot be tested because Query has a wrong column name which makes the function to die. - - /*$Account = BeanFactory::newBean('Accounts'); - $Account->clear_account_case_relationship('','');*/ - } - - public function testremove_redundant_http() + public function testremove_redundant_http(): void { $Account = BeanFactory::newBean('Accounts'); //this method has no implementation. so test for exceptions only. try { $Account->remove_redundant_http(); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } } - public function testfill_in_additional_list_fields() + public function testfill_in_additional_list_fields(): void { $Account = new Account(''); // Execute the method and test that it works and doesn't throw an exception. try { $Account->fill_in_additional_list_fields(); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } } - public function testfill_in_additional_detail_fields() + public function testfill_in_additional_detail_fields(): void { $Account = new Account(''); // Execute the method and test that it works and doesn't throw an exception. try { $Account->fill_in_additional_detail_fields(); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } } - public function testget_list_view_data() + public function testget_list_view_data(): void { - $this->markTestIncomplete('Breaks on php 7.1'); + self::markTestIncomplete('Breaks on php 7.1'); $this-> $expected = array( 'DELETED' => 0, @@ -146,70 +135,47 @@ class AccountTest extends SuitePHPUnitFrameworkTestCase 'SHIPPING_ADDRESS_STREET' => null, ); - $Account = BeanFactory::newBean('Accounts'); - //execute the method and verify that it retunrs expected results - $actual = $Account->get_list_view_data(); + $actual = BeanFactory::newBean('Accounts')->get_list_view_data(); foreach ($expected as $key => $value) { - $this->assertSame($expected[$key], $actual[$key]); + self::assertSame($expected[$key], $actual[$key]); } } - public function testbuild_generic_where_clause() + public function testbuild_generic_where_clause(): void { $Account = BeanFactory::newBean('Accounts'); //execute the method with a string as parameter and verify that it retunrs expected results $expected = "accounts.name like 'value%'"; $actual = $Account->build_generic_where_clause('value'); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); //execute the method with number as parameter and verify that it retunrs expected results $expected = "accounts.name like '1234%' or accounts.phone_alternate like '%1234%' or accounts.phone_fax like '%1234%' or accounts.phone_office like '%1234%'"; $actual = $Account->build_generic_where_clause('1234'); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } - public function testcreate_export_query() + public function testset_notification_body(): void { - $this->markTestIncomplete('Needs to clearify'); - -// $Account = BeanFactory::newBean('Accounts'); -// -// // execute the method with empty strings and verify that it retunrs expected results -// $expected = "SELECT -// accounts.*, -// email_addresses.email_address email_address, -// '' email_addresses_non_primary, accounts.name as account_name, -// users.user_name as assigned_user_name ,accounts_cstm.jjwg_maps_address_c,accounts_cstm.jjwg_maps_geocode_status_c,accounts_cstm.jjwg_maps_lat_c,accounts_cstm.jjwg_maps_lng_c FROM accounts LEFT JOIN users -// ON accounts.assigned_user_id=users.id LEFT JOIN email_addr_bean_rel on accounts.id = email_addr_bean_rel.bean_id and email_addr_bean_rel.bean_module='Accounts' and email_addr_bean_rel.deleted=0 and email_addr_bean_rel.primary_address=1 LEFT JOIN email_addresses on email_addresses.id = email_addr_bean_rel.email_address_id LEFT JOIN accounts_cstm ON accounts.id = accounts_cstm.id_c where ( accounts.deleted IS NULL OR accounts.deleted=0 )"; -// -// $actual = $Account->create_export_query('', ''); -// -// $this->assertSame($expected, $actual); - } - - public function testset_notification_body() - { - $Account = BeanFactory::newBean('Accounts'); - //execute the method and test if populates provided sugar_smarty - $result = $Account->set_notification_body(new Sugar_Smarty(), BeanFactory::newBean('Accounts')); - $this->assertInstanceOf('Sugar_Smarty', $result); - $this->assertNotEquals(new Sugar_Smarty(), $result); + $result = BeanFactory::newBean('Accounts')->set_notification_body(new Sugar_Smarty(), BeanFactory::newBean('Accounts')); + self::assertInstanceOf('Sugar_Smarty', $result); + self::assertNotEquals(new Sugar_Smarty(), $result); } - public function testbean_implements() + public function testbean_implements(): void { $Account = BeanFactory::newBean('Accounts'); - $this->assertTrue($Account->bean_implements('ACL')); //test with valid value - $this->assertFalse($Account->bean_implements('')); //test with empty value - $this->assertFalse($Account->bean_implements('Basic'));//test with invalid value + self::assertTrue($Account->bean_implements('ACL')); //test with valid value + self::assertFalse($Account->bean_implements('')); //test with empty value + self::assertFalse($Account->bean_implements('Basic'));//test with invalid value } - public function testget_unlinked_email_query() + public function testget_unlinked_email_query(): void { $Account = BeanFactory::newBean('Accounts'); @@ -222,7 +188,7 @@ class AccountTest extends SuitePHPUnitFrameworkTestCase (select eb.email_id from emails_beans eb where eb.bean_module ='Accounts' and eb.bean_id = '') ) derivedemails on derivedemails.email_id = emails.id"; $actual = $Account->get_unlinked_email_query(); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); //with type parameter set $expected = array( @@ -240,6 +206,6 @@ class AccountTest extends SuitePHPUnitFrameworkTestCase ); $actual = $Account->get_unlinked_email_query(array('return_as_array' => 'true')); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } } diff --git a/tests/unit/phpunit/modules/Administration/AdministrationTest.php b/tests/unit/phpunit/modules/Administration/AdministrationTest.php index 7d3d24748..6ea099e4d 100644 --- a/tests/unit/phpunit/modules/Administration/AdministrationTest.php +++ b/tests/unit/phpunit/modules/Administration/AdministrationTest.php @@ -13,50 +13,48 @@ class AdministrationTest extends SuitePHPUnitFrameworkTestCase $current_user = BeanFactory::newBean('Users'); } - public function testAdministration() + public function testAdministration(): void { // Execute the constructor and check for the Object type and type attribute $admin = BeanFactory::newBean('Administration'); - $this->assertInstanceOf('Administration', $admin); - $this->assertInstanceOf('SugarBean', $admin); + self::assertInstanceOf('Administration', $admin); + self::assertInstanceOf('SugarBean', $admin); - $this->assertAttributeEquals('Administration', 'module_dir', $admin); - $this->assertAttributeEquals('Administration', 'object_name', $admin); - $this->assertAttributeEquals('config', 'table_name', $admin); - $this->assertAttributeEquals(true, 'new_schema', $admin); - $this->assertAttributeEquals(true, 'disable_custom_fields', $admin); - $this->assertAttributeEquals(array('disclosure', 'notify', 'system', 'portal', 'proxy', 'massemailer', 'ldap', 'captcha', 'sugarpdf'), 'config_categories', $admin); - $this->assertAttributeEquals(array('notify_send_by_default', 'mail_smtpauth_req', 'notify_on', 'portal_on', 'system_mailmerge_on', 'proxy_auth', 'proxy_on', 'system_ldap_enabled', 'captcha_on'), 'checkbox_fields', $admin); + self::assertEquals('Administration', $admin->module_dir); + self::assertEquals('Administration', $admin->object_name); + self::assertEquals('config', $admin->table_name); + self::assertEquals(true, $admin->new_schema); + self::assertEquals(true, $admin->disable_custom_fields); } - public function testretrieveSettings() + public function testretrieveSettings(): void { $admin = BeanFactory::newBean('Administration'); //execute with default parameters and test if it returns object itself $result = $admin->retrieveSettings(); - $this->assertInstanceOf('Administration', $result); - $this->assertSame($admin, $result); + self::assertInstanceOf('Administration', $result); + self::assertSame($admin, $result); //execute with a invalid category and test if it returns object itself. $result = $admin->retrieveSettings('test'); - $this->assertInstanceOf('Administration', $result); - $this->assertSame($admin, $result); - $this->assertEquals(true, $admin->settings['test']); + self::assertInstanceOf('Administration', $result); + self::assertSame($admin, $result); + self::assertEquals(true, $admin->settings['test']); //execute with a valid category and test if it returns object itself. $result = $admin->retrieveSettings('notify'); - $this->assertInstanceOf('Administration', $result); - $this->assertSame($admin, $result); + self::assertInstanceOf('Administration', $result); + self::assertSame($admin, $result); //execute with a valid category and clean=true and test if it returns object itself. $admin = BeanFactory::newBean('Administration'); $result = $admin->retrieveSettings('notify', true); - $this->assertInstanceOf('Administration', $result); - $this->assertSame($admin, $result); + self::assertInstanceOf('Administration', $result); + self::assertSame($admin, $result); } - public function testsaveConfig() + public function testsaveConfig(): void { self::markTestIncomplete('environment dependency'); @@ -68,10 +66,10 @@ class AdministrationTest extends SuitePHPUnitFrameworkTestCase //execute the method and verify that it sets the correct config key $admin->saveConfig(); $actual = $admin->settings['proxy_test']; - $this->assertEquals($actual, 'test value'); + self::assertEquals('test value', $actual); } - public function testsaveSetting() + public function testsaveSetting(): void { self::markTestIncomplete('environment dependency'); @@ -82,21 +80,21 @@ class AdministrationTest extends SuitePHPUnitFrameworkTestCase $result = $admin->saveSetting('category', 'key', 'test value'); $admin->retrieveSettings('category'); $actual = $admin->settings['category_key']; - $this->assertEquals($actual, 'test value'); + self::assertEquals('test value', $actual); } - public function testget_config_prefix() + public function testget_config_prefix(): void { $admin = BeanFactory::newBean('Administration'); //test with empty string $expected = array(false, false); $actual = $admin->get_config_prefix(''); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); //test with a valid string $expected = array('category', 'test'); $actual = $admin->get_config_prefix('category_test'); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } } diff --git a/tests/unit/phpunit/modules/Administration/BaseHandlerTest.php b/tests/unit/phpunit/modules/Administration/BaseHandlerTest.php index dd9907c64..0ba56e4de 100644 --- a/tests/unit/phpunit/modules/Administration/BaseHandlerTest.php +++ b/tests/unit/phpunit/modules/Administration/BaseHandlerTest.php @@ -51,8 +51,8 @@ class BaseHandlerTest extends SuitePHPUnitFrameworkTestCase parent::setUp(); } - public function testFirst() + public function testFirst(): void { - $this->assertEquals(true, true); + self::assertEquals(true, true); } } diff --git a/tests/unit/phpunit/modules/Administration/GoogleCalendarSettingsHandlerMock.php b/tests/unit/phpunit/modules/Administration/GoogleCalendarSettingsHandlerMock.php index 649d6409f..0850c94f3 100644 --- a/tests/unit/phpunit/modules/Administration/GoogleCalendarSettingsHandlerMock.php +++ b/tests/unit/phpunit/modules/Administration/GoogleCalendarSettingsHandlerMock.php @@ -55,6 +55,10 @@ class GoogleCalendarSettingsHandlerMock extends GoogleCalendarSettingsHandler parent::__construct($tplPath, $current_user, $request, $mod_strings, $config, $sugar_smarty, $js); } + /** + * @param string $exitstring + * @noinspection ReturnTypeCanBeDeclaredInspection + */ protected function protectedDie($exitstring) { $this->exitstring = $exitstring; @@ -65,32 +69,42 @@ class GoogleCalendarSettingsHandlerMock extends GoogleCalendarSettingsHandler return $this->diedOk; } + /** + * @noinspection ReturnTypeCanBeDeclaredInspection + */ protected function protectedExit() { $this->exitOk = true; } - public function getExitOk() + public function getExitOk(): bool { return $this->exitOk; } + /** + * @param string $url + * @noinspection ReturnTypeCanBeDeclaredInspection + */ protected function redirect($url) { $this->url = $url; } - public function getRedirectUrl() + public function getRedirectUrl(): string { return $this->url; } + /** + * @noinspection ReturnTypeCanBeDeclaredInspection + */ protected function getJavascript() { $this->javascriptCalled = true; } - public function getJavascriptCalled() + public function getJavascriptCalled(): bool { return $this->javascriptCalled; } diff --git a/tests/unit/phpunit/modules/Administration/GoogleCalendarSettingsHandlerTest.php b/tests/unit/phpunit/modules/Administration/GoogleCalendarSettingsHandlerTest.php index 20f2900e2..20074e82c 100644 --- a/tests/unit/phpunit/modules/Administration/GoogleCalendarSettingsHandlerTest.php +++ b/tests/unit/phpunit/modules/Administration/GoogleCalendarSettingsHandlerTest.php @@ -48,7 +48,7 @@ include_once __DIR__ . '/../../../../../include/utils/BaseHandler.php'; include_once __DIR__ . '/../../../../../modules/Administration/GoogleCalendarSettingsHandler.php'; include_once __DIR__ . '/GoogleCalendarSettingsHandlerMock.php'; include_once __DIR__ . '/../../../../../include/utils/layout_utils.php'; - + class GoogleCalendarSettingsHandlerTest extends SuitePHPUnitFrameworkTestCase { protected function setUp(): void @@ -57,12 +57,12 @@ class GoogleCalendarSettingsHandlerTest extends SuitePHPUnitFrameworkTestCase $GLOBALS['mod_strings'] = return_module_language($GLOBALS['current_language'], 'Administration'); } - public function testFirst() + public function testFirst(): void { - $this->assertEquals(true, true); + self::assertEquals(true, true); } - public function testDoAction() + public function testDoAction(): void { global $current_user; global $mod_strings; @@ -82,11 +82,11 @@ class GoogleCalendarSettingsHandlerTest extends SuitePHPUnitFrameworkTestCase new javascript() ); - $this->assertTrue($gcsHandler->getExitOk()); - $this->assertEquals('index.php?module=Administration&action=index', $gcsHandler->getRedirectUrl()); + self::assertTrue($gcsHandler->getExitOk()); + self::assertEquals('index.php?module=Administration&action=index', $gcsHandler->getRedirectUrl()); } - public function testNoDoAction() + public function testNoDoAction(): void { global $current_user; global $mod_strings; @@ -106,11 +106,11 @@ class GoogleCalendarSettingsHandlerTest extends SuitePHPUnitFrameworkTestCase new javascript() ); - $this->assertFalse($gcsHandler->getExitOk()); - $this->assertEquals('', $gcsHandler->getRedirectUrl()); + self::assertFalse($gcsHandler->getExitOk()); + self::assertEquals('', $gcsHandler->getRedirectUrl()); } - public function testHandleDisplay() + public function testHandleDisplay(): void { global $current_user; global $mod_strings; @@ -134,10 +134,10 @@ class GoogleCalendarSettingsHandlerTest extends SuitePHPUnitFrameworkTestCase $ret = $gcsHandler->handleDisplay(); - $this->assertTrue($gcsHandler->getJavascriptCalled()); - $this->assertFalse($cfg->config['google_auth_json']); + self::assertTrue($gcsHandler->getJavascriptCalled()); + self::assertFalse($cfg->config['google_auth_json']); - $this->assertEquals(array( + self::assertEquals(array( 'status' => 'UNCONFIGURED', 'color' => 'black' ), $s->get_template_vars('GOOGLE_JSON_CONF')); diff --git a/tests/unit/phpunit/modules/Alerts/AlertTest.php b/tests/unit/phpunit/modules/Alerts/AlertTest.php index ccca2239b..c2a2bda89 100644 --- a/tests/unit/phpunit/modules/Alerts/AlertTest.php +++ b/tests/unit/phpunit/modules/Alerts/AlertTest.php @@ -13,28 +13,28 @@ class AlertTest extends SuitePHPUnitFrameworkTestCase $current_user = BeanFactory::newBean('Users'); } - public function testAlert() + public function testAlert(): void { // Execute the constructor and check for the Object type and type attribute $alert = BeanFactory::newBean('Alerts'); - $this->assertInstanceOf('Alert', $alert); - $this->assertInstanceOf('Basic', $alert); - $this->assertInstanceOf('SugarBean', $alert); + self::assertInstanceOf('Alert', $alert); + self::assertInstanceOf('Basic', $alert); + self::assertInstanceOf('SugarBean', $alert); - $this->assertAttributeEquals('Alerts', 'module_dir', $alert); - $this->assertAttributeEquals('Alert', 'object_name', $alert); - $this->assertAttributeEquals('alerts', 'table_name', $alert); - $this->assertAttributeEquals(true, 'new_schema', $alert); - $this->assertAttributeEquals(true, 'disable_row_level_security', $alert); - $this->assertAttributeEquals(false, 'importable', $alert); + self::assertEquals('Alerts', $alert->module_dir); + self::assertEquals('Alert', $alert->object_name); + self::assertEquals('alerts', $alert->table_name); + self::assertEquals(true, $alert->new_schema); + self::assertEquals(true, $alert->disable_row_level_security); + self::assertEquals(false, $alert->importable); } - public function testbean_implements() + public function testbean_implements(): void { $alert = BeanFactory::newBean('Alerts'); - $this->assertEquals(false, $alert->bean_implements('')); //test with empty value - $this->assertEquals(false, $alert->bean_implements('test')); //test with invalid value - $this->assertEquals(true, $alert->bean_implements('ACL')); //test with valid value + self::assertEquals(false, $alert->bean_implements('')); //test with empty value + self::assertEquals(false, $alert->bean_implements('test')); //test with invalid value + self::assertEquals(true, $alert->bean_implements('ACL')); //test with valid value } } diff --git a/tests/unit/phpunit/modules/Audit/AuditTest.php b/tests/unit/phpunit/modules/Audit/AuditTest.php index 570716b60..5981a8c38 100644 --- a/tests/unit/phpunit/modules/Audit/AuditTest.php +++ b/tests/unit/phpunit/modules/Audit/AuditTest.php @@ -14,126 +14,124 @@ class AuditTest extends SuitePHPUnitFrameworkTestCase $current_user = BeanFactory::newBean('Users'); } - public function testAudit() + public function testAudit(): void { // Execute the constructor and check for the Object type and attributes $audit = BeanFactory::newBean('Audit'); - $this->assertInstanceOf('Audit', $audit); - $this->assertInstanceOf('SugarBean', $audit); - $this->assertAttributeEquals('Audit', 'module_dir', $audit); - $this->assertAttributeEquals('Audit', 'object_name', $audit); + self::assertInstanceOf('Audit', $audit); + self::assertInstanceOf('SugarBean', $audit); + self::assertEquals('Audit', $audit->module_dir); + self::assertEquals('Audit', $audit->object_name); } - public function testget_summary_text() + public function testget_summary_text(): void { $audit = BeanFactory::newBean('Audit'); //test without setting name - $this->assertEquals(null, $audit->get_summary_text()); + self::assertEquals(null, $audit->get_summary_text()); //test with name set $audit->name = 'test'; - $this->assertEquals('test', $audit->get_summary_text()); + self::assertEquals('test', $audit->get_summary_text()); } - public function testcreate_export_query() + public function testcreate_export_query(): void { $audit = BeanFactory::newBean('Audit'); // Execute the method and test that it works and doesn't throw an exception. try { $audit->create_export_query('', ''); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } - $this->markTestIncomplete('method has no implementation'); + self::markTestIncomplete('method has no implementation'); } - public function testfill_in_additional_list_fields() + public function testfill_in_additional_list_fields(): void { $audit = BeanFactory::newBean('Audit'); // Execute the method and test that it works and doesn't throw an exception. try { $audit->fill_in_additional_list_fields(); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } - $this->markTestIncomplete('method has no implementation'); + self::markTestIncomplete('method has no implementation'); } - public function testfill_in_additional_detail_fields() + public function testfill_in_additional_detail_fields(): void { $audit = BeanFactory::newBean('Audit'); // Execute the method and test that it works and doesn't throw an exception. try { $audit->fill_in_additional_detail_fields(); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } - $this->markTestIncomplete('method has no implementation'); + self::markTestIncomplete('method has no implementation'); } - public function testfill_in_additional_parent_fields() + public function testfill_in_additional_parent_fields(): void { $audit = BeanFactory::newBean('Audit'); // Execute the method and test that it works and doesn't throw an exception. try { $audit->fill_in_additional_parent_fields(); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } - $this->markTestIncomplete('method has no implementation'); + self::markTestIncomplete('method has no implementation'); } - public function testget_list_view_data() + public function testget_list_view_data(): void { $audit = BeanFactory::newBean('Audit'); // Execute the method and test that it works and doesn't throw an exception. try { $audit->get_list_view_data(); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } - $this->markTestIncomplete('method has no implementation'); + self::markTestIncomplete('method has no implementation'); } - public function testget_audit_link() + public function testget_audit_link(): void { $audit = BeanFactory::newBean('Audit'); // Execute the method and test that it works and doesn't throw an exception. try { $audit->get_audit_link(); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } - $this->markTestIncomplete('method has no implementation'); + self::markTestIncomplete('method has no implementation'); } - public function testget_audit_list() + public function testget_audit_list(): void { global $focus; $focus = BeanFactory::newBean('Accounts'); //use audit enabbled module object - $audit = BeanFactory::newBean('Audit'); - //execute the method and verify that it returns an array - $result = $audit->get_audit_list(); - $this->assertTrue(is_array($result)); + $result = BeanFactory::newBean('Audit')->get_audit_list(); + self::assertIsArray($result); } - public function testgetAssociatedFieldName() + public function testgetAssociatedFieldName(): void { global $focus; $focus = BeanFactory::newBean('Accounts'); //use audit enabbled module object @@ -142,10 +140,10 @@ class AuditTest extends SuitePHPUnitFrameworkTestCase //test with name field $result = $audit->getAssociatedFieldName('name', '1'); - $this->assertEquals('1', $result); + self::assertEquals('1', $result); //test with parent_id field $result = $audit->getAssociatedFieldName('parent_id', '1'); - $this->assertEquals(null, $result); + self::assertEquals(null, $result); } } diff --git a/tests/unit/phpunit/modules/Audit/PopupPickerTest.php b/tests/unit/phpunit/modules/Audit/PopupPickerTest.php index 547f0a248..27003010a 100644 --- a/tests/unit/phpunit/modules/Audit/PopupPickerTest.php +++ b/tests/unit/phpunit/modules/Audit/PopupPickerTest.php @@ -6,28 +6,27 @@ require_once 'modules/Audit/Popup_picker.php'; class PopupPickerTest extends SuitePHPUnitFrameworkTestCase { - public function testProcessPage() + public function testProcessPage(): void { global $focus; $focus = BeanFactory::getBean('Contacts'); $focus->name = 'test'; $focus->save(); - + ob_start(); - $popupPicker = new Popup_Picker(); - $result = $popupPicker->process_page(); + $result = (new Popup_Picker())->process_page(); $output = ob_get_contents(); ob_end_clean(); - $this->assertTrue(is_null($result)); - $this->assertNotEmpty($output); - $this->assertContains('', $output); - $this->assertContains('', $output); - $this->assertContains('SuiteCRM - Open Source CRM', $output); - $this->assertContains('', $output); - $this->assertContains('', $output); - $this->assertContains('
', $output); - $this->assertContains('', $output); + self::assertStringContainsStringIgnoringCase('', $output); + self::assertStringContainsStringIgnoringCase('
', $output); + self::assertStringContainsStringIgnoringCase('create_list_query('', ''); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); //test with valid string params $expected = "SELECT \n bugs.*\n\n ,users.user_name as assigned_user_name, releases.id release_id, releases.name release_name FROM bugs LEFT JOIN releases ON bugs.found_in_release=releases.id\n LEFT JOIN users\n ON bugs.assigned_user_id=users.id where bugs.name=\"\" AND bugs.deleted=0 ORDER BY releases.id"; $actual = $bug->create_list_query('releases.id', 'bugs.name=""'); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } - public function testcreate_export_query() + public function testcreate_export_query(): void { self::markTestIncomplete('#Warning: Strings contain different line endings!'); $bug = BeanFactory::newBean('Bugs'); @@ -65,28 +65,28 @@ class BugTest extends SuitePHPUnitFrameworkTestCase //test with empty string params $expected = "SELECT\n bugs.*,\n r1.name found_in_release_name,\n r2.name fixed_in_release_name,\n users.user_name assigned_user_name FROM bugs LEFT JOIN releases r1 ON bugs.found_in_release = r1.id\n LEFT JOIN releases r2 ON bugs.fixed_in_release = r2.id\n LEFT JOIN users\n ON bugs.assigned_user_id=users.id where bugs.deleted=0\n ORDER BY bugs.bug_number"; $actual = $bug->create_export_query('', ''); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); //test with valid string params $expected = "SELECT\n bugs.*,\n r1.name found_in_release_name,\n r2.name fixed_in_release_name,\n users.user_name assigned_user_name FROM bugs LEFT JOIN releases r1 ON bugs.found_in_release = r1.id\n LEFT JOIN releases r2 ON bugs.fixed_in_release = r2.id\n LEFT JOIN users\n ON bugs.assigned_user_id=users.id where bugs.name=\"\" AND bugs.deleted=0\n ORDER BY releases.id"; $actual = $bug->create_export_query('releases.id', 'bugs.name=""'); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } - public function testfill_in_additional_list_fields() + public function testfill_in_additional_list_fields(): void { $bug = BeanFactory::newBean('Bugs'); // Execute the method and test that it works and doesn't throw an exception. try { $bug->fill_in_additional_list_fields(); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } } - public function testfill_in_additional_detail_fields() + public function testfill_in_additional_detail_fields(): void { $bug = BeanFactory::newBean('Bugs'); $bug->assigned_user_id = 1; @@ -96,32 +96,32 @@ class BugTest extends SuitePHPUnitFrameworkTestCase //test with attributes preset and verify attributes are set accordingly $bug->fill_in_additional_detail_fields(); - $this->assertEquals('Administrator', $bug->assigned_user_name); - $this->assertEquals('Administrator', $bug->created_by_name); - $this->assertEquals('Administrator', $bug->modified_by_name); + self::assertEquals('Administrator', $bug->assigned_user_name); + self::assertEquals('Administrator', $bug->created_by_name); + self::assertEquals('Administrator', $bug->modified_by_name); } - public function testset_release() + public function testset_release(): void { $bug = BeanFactory::newBean('Bugs'); $bug->found_in_release = '1'; $bug->set_release(); - $this->assertEquals('', $bug->release_name); + self::assertEquals('', $bug->release_name); } - public function testset_fixed_in_release() + public function testset_fixed_in_release(): void { $bug = BeanFactory::newBean('Bugs'); $bug->found_in_release = '1'; $bug->set_release(); - $this->assertEquals('', $bug->fixed_in_release_name); + self::assertEquals('', $bug->fixed_in_release_name); } - public function testget_list_view_data() + public function testget_list_view_data(): void { $bug = BeanFactory::newBean('Bugs'); @@ -138,25 +138,25 @@ class BugTest extends SuitePHPUnitFrameworkTestCase ); $actual = $bug->get_list_view_data(); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } - public function testbuild_generic_where_clause() + public function testbuild_generic_where_clause(): void { $bug = BeanFactory::newBean('Bugs'); //execute with blank parameters $expected = "bugs.name like '%'"; $actual = $bug->build_generic_where_clause(''); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); //execute with numeric parameter $expected = "bugs.name like '1%' or bugs.bug_number like '1%'"; $actual = $bug->build_generic_where_clause(1); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } - public function testset_notification_body() + public function testset_notification_body(): void { $bug = BeanFactory::newBean('Bugs'); @@ -170,23 +170,23 @@ class BugTest extends SuitePHPUnitFrameworkTestCase //test with attributes preset and verify template variables are set accordingly $result = $bug->set_notification_body(new Sugar_Smarty(), $bug); - $this->assertEquals($bug->name, $result->_tpl_vars['BUG_SUBJECT']); - $this->assertEquals($bug->type, $result->_tpl_vars['BUG_TYPE']); - $this->assertEquals($bug->priority, $result->_tpl_vars['BUG_PRIORITY']); - $this->assertEquals($bug->status, $result->_tpl_vars['BUG_STATUS']); - $this->assertEquals($bug->resolution, $result->_tpl_vars['BUG_RESOLUTION']); - $this->assertEquals($bug->bug_number, $result->_tpl_vars['BUG_BUG_NUMBER']); + self::assertEquals($bug->name, $result->_tpl_vars['BUG_SUBJECT']); + self::assertEquals($bug->type, $result->_tpl_vars['BUG_TYPE']); + self::assertEquals($bug->priority, $result->_tpl_vars['BUG_PRIORITY']); + self::assertEquals($bug->status, $result->_tpl_vars['BUG_STATUS']); + self::assertEquals($bug->resolution, $result->_tpl_vars['BUG_RESOLUTION']); + self::assertEquals($bug->bug_number, $result->_tpl_vars['BUG_BUG_NUMBER']); } - public function testbean_implements() + public function testbean_implements(): void { $bug = BeanFactory::newBean('Bugs'); - $this->assertEquals(false, $bug->bean_implements('')); //test with blank value - $this->assertEquals(false, $bug->bean_implements('test')); //test with invalid value - $this->assertEquals(true, $bug->bean_implements('ACL')); //test with valid value + self::assertEquals(false, $bug->bean_implements('')); //test with blank value + self::assertEquals(false, $bug->bean_implements('test')); //test with invalid value + self::assertEquals(true, $bug->bean_implements('ACL')); //test with valid value } - public function testsave() + public function testsave(): void { $bug = BeanFactory::newBean('Bugs'); @@ -200,20 +200,20 @@ class BugTest extends SuitePHPUnitFrameworkTestCase $bug->save(); //test for record ID to verify that record is saved - $this->assertTrue(isset($bug->id)); - $this->assertEquals(36, strlen($bug->id)); + self::assertTrue(isset($bug->id)); + self::assertEquals(36, strlen($bug->id)); //mark the record as deleted and verify that this record cannot be retrieved anymore. $bug->mark_deleted($bug->id); $result = $bug->retrieve($bug->id); - $this->assertEquals(null, $result); + self::assertEquals(null, $result); } - public function testgetReleaseDropDown() + public function testgetReleaseDropDown(): void { $result = getReleaseDropDown(); //execute the method and verify it returns an array - $this->assertTrue(is_array($result)); + self::assertIsArray($result); } } diff --git a/tests/unit/phpunit/modules/Calls/CallTest.php b/tests/unit/phpunit/modules/Calls/CallTest.php index 57616871f..ee18a4019 100644 --- a/tests/unit/phpunit/modules/Calls/CallTest.php +++ b/tests/unit/phpunit/modules/Calls/CallTest.php @@ -13,40 +13,39 @@ class CallTest extends SuitePHPUnitFrameworkTestCase $current_user = BeanFactory::newBean('Users'); } - public function testCall() + public function testCall(): void { // Execute the constructor and check for the Object type and attributes $call = BeanFactory::newBean('Calls'); - $this->assertInstanceOf('Call', $call); - $this->assertInstanceOf('SugarBean', $call); + self::assertInstanceOf('Call', $call); + self::assertInstanceOf('SugarBean', $call); - $this->assertAttributeEquals('Calls', 'module_dir', $call); - $this->assertAttributeEquals('Call', 'object_name', $call); - $this->assertAttributeEquals('calls', 'table_name', $call); - $this->assertAttributeEquals('calls_users', 'rel_users_table', $call); - $this->assertAttributeEquals('calls_contacts', 'rel_contacts_table', $call); - $this->assertAttributeEquals('calls_leads', 'rel_leads_table', $call); - $this->assertAttributeEquals(true, 'new_schema', $call); - $this->assertAttributeEquals(true, 'importable', $call); - $this->assertAttributeEquals(false, 'syncing', $call); - $this->assertAttributeEquals(true, 'update_vcal', $call); - $this->assertAttributeEquals(array(0 => '00', 15 => '15', 30 => '30', 45 => '45'), 'minutes_values', $call); + self::assertEquals('Calls', $call->module_dir); + self::assertEquals('Call', $call->object_name); + self::assertEquals('calls', $call->table_name); + self::assertEquals('calls_users', $call->rel_users_table); + self::assertEquals('calls_contacts', $call->rel_contacts_table); + self::assertEquals('calls_leads', $call->rel_leads_table); + self::assertEquals(true, $call->new_schema); + self::assertEquals(true, $call->importable); + self::assertEquals(false, $call->syncing); + self::assertEquals(true, $call->update_vcal); } - public function testACLAccess() + public function testACLAccess(): void { $call = BeanFactory::newBean('Calls'); //test without setting recurring_source attribute - $this->assertTrue($call->ACLAccess('')); + self::assertTrue($call->ACLAccess('')); //$this->assertTrue($call->ACLAccess('edit')); //test with recurring_source attribute set $call->recurring_source = 'test'; - $this->assertFalse($call->ACLAccess('edit')); + self::assertFalse($call->ACLAccess('edit')); } - public function testSaveAndMarkDeleted() + public function testSaveAndMarkDeleted(): void { $call = BeanFactory::newBean('Calls'); @@ -54,38 +53,38 @@ class CallTest extends SuitePHPUnitFrameworkTestCase $call->id = $call->save(); //test for record ID to verify that record is saved - $this->assertTrue(isset($call->id)); - $this->assertEquals(36, strlen($call->id)); + self::assertTrue(isset($call->id)); + self::assertEquals(36, strlen($call->id)); //mark the record as deleted and verify that this record cannot be retrieved anymore. $call->mark_deleted($call->id); $result = $call->retrieve($call->id); - $this->assertEquals(null, $result); + self::assertEquals(null, $result); } - public function testget_contacts() + public function testget_contacts(): void { $call = BeanFactory::newBean('Calls'); $call->id = 1; //execute the method and verify if it returns an array $result = $call->get_contacts(); - $this->assertTrue(is_array($result)); + self::assertIsArray($result); } - public function testget_summary_text() + public function testget_summary_text(): void { $call = BeanFactory::newBean('Calls'); //test without setting name - $this->assertEquals(null, $call->get_summary_text()); + self::assertEquals(null, $call->get_summary_text()); //test with name set $call->name = 'test'; - $this->assertEquals('test', $call->get_summary_text()); + self::assertEquals('test', $call->get_summary_text()); } - public function testcreate_list_query() + public function testcreate_list_query(): void { self::markTestIncomplete('environment dependency'); @@ -94,47 +93,47 @@ class CallTest extends SuitePHPUnitFrameworkTestCase //test with empty string params $expected = "SELECT \n calls.*,\n users.user_name as assigned_user_name FROM calls \n LEFT JOIN users\n ON calls.assigned_user_id=users.id where calls.deleted=0 ORDER BY calls.name"; $actual = $call->create_list_query('', ''); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); //test with valid string params $expected = "SELECT \n calls.*,\n users.user_name as assigned_user_name FROM calls \n LEFT JOIN users\n ON calls.assigned_user_id=users.id where users.user_name=\"\" AND calls.deleted=0 ORDER BY calls.name"; $actual = $call->create_list_query('name', 'users.user_name=""'); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } - public function testcreate_export_query() + public function testcreate_export_query(): void { $call = BeanFactory::newBean('Calls'); //test with empty string params $expected = 'SELECT calls.*, users.user_name as assigned_user_name FROM calls LEFT JOIN users ON calls.assigned_user_id=users.id where calls.deleted=0 ORDER BY calls.name'; $actual = $call->create_export_query('', ''); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); //test with empty string params $expected = 'SELECT calls.*, users.user_name as assigned_user_name FROM calls LEFT JOIN users ON calls.assigned_user_id=users.id where users.user_name="" AND calls.deleted=0 ORDER BY calls.name'; $actual = $call->create_export_query('name', 'users.user_name=""'); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } - public function testfill_in_additional_detail_fields() + public function testfill_in_additional_detail_fields(): void { $call = BeanFactory::newBean('Calls'); //execute the method and verify it sets up the intended fields $call->fill_in_additional_detail_fields(); - $this->assertEquals('0', $call->duration_hours); - $this->assertEquals('15', $call->duration_minutes); - $this->assertEquals(-1, $call->reminder_time); - $this->assertEquals(false, $call->reminder_checked); - $this->assertEquals(-1, $call->email_reminder_time); - $this->assertEquals(false, $call->email_reminder_checked); - $this->assertEquals('Accounts', $call->parent_type); + self::assertEquals('0', $call->duration_hours); + self::assertEquals('15', $call->duration_minutes); + self::assertEquals(-1, $call->reminder_time); + self::assertEquals(false, $call->reminder_checked); + self::assertEquals(-1, $call->email_reminder_time); + self::assertEquals(false, $call->email_reminder_checked); + self::assertEquals('Accounts', $call->parent_type); } - public function testget_list_view_data() + public function testget_list_view_data(): void { self::markTestIncomplete('environment dependency (php5/php7)'); @@ -165,14 +164,14 @@ class CallTest extends SuitePHPUnitFrameworkTestCase ); $actual = $call->get_list_view_data(); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); - $this->assertEquals('Administrator', $call->assigned_user_name); - $this->assertEquals('Administrator', $call->created_by_name); - $this->assertEquals('Administrator', $call->modified_by_name); + self::assertEquals('Administrator', $call->assigned_user_name); + self::assertEquals('Administrator', $call->created_by_name); + self::assertEquals('Administrator', $call->modified_by_name); } - public function testset_notification_body() + public function testset_notification_body(): void { $call = BeanFactory::newBean('Calls'); @@ -189,36 +188,36 @@ class CallTest extends SuitePHPUnitFrameworkTestCase $result = $call->set_notification_body(new Sugar_Smarty(), $call); - $this->assertEquals($call->name, $result->_tpl_vars['CALL_SUBJECT']); - $this->assertEquals($call->current_notify_user->new_assigned_user_name, $result->_tpl_vars['CALL_TO']); - $this->assertEquals($call->duration_hours, $result->_tpl_vars['CALL_HOURS']); - $this->assertEquals($call->duration_minutes, $result->_tpl_vars['CALL_MINUTES']); - $this->assertEquals($call->status, $result->_tpl_vars['CALL_STATUS']); - $this->assertEquals('09/01/2015 00:02 UTC(+00:00)', $result->_tpl_vars['CALL_STARTDATE']); - $this->assertEquals($call->description, $result->_tpl_vars['CALL_DESCRIPTION']); + self::assertEquals($call->name, $result->_tpl_vars['CALL_SUBJECT']); + self::assertEquals($call->current_notify_user->new_assigned_user_name, $result->_tpl_vars['CALL_TO']); + self::assertEquals($call->duration_hours, $result->_tpl_vars['CALL_HOURS']); + self::assertEquals($call->duration_minutes, $result->_tpl_vars['CALL_MINUTES']); + self::assertEquals($call->status, $result->_tpl_vars['CALL_STATUS']); + self::assertEquals('09/01/2015 00:02 UTC(+00:00)', $result->_tpl_vars['CALL_STARTDATE']); + self::assertEquals($call->description, $result->_tpl_vars['CALL_DESCRIPTION']); } - public function testget_call_users() + public function testget_call_users(): void { $call = BeanFactory::newBean('Calls'); $call->id = 1; //execute the method and verify it returns an array $result = $call->get_call_users(); - $this->assertTrue(is_array($result)); + self::assertIsArray($result); } - public function testget_invite_calls() + public function testget_invite_calls(): void { $call = BeanFactory::newBean('Calls'); $user = new User(1); //execute the method and verify it returns an array $result = $call->get_invite_calls($user); - $this->assertTrue(is_array($result)); + self::assertIsArray($result); } - public function testset_accept_status() + public function testset_accept_status(): void { $call = BeanFactory::newBean('Calls'); $call->id = 1; @@ -230,60 +229,59 @@ class CallTest extends SuitePHPUnitFrameworkTestCase $call->set_accept_status($user, 'test'); $call_users = $call->get_linked_beans('users', $call->object_name); - $this->assertEquals(1, count($call_users)); + self::assertCount(1, $call_users); $call->delete_linked($call->id); } - public function testget_notification_recipients() + public function testget_notification_recipients(): void { $call = BeanFactory::newBean('Calls'); //test without setting any user list $result = $call->get_notification_recipients(); - $this->assertTrue(is_array($result)); + self::assertIsArray($result); //test with a user in notofication list set $call->users_arr = array(1); $result = $call->get_notification_recipients(); - $this->assertTrue(is_array($result)); - $this->assertEquals(1, count($result)); + self::assertIsArray($result); + self::assertCount(1, $result); } - public function testbean_implements() + public function testbean_implements(): void { $call = BeanFactory::newBean('Calls'); - $this->assertEquals(false, $call->bean_implements('')); //test with blank value - $this->assertEquals(false, $call->bean_implements('test')); //test with invalid value - $this->assertEquals(true, $call->bean_implements('ACL')); //test with valid value + self::assertEquals(false, $call->bean_implements('')); //test with blank value + self::assertEquals(false, $call->bean_implements('test')); //test with invalid value + self::assertEquals(true, $call->bean_implements('ACL')); //test with valid value } - public function testlistviewACLHelper() + public function testlistviewACLHelper(): void { self::markTestIncomplete('environment dependency'); $call = BeanFactory::newBean('Calls'); $expected = array('MAIN' => 'a', 'PARENT' => 'a', 'CONTACT' => 'a'); $actual = $call->listviewACLHelper(); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } - public function testsave_relationship_changes() + public function testsave_relationship_changes(): void { $call = BeanFactory::newBean('Calls'); // Execute the method and test that it works and doesn't throw an exception. try { $call->save_relationship_changes(true); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } } - public function testgetDefaultStatus() + public function testgetDefaultStatus(): void { - $call = BeanFactory::newBean('Calls'); - $result = $call->getDefaultStatus(); - $this->assertEquals('Planned', $result); + $result = BeanFactory::newBean('Calls')->getDefaultStatus(); + self::assertEquals('Planned', $result); } } diff --git a/tests/unit/phpunit/modules/Calls_Reschedule/Calls_RescheduleTest.php b/tests/unit/phpunit/modules/Calls_Reschedule/Calls_RescheduleTest.php index e8f292ba3..3c4024b91 100644 --- a/tests/unit/phpunit/modules/Calls_Reschedule/Calls_RescheduleTest.php +++ b/tests/unit/phpunit/modules/Calls_Reschedule/Calls_RescheduleTest.php @@ -13,20 +13,20 @@ class Calls_RescheduleTest extends SuitePHPUnitFrameworkTestCase $current_user = BeanFactory::newBean('Users'); } - public function testCalls_Reschedule() + public function testCalls_Reschedule(): void { // Execute the constructor and check for the Object type and attributes $callsReschedule = BeanFactory::newBean('Calls_Reschedule'); - $this->assertInstanceOf('Calls_Reschedule', $callsReschedule); - $this->assertInstanceOf('Basic', $callsReschedule); - $this->assertInstanceOf('SugarBean', $callsReschedule); + self::assertInstanceOf('Calls_Reschedule', $callsReschedule); + self::assertInstanceOf('Basic', $callsReschedule); + self::assertInstanceOf('SugarBean', $callsReschedule); - $this->assertAttributeEquals('Calls_Reschedule', 'module_dir', $callsReschedule); - $this->assertAttributeEquals('Calls_Reschedule', 'object_name', $callsReschedule); - $this->assertAttributeEquals('calls_reschedule', 'table_name', $callsReschedule); - $this->assertAttributeEquals(true, 'new_schema', $callsReschedule); - $this->assertAttributeEquals(true, 'disable_row_level_security', $callsReschedule); - $this->assertAttributeEquals(true, 'importable', $callsReschedule); - $this->assertAttributeEquals(false, 'tracker_visibility', $callsReschedule); + self::assertEquals('Calls_Reschedule', $callsReschedule->module_dir); + self::assertEquals('Calls_Reschedule', $callsReschedule->object_name); + self::assertEquals('calls_reschedule', $callsReschedule->table_name); + self::assertEquals(true, $callsReschedule->new_schema); + self::assertEquals(true, $callsReschedule->disable_row_level_security); + self::assertEquals(true, $callsReschedule->importable); + self::assertEquals(false, $callsReschedule->tracker_visibility); } } diff --git a/tests/unit/phpunit/modules/CampaignLog/CampaignLogTest.php b/tests/unit/phpunit/modules/CampaignLog/CampaignLogTest.php index 556c38448..67f064297 100644 --- a/tests/unit/phpunit/modules/CampaignLog/CampaignLogTest.php +++ b/tests/unit/phpunit/modules/CampaignLog/CampaignLogTest.php @@ -13,46 +13,43 @@ class CampaignLogTest extends SuitePHPUnitFrameworkTestCase $current_user = BeanFactory::newBean('Users'); } - public function testCampaignLog() + public function testCampaignLog(): void { // Execute the constructor and check for the Object type and attributes $campaignLog = BeanFactory::newBean('CampaignLog'); - $this->assertInstanceOf('CampaignLog', $campaignLog); - $this->assertInstanceOf('SugarBean', $campaignLog); + self::assertInstanceOf('CampaignLog', $campaignLog); + self::assertInstanceOf('SugarBean', $campaignLog); - $this->assertAttributeEquals('CampaignLog', 'module_dir', $campaignLog); - $this->assertAttributeEquals('CampaignLog', 'object_name', $campaignLog); - $this->assertAttributeEquals('campaign_log', 'table_name', $campaignLog); - $this->assertAttributeEquals(true, 'new_schema', $campaignLog); + self::assertEquals('CampaignLog', $campaignLog->module_dir); + self::assertEquals('CampaignLog', $campaignLog->object_name); + self::assertEquals('campaign_log', $campaignLog->table_name); + self::assertEquals(true, $campaignLog->new_schema); } - public function testget_list_view_data() + public function testget_list_view_data(): void { - $campaignLog = BeanFactory::newBean('CampaignLog'); - //execute the method and verify it returns an array - $actual = $campaignLog->get_list_view_data(); - $this->assertTrue(is_array($actual)); - $this->assertSame(array(), $actual); + $actual = BeanFactory::newBean('CampaignLog')->get_list_view_data(); + self::assertIsArray($actual); + self::assertSame(array(), $actual); } - public function testretrieve_email_address() + public function testretrieve_email_address(): void { - $campaignLog = BeanFactory::newBean('CampaignLog'); - $actual = $campaignLog->retrieve_email_address(); - $this->assertGreaterThanOrEqual('', $actual); + $actual = BeanFactory::newBean('CampaignLog')->retrieve_email_address(); + self::assertGreaterThanOrEqual('', $actual); } - public function testget_related_name() + public function testGetRelatedName(): void { $campaignLog = BeanFactory::newBean('CampaignLog'); - //execute the method and verify that it retunrs expected results for all type parameters - $this->assertEquals('1Emails', $campaignLog->get_related_name(1, 'Emails')); - $this->assertEquals('1Contacts', $campaignLog->get_related_name(1, 'Contacts')); - $this->assertEquals('1Leads', $campaignLog->get_related_name(1, 'Leads')); - $this->assertEquals('1Prospects', $campaignLog->get_related_name(1, 'Prospects')); - $this->assertEquals('1CampaignTrackers', $campaignLog->get_related_name(1, 'CampaignTrackers')); - $this->assertEquals('1Accounts', $campaignLog->get_related_name(1, 'Accounts')); + // Execute the method and verify that it returns expected results for all type parameters + self::assertEquals('1Emails', $campaignLog::get_related_name(1, 'Emails')); + self::assertEquals('1Contacts', $campaignLog::get_related_name(1, 'Contacts')); + self::assertEquals('1Leads', $campaignLog::get_related_name(1, 'Leads')); + self::assertEquals('1Prospects', $campaignLog::get_related_name(1, 'Prospects')); + self::assertEquals('1CampaignTrackers', $campaignLog::get_related_name(1, 'CampaignTrackers')); + self::assertEquals('1Accounts', $campaignLog::get_related_name(1, 'Accounts')); } } diff --git a/tests/unit/phpunit/modules/CampaignTrackers/CampaignTrackerTest.php b/tests/unit/phpunit/modules/CampaignTrackers/CampaignTrackerTest.php index 588be28f3..895bbb938 100644 --- a/tests/unit/phpunit/modules/CampaignTrackers/CampaignTrackerTest.php +++ b/tests/unit/phpunit/modules/CampaignTrackers/CampaignTrackerTest.php @@ -13,20 +13,20 @@ class CampaignTrackerTest extends SuitePHPUnitFrameworkTestCase $current_user = BeanFactory::newBean('Users'); } - public function testCampaignTracker() + public function testCampaignTracker(): void { // Execute the constructor and check for the Object type and attributes $campaignTracker = BeanFactory::newBean('CampaignTrackers'); - $this->assertInstanceOf('CampaignTracker', $campaignTracker); - $this->assertInstanceOf('SugarBean', $campaignTracker); + self::assertInstanceOf('CampaignTracker', $campaignTracker); + self::assertInstanceOf('SugarBean', $campaignTracker); - $this->assertAttributeEquals('CampaignTrackers', 'module_dir', $campaignTracker); - $this->assertAttributeEquals('CampaignTracker', 'object_name', $campaignTracker); - $this->assertAttributeEquals('campaign_trkrs', 'table_name', $campaignTracker); - $this->assertAttributeEquals(true, 'new_schema', $campaignTracker); + self::assertEquals('CampaignTrackers', $campaignTracker->module_dir); + self::assertEquals('CampaignTracker', $campaignTracker->object_name); + self::assertEquals('campaign_trkrs', $campaignTracker->table_name); + self::assertEquals(true, $campaignTracker->new_schema); } - public function testsave() + public function testsave(): void { $campaignTracker = BeanFactory::newBean('CampaignTrackers'); @@ -36,38 +36,38 @@ class CampaignTrackerTest extends SuitePHPUnitFrameworkTestCase $campaignTracker->save(); //test for record ID to verify that record is saved - $this->assertTrue(isset($campaignTracker->id)); - $this->assertEquals(36, strlen($campaignTracker->id)); + self::assertTrue(isset($campaignTracker->id)); + self::assertEquals(36, strlen($campaignTracker->id)); //mark the record as deleted and verify that this record cannot be retrieved anymore. $campaignTracker->mark_deleted($campaignTracker->id); $result = $campaignTracker->retrieve($campaignTracker->id); - $this->assertEquals(null, $result); + self::assertEquals(null, $result); } - public function testget_summary_text() + public function testget_summary_text(): void { $campaignTracker = BeanFactory::newBean('CampaignTrackers'); //test without setting name - $this->assertEquals(null, $campaignTracker->get_summary_text()); + self::assertEquals(null, $campaignTracker->get_summary_text()); //test with name set $campaignTracker->tracker_name = 'test'; - $this->assertEquals('test', $campaignTracker->get_summary_text()); + self::assertEquals('test', $campaignTracker->get_summary_text()); } - public function testfill_in_additional_detail_fields() + public function testfill_in_additional_detail_fields(): void { $campaignTracker = BeanFactory::newBean('CampaignTrackers'); //test without is_optout set $campaignTracker->fill_in_additional_detail_fields(); - $this->assertStringEndsWith('/index.php?entryPoint=campaign_trackerv2&track=', $campaignTracker->message_url); + self::assertStringEndsWith('/index.php?entryPoint=campaign_trackerv2&track=', $campaignTracker->message_url); //test with is_optout set $campaignTracker->is_optout = 1; $campaignTracker->fill_in_additional_detail_fields(); - $this->assertStringEndsWith('/index.php?entryPoint=removeme&identifier={MESSAGE_ID}', $campaignTracker->message_url); + self::assertStringEndsWith('/index.php?entryPoint=removeme&identifier={MESSAGE_ID}', $campaignTracker->message_url); } } diff --git a/tests/unit/phpunit/modules/Campaigns/CampaignTest.php b/tests/unit/phpunit/modules/Campaigns/CampaignTest.php index 3d6f2fa1b..829984b77 100644 --- a/tests/unit/phpunit/modules/Campaigns/CampaignTest.php +++ b/tests/unit/phpunit/modules/Campaigns/CampaignTest.php @@ -15,7 +15,7 @@ class CampaignTest extends SuitePHPUnitFrameworkTestCase $current_user = BeanFactory::newBean('Users'); } - public function testSubscribeUnsubscribeFromNewsLetterCampaign() + public function testSubscribeUnsubscribeFromNewsLetterCampaign(): void { $campaign = BeanFactory::newBean('Campaigns'); $campaign->name = create_guid(); @@ -45,54 +45,54 @@ class CampaignTest extends SuitePHPUnitFrameworkTestCase // Subscribe subscribe($campaign->id, null, $lead, true); $keyed = get_subscription_lists_keyed($lead); - $this->assertArrayHasKey($campaign->name, $keyed['subscribed']); - $this->assertEquals($default_list->id, $keyed['subscribed'][$campaign->name]['prospect_list_id']); + self::assertArrayHasKey($campaign->name, $keyed['subscribed']); + self::assertEquals($default_list->id, $keyed['subscribed'][$campaign->name]['prospect_list_id']); // Unsubscribe unsubscribe($campaign->id, $lead); $keyed = get_subscription_lists_keyed($lead); - $this->assertArrayNotHasKey($campaign->name, $keyed['subscribed']); - $this->assertArrayHasKey($campaign->name, $keyed['unsubscribed']); - $this->assertEquals($default_list->id, $keyed['unsubscribed'][$campaign->name]['prospect_list_id']); + self::assertArrayNotHasKey($campaign->name, $keyed['subscribed']); + self::assertArrayHasKey($campaign->name, $keyed['unsubscribed']); + self::assertEquals($default_list->id, $keyed['unsubscribed'][$campaign->name]['prospect_list_id']); } - public function testCampaign() + public function testCampaign(): void { // Execute the constructor and check for the Object type and attributes $campaign = BeanFactory::newBean('Campaigns'); - $this->assertInstanceOf('Campaign', $campaign); - $this->assertInstanceOf('SugarBean', $campaign); + self::assertInstanceOf('Campaign', $campaign); + self::assertInstanceOf('SugarBean', $campaign); - $this->assertAttributeEquals('Campaigns', 'module_dir', $campaign); - $this->assertAttributeEquals('Campaign', 'object_name', $campaign); - $this->assertAttributeEquals('campaigns', 'table_name', $campaign); - $this->assertAttributeEquals(true, 'new_schema', $campaign); - $this->assertAttributeEquals(true, 'importable', $campaign); + self::assertEquals('Campaigns', $campaign->module_dir); + self::assertEquals('Campaign', $campaign->object_name); + self::assertEquals('campaigns', $campaign->table_name); + self::assertEquals(true, $campaign->new_schema); + self::assertEquals(true, $campaign->importable); } - public function testlist_view_parse_additional_sections() + public function testlist_view_parse_additional_sections(): void { $campaign = BeanFactory::newBean('Campaigns'); //test with attributes preset and verify template variables are set accordingly $tpl = new Sugar_Smarty(); $campaign->list_view_parse_additional_sections($tpl); - $this->assertEquals('', isset($tpl->_tpl_vars['ASSIGNED_USER_NAME']) ? $tpl->_tpl_vars['ASSIGNED_USER_NAME'] : null); + self::assertEquals('', isset($tpl->_tpl_vars['ASSIGNED_USER_NAME']) ? $tpl->_tpl_vars['ASSIGNED_USER_NAME'] : null); } - public function testget_summary_text() + public function testget_summary_text(): void { $campaign = BeanFactory::newBean('Campaigns'); //test without setting name - $this->assertEquals(null, $campaign->get_summary_text()); + self::assertEquals(null, $campaign->get_summary_text()); //test with name set $campaign->name = 'test'; - $this->assertEquals('test', $campaign->get_summary_text()); + self::assertEquals('test', $campaign->get_summary_text()); } - public function testcreate_export_query() + public function testcreate_export_query(): void { self::markTestIncomplete('#Warning: Strings contain different line endings!'); $campaign = BeanFactory::newBean('Campaigns'); @@ -100,15 +100,15 @@ class CampaignTest extends SuitePHPUnitFrameworkTestCase //test with empty string params $expected = "SELECT\n campaigns.*,\n users.user_name as assigned_user_name FROM campaigns LEFT JOIN users\n ON campaigns.assigned_user_id=users.id where campaigns.deleted=0 ORDER BY campaigns.name"; $actual = $campaign->create_export_query('', ''); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); //test with valid string params $expected = "SELECT\n campaigns.*,\n users.user_name as assigned_user_name FROM campaigns LEFT JOIN users\n ON campaigns.assigned_user_id=users.id where campaigns.name=\"\" AND campaigns.deleted=0 ORDER BY campaigns.id"; $actual = $campaign->create_export_query('campaigns.id', 'campaigns.name=""'); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } - public function testclear_campaign_prospect_list_relationship() + public function testclear_campaign_prospect_list_relationship(): void { $campaign = BeanFactory::newBean('Campaigns'); @@ -116,13 +116,13 @@ class CampaignTest extends SuitePHPUnitFrameworkTestCase try { $campaign->clear_campaign_prospect_list_relationship(''); $campaign->clear_campaign_prospect_list_relationship('1'); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } } - public function testmark_relationships_deleted() + public function testmark_relationships_deleted(): void { $campaign = BeanFactory::newBean('Campaigns'); @@ -130,52 +130,52 @@ class CampaignTest extends SuitePHPUnitFrameworkTestCase try { $campaign->mark_relationships_deleted(''); $campaign->mark_relationships_deleted('1'); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } } - public function testfill_in_additional_list_fields() + public function testfill_in_additional_list_fields(): void { $campaign = BeanFactory::newBean('Campaigns'); // Execute the method and test that it works and doesn't throw an exception. try { $campaign->fill_in_additional_list_fields(); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } } - public function testfill_in_additional_detail_fields() + public function testfill_in_additional_detail_fields(): void { $campaign = BeanFactory::newBean('Campaigns'); // Execute the method and test that it works and doesn't throw an exception. try { $campaign->fill_in_additional_detail_fields(); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } } - public function testupdate_currency_id() + public function testupdate_currency_id(): void { $campaign = BeanFactory::newBean('Campaigns'); // Execute the method and test that it works and doesn't throw an exception. try { $campaign->update_currency_id('', ''); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } } - public function testget_list_view_data() + public function testget_list_view_data(): void { $campaign = BeanFactory::newBean('Campaigns'); @@ -199,29 +199,29 @@ class CampaignTest extends SuitePHPUnitFrameworkTestCase $actual = $campaign->get_list_view_data(); foreach ($expected as $expectedKey => $expectedVal) { if ($expectedKey == 'LAUNCH_WIZARD_IMAGE' || $expectedKey == 'TRACK_CAMPAIGN_IMAGE') { - $this->assertRegExp($expected[$expectedKey], $actual[$expectedKey]); + self::assertMatchesRegularExpression($expected[$expectedKey], $actual[$expectedKey]); } else { - $this->assertSame($expected[$expectedKey], $actual[$expectedKey]); + self::assertSame($expected[$expectedKey], $actual[$expectedKey]); } } } - public function testbuild_generic_where_clause() + public function testbuild_generic_where_clause(): void { $campaign = BeanFactory::newBean('Campaigns'); //test with blank parameter $expected = "campaigns.name like '%'"; $actual = $campaign->build_generic_where_clause(''); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); //test with valid parameter $expected = "campaigns.name like '1%'"; $actual = $campaign->build_generic_where_clause(1); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } - public function testSaveAndMarkDeleted() + public function testSaveAndMarkDeleted(): void { $campaign = BeanFactory::newBean('Campaigns'); $campaign->name = 'test'; @@ -230,16 +230,16 @@ class CampaignTest extends SuitePHPUnitFrameworkTestCase $campaign->save(); //test for record ID to verify that record is saved - $this->assertTrue(isset($campaign->id)); - $this->assertEquals(36, strlen($campaign->id)); + self::assertTrue(isset($campaign->id)); + self::assertEquals(36, strlen($campaign->id)); //mark the record as deleted and verify that this record cannot be retrieved anymore. $campaign->mark_deleted($campaign->id); $result = $campaign->retrieve($campaign->id); - $this->assertEquals(null, $result); + self::assertEquals(null, $result); } - public function testset_notification_body() + public function testset_notification_body(): void { $campaign = BeanFactory::newBean('Campaigns'); @@ -252,38 +252,38 @@ class CampaignTest extends SuitePHPUnitFrameworkTestCase $result = $campaign->set_notification_body(new Sugar_Smarty(), $campaign); - $this->assertEquals($campaign->name, $result->_tpl_vars['CAMPAIGN_NAME']); - $this->assertEquals($campaign->budget, $result->_tpl_vars['CAMPAIGN_AMOUNT']); - $this->assertEquals($campaign->end_date, $result->_tpl_vars['CAMPAIGN_CLOSEDATE']); - $this->assertEquals($campaign->status, $result->_tpl_vars['CAMPAIGN_STATUS']); - $this->assertEquals($campaign->content, $result->_tpl_vars['CAMPAIGN_DESCRIPTION']); + self::assertEquals($campaign->name, $result->_tpl_vars['CAMPAIGN_NAME']); + self::assertEquals($campaign->budget, $result->_tpl_vars['CAMPAIGN_AMOUNT']); + self::assertEquals($campaign->end_date, $result->_tpl_vars['CAMPAIGN_CLOSEDATE']); + self::assertEquals($campaign->status, $result->_tpl_vars['CAMPAIGN_STATUS']); + self::assertEquals($campaign->content, $result->_tpl_vars['CAMPAIGN_DESCRIPTION']); } - public function testtrack_log_leads() + public function testtrack_log_leads(): void { $campaign = BeanFactory::newBean('Campaigns'); $expected = "SELECT campaign_log.* FROM campaign_log WHERE campaign_log.campaign_id = '' AND campaign_log.deleted=0 AND activity_type = 'lead' AND archived = 0 AND target_id IS NOT NULL "; $actual = $campaign->track_log_leads(); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } - public function testtrack_log_entries() + public function testtrack_log_entries(): void { $campaign = BeanFactory::newBean('Campaigns'); //test without parameters $expected = "SELECT campaign_log.* FROM campaign_log WHERE campaign_log.campaign_id = '' AND campaign_log.deleted=0 AND activity_type='targeted' AND archived=0 "; $actual = $campaign->track_log_entries(); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); //test with parameters $expected = "SELECT campaign_log.* FROM campaign_log WHERE campaign_log.campaign_id = '' AND campaign_log.deleted=0 AND activity_type='test1' AND archived=0 "; $actual = $campaign->track_log_entries(array('test1', 'test2')); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } - public function testget_queue_items() + public function testget_queue_items(): void { $campaign = BeanFactory::newBean('Campaigns'); @@ -355,7 +355,7 @@ WHERE emailman.campaign_id = '' $actual = str_replace("\t", '', $actual); $actual = strtolower($actual); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); //with parameters $expected = "SELECT emailman.*, @@ -430,41 +430,40 @@ WHERE emailman.campaign_id = '' $actual = str_replace("\r", '', $actual); $actual = str_replace("\t", '', $actual); $actual = strtolower($actual); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } - public function testbean_implements() + public function testbean_implements(): void { $campaign = BeanFactory::newBean('Campaigns'); - $this->assertEquals(false, $campaign->bean_implements('')); //test with blank value - $this->assertEquals(false, $campaign->bean_implements('test')); //test with invalid value - $this->assertEquals(true, $campaign->bean_implements('ACL')); //test with valid value + self::assertEquals(false, $campaign->bean_implements('')); //test with blank value + self::assertEquals(false, $campaign->bean_implements('test')); //test with invalid value + self::assertEquals(true, $campaign->bean_implements('ACL')); //test with valid value } - public function testcreate_list_count_query() + public function testcreate_list_count_query(): void { $campaign = BeanFactory::newBean('Campaigns'); //test without parameters $expected = ''; $actual = $campaign->create_list_count_query(''); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); //test with query parameters $expected = 'SELECT count(*) c FROM campaigns'; $actual = $campaign->create_list_count_query('select * from campaigns'); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); //test with distinct $expected = 'SELECT count(DISTINCT campaigns.id) c FROM campaigns'; $actual = $campaign->create_list_count_query('SELECT distinct marketing_id FROM campaigns'); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } - public function testgetDeletedCampaignLogLeadsCount() + public function testgetDeletedCampaignLogLeadsCount(): void { - $campaign = BeanFactory::newBean('Campaigns'); - $result = $campaign->getDeletedCampaignLogLeadsCount(); - $this->assertEquals(0, $result); + $result = BeanFactory::newBean('Campaigns')->getDeletedCampaignLogLeadsCount(); + self::assertEquals(0, $result); } } diff --git a/tests/unit/phpunit/modules/Cases/CaseTest.php b/tests/unit/phpunit/modules/Cases/CaseTest.php deleted file mode 100644 index 181761dc3..000000000 --- a/tests/unit/phpunit/modules/Cases/CaseTest.php +++ /dev/null @@ -1,244 +0,0 @@ -assertInstanceOf('aCase', $aCase); - $this->assertInstanceOf('Basic', $aCase); - $this->assertInstanceOf('SugarBean', $aCase); - - $this->assertAttributeEquals('Cases', 'module_dir', $aCase); - $this->assertAttributeEquals('Case', 'object_name', $aCase); - $this->assertAttributeEquals('cases', 'table_name', $aCase); - $this->assertAttributeEquals('accounts_cases', 'rel_account_table', $aCase); - $this->assertAttributeEquals('contacts_cases', 'rel_contact_table', $aCase); - $this->assertAttributeEquals(true, 'importable', $aCase); - $this->assertAttributeEquals(true, 'new_schema', $aCase); - } - - public function testget_summary_text() - { - $aCase = BeanFactory::newBean('Cases'); - $this->assertEquals(null, $aCase->get_summary_text()); - - $aCase->name = 'test'; - $this->assertEquals('test', $aCase->get_summary_text()); - } - - public function testlistviewACLHelper() - { - self::markTestIncomplete('environment dependency'); - - - $aCase = BeanFactory::newBean('Cases'); - $expected = array('MAIN' => 'span', 'ACCOUNT' => 'span'); - $actual = $aCase->listviewACLHelper(); - $this->assertSame($expected, $actual); - } - - public function testsave_relationship_changes() - { - $aCase = BeanFactory::newBean('Cases'); - - // Execute the method and test that it works and doesn't throw an exception. - try { - $aCase->save_relationship_changes(true); - $aCase->save_relationship_changes(false); - - $this->assertTrue(true); - } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); - } - } - - public function testset_case_contact_relationship() - { - $aCase = BeanFactory::newBean('Cases'); - - // Execute the method and test that it works and doesn't throw an exception. - try { - $aCase->set_case_contact_relationship(1); - $this->assertTrue(true); - } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); - } - } - - public function testfill_in_additional_list_fields() - { - $aCase = BeanFactory::newBean('Cases'); - - // Execute the method and test that it works and doesn't throw an exception. - try { - $aCase->fill_in_additional_list_fields(); - $this->assertTrue(true); - } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); - } - } - - public function testfill_in_additional_detail_fields() - { - $aCase = BeanFactory::newBean('Cases'); - $aCase->assigned_user_id = 1; - $aCase->created_by = 1; - $aCase->modified_user_id = 1; - - $aCase->fill_in_additional_detail_fields(); - - $this->assertEquals('Administrator', $aCase->assigned_user_name); - $this->assertEquals('Administrator', $aCase->created_by_name); - $this->assertEquals('Administrator', $aCase->modified_by_name); - } - - public function testget_contacts() - { - $aCase = BeanFactory::newBean('Cases'); - $result = $aCase->get_contacts(); - $this->assertFalse(is_array($result)); - $this->assertEquals(false, $result); - } - - public function testget_list_view_data() - { - $aCase = BeanFactory::newBean('Cases'); - $current_theme = SugarThemeRegistry::current(); - //test without setting attributes - $expected = array( - 'DELETED' => 0, - 'STATE' => 'Open', - 'UPDATE_TEXT' => '', - 'NAME' => 'blank', - 'PRIORITY' => '', - 'STATUS' => '', - 'ENCODED_NAME' => null, - 'CASE_NUMBER' => null, - 'SET_COMPLETE' => '~' - .preg_quote('Close') - .'~', - ); - - $actual = $aCase->get_list_view_data(); - //$this->assertSame($expected ,$actual); - $this->assertEquals($expected['STATE'], $actual['STATE']); - $this->assertEquals($expected['UPDATE_TEXT'], $actual['UPDATE_TEXT']); - $this->assertEquals($expected['NAME'], $actual['NAME']); - $this->assertEquals($expected['PRIORITY'], $actual['PRIORITY']); - $this->assertRegExp($expected['SET_COMPLETE'], $actual['SET_COMPLETE']); - - //test with attributes preset - $aCase->name = 'test'; - $aCase->priority = 'P1'; - $aCase->status = 'Open_New'; - $aCase->case_number = 1; - - $expected = array( - 'NAME' => 'test', - 'DELETED' => 0, - 'CASE_NUMBER' => 1, - 'STATUS' => 'New', - 'PRIORITY' => 'High', - 'STATE' => 'Open', - 'UPDATE_TEXT' => '', - 'ENCODED_NAME' => 'test', - 'SET_COMPLETE' => 'Close', - ); - - $actual = $aCase->get_list_view_data(); - //$this->assertSame($expected ,$actual); - $this->assertEquals($expected['NAME'], $actual['NAME']); - $this->assertEquals($expected['CASE_NUMBER'], $actual['CASE_NUMBER']); - $this->assertEquals($expected['STATUS'], $actual['STATUS']); - $this->assertEquals($expected['PRIORITY'], $actual['PRIORITY']); - $this->assertEquals($expected['STATE'], $actual['STATE']); - } - - public function testbuild_generic_where_clause() - { - $aCase = BeanFactory::newBean('Cases'); - - //test with string - $expected = "(cases.name like 'test%' or accounts.name like 'test%')"; - $actual = $aCase->build_generic_where_clause('test'); - $this->assertSame($expected, $actual); - - //test with number - $expected = "(cases.name like '1%' or accounts.name like '1%' or cases.case_number like '1%')"; - $actual = $aCase->build_generic_where_clause(1); - $this->assertSame($expected, $actual); - } - - public function testset_notification_body() - { - $aCase = BeanFactory::newBean('Cases'); - - $aCase->name = 'test'; - $aCase->priority = 'P1'; - $aCase->status = 'Open_New'; - $aCase->description = 'some text'; - - $result = $aCase->set_notification_body(new Sugar_Smarty(), $aCase); - - $this->assertEquals($aCase->name, $result->_tpl_vars['CASE_SUBJECT']); - $this->assertEquals('High', $result->_tpl_vars['CASE_PRIORITY']); - $this->assertEquals('New', $result->_tpl_vars['CASE_STATUS']); - $this->assertEquals($aCase->description, $result->_tpl_vars['CASE_DESCRIPTION']); - } - - public function testbean_implements() - { - $aCase = BeanFactory::newBean('Cases'); - $this->assertEquals(false, $aCase->bean_implements('')); //test with blank value - $this->assertEquals(false, $aCase->bean_implements('test')); //test with invalid value - $this->assertEquals(true, $aCase->bean_implements('ACL')); //test with valid value - } - - public function testsave() - { - $aCase = BeanFactory::newBean('Cases'); - $aCase->name = 'test'; - $aCase->priority = 'P1'; - - $aCase->save(); - - //test for record ID to verify that record is saved - $this->assertTrue(isset($aCase->id)); - $this->assertEquals(36, strlen($aCase->id)); - - //mark the record as deleted and verify that this record cannot be retrieved anymore. - $aCase->mark_deleted($aCase->id); - $result = $aCase->retrieve($aCase->id); - $this->assertEquals(null, $result); - } - - public function testgetEmailSubjectMacro() - { - $aCase = BeanFactory::newBean('Cases'); - $result = $aCase->getEmailSubjectMacro(); - $this->assertEquals('[CASE:%1]', $result); - } - - public function testgetAccount() - { - $aCase = BeanFactory::newBean('Cases'); - $result = $aCase->getAccount(1); - $this->assertTrue(is_array($result)); - $this->assertEquals(array('account_name' => '', 'account_id' => ''), $result); - } -} diff --git a/tests/unit/phpunit/modules/Cases/aCaseTest.php b/tests/unit/phpunit/modules/Cases/aCaseTest.php new file mode 100644 index 000000000..848b0ee76 --- /dev/null +++ b/tests/unit/phpunit/modules/Cases/aCaseTest.php @@ -0,0 +1,289 @@ +module_dir); + self::assertEquals('Case', $aCase->object_name); + self::assertEquals('cases', $aCase->table_name); + self::assertEquals('accounts_cases', $aCase->rel_account_table); + self::assertEquals('contacts_cases', $aCase->rel_contact_table); + self::assertEquals(true, $aCase->importable); + self::assertEquals(true, $aCase->new_schema); + } + + public function testget_summary_text(): void + { + $aCase = BeanFactory::newBean('Cases'); + self::assertEquals(null, $aCase->get_summary_text()); + + $aCase->name = 'test'; + self::assertEquals('test', $aCase->get_summary_text()); + } + + public function testlistviewACLHelper(): void + { + self::markTestIncomplete('environment dependency'); + + + $aCase = BeanFactory::newBean('Cases'); + $expected = array('MAIN' => 'span', 'ACCOUNT' => 'span'); + $actual = $aCase->listviewACLHelper(); + self::assertSame($expected, $actual); + } + + public function testsave_relationship_changes(): void + { + $aCase = BeanFactory::newBean('Cases'); + + // Execute the method and test that it works and doesn't throw an exception. + try { + $aCase->save_relationship_changes(true); + $aCase->save_relationship_changes(false); + + self::assertTrue(true); + } catch (Exception $e) { + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + } + } + + public function testset_case_contact_relationship(): void + { + $aCase = BeanFactory::newBean('Cases'); + + // Execute the method and test that it works and doesn't throw an exception. + try { + $aCase->set_case_contact_relationship(1); + self::assertTrue(true); + } catch (Exception $e) { + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + } + } + + public function testfill_in_additional_list_fields(): void + { + $aCase = BeanFactory::newBean('Cases'); + + // Execute the method and test that it works and doesn't throw an exception. + try { + $aCase->fill_in_additional_list_fields(); + self::assertTrue(true); + } catch (Exception $e) { + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + } + } + + public function testfill_in_additional_detail_fields(): void + { + $aCase = BeanFactory::newBean('Cases'); + $aCase->assigned_user_id = 1; + $aCase->created_by = 1; + $aCase->modified_user_id = 1; + + $aCase->fill_in_additional_detail_fields(); + + self::assertEquals('Administrator', $aCase->assigned_user_name); + self::assertEquals('Administrator', $aCase->created_by_name); + self::assertEquals('Administrator', $aCase->modified_by_name); + } + + public function testget_contacts(): void + { + $result = BeanFactory::newBean('Cases')->get_contacts(); + self::assertIsNotArray($result); + self::assertEquals(false, $result); + } + + public function testget_list_view_data(): void + { + $aCase = BeanFactory::newBean('Cases'); + $current_theme = SugarThemeRegistry::current(); + //test without setting attributes + $expected = array( + 'DELETED' => 0, + 'STATE' => 'Open', + 'UPDATE_TEXT' => '', + 'NAME' => 'blank', + 'PRIORITY' => '', + 'STATUS' => '', + 'ENCODED_NAME' => null, + 'CASE_NUMBER' => null, + 'SET_COMPLETE' => '~' + .preg_quote('Close') + .'~', + ); + + $actual = $aCase->get_list_view_data(); + //$this->assertSame($expected ,$actual); + self::assertEquals($expected['STATE'], $actual['STATE']); + self::assertEquals($expected['UPDATE_TEXT'], $actual['UPDATE_TEXT']); + self::assertEquals($expected['NAME'], $actual['NAME']); + self::assertEquals($expected['PRIORITY'], $actual['PRIORITY']); + self::assertMatchesRegularExpression($expected['SET_COMPLETE'], $actual['SET_COMPLETE']); + + //test with attributes preset + $aCase->name = 'test'; + $aCase->priority = 'P1'; + $aCase->status = 'Open_New'; + $aCase->case_number = 1; + + $expected = array( + 'NAME' => 'test', + 'DELETED' => 0, + 'CASE_NUMBER' => 1, + 'STATUS' => 'New', + 'PRIORITY' => 'High', + 'STATE' => 'Open', + 'UPDATE_TEXT' => '', + 'ENCODED_NAME' => 'test', + 'SET_COMPLETE' => 'Close', + ); + + $actual = $aCase->get_list_view_data(); + //$this->assertSame($expected ,$actual); + self::assertEquals($expected['NAME'], $actual['NAME']); + self::assertEquals($expected['CASE_NUMBER'], $actual['CASE_NUMBER']); + self::assertEquals($expected['STATUS'], $actual['STATUS']); + self::assertEquals($expected['PRIORITY'], $actual['PRIORITY']); + self::assertEquals($expected['STATE'], $actual['STATE']); + } + + public function testbuild_generic_where_clause(): void + { + $aCase = BeanFactory::newBean('Cases'); + + //test with string + $expected = "(cases.name like 'test%' or accounts.name like 'test%')"; + $actual = $aCase->build_generic_where_clause('test'); + self::assertSame($expected, $actual); + + //test with number + $expected = "(cases.name like '1%' or accounts.name like '1%' or cases.case_number like '1%')"; + $actual = $aCase->build_generic_where_clause(1); + self::assertSame($expected, $actual); + } + + public function testset_notification_body(): void + { + $aCase = BeanFactory::newBean('Cases'); + + $aCase->name = 'test'; + $aCase->priority = 'P1'; + $aCase->status = 'Open_New'; + $aCase->description = 'some text'; + + $result = $aCase->set_notification_body(new Sugar_Smarty(), $aCase); + + self::assertEquals($aCase->name, $result->_tpl_vars['CASE_SUBJECT']); + self::assertEquals('High', $result->_tpl_vars['CASE_PRIORITY']); + self::assertEquals('New', $result->_tpl_vars['CASE_STATUS']); + self::assertEquals($aCase->description, $result->_tpl_vars['CASE_DESCRIPTION']); + } + + public function testbean_implements(): void + { + $aCase = BeanFactory::newBean('Cases'); + self::assertEquals(false, $aCase->bean_implements('')); //test with blank value + self::assertEquals(false, $aCase->bean_implements('test')); //test with invalid value + self::assertEquals(true, $aCase->bean_implements('ACL')); //test with valid value + } + + public function testsave(): void + { + $aCase = BeanFactory::newBean('Cases'); + $aCase->name = 'test'; + $aCase->priority = 'P1'; + + $aCase->save(); + + //test for record ID to verify that record is saved + self::assertTrue(isset($aCase->id)); + self::assertEquals(36, strlen($aCase->id)); + + //mark the record as deleted and verify that this record cannot be retrieved anymore. + $aCase->mark_deleted($aCase->id); + $result = $aCase->retrieve($aCase->id); + self::assertEquals(null, $result); + } + + public function testgetEmailSubjectMacro(): void + { + $result = BeanFactory::newBean('Cases')->getEmailSubjectMacro(); + self::assertEquals('[CASE:%1]', $result); + } + + public function testgetAccount(): void + { + $result = BeanFactory::newBean('Cases')->getAccount(1); + self::assertIsArray($result); + self::assertEquals(array('account_name' => '', 'account_id' => ''), $result); + } +} diff --git a/tests/unit/phpunit/modules/Contacts/ContactTest.php b/tests/unit/phpunit/modules/Contacts/ContactTest.php index 9177816e9..773b1e306 100644 --- a/tests/unit/phpunit/modules/Contacts/ContactTest.php +++ b/tests/unit/phpunit/modules/Contacts/ContactTest.php @@ -13,33 +13,33 @@ class ContactTest extends SuitePHPUnitFrameworkTestCase $current_user = BeanFactory::newBean('Users'); } - public function testContact() + public function testContact(): void { // Execute the constructor and check for the Object type and attributes $contact = BeanFactory::newBean('Contacts'); - $this->assertInstanceOf('Contact', $contact); - $this->assertInstanceOf('Person', $contact); - $this->assertInstanceOf('SugarBean', $contact); + self::assertInstanceOf('Contact', $contact); + self::assertInstanceOf('Person', $contact); + self::assertInstanceOf('SugarBean', $contact); - $this->assertAttributeEquals('Contacts', 'module_dir', $contact); - $this->assertAttributeEquals('Contact', 'object_name', $contact); - $this->assertAttributeEquals('contacts', 'table_name', $contact); - $this->assertAttributeEquals('accounts_contacts', 'rel_account_table', $contact); - $this->assertAttributeEquals('opportunities_contacts', 'rel_opportunity_table', $contact); - $this->assertAttributeEquals(true, 'importable', $contact); - $this->assertAttributeEquals(true, 'new_schema', $contact); + self::assertEquals('Contacts', $contact->module_dir); + self::assertEquals('Contact', $contact->object_name); + self::assertEquals('contacts', $contact->table_name); + self::assertEquals('accounts_contacts', $contact->rel_account_table); + self::assertEquals('opportunities_contacts', $contact->rel_opportunity_table); + self::assertEquals(true, $contact->importable); + self::assertEquals(true, $contact->new_schema); } - public function testadd_list_count_joins() + public function testadd_list_count_joins(): void { - $this->markTestIncomplete('Breaks on php 7.1'); + self::markTestIncomplete('Breaks on php 7.1'); $contact = BeanFactory::newBean('Contacts'); //test with empty strings $query = ""; $contact->add_list_count_joins($query, ''); - $this->assertEquals(" LEFT JOIN contacts_cstm ON contacts.id = contacts_cstm.id_c ", $query); + self::assertEquals(" LEFT JOIN contacts_cstm ON contacts.id = contacts_cstm.id_c ", $query); //test with valid string @@ -48,16 +48,16 @@ class ContactTest extends SuitePHPUnitFrameworkTestCase $contact->add_list_count_joins($query, 'accounts.name'); $query = preg_replace('/\s+/', '', $query); $expected =preg_replace('/\s+/', '', $expected); - $this->assertSame($expected, $query); + self::assertSame($expected, $query); //test with valid string $query = ""; $expected = "\n LEFT JOIN accounts_contacts\n ON contacts.id=accounts_contacts.contact_id\n LEFT JOIN accounts\n ON accounts_contacts.account_id=accounts.id\n LEFT JOIN contacts_cstm ON contacts.id = contacts_cstm.id_c "; $contact->add_list_count_joins($query, 'contacts.name'); - $this->assertSame(" LEFT JOIN contacts_cstm ON contacts.id = contacts_cstm.id_c ", $query); + self::assertSame(" LEFT JOIN contacts_cstm ON contacts.id = contacts_cstm.id_c ", $query); } - public function testlistviewACLHelper() + public function testlistviewACLHelper(): void { self::markTestIncomplete('environment dependency'); @@ -66,13 +66,13 @@ class ContactTest extends SuitePHPUnitFrameworkTestCase $expected = array( "MAIN"=>"span", "ACCOUNT"=>"span"); $actual = $contact->listviewACLHelper(); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } /** * @todo: NEEDS FIXING! */ - public function testcreate_new_list_query() + public function testcreate_new_list_query(): void { /* $contact = BeanFactory::newBean('Contacts'); @@ -88,32 +88,32 @@ class ContactTest extends SuitePHPUnitFrameworkTestCase $actual = $contact->create_new_list_query("account.name","account.name is null"); $this->assertSame($expected,$actual); */ - $this->assertTrue(true, "NEEDS FIXING!"); + self::assertTrue(true, "NEEDS FIXING!"); } - public function testaddress_popup_create_new_list_query() + public function testaddress_popup_create_new_list_query(): void { - $this->markTestIncomplete('Breaks on php 7.1'); + self::markTestIncomplete('Breaks on php 7.1'); $contact = BeanFactory::newBean('Contacts'); //test with empty string params $expected = "SELECT LTRIM(RTRIM(CONCAT(IFNULL(contacts.first_name,''),'',IFNULL(contacts.last_name,'')))) name, \n contacts.*,\n accounts.name as account_name,\n accounts.id as account_id,\n accounts.assigned_user_id account_id_owner,\n users.user_name as assigned_user_name ,contacts_cstm.*\n FROM contacts LEFT JOIN users\n ON contacts.assigned_user_id=users.id\n LEFT JOIN accounts_contacts\n ON contacts.id=accounts_contacts.contact_id and accounts_contacts.deleted = 0\n LEFT JOIN accounts\n ON accounts_contacts.account_id=accounts.id AND accounts.deleted=0 LEFT JOIN email_addr_bean_rel eabl ON eabl.bean_id = contacts.id AND eabl.bean_module = 'Contacts' and eabl.primary_address = 1 and eabl.deleted=0 LEFT JOIN email_addresses ea ON (ea.id = eabl.email_address_id) LEFT JOIN contacts_cstm ON contacts.id = contacts_cstm.id_c where contacts.deleted=0 "; $actual = $contact->address_popup_create_new_list_query('', ''); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); //test with valid string params $expected = "SELECT LTRIM(RTRIM(CONCAT(IFNULL(contacts.first_name,''),'',IFNULL(contacts.last_name,'')))) name, \n contacts.*,\n accounts.name as account_name,\n accounts.id as account_id,\n accounts.assigned_user_id account_id_owner,\n users.user_name as assigned_user_name ,contacts_cstm.*\n FROM contacts LEFT JOIN users\n ON contacts.assigned_user_id=users.id\n LEFT JOIN accounts_contacts\n ON contacts.id=accounts_contacts.contact_id and accounts_contacts.deleted = 0\n LEFT JOIN accounts\n ON accounts_contacts.account_id=accounts.id AND accounts.deleted=0 LEFT JOIN email_addr_bean_rel eabl ON eabl.bean_id = contacts.id AND eabl.bean_module = 'Contacts' and eabl.primary_address = 1 and eabl.deleted=0 LEFT JOIN email_addresses ea ON (ea.id = eabl.email_address_id) LEFT JOIN contacts_cstm ON contacts.id = contacts_cstm.id_c where (contacts.name=\"\") AND contacts.deleted=0 "; $actual = $contact->address_popup_create_new_list_query('contacts.id', 'contacts.name=""'); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } - public function testcreate_export_query() + public function testcreate_export_query(): void { - $this->markTestIncomplete('Refactor needed as field ording changes on different test environments'); + self::markTestIncomplete('Refactor needed as field ording changes on different test environments'); } - public function testfill_in_additional_list_fields() + public function testfill_in_additional_list_fields(): void { $contact = BeanFactory::newBean('Contacts'); @@ -126,12 +126,12 @@ class ContactTest extends SuitePHPUnitFrameworkTestCase $contact->fill_in_additional_list_fields(); - $this->assertEquals("firstn lastn", $contact->full_name); - $this->assertEquals("firstn lastn <1@test.com>", $contact->email_and_name1); - $this->assertEquals("firstn lastn <2@test.com>", $contact->email_and_name2); + self::assertEquals("firstn lastn", $contact->full_name); + self::assertEquals("firstn lastn <1@test.com>", $contact->email_and_name1); + self::assertEquals("firstn lastn <2@test.com>", $contact->email_and_name2); } - public function testfill_in_additional_detail_fields() + public function testfill_in_additional_detail_fields(): void { $contact = BeanFactory::newBean('Contacts'); @@ -140,25 +140,25 @@ class ContactTest extends SuitePHPUnitFrameworkTestCase $contact->fill_in_additional_detail_fields(); - $this->assertEquals("", $contact->account_name); - $this->assertEquals("", $contact->account_id); - $this->assertEquals("", $contact->report_to_name); + self::assertEquals("", $contact->account_name); + self::assertEquals("", $contact->account_id); + self::assertEquals("", $contact->report_to_name); } - public function testload_contacts_users_relationship() + public function testload_contacts_users_relationship(): void { $contact = BeanFactory::newBean('Contacts'); // Execute the method and test that it works and doesn't throw an exception. try { $contact->load_contacts_users_relationship(); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } } - public function testget_list_view_data() + public function testget_list_view_data(): void { $contact = BeanFactory::newBean('Contacts'); @@ -182,31 +182,31 @@ class ContactTest extends SuitePHPUnitFrameworkTestCase $actual = $contact->get_list_view_data(); - $this->assertEquals($expected['NAME'], $actual['NAME']); - $this->assertEquals($expected['FIRST_NAME'], $actual['FIRST_NAME']); - $this->assertEquals($expected['LAST_NAME'], $actual['LAST_NAME']); - $this->assertEquals($expected['FULL_NAME'], $actual['FULL_NAME']); - $this->assertEquals($expected['ENCODED_NAME'], $actual['ENCODED_NAME']); - $this->assertEquals($expected['EMAIL_AND_NAME1'], $actual['EMAIL_AND_NAME1']); + self::assertEquals($expected['NAME'], $actual['NAME']); + self::assertEquals($expected['FIRST_NAME'], $actual['FIRST_NAME']); + self::assertEquals($expected['LAST_NAME'], $actual['LAST_NAME']); + self::assertEquals($expected['FULL_NAME'], $actual['FULL_NAME']); + self::assertEquals($expected['ENCODED_NAME'], $actual['ENCODED_NAME']); + self::assertEquals($expected['EMAIL_AND_NAME1'], $actual['EMAIL_AND_NAME1']); } - public function testbuild_generic_where_clause() + public function testbuild_generic_where_clause(): void { $contact = BeanFactory::newBean('Contacts'); //test with string $expected = "contacts.last_name like 'test%' or contacts.first_name like 'test%' or accounts.name like 'test%' or contacts.assistant like 'test%' or ea.email_address like 'test%'"; $actual = $contact->build_generic_where_clause('test'); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); //test with number $expected = "contacts.last_name like '1%' or contacts.first_name like '1%' or accounts.name like '1%' or contacts.assistant like '1%' or ea.email_address like '1%' or contacts.phone_home like '%1%' or contacts.phone_mobile like '%1%' or contacts.phone_work like '%1%' or contacts.phone_other like '%1%' or contacts.phone_fax like '%1%' or contacts.assistant_phone like '%1%'"; $actual = $contact->build_generic_where_clause(1); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } - public function testset_notification_body() + public function testset_notification_body(): void { $contact = BeanFactory::newBean('Contacts'); @@ -218,22 +218,20 @@ class ContactTest extends SuitePHPUnitFrameworkTestCase $result = $contact->set_notification_body(new Sugar_Smarty(), $contact); - $this->assertEquals($contact->full_name, $result->_tpl_vars['CONTACT_NAME']); - $this->assertEquals($contact->description, $result->_tpl_vars['CONTACT_DESCRIPTION']); + self::assertEquals($contact->full_name, $result->_tpl_vars['CONTACT_NAME']); + self::assertEquals($contact->description, $result->_tpl_vars['CONTACT_DESCRIPTION']); } - public function testget_contact_id_by_email() + public function testget_contact_id_by_email(): void { - $contact = BeanFactory::newBean('Contacts'); - - $result = $contact->get_contact_id_by_email(""); - $this->assertEquals(null, $result); + $result = BeanFactory::newBean('Contacts')->get_contact_id_by_email(""); + self::assertEquals(null, $result); - $this->markTestSkipped('Invalid Columns(email1,email2) in Query '); + self::markTestSkipped('Invalid Columns(email1,email2) in Query '); } - public function testsave_relationship_changes() + public function testsave_relationship_changes(): void { $contact = BeanFactory::newBean('Contacts'); @@ -241,21 +239,21 @@ class ContactTest extends SuitePHPUnitFrameworkTestCase try { $contact->save_relationship_changes(true); $contact->save_relationship_changes(false); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } } - public function testbean_implements() + public function testbean_implements(): void { $contact = BeanFactory::newBean('Contacts'); - $this->assertEquals(false, $contact->bean_implements('')); //test with blank value - $this->assertEquals(false, $contact->bean_implements('test')); //test with invalid value - $this->assertEquals(true, $contact->bean_implements('ACL')); //test with valid value + self::assertEquals(false, $contact->bean_implements('')); //test with blank value + self::assertEquals(false, $contact->bean_implements('test')); //test with invalid value + self::assertEquals(true, $contact->bean_implements('ACL')); //test with valid value } - public function testget_unlinked_email_query() + public function testget_unlinked_email_query(): void { $contact = BeanFactory::newBean('Contacts'); @@ -268,27 +266,27 @@ class ContactTest extends SuitePHPUnitFrameworkTestCase (select eb.email_id from emails_beans eb where eb.bean_module ='Contacts' and eb.bean_id = '') ) derivedemails on derivedemails.email_id = emails.id"; $actual = $contact->get_unlinked_email_query(); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } - public function testprocess_sync_to_outlook() + public function testprocess_sync_to_outlook(): void { $contact = BeanFactory::newBean('Contacts'); // Execute the method and test that it works and doesn't throw an exception. try { $contact->process_sync_to_outlook("all"); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } // Execute the method and test that it works and doesn't throw an exception. try { $contact->process_sync_to_outlook("1"); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } } } diff --git a/tests/unit/phpunit/modules/Currencies/CurrencyTest.php b/tests/unit/phpunit/modules/Currencies/CurrencyTest.php index 315f83129..d283bb3df 100644 --- a/tests/unit/phpunit/modules/Currencies/CurrencyTest.php +++ b/tests/unit/phpunit/modules/Currencies/CurrencyTest.php @@ -13,70 +13,70 @@ class CurrencyTest extends SuitePHPUnitFrameworkTestCase $current_user = BeanFactory::newBean('Users'); } - public function testCurrency() + public function testCurrency(): void { // Execute the constructor and check for the Object type and attributes $currency = BeanFactory::newBean('Currencies'); - $this->assertInstanceOf('Currency', $currency); - $this->assertInstanceOf('SugarBean', $currency); + self::assertInstanceOf('Currency', $currency); + self::assertInstanceOf('SugarBean', $currency); - $this->assertAttributeEquals('Currencies', 'module_dir', $currency); - $this->assertAttributeEquals('Currency', 'object_name', $currency); - $this->assertAttributeEquals('currencies', 'table_name', $currency); - $this->assertAttributeEquals(true, 'disable_num_format', $currency); - $this->assertAttributeEquals(true, 'new_schema', $currency); + self::assertEquals('Currencies', $currency->module_dir); + self::assertEquals('Currency', $currency->object_name); + self::assertEquals('currencies', $currency->table_name); + self::assertEquals(true, $currency->disable_num_format); + self::assertEquals(true, $currency->new_schema); } - public function testconvertToDollar() + public function testconvertToDollar(): void { $currency = BeanFactory::newBean('Currencies'); //test without setting attributes - $this->assertEquals(0, $currency->convertToDollar(100, 2)); + self::assertEquals(0, $currency->convertToDollar(100, 2)); //test with required attributes set $currency->conversion_rate = 1.6; - $this->assertEquals(62.5, $currency->convertToDollar(100, 2)); + self::assertEquals(62.5, $currency->convertToDollar(100, 2)); } - public function testconvertFromDollar() + public function testconvertFromDollar(): void { $currency = BeanFactory::newBean('Currencies'); //test without setting attributes - $this->assertEquals(0, $currency->convertFromDollar(100, 2)); + self::assertEquals(0, $currency->convertFromDollar(100, 2)); //test with required attributes set $currency->conversion_rate = 1.6; - $this->assertEquals(160, $currency->convertFromDollar(100, 2)); + self::assertEquals(160, $currency->convertFromDollar(100, 2)); } - public function testgetDefaultCurrencyName() + public function testgetDefaultCurrencyName(): void { $currency = BeanFactory::newBean('Currencies'); - $this->assertEquals('US Dollars', $currency->getDefaultCurrencyName()); + self::assertEquals('US Dollars', $currency->getDefaultCurrencyName()); } - public function testgetDefaultCurrencySymbol() + public function testgetDefaultCurrencySymbol(): void { $currency = BeanFactory::newBean('Currencies'); - $this->assertEquals('$', $currency->getDefaultCurrencySymbol()); + self::assertEquals('$', $currency->getDefaultCurrencySymbol()); } - public function testgetDefaultISO4217() + public function testgetDefaultISO4217(): void { $currency = BeanFactory::newBean('Currencies'); - $this->assertEquals('USD', $currency->getDefaultISO4217()); + self::assertEquals('USD', $currency->getDefaultISO4217()); } - public function testretrieveIDBySymbol() + public function testretrieveIDBySymbol(): void { $currency = BeanFactory::newBean('Currencies'); - $this->assertEquals('', $currency->retrieveIDBySymbol('')); - $this->assertEquals('', $currency->retrieveIDBySymbol('\$')); + self::assertEquals('', $currency->retrieveIDBySymbol('')); + self::assertEquals('', $currency->retrieveIDBySymbol('\$')); } - public function testlist_view_parse_additional_sections() + public function testlist_view_parse_additional_sections(): void { global $isMerge; @@ -85,53 +85,53 @@ class CurrencyTest extends SuitePHPUnitFrameworkTestCase //test without setting attributes $ss = new Sugar_Smarty(); $result = $currency->list_view_parse_additional_sections($ss); - $this->assertEquals(null, isset($result->_tpl_vars['PREROW']) ? $result->_tpl_vars['PREROW'] : null); + self::assertEquals(null, isset($result->_tpl_vars['PREROW']) ? $result->_tpl_vars['PREROW'] : null); //test with required attributes set $isMerge = true; $ss = new Sugar_Smarty(); $result = $currency->list_view_parse_additional_sections($ss); - $this->assertEquals('', $result->_tpl_vars['PREROW']); + self::assertEquals('', $result->_tpl_vars['PREROW']); } - public function testretrieve_id_by_name() + public function testretrieve_id_by_name(): void { $currency = BeanFactory::newBean('Currencies'); - $this->assertEquals('', $currency->retrieve_id_by_name('')); - $this->assertEquals('', $currency->retrieve_id_by_name('US Dollars')); + self::assertEquals('', $currency->retrieve_id_by_name('')); + self::assertEquals('', $currency->retrieve_id_by_name('US Dollars')); } - public function testretrieve() + public function testretrieve(): void { $currency = BeanFactory::newBean('Currencies'); //execute the method and verify that it returns expected results $currency->retrieve(); - $this->assertEquals('US Dollars', $currency->name); - $this->assertEquals('$', $currency->symbol); - $this->assertEquals('-99', $currency->id); - $this->assertEquals(1, $currency->conversion_rate); - $this->assertEquals('USD', $currency->iso4217); - $this->assertEquals(0, $currency->deleted); - $this->assertEquals('Active', $currency->status); - $this->assertEquals('', $currency->unhide); + self::assertEquals('US Dollars', $currency->name); + self::assertEquals('$', $currency->symbol); + self::assertEquals('-99', $currency->id); + self::assertEquals(1, $currency->conversion_rate); + self::assertEquals('USD', $currency->iso4217); + self::assertEquals(0, $currency->deleted); + self::assertEquals('Active', $currency->status); + self::assertEquals('', $currency->unhide); } - public function testgetPdfCurrencySymbol() + public function testgetPdfCurrencySymbol(): void { $currency = BeanFactory::newBean('Currencies'); //test without setting attributes - $this->assertEquals('', $currency->getPdfCurrencySymbol()); + self::assertEquals('', $currency->getPdfCurrencySymbol()); //test with required attributes set $currency->symbol = '�'; - $this->assertEquals('�', $currency->getPdfCurrencySymbol()); + self::assertEquals('�', $currency->getPdfCurrencySymbol()); } - public function testget_list_view_data() + public function testget_list_view_data(): void { $currency = BeanFactory::newBean('Currencies'); @@ -143,10 +143,10 @@ class CurrencyTest extends SuitePHPUnitFrameworkTestCase ); $actual = $currency->get_list_view_data(); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } - public function testsave() + public function testsave(): void { $currency = BeanFactory::newBean('Currencies'); $currency->name = 'Rand'; @@ -157,95 +157,95 @@ class CurrencyTest extends SuitePHPUnitFrameworkTestCase $currency->save(); //test for record ID to verify that record is saved - $this->assertTrue(isset($currency->id)); - $this->assertEquals(36, strlen($currency->id)); + self::assertTrue(isset($currency->id)); + self::assertEquals(36, strlen($currency->id)); //mark the record as deleted and verify that this record cannot be retrieved anymore. $currency->mark_deleted($currency->id); $result = $currency->retrieve($currency->id); - $this->assertEquals(-99, $result->id); + self::assertEquals(-99, $result->id); } - public function testcurrency_format_number() + public function testcurrency_format_number(): void { - $this->assertEquals('$100.00', currency_format_number(100)); - $this->assertEquals('$100.0', currency_format_number(100, array('round' => 1, 'decimals' => 1))); + self::assertEquals('$100.00', currency_format_number(100)); + self::assertEquals('$100.0', currency_format_number(100, array('round' => 1, 'decimals' => 1))); } - public function testformat_number() + public function testformat_number(): void { - $this->assertEquals('100.00', format_number(100)); - $this->assertEquals('100.1', format_number(100.09, 1, 1)); - $this->assertEquals('$100.1', format_number(100.09, 1, 1, array('convert' => 1, 'currency_symbol' => 'R'))); + self::assertEquals('100.00', format_number(100)); + self::assertEquals('100.1', format_number(100.09, 1, 1)); + self::assertEquals('$100.1', format_number(100.09, 1, 1, array('convert' => 1, 'currency_symbol' => 'R'))); } - public function testformat_place_symbol() + public function testformat_place_symbol(): void { - $this->assertEquals('R 100', format_place_symbol(100, 'R', true)); - $this->assertEquals('R100', format_place_symbol(100, 'R', false)); - $this->assertEquals('100', format_place_symbol(100, '', false)); + self::assertEquals('R 100', format_place_symbol(100, 'R', true)); + self::assertEquals('R100', format_place_symbol(100, 'R', false)); + self::assertEquals('100', format_place_symbol(100, '', false)); } - public function testunformat_number() + public function testunformat_number(): void { - $this->assertEquals('100', unformat_number('$100')); - $this->assertEquals('100', unformat_number(100)); + self::assertEquals('100', unformat_number('$100')); + self::assertEquals('100', unformat_number(100)); } - public function testformat_money() + public function testformat_money(): void { - $this->assertEquals('100.00', format_money('100')); - $this->assertEquals('100.00', format_money('100', false)); + self::assertEquals('100.00', format_money('100')); + self::assertEquals('100.00', format_money('100', false)); } - public function testget_number_separators() + public function testget_number_separators(): void { - $this->assertEquals([',', '.'], get_number_separators()); - $this->assertEquals([',', '.'], get_number_separators(false)); + self::assertEquals([',', '.'], get_number_separators()); + self::assertEquals([',', '.'], get_number_separators(false)); } - public function testget_number_seperators() + public function testget_number_seperators(): void { - $this->assertEquals(null, get_number_seperators(false)); + self::assertEquals(null, get_number_seperators(false)); } - public function testtoString() + public function testtoString(): void { $expected = "\$m_currency_round= \n\$m_currency_decimal= \n\$m_currency_symbol= \n\$m_currency_iso= \n\$m_currency_name= \n"; - $this->assertSame($expected, toString(false)); + self::assertSame($expected, toString(false)); } - public function testgetCurrencyDropDown() + public function testgetCurrencyDropDown(): void { self::markTestIncomplete('#Warning: Strings contain different line endings!'); //test with view = Default / DetailView - $this->assertEquals('US Dollars', getCurrencyDropDown(null)); + self::assertEquals('US Dollars', getCurrencyDropDown(null)); //test with view = EditView $expected = ""; $actual = getCurrencyDropDown(null, 'currency_id', '', 'EditView'); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } - public function testgetCurrencyNameDropDown() + public function testgetCurrencyNameDropDown(): void { //test with view = Default / DetailView - $this->assertEquals('US Dollars', getCurrencyNameDropDown(null)); + self::assertEquals('US Dollars', getCurrencyNameDropDown(null)); //test with view = EditView $expected = $expected = ""; $actual = getCurrencyNameDropDown(null, 'currency_name', '', 'EditView'); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } - public function testgetCurrencySymbolDropDown() + public function testgetCurrencySymbolDropDown(): void { //test with view = Default / DetailView - $this->assertEquals('US Dollars', getCurrencySymbolDropDown(null)); + self::assertEquals('US Dollars', getCurrencySymbolDropDown(null)); //test with view = EditView $expected = $expected = ""; $actual = getCurrencySymbolDropDown(null, 'currency_name', '', 'EditView'); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } } diff --git a/tests/unit/phpunit/modules/DocumentRevisions/DocumentRevisionTest.php b/tests/unit/phpunit/modules/DocumentRevisions/DocumentRevisionTest.php index 9937ab49c..1ff869b75 100644 --- a/tests/unit/phpunit/modules/DocumentRevisions/DocumentRevisionTest.php +++ b/tests/unit/phpunit/modules/DocumentRevisions/DocumentRevisionTest.php @@ -13,20 +13,20 @@ class DocumentRevisionTest extends SuitePHPUnitFrameworkTestCase $current_user = BeanFactory::newBean('Users'); } - public function testDocumentRevision() + public function testDocumentRevision(): void { // Execute the constructor and check for the Object type and attributes $documentRevision = BeanFactory::newBean('DocumentRevisions'); - $this->assertInstanceOf('DocumentRevision', $documentRevision); - $this->assertInstanceOf('SugarBean', $documentRevision); + self::assertInstanceOf('DocumentRevision', $documentRevision); + self::assertInstanceOf('SugarBean', $documentRevision); - $this->assertAttributeEquals('DocumentRevisions', 'module_dir', $documentRevision); - $this->assertAttributeEquals('DocumentRevision', 'object_name', $documentRevision); - $this->assertAttributeEquals('document_revisions', 'table_name', $documentRevision); - $this->assertAttributeEquals(true, 'new_schema', $documentRevision); + self::assertEquals('DocumentRevisions', $documentRevision->module_dir); + self::assertEquals('DocumentRevision', $documentRevision->object_name); + self::assertEquals('document_revisions', $documentRevision->table_name); + self::assertEquals(true, $documentRevision->new_schema); } - public function testSaveAndRetrieve() + public function testSaveAndRetrieve(): void { $documentRevision = BeanFactory::newBean('DocumentRevisions'); @@ -39,102 +39,102 @@ class DocumentRevisionTest extends SuitePHPUnitFrameworkTestCase $documentRevision->save(); //test for record ID to verify that record is saved - $this->assertTrue(isset($documentRevision->id)); - $this->assertEquals(36, strlen($documentRevision->id)); + self::assertTrue(isset($documentRevision->id)); + self::assertEquals(36, strlen($documentRevision->id)); //test document retrieve method $docRev = $documentRevision->retrieve($documentRevision->id); - $this->assertEquals('1', $docRev->document_id); - $this->assertEquals('1', $docRev->doc_id); - $this->assertEquals('text', $docRev->doc_type); - $this->assertEquals('test', $docRev->filename); - $this->assertEquals('ext', $docRev->file_ext); + self::assertEquals('1', $docRev->document_id); + self::assertEquals('1', $docRev->doc_id); + self::assertEquals('text', $docRev->doc_type); + self::assertEquals('test', $docRev->filename); + self::assertEquals('ext', $docRev->file_ext); //mark the record as deleted and verify that this record cannot be retrieved anymore. $docRev->mark_deleted($docRev->id); $result = $docRev->retrieve($docRev->id); - $this->assertEquals(null, $result); + self::assertEquals(null, $result); } - public function testget_summary_text() + public function testget_summary_text(): void { $documentRevision = BeanFactory::newBean('DocumentRevisions'); //test without setting name - $this->assertEquals(null, $documentRevision->get_summary_text()); + self::assertEquals(null, $documentRevision->get_summary_text()); //test with name set $documentRevision->filename = 'test'; - $this->assertEquals('test', $documentRevision->get_summary_text()); + self::assertEquals('test', $documentRevision->get_summary_text()); } - public function testis_authenticated() + public function testis_authenticated(): void { $documentRevision = BeanFactory::newBean('DocumentRevisions'); //test wihout setting attributes - $this->assertEquals(null, $documentRevision->is_authenticated()); + self::assertEquals(null, $documentRevision->is_authenticated()); //test with attributes preset $documentRevision->authenticated = true; - $this->assertEquals(true, $documentRevision->is_authenticated()); + self::assertEquals(true, $documentRevision->is_authenticated()); } - public function testfill_in_additional_list_fields() + public function testfill_in_additional_list_fields(): void { $documentRevision = BeanFactory::newBean('DocumentRevisions'); // Execute the method and test that it works and doesn't throw an exception. try { $documentRevision->fill_in_additional_list_fields(); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } } - public function testfill_in_additional_detail_fields() + public function testfill_in_additional_detail_fields(): void { $documentRevision = BeanFactory::newBean('DocumentRevisions'); // Execute the method and test that it works and doesn't throw an exception. try { $documentRevision->fill_in_additional_detail_fields(); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } } - public function testgetDocumentRevisionNameForDisplay() + public function testgetDocumentRevisionNameForDisplay(): void { $documentRevision = BeanFactory::newBean('DocumentRevisions'); //test wihout setting attributes $result = $documentRevision->getDocumentRevisionNameForDisplay(); - $this->assertEquals('.', $result); + self::assertEquals('.', $result); //test with attributes preset $documentRevision->filename = 'test.ext'; $documentRevision->revision = 1; $result = $documentRevision->getDocumentRevisionNameForDisplay(); - $this->assertEquals('-Revision_1.ext', $result); + self::assertEquals('-Revision_1.ext', $result); } - public function testfill_document_name_revision() + public function testfill_document_name_revision(): void { $documentRevision = BeanFactory::newBean('DocumentRevisions'); // Execute the method and test that it works and doesn't throw an exception. try { $documentRevision->fill_document_name_revision('dummy_id'); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } } - public function testlist_view_parse_additional_sections() + public function testlist_view_parse_additional_sections(): void { $documentRevision = BeanFactory::newBean('DocumentRevisions'); @@ -144,38 +144,35 @@ class DocumentRevisionTest extends SuitePHPUnitFrameworkTestCase try { $ss = new Sugar_Smarty(); $documentRevision->list_view_parse_additional_sections($ss, $xTemplateSection); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } } - public function testget_list_view_data() + public function testget_list_view_data(): void { - $documentRevision = BeanFactory::newBean('DocumentRevisions'); - $result = $documentRevision->get_list_view_data(); - $this->assertEquals(array('DELETED' => 0), $result); + $result = BeanFactory::newBean('DocumentRevisions')->get_list_view_data(); + self::assertEquals(array('DELETED' => 0), $result); } - public function testget_document_revision_name() + public function testget_document_revision_name(): void { - $documentRevision = BeanFactory::newBean('DocumentRevisions'); - $result = $documentRevision->get_document_revision_name(1); - $this->assertEquals(null, $result); + $result = BeanFactory::newBean('DocumentRevisions')->get_document_revision_name(1); + self::assertEquals(null, $result); } - public function testget_document_revisions() + public function testget_document_revisions(): void { - $documentRevision = BeanFactory::newBean('DocumentRevisions'); - $results = $documentRevision->get_document_revisions(1); - $this->assertTrue(is_array($results)); + $results = BeanFactory::newBean('DocumentRevisions')->get_document_revisions(1); + self::assertIsArray($results); } - public function testbean_implements() + public function testbean_implements(): void { $documentRevision = BeanFactory::newBean('DocumentRevisions'); - $this->assertEquals(false, $documentRevision->bean_implements('')); //test with blank value - $this->assertEquals(false, $documentRevision->bean_implements('test')); //test with invalid value - $this->assertEquals(true, $documentRevision->bean_implements('FILE')); //test with valid value + self::assertEquals(false, $documentRevision->bean_implements('')); //test with blank value + self::assertEquals(false, $documentRevision->bean_implements('test')); //test with invalid value + self::assertEquals(true, $documentRevision->bean_implements('FILE')); //test with valid value } } diff --git a/tests/unit/phpunit/modules/Documents/DocumentTest.php b/tests/unit/phpunit/modules/Documents/DocumentTest.php index 6d080be9e..0b3927d15 100644 --- a/tests/unit/phpunit/modules/Documents/DocumentTest.php +++ b/tests/unit/phpunit/modules/Documents/DocumentTest.php @@ -13,22 +13,22 @@ class DocumentTest extends SuitePHPUnitFrameworkTestCase $current_user = BeanFactory::newBean('Users'); } - public function testDocument() + public function testDocument(): void { // Execute the constructor and check for the Object type and attributes $document = BeanFactory::newBean('Documents'); - $this->assertInstanceOf('Document', $document); - $this->assertInstanceOf('File', $document); - $this->assertInstanceOf('SugarBean', $document); + self::assertInstanceOf('Document', $document); + self::assertInstanceOf('File', $document); + self::assertInstanceOf('SugarBean', $document); - $this->assertAttributeEquals('Documents', 'module_dir', $document); - $this->assertAttributeEquals('Document', 'object_name', $document); - $this->assertAttributeEquals('documents', 'table_name', $document); - $this->assertAttributeEquals(true, 'new_schema', $document); - $this->assertAttributeEquals(false, 'disable_row_level_security', $document); + self::assertEquals('Documents', $document->module_dir); + self::assertEquals('Document', $document->object_name); + self::assertEquals('documents', $document->table_name); + self::assertEquals(true, $document->new_schema); + self::assertEquals(false, $document->disable_row_level_security); } - public function testSaveAndGet_document_name() + public function testSaveAndGet_document_name(): void { $document = BeanFactory::newBean('Documents'); @@ -43,57 +43,57 @@ class DocumentTest extends SuitePHPUnitFrameworkTestCase $document->save(); //test for record ID to verify that record is saved - $this->assertTrue(isset($document->id)); - $this->assertEquals(36, strlen($document->id)); + self::assertTrue(isset($document->id)); + self::assertEquals(36, strlen($document->id)); //execute Get_document_name() method and verify it gets the name correctly - $this->assertEquals(null, $document->get_document_name(1)); - $this->assertEquals('test', $document->get_document_name($document->id)); + self::assertEquals(null, $document->get_document_name(1)); + self::assertEquals('test', $document->get_document_name($document->id)); //mark the record as deleted and verify that this record cannot be retrieved anymore. $document->mark_deleted($document->id); $result = $document->retrieve($document->id); - $this->assertEquals(null, $result); + self::assertEquals(null, $result); } - public function testget_summary_text() + public function testget_summary_text(): void { $document = BeanFactory::newBean('Documents'); //test without setting name - $this->assertEquals(null, $document->get_summary_text()); + self::assertEquals(null, $document->get_summary_text()); //test with name set $document->document_name = 'test'; - $this->assertEquals('test', $document->get_summary_text()); + self::assertEquals('test', $document->get_summary_text()); } - public function testis_authenticated() + public function testis_authenticated(): void { $document = BeanFactory::newBean('Documents'); //test without presetting attributes - $this->assertEquals(null, $document->is_authenticated()); + self::assertEquals(null, $document->is_authenticated()); //test with attributes preset $document->authenticated = true; - $this->assertEquals(true, $document->is_authenticated()); + self::assertEquals(true, $document->is_authenticated()); } - public function testfill_in_additional_list_fields() + public function testfill_in_additional_list_fields(): void { $document = BeanFactory::newBean('Documents'); // Execute the method and test that it works and doesn't throw an exception. try { $document->fill_in_additional_list_fields(); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } } - public function testfill_in_additional_detail_fields() + public function testfill_in_additional_detail_fields(): void { self::markTestIncomplete('environment dependency (random generated token in url)'); @@ -104,12 +104,12 @@ class DocumentTest extends SuitePHPUnitFrameworkTestCase $document->fill_in_additional_detail_fields(); // test the urls instead of the a tag itself - $this->assertEquals('', $document->file_url, 'file url: [[' . $document->file_url . ']]'); + self::assertEquals('', $document->file_url, 'file url: [[' . $document->file_url . ']]'); // - $this->assertEquals('', $document->file_url_noimage, 'file url noimage: [[' . $document->file_url_noimage . ']]'); + self::assertEquals('', $document->file_url_noimage, 'file url noimage: [[' . $document->file_url_noimage . ']]'); } - public function testlist_view_parse_additional_sections() + public function testlist_view_parse_additional_sections(): void { $document = BeanFactory::newBean('Documents'); @@ -119,13 +119,13 @@ class DocumentTest extends SuitePHPUnitFrameworkTestCase try { $ss = new Sugar_Smarty(); $document->list_view_parse_additional_sections($ss, $xTemplateSection); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } } - public function testcreate_export_query() + public function testcreate_export_query(): void { self::markTestIncomplete('environment dependency'); @@ -134,15 +134,15 @@ class DocumentTest extends SuitePHPUnitFrameworkTestCase //test with empty string parameters $expected = "SELECT\n documents.* FROM documents WHERE documents.deleted = 0 ORDER BY documents.document_name"; $actual = $document->create_export_query('', ''); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); //test with valid string parameters $expected = "SELECT\n documents.* FROM documents WHERE documents.document_name = \"\" AND documents.deleted = 0 ORDER BY documents.id"; $actual = $document->create_export_query('documents.id', 'documents.document_name = ""'); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } - public function testget_list_view_data() + public function testget_list_view_data(): void { self::markTestIncomplete(); @@ -180,31 +180,31 @@ class DocumentTest extends SuitePHPUnitFrameworkTestCase $actual = $document->get_list_view_data(); foreach ($expected as $expectedKey => $expectedVal) { if ($expectedKey == 'FILE_URL') { - $this->assertRegExp($expected[$expectedKey], $actual[$expectedKey]); + self::assertMatchesRegularExpression($expected[$expectedKey], $actual[$expectedKey]); } else { - $this->assertSame($expected[$expectedKey], $actual[$expectedKey]); + self::assertSame($expected[$expectedKey], $actual[$expectedKey]); } } } - public function testmark_relationships_deleted() + public function testmark_relationships_deleted(): void { $document = BeanFactory::newBean('Documents'); // Execute the method and test that it works and doesn't throw an exception. try { $document->mark_relationships_deleted(1); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } } - public function testbean_implements() + public function testbean_implements(): void { $document = BeanFactory::newBean('Documents'); - $this->assertEquals(false, $document->bean_implements('')); //test with blank value - $this->assertEquals(false, $document->bean_implements('test')); //test with invalid value - $this->assertEquals(true, $document->bean_implements('ACL')); //test with valid value + self::assertEquals(false, $document->bean_implements('')); //test with blank value + self::assertEquals(false, $document->bean_implements('test')); //test with invalid value + self::assertEquals(true, $document->bean_implements('ACL')); //test with valid value } } diff --git a/tests/unit/phpunit/modules/EAPM/EAPMTest.php b/tests/unit/phpunit/modules/EAPM/EAPMTest.php index 202a16de3..6098c0599 100644 --- a/tests/unit/phpunit/modules/EAPM/EAPMTest.php +++ b/tests/unit/phpunit/modules/EAPM/EAPMTest.php @@ -4,60 +4,59 @@ use SuiteCRM\Test\SuitePHPUnitFrameworkTestCase; class EAPMTest extends SuitePHPUnitFrameworkTestCase { - public function testEAPM() + public function testEAPM(): void { // Execute the constructor and check for the Object type and attributes $eapm = BeanFactory::newBean('EAPM'); - $this->assertInstanceOf('EAPM', $eapm); - $this->assertInstanceOf('Basic', $eapm); - $this->assertInstanceOf('SugarBean', $eapm); + self::assertInstanceOf('EAPM', $eapm); + self::assertInstanceOf('Basic', $eapm); + self::assertInstanceOf('SugarBean', $eapm); - $this->assertAttributeEquals('EAPM', 'module_dir', $eapm); - $this->assertAttributeEquals('EAPM', 'object_name', $eapm); - $this->assertAttributeEquals('eapm', 'table_name', $eapm); - $this->assertAttributeEquals(true, 'new_schema', $eapm); - $this->assertAttributeEquals(false, 'importable', $eapm); - $this->assertAttributeEquals(false, 'validated', $eapm); - $this->assertAttributeEquals(true, 'disable_row_level_security', $eapm); + self::assertEquals('EAPM', $eapm->module_dir); + self::assertEquals('EAPM', $eapm->object_name); + self::assertEquals('eapm', $eapm->table_name); + self::assertEquals(true, $eapm->new_schema); + self::assertEquals(false, $eapm->importable); + self::assertEquals(false, $eapm->validated); + self::assertEquals(true, $eapm->disable_row_level_security); } - public function testbean_implements() + public function testbean_implements(): void { $eapm = BeanFactory::newBean('EAPM'); - $this->assertEquals(false, $eapm->bean_implements('')); //test with blank value - $this->assertEquals(false, $eapm->bean_implements('test')); //test with invalid value - $this->assertEquals(true, $eapm->bean_implements('ACL')); //test with valid value + self::assertEquals(false, $eapm->bean_implements('')); //test with blank value + self::assertEquals(false, $eapm->bean_implements('test')); //test with invalid value + self::assertEquals(true, $eapm->bean_implements('ACL')); //test with valid value } - public function testgetLoginInfo() + public function testGetLoginInfo(): void { $eapm = BeanFactory::newBean('EAPM'); - //test with default value/false - $result = $eapm->getLoginInfo(''); - $this->assertEquals(null, $result); + // Test with default value/false + $result = $eapm::getLoginInfo(''); + self::assertEquals(null, $result); - //test with true - $result = $eapm->getLoginInfo('', true); - $this->assertEquals(null, $result); + $result = $eapm::getLoginInfo('', true); + self::assertEquals(null, $result); } - public function testcreate_new_list_query() + public function testcreate_new_list_query(): void { $eapm = BeanFactory::newBean('EAPM'); //test with empty string params $expected = " SELECT eapm.* , jt0.user_name modified_by_name , jt0.created_by modified_by_name_owner , 'Users' modified_by_name_mod , jt1.user_name created_by_name , jt1.created_by created_by_name_owner , 'Users' created_by_name_mod , jt2.user_name assigned_user_name , jt2.created_by assigned_user_name_owner , 'Users' assigned_user_name_mod FROM eapm LEFT JOIN users jt0 ON eapm.modified_user_id=jt0.id AND jt0.deleted=0\n\n AND jt0.deleted=0 LEFT JOIN users jt1 ON eapm.created_by=jt1.id AND jt1.deleted=0\n\n AND jt1.deleted=0 LEFT JOIN users jt2 ON eapm.assigned_user_id=jt2.id AND jt2.deleted=0\n\n AND jt2.deleted=0 where ( eapm.assigned_user_id ='' ) AND eapm.deleted=0"; $actual = $eapm->create_new_list_query('', ''); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); //test with valid string params $expected = " SELECT eapm.* , jt0.user_name modified_by_name , jt0.created_by modified_by_name_owner , 'Users' modified_by_name_mod , jt1.user_name created_by_name , jt1.created_by created_by_name_owner , 'Users' created_by_name_mod , jt2.user_name assigned_user_name , jt2.created_by assigned_user_name_owner , 'Users' assigned_user_name_mod FROM eapm LEFT JOIN users jt0 ON eapm.modified_user_id=jt0.id AND jt0.deleted=0\n\n AND jt0.deleted=0 LEFT JOIN users jt1 ON eapm.created_by=jt1.id AND jt1.deleted=0\n\n AND jt1.deleted=0 LEFT JOIN users jt2 ON eapm.assigned_user_id=jt2.id AND jt2.deleted=0\n\n AND jt2.deleted=0 where (eapm.name=\"\" AND eapm.assigned_user_id ='' ) AND eapm.deleted=0"; $actual = $eapm->create_new_list_query('eapm.id', 'eapm.name=""'); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } - public function testsaveAndMarkDeletedAndValidated() + public function testsaveAndMarkDeletedAndValidated(): void { self::markTestIncomplete('eapm table fails'); $eapm = BeanFactory::newBean('EAPM'); @@ -67,82 +66,82 @@ class EAPMTest extends SuitePHPUnitFrameworkTestCase $eapm->application = 'webex'; //test validated method initially - $this->assertEquals(false, $eapm->validated()); + self::assertEquals(false, $eapm->validated()); $eapm->save(); //test for record ID to verify that record is saved - $this->assertTrue(isset($eapm->id)); - $this->assertEquals(36, strlen($eapm->id)); + self::assertTrue(isset($eapm->id)); + self::assertEquals(36, strlen($eapm->id)); //test validated method finally after save - $this->assertEquals(null, $eapm->validated()); + self::assertEquals(null, $eapm->validated()); //retrieve back to test if validated attribute is updated in db $eapmValidated = $eapm->retrieve($eapm->id); //$this->assertEquals(1, $eapmValidated->validated); - $this->markTestSkipped('Validated column never gets updated in Db '); + self::markTestSkipped('Validated column never gets updated in Db '); //mark the record as deleted and verify that this record cannot be retrieved anymore. $eapm->mark_deleted($eapm->id); $result = $eapm->retrieve($eapm->id); - $this->assertEquals(null, $result); + self::assertEquals(null, $result); } - public function testfill_in_additional_detail_fields() + public function testfill_in_additional_detail_fields(): void { $eapm = BeanFactory::newBean('EAPM'); // Execute the method and test that it works and doesn't throw an exception. try { $eapm->fill_in_additional_detail_fields(); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } } - public function testfill_in_additional_list_fields() + public function testfill_in_additional_list_fields(): void { $eapm = BeanFactory::newBean('EAPM'); // Execute the method and test that it works and doesn't throw an exception. try { $eapm->fill_in_additional_list_fields(); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } } - public function testsave_cleanup() + public function testsave_cleanup(): void { $eapm = BeanFactory::newBean('EAPM'); //execute the method and verify attributes are set accordingly $eapm->save_cleanup(); - $this->assertEquals('', $eapm->oauth_token); - $this->assertEquals('', $eapm->oauth_secret); - $this->assertEquals('', $eapm->api_data); + self::assertEquals('', $eapm->oauth_token); + self::assertEquals('', $eapm->oauth_secret); + self::assertEquals('', $eapm->api_data); } - public function testdelete_user_accounts() + public function testdelete_user_accounts(): void { $eapm = BeanFactory::newBean('EAPM'); // Execute the method and test that it works and doesn't throw an exception. try { $eapm->delete_user_accounts(1); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } } - public function testgetEAPMExternalApiDropDown() + public function testgetEAPMExternalApiDropDown(): void { $result = getEAPMExternalApiDropDown(); - $this->assertEquals(array('' => ''), $result); + self::assertEquals(array('' => ''), $result); } } diff --git a/tests/unit/phpunit/modules/EmailAddresses/EmailAddressTest.php b/tests/unit/phpunit/modules/EmailAddresses/EmailAddressTest.php index 27bd8990f..40165ec26 100644 --- a/tests/unit/phpunit/modules/EmailAddresses/EmailAddressTest.php +++ b/tests/unit/phpunit/modules/EmailAddresses/EmailAddressTest.php @@ -4,23 +4,22 @@ use SuiteCRM\Test\SuitePHPUnitFrameworkTestCase; class EmailAddressTest extends SuitePHPUnitFrameworkTestCase { - public function testEmailAddress() + public function testEmailAddress(): void { // Execute the constructor and check for the Object type and attributes $email = BeanFactory::newBean('EmailAddresses'); - $this->assertInstanceOf('EmailAddress', $email); - $this->assertInstanceOf('SugarEmailAddress', $email); - $this->assertInstanceOf('SugarBean', $email); + self::assertInstanceOf('EmailAddress', $email); + self::assertInstanceOf('SugarEmailAddress', $email); + self::assertInstanceOf('SugarBean', $email); - $this->assertAttributeEquals('EmailAddresses', 'module_dir', $email); - $this->assertAttributeEquals('EmailAddresses', 'module_name', $email); - $this->assertAttributeEquals('EmailAddress', 'object_name', $email); - $this->assertAttributeEquals('email_addresses', 'table_name', $email); - - $this->assertAttributeEquals(true, 'disable_row_level_security', $email); + self::assertEquals('EmailAddresses', $email->module_dir); + self::assertEquals('EmailAddresses', $email->module_name); + self::assertEquals('EmailAddress', $email->object_name); + self::assertEquals('email_addresses', $email->table_name); + self::assertEquals(true, $email->disable_row_level_security); } - public function testsave() + public function testsave(): void { $email = BeanFactory::newBean('EmailAddresses'); @@ -30,12 +29,12 @@ class EmailAddressTest extends SuitePHPUnitFrameworkTestCase $email->save(); //test for record ID to verify that record is saved - $this->assertTrue(isset($email->id)); - $this->assertEquals(36, strlen($email->id)); + self::assertTrue(isset($email->id)); + self::assertEquals(36, strlen($email->id)); //mark the record as deleted and verify that this record cannot be retrieved anymore. $email->mark_deleted($email->id); $result = $email->retrieve($email->id); - $this->assertEquals(null, $result); + self::assertEquals(null, $result); } } diff --git a/tests/unit/phpunit/modules/EmailMan/EmailManTest.php b/tests/unit/phpunit/modules/EmailMan/EmailManTest.php index 34837cedf..a0ecb9b22 100644 --- a/tests/unit/phpunit/modules/EmailMan/EmailManTest.php +++ b/tests/unit/phpunit/modules/EmailMan/EmailManTest.php @@ -14,14 +14,14 @@ class EmailManTest extends SuitePHPUnitFrameworkTestCase $GLOBALS['mod_strings'] = return_module_language($GLOBALS['current_language'], 'EmailMan'); } - public function testtoString() + public function testtoString(): void { $emailMan = BeanFactory::newBean('EmailMan'); //execute the method without setting attributes and verify that it retunrs expected results $expected = "EmailMan:\nid = ,user_id= module = , related_id = , related_type = ,list_id = , send_date_time= \n"; $actual = $emailMan->toString(); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); //execute the method with attributes set and verify that it retunrs expected results $emailMan->id = 1; @@ -34,46 +34,45 @@ class EmailManTest extends SuitePHPUnitFrameworkTestCase $expected = "EmailMan:\nid = 1 ,user_id= 1 module = test , related_id = 1 , related_type = test ,list_id = 1, send_date_time= 1/1/2015\n"; $actual = $emailMan->toString(); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } - public function testEmailMan() + public function testEmailMan(): void { // Execute the constructor and check for the Object type and attributes $emailMan = BeanFactory::newBean('EmailMan'); - $this->assertInstanceOf('EmailMan', $emailMan); - $this->assertInstanceOf('SugarBean', $emailMan); + self::assertInstanceOf('EmailMan', $emailMan); + self::assertInstanceOf('SugarBean', $emailMan); - $this->assertAttributeEquals('EmailMan', 'module_dir', $emailMan); - $this->assertAttributeEquals('EmailMan', 'object_name', $emailMan); - $this->assertAttributeEquals('emailman', 'table_name', $emailMan); - - $this->assertAttributeEquals(false, 'test', $emailMan); + self::assertEquals('EmailMan', $emailMan->module_dir); + self::assertEquals('EmailMan', $emailMan->object_name); + self::assertEquals('emailman', $emailMan->table_name); + self::assertEquals(false, $emailMan->test); } - public function testcreate_new_list_query() + public function testcreate_new_list_query(): void { $emailMan = BeanFactory::newBean('EmailMan'); //test with empty string params $expected = 'SELECT emailman.* , campaigns.name as campaign_name, email_marketing.name as message_name, (CASE related_type WHEN \'Contacts\' THEN LTRIM(RTRIM(CONCAT(IFNULL(contacts.first_name,\'\'),\' \',IFNULL(contacts.last_name,\'\')))) WHEN \'Leads\' THEN LTRIM(RTRIM(CONCAT(IFNULL(leads.first_name,\'\'),\' \',IFNULL(leads.last_name,\'\')))) WHEN \'Accounts\' THEN accounts.name WHEN \'Users\' THEN LTRIM(RTRIM(CONCAT(IFNULL(users.first_name,\'\'),\' \',IFNULL(users.last_name,\'\')))) WHEN \'Prospects\' THEN LTRIM(RTRIM(CONCAT(IFNULL(prospects.first_name,\'\'),\' \',IFNULL(prospects.last_name,\'\')))) END) recipient_name FROM emailman LEFT JOIN users ON users.id = emailman.related_id and emailman.related_type =\'Users\' LEFT JOIN contacts ON contacts.id = emailman.related_id and emailman.related_type =\'Contacts\' LEFT JOIN leads ON leads.id = emailman.related_id and emailman.related_type =\'Leads\' LEFT JOIN accounts ON accounts.id = emailman.related_id and emailman.related_type =\'Accounts\' LEFT JOIN prospects ON prospects.id = emailman.related_id and emailman.related_type =\'Prospects\' LEFT JOIN prospect_lists ON prospect_lists.id = emailman.list_id LEFT JOIN email_addr_bean_rel ON email_addr_bean_rel.bean_id = emailman.related_id and emailman.related_type = email_addr_bean_rel.bean_module and email_addr_bean_rel.primary_address = 1 and email_addr_bean_rel.deleted=0 LEFT JOIN campaigns ON campaigns.id = emailman.campaign_id LEFT JOIN email_marketing ON email_marketing.id = emailman.marketing_id WHERE emailman.deleted=0'; $actual = $emailMan->create_new_list_query('', ''); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); //test with valid string params $expected = 'SELECT emailman.* , campaigns.name as campaign_name, email_marketing.name as message_name, (CASE related_type WHEN \'Contacts\' THEN LTRIM(RTRIM(CONCAT(IFNULL(contacts.first_name,\'\'),\' \',IFNULL(contacts.last_name,\'\')))) WHEN \'Leads\' THEN LTRIM(RTRIM(CONCAT(IFNULL(leads.first_name,\'\'),\' \',IFNULL(leads.last_name,\'\')))) WHEN \'Accounts\' THEN accounts.name WHEN \'Users\' THEN LTRIM(RTRIM(CONCAT(IFNULL(users.first_name,\'\'),\' \',IFNULL(users.last_name,\'\')))) WHEN \'Prospects\' THEN LTRIM(RTRIM(CONCAT(IFNULL(prospects.first_name,\'\'),\' \',IFNULL(prospects.last_name,\'\')))) END) recipient_name FROM emailman LEFT JOIN users ON users.id = emailman.related_id and emailman.related_type =\'Users\' LEFT JOIN contacts ON contacts.id = emailman.related_id and emailman.related_type =\'Contacts\' LEFT JOIN leads ON leads.id = emailman.related_id and emailman.related_type =\'Leads\' LEFT JOIN accounts ON accounts.id = emailman.related_id and emailman.related_type =\'Accounts\' LEFT JOIN prospects ON prospects.id = emailman.related_id and emailman.related_type =\'Prospects\' LEFT JOIN prospect_lists ON prospect_lists.id = emailman.list_id LEFT JOIN email_addr_bean_rel ON email_addr_bean_rel.bean_id = emailman.related_id and emailman.related_type = email_addr_bean_rel.bean_module and email_addr_bean_rel.primary_address = 1 and email_addr_bean_rel.deleted=0 LEFT JOIN campaigns ON campaigns.id = emailman.campaign_id LEFT JOIN email_marketing ON email_marketing.id = emailman.marketing_id WHERE emailman.user_id="" AND emailman.deleted=0'; $actual = $emailMan->create_new_list_query('emailman.id', 'emailman.user_id=""'); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } - public function testcreate_queue_items_query() + public function testcreate_queue_items_query(): void { $emailMan = BeanFactory::newBean('EmailMan'); //without parameters $expected = 'SELECT emailman.* , campaigns.name as campaign_name, email_marketing.name as message_name, (CASE related_type WHEN \'Contacts\' THEN LTRIM(RTRIM(CONCAT(IFNULL(contacts.first_name,\'\'),\' \',IFNULL(contacts.last_name,\'\')))) WHEN \'Leads\' THEN LTRIM(RTRIM(CONCAT(IFNULL(leads.first_name,\'\'),\' \',IFNULL(leads.last_name,\'\')))) WHEN \'Accounts\' THEN accounts.name WHEN \'Users\' THEN LTRIM(RTRIM(CONCAT(IFNULL(users.first_name,\'\'),\' \',IFNULL(users.last_name,\'\')))) WHEN \'Prospects\' THEN LTRIM(RTRIM(CONCAT(IFNULL(prospects.first_name,\'\'),\' \',IFNULL(prospects.last_name,\'\')))) END) recipient_name FROM emailman LEFT JOIN users ON users.id = emailman.related_id and emailman.related_type =\'Users\' LEFT JOIN contacts ON contacts.id = emailman.related_id and emailman.related_type =\'Contacts\' LEFT JOIN leads ON leads.id = emailman.related_id and emailman.related_type =\'Leads\' LEFT JOIN accounts ON accounts.id = emailman.related_id and emailman.related_type =\'Accounts\' LEFT JOIN prospects ON prospects.id = emailman.related_id and emailman.related_type =\'Prospects\' LEFT JOIN prospect_lists ON prospect_lists.id = emailman.list_id LEFT JOIN email_addr_bean_rel ON email_addr_bean_rel.bean_id = emailman.related_id and emailman.related_type = email_addr_bean_rel.bean_module and email_addr_bean_rel.primary_address = 1 and email_addr_bean_rel.deleted=0 LEFT JOIN campaigns ON campaigns.id = emailman.campaign_id LEFT JOIN email_marketing ON email_marketing.id = emailman.marketing_id WHERE emailman.deleted=0'; $actual = $emailMan->create_queue_items_query('', ''); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); //with parameters $expected = 'SELECT emailman.* , campaigns.name as campaign_name, email_marketing.name as message_name, (CASE related_type WHEN \'Contacts\' THEN LTRIM(RTRIM(CONCAT(IFNULL(contacts.first_name,\'\'),\' \',IFNULL(contacts.last_name,\'\')))) WHEN \'Leads\' THEN LTRIM(RTRIM(CONCAT(IFNULL(leads.first_name,\'\'),\' \',IFNULL(leads.last_name,\'\')))) WHEN \'Accounts\' THEN accounts.name WHEN \'Users\' THEN LTRIM(RTRIM(CONCAT(IFNULL(users.first_name,\'\'),\' \',IFNULL(users.last_name,\'\')))) WHEN \'Prospects\' THEN LTRIM(RTRIM(CONCAT(IFNULL(prospects.first_name,\'\'),\' \',IFNULL(prospects.last_name,\'\')))) END) recipient_name FROM emailman LEFT JOIN users ON users.id = emailman.related_id and emailman.related_type =\'Users\' LEFT JOIN contacts ON contacts.id = emailman.related_id and emailman.related_type =\'Contacts\' LEFT JOIN leads ON leads.id = emailman.related_id and emailman.related_type =\'Leads\' LEFT JOIN accounts ON accounts.id = emailman.related_id and emailman.related_type =\'Accounts\' LEFT JOIN prospects ON prospects.id = emailman.related_id and emailman.related_type =\'Prospects\' LEFT JOIN prospect_lists ON prospect_lists.id = emailman.list_id LEFT JOIN email_addr_bean_rel ON email_addr_bean_rel.bean_id = emailman.related_id and emailman.related_type = email_addr_bean_rel.bean_module and email_addr_bean_rel.primary_address = 1 and email_addr_bean_rel.deleted=0 LEFT JOIN campaigns ON campaigns.id = emailman.campaign_id LEFT JOIN email_marketing ON email_marketing.id = emailman.marketing_id INNER JOIN (select min(id) as id from emailman em GROUP BY em.user_id) secondary on emailman.id = secondary.id WHERE emailman.user_id="" AND emailman.deleted=0'; @@ -83,25 +82,25 @@ class EmailManTest extends SuitePHPUnitFrameworkTestCase array(), array('group_by' => 'emailman.user_id') ); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } - public function testcreate_list_query() + public function testcreate_list_query(): void { $emailMan = BeanFactory::newBean('EmailMan'); //test with empty string params $expected = 'SELECT emailman.* ,campaigns.name as campaign_name,email_marketing.name as message_name,(CASE related_type WHEN \'Contacts\' THEN LTRIM(RTRIM(CONCAT(IFNULL(contacts.first_name,\'\'),\' \',IFNULL(contacts.last_name,\'\'))))WHEN \'Leads\' THEN LTRIM(RTRIM(CONCAT(IFNULL(leads.first_name,\'\'),\' \',IFNULL(leads.last_name,\'\'))))WHEN \'Accounts\' THEN accounts.name WHEN \'Users\' THEN LTRIM(RTRIM(CONCAT(IFNULL(users.first_name,\'\'),\' \',IFNULL(users.last_name,\'\'))))WHEN \'Prospects\' THEN LTRIM(RTRIM(CONCAT(IFNULL(prospects.first_name,\'\'),\' \',IFNULL(prospects.last_name,\'\'))))END) recipient_name FROM emailman LEFT JOIN users ON users.id = emailman.related_id and emailman.related_type =\'Users\' LEFT JOIN contacts ON contacts.id = emailman.related_id and emailman.related_type =\'Contacts\' LEFT JOIN leads ON leads.id = emailman.related_id and emailman.related_type =\'Leads\' LEFT JOIN accounts ON accounts.id = emailman.related_id and emailman.related_type =\'Accounts\' LEFT JOIN prospects ON prospects.id = emailman.related_id and emailman.related_type =\'Prospects\' LEFT JOIN prospect_lists ON prospect_lists.id = emailman.list_id LEFT JOIN email_addr_bean_rel ON email_addr_bean_rel.bean_id = emailman.related_id and emailman.related_type = email_addr_bean_rel.bean_module and email_addr_bean_rel.primary_address = 1 and email_addr_bean_rel.deleted=0 LEFT JOIN campaigns ON campaigns.id = emailman.campaign_id LEFT JOIN email_marketing ON email_marketing.id = emailman.marketing_idwhere emailman.deleted=0'; $actual = $emailMan->create_list_query('', ''); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); //test with valid string params $expected = 'SELECT emailman.* ,campaigns.name as campaign_name,email_marketing.name as message_name,(CASE related_type WHEN \'Contacts\' THEN LTRIM(RTRIM(CONCAT(IFNULL(contacts.first_name,\'\'),\' \',IFNULL(contacts.last_name,\'\'))))WHEN \'Leads\' THEN LTRIM(RTRIM(CONCAT(IFNULL(leads.first_name,\'\'),\' \',IFNULL(leads.last_name,\'\'))))WHEN \'Accounts\' THEN accounts.name WHEN \'Users\' THEN LTRIM(RTRIM(CONCAT(IFNULL(users.first_name,\'\'),\' \',IFNULL(users.last_name,\'\'))))WHEN \'Prospects\' THEN LTRIM(RTRIM(CONCAT(IFNULL(prospects.first_name,\'\'),\' \',IFNULL(prospects.last_name,\'\'))))END) recipient_name FROM emailman LEFT JOIN users ON users.id = emailman.related_id and emailman.related_type =\'Users\' LEFT JOIN contacts ON contacts.id = emailman.related_id and emailman.related_type =\'Contacts\' LEFT JOIN leads ON leads.id = emailman.related_id and emailman.related_type =\'Leads\' LEFT JOIN accounts ON accounts.id = emailman.related_id and emailman.related_type =\'Accounts\' LEFT JOIN prospects ON prospects.id = emailman.related_id and emailman.related_type =\'Prospects\' LEFT JOIN prospect_lists ON prospect_lists.id = emailman.list_id LEFT JOIN email_addr_bean_rel ON email_addr_bean_rel.bean_id = emailman.related_id and emailman.related_type = email_addr_bean_rel.bean_module and email_addr_bean_rel.primary_address = 1 and email_addr_bean_rel.deleted=0 LEFT JOIN campaigns ON campaigns.id = emailman.campaign_id LEFT JOIN email_marketing ON email_marketing.id = emailman.marketing_idwhere emailman.user_id="" AND emailman.deleted=0'; $actual = $emailMan->create_list_query('emailman.id', 'emailman.user_id=""'); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } - public function testget_list_view_data() + public function testget_list_view_data(): void { $emailMan = BeanFactory::newBean('EmailMan'); @@ -118,10 +117,10 @@ class EmailManTest extends SuitePHPUnitFrameworkTestCase ); $actual = $emailMan->get_list_view_data(); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } - public function testset_as_sent() + public function testset_as_sent(): void { $emailMan = BeanFactory::newBean('EmailMan'); @@ -129,105 +128,102 @@ class EmailManTest extends SuitePHPUnitFrameworkTestCase //test with delete true/default try { $emailMan->set_as_sent('test@test.com', true, null, null, 'send error'); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } // Execute the method and test that it works and doesn't throw an exception. //test with delete false try { $emailMan->set_as_sent('test@test.com', false, null, null, 'send error'); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } } - public function testcreate_indiv_email() + public function testcreate_indiv_email(): void { - $emailMan = BeanFactory::newBean('EmailMan'); - - $result = $emailMan->create_indiv_email(BeanFactory::newBean('Contacts'), BeanFactory::newBean('Emails')); + $result = BeanFactory::newBean('EmailMan')->create_indiv_email(BeanFactory::newBean('Contacts'), BeanFactory::newBean('Emails')); //test for record ID to verify that record is saved - $this->assertEquals(36, strlen($result)); + self::assertEquals(36, strlen($result)); $email = BeanFactory::newBean('Emails'); $email->mark_deleted($result); } - public function testverify_campaign() + public function testverify_campaign(): void { // test - $emailMan = BeanFactory::newBean('EmailMan'); - $result = $emailMan->verify_campaign(''); - $this->assertEquals(false, $result); + $result = BeanFactory::newBean('EmailMan')->verify_campaign(''); + self::assertEquals(false, $result); } - public function testsendEmail() + public function testsendEmail(): void { $emailMan = BeanFactory::newBean('EmailMan'); //test without setting any attributes $result = $emailMan->sendEmail(new SugarPHPMailer(), 1, true); - $this->assertEquals(false, $result); + self::assertEquals(false, $result); //test with related type attribute set $emailMan->related_type = 'Contacts'; $emailMan->related_id = 1; $result = $emailMan->sendEmail(new SugarPHPMailer(), 1, true); - $this->assertEquals(true, $result); + self::assertEquals(true, $result); } - public function testvalid_email_address() + public function testvalid_email_address(): void { $emailMan = BeanFactory::newBean('EmailMan'); - $this->assertEquals(false, $emailMan->valid_email_address('')); - $this->assertEquals(false, $emailMan->valid_email_address('test')); - $this->assertEquals(true, $emailMan->valid_email_address('test@test.com')); + self::assertEquals(false, $emailMan->valid_email_address('')); + self::assertEquals(false, $emailMan->valid_email_address('test')); + self::assertEquals(true, $emailMan->valid_email_address('test@test.com')); } - public function testis_primary_email_address() + public function testis_primary_email_address(): void { $emailMan = BeanFactory::newBean('EmailMan'); $bean = BeanFactory::newBean('Contacts'); //test without setting any email - $this->assertEquals(false, $emailMan->is_primary_email_address($bean)); + self::assertEquals(false, $emailMan->is_primary_email_address($bean)); } - public function testcreate_export_query() + public function testcreate_export_query(): void { $emailMan = BeanFactory::newBean('EmailMan'); //test with empty string params $expected = 'SELECT emailman.* FROM emailman where ( emailman.deleted IS NULL OR emailman.deleted=0 )'; $actual = $emailMan->create_export_query('', ''); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); //test with valid string params $expected = 'SELECT emailman.* FROM emailman where (emailman.user_id="") AND ( emailman.deleted IS NULL OR emailman.deleted=0 )'; $actual = $emailMan->create_export_query('emailman.id', 'emailman.user_id=""'); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } - public function testmark_deleted() + public function testmark_deleted(): void { $emailMan = BeanFactory::newBean('EmailMan'); // Execute the method and test that it works and doesn't throw an exception. try { $emailMan->mark_deleted(''); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } } - public function testcreate_ref_email() + public function testcreate_ref_email(): void { $emailMan = BeanFactory::newBean('EmailMan'); $emailMan->test = true; @@ -247,7 +243,7 @@ class EmailManTest extends SuitePHPUnitFrameworkTestCase ); //test for email id returned and mark delete for cleanup - $this->assertEquals(36, strlen($result)); + self::assertEquals(36, strlen($result)); $email = BeanFactory::newBean('Emails'); $email->mark_deleted($result); } diff --git a/tests/unit/phpunit/modules/EmailMarketing/EmailMarketingTest.php b/tests/unit/phpunit/modules/EmailMarketing/EmailMarketingTest.php index abd02b3c7..e7e2c1a96 100644 --- a/tests/unit/phpunit/modules/EmailMarketing/EmailMarketingTest.php +++ b/tests/unit/phpunit/modules/EmailMarketing/EmailMarketingTest.php @@ -4,57 +4,54 @@ use SuiteCRM\Test\SuitePHPUnitFrameworkTestCase; class EmailMarketingTest extends SuitePHPUnitFrameworkTestCase { - public function testEmailMarketing() + public function testEmailMarketing(): void { // execute the constructor and check for the Object type and attributes $emailMarketing = BeanFactory::newBean('EmailMarketing'); - $this->assertInstanceOf('EmailMarketing', $emailMarketing); - $this->assertInstanceOf('SugarBean', $emailMarketing); + self::assertInstanceOf('EmailMarketing', $emailMarketing); + self::assertInstanceOf('SugarBean', $emailMarketing); - $this->assertAttributeEquals('EmailMarketing', 'module_dir', $emailMarketing); - $this->assertAttributeEquals('EmailMarketing', 'object_name', $emailMarketing); - $this->assertAttributeEquals('email_marketing', 'table_name', $emailMarketing); - - $this->assertAttributeEquals(true, 'new_schema', $emailMarketing); + self::assertEquals('EmailMarketing', $emailMarketing->module_dir); + self::assertEquals('EmailMarketing', $emailMarketing->object_name); + self::assertEquals('email_marketing', $emailMarketing->table_name); + self::assertEquals(true, $emailMarketing->new_schema); } - public function testretrieve() + public function testretrieve(): void { - $emailMarketing = BeanFactory::newBean('EmailMarketing'); - - $result = $emailMarketing->retrieve(); - $this->assertInstanceOf('EmailMarketing', $result); + $result = BeanFactory::newBean('EmailMarketing')->retrieve(); + self::assertInstanceOf('EmailMarketing', $result); } - public function testget_summary_text() + public function testget_summary_text(): void { $emailMarketing = BeanFactory::newBean('EmailMarketing'); // test without setting name - $this->assertEquals(null, $emailMarketing->get_summary_text()); + self::assertEquals(null, $emailMarketing->get_summary_text()); // test with name set $emailMarketing->name = 'test'; - $this->assertEquals('test', $emailMarketing->get_summary_text()); + self::assertEquals('test', $emailMarketing->get_summary_text()); } - public function testcreate_export_query() + public function testcreate_export_query(): void { $emailMarketing = BeanFactory::newBean('EmailMarketing'); //test with empty string params $expected = " SELECT email_marketing.* , jt0.name template_name , jt0.assigned_user_id template_name_owner , 'EmailTemplates' template_name_mod FROM email_marketing LEFT JOIN email_templates jt0 ON email_marketing.template_id=jt0.id AND jt0.deleted=0\n\n AND jt0.deleted=0 where email_marketing.deleted=0"; $actual = $emailMarketing->create_export_query('', ''); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); //test with valid string params $expected = " SELECT email_marketing.* , jt0.name template_name , jt0.assigned_user_id template_name_owner , 'EmailTemplates' template_name_mod FROM email_marketing LEFT JOIN email_templates jt0 ON email_marketing.template_id=jt0.id AND jt0.deleted=0\n\n AND jt0.deleted=0 where (email_marketing.name=\"\") AND email_marketing.deleted=0"; $actual = $emailMarketing->create_export_query('email_marketing.id', 'email_marketing.name=""'); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } - public function testget_list_view_data() + public function testget_list_view_data(): void { $emailMarketing = BeanFactory::newBean('EmailMarketing'); @@ -64,24 +61,24 @@ class EmailMarketingTest extends SuitePHPUnitFrameworkTestCase ); $actual = $emailMarketing->get_list_view_data(); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } - public function testbean_implements() + public function testbean_implements(): void { $emailMarketing = BeanFactory::newBean('EmailMarketing'); - $this->assertEquals(false, $emailMarketing->bean_implements('')); //test with blank value - $this->assertEquals(false, $emailMarketing->bean_implements('test')); //test with invalid value - $this->assertEquals(true, $emailMarketing->bean_implements('ACL')); //test with valid value + self::assertEquals(false, $emailMarketing->bean_implements('')); //test with blank value + self::assertEquals(false, $emailMarketing->bean_implements('test')); //test with invalid value + self::assertEquals(true, $emailMarketing->bean_implements('ACL')); //test with valid value } - public function testget_all_prospect_lists() + public function testget_all_prospect_lists(): void { $emailMarketing = BeanFactory::newBean('EmailMarketing'); //execute the method and verify that it retunrs expected results $expected = "select prospect_lists.* from prospect_lists left join prospect_list_campaigns on prospect_list_campaigns.prospect_list_id=prospect_lists.id where prospect_list_campaigns.deleted=0 and prospect_list_campaigns.campaign_id='' and prospect_lists.deleted=0 and prospect_lists.list_type not like 'exempt%'"; $actual = $emailMarketing->get_all_prospect_lists(); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } } diff --git a/tests/unit/phpunit/modules/EmailTemplates/EmailTemplateTest.php b/tests/unit/phpunit/modules/EmailTemplates/EmailTemplateTest.php index 202c71a50..26276669e 100644 --- a/tests/unit/phpunit/modules/EmailTemplates/EmailTemplateTest.php +++ b/tests/unit/phpunit/modules/EmailTemplates/EmailTemplateTest.php @@ -15,7 +15,7 @@ class EmailTemplateTest extends SuitePHPUnitFrameworkTestCase $current_user = BeanFactory::newBean('Users'); } - public function testEmailTemplateParser() + public function testEmailTemplateParser(): void { $emailTemplate = BeanFactory::newBean('EmailTemplates'); $emailTemplate->body_html = to_html('

Hello $contact_name

'); @@ -27,15 +27,14 @@ class EmailTemplateTest extends SuitePHPUnitFrameworkTestCase foreach ($related as $bean) { $bean->name = 'foobar'; - $parser = new EmailTemplateParser($emailTemplate, $campaign, $bean, "", ""); - $result = $parser->parseVariables(); - $this->assertEquals('

Hello foobar

', from_html($result['body_html'])); - $this->assertEquals('Hello foobar', $result['body']); - $this->assertEquals('Hello foobar', $result['subject']); + $result = (new EmailTemplateParser($emailTemplate, $campaign, $bean, "", ""))->parseVariables(); + self::assertEquals('

Hello foobar

', from_html($result['body_html'])); + self::assertEquals('Hello foobar', $result['body']); + self::assertEquals('Hello foobar', $result['subject']); } } - public function testEmailTemplateParserUser() + public function testEmailTemplateParserUser(): void { $emailTemplate = BeanFactory::newBean('EmailTemplates'); $emailTemplate->body = 'Hello $contact_user_full_name'; @@ -46,12 +45,11 @@ class EmailTemplateTest extends SuitePHPUnitFrameworkTestCase $bean->last_name = 'bar'; $bean->fill_in_additional_detail_fields(); - $parser = new EmailTemplateParser($emailTemplate, $campaign, $bean, "", ""); - $result = $parser->parseVariables(); - $this->assertEquals('Hello foo bar', $result['body']); + $result = (new EmailTemplateParser($emailTemplate, $campaign, $bean, "", ""))->parseVariables(); + self::assertEquals('Hello foo bar', $result['body']); } - public function testcreateCopyTemplate() + public function testcreateCopyTemplate(): void { global $current_user; @@ -66,15 +64,15 @@ class EmailTemplateTest extends SuitePHPUnitFrameworkTestCase require('modules/EmailTemplates/EmailTemplateData.php'); $output = json_decode($this->getActualOutput(), true); - $this->assertNotEmpty($output['data']); - $this->assertNotEmpty($output['data']['id']); + self::assertNotEmpty($output['data']); + self::assertNotEmpty($output['data']['id']); $template = BeanFactory::newBean('EmailTemplates'); - $this->assertNotNull($template->retrieve($output['data']['id'])); + self::assertNotNull($template->retrieve($output['data']['id'])); - $this->assertEquals($current_user->id, $template->assigned_user_id); + self::assertEquals($current_user->id, $template->assigned_user_id); } - public function testaddDomainToRelativeImagesSrc() + public function testaddDomainToRelativeImagesSrc(): void { global $sugar_config; @@ -86,10 +84,10 @@ class EmailTemplateTest extends SuitePHPUnitFrameworkTestCase $template->addDomainToRelativeImagesSrc(); $result = from_html($template->body_html); - $this->assertContains('src="https://foobar.com/public/c1270a2d-a083-495e-7c61-5c8a9046ec0d.png" alt="c1270a2d-a083-495e-7c61-5c8a9046ec0d.png"', $result); + self::assertStringContainsString('src="https://foobar.com/public/c1270a2d-a083-495e-7c61-5c8a9046ec0d.png" alt="c1270a2d-a083-495e-7c61-5c8a9046ec0d.png"', $result); } - public function testrepairEntryPointImages() + public function testrepairEntryPointImages(): void { global $sugar_config; @@ -107,35 +105,34 @@ class EmailTemplateTest extends SuitePHPUnitFrameworkTestCase $template->body_html = to_html($html); $template->new_with_id = true; $template->save(); - $this->assertNotNull($template->retrieve($template->id)); + self::assertNotNull($template->retrieve($template->id)); foreach ($ids as $id) { - $this->assertTrue(is_file('public/' . $id . '.png')); + self::assertTrue(is_file('public/' . $id . '.png')); unlink('public/' . $id . '.png'); unlink('upload/' . $id); } $expected = ''; $expected .= 'test.png'; - $this->assertEquals($expected, from_html($template->body_html)); + self::assertEquals($expected, from_html($template->body_html)); } - public function testEmailTemplate() + public function testEmailTemplate(): void { // Execute the constructor and check for the Object type and attributes $emailTemplate = BeanFactory::newBean('EmailTemplates'); - $this->assertInstanceOf('EmailTemplate', $emailTemplate); - $this->assertInstanceOf('SugarBean', $emailTemplate); + self::assertInstanceOf('EmailTemplate', $emailTemplate); + self::assertInstanceOf('SugarBean', $emailTemplate); - $this->assertAttributeEquals('EmailTemplates', 'module_dir', $emailTemplate); - $this->assertAttributeEquals('EmailTemplate', 'object_name', $emailTemplate); - $this->assertAttributeEquals('email_templates', 'table_name', $emailTemplate); - - $this->assertAttributeEquals(true, 'new_schema', $emailTemplate); + self::assertEquals('EmailTemplates', $emailTemplate->module_dir); + self::assertEquals('EmailTemplate', $emailTemplate->object_name); + self::assertEquals('email_templates', $emailTemplate->table_name); + self::assertEquals(true, $emailTemplate->new_schema); } - public function testgenerateFieldDefsJS() + public function testgenerateFieldDefsJS(): void { $emailTemplate = BeanFactory::newBean('EmailTemplates'); @@ -144,50 +141,50 @@ class EmailTemplateTest extends SuitePHPUnitFrameworkTestCase $actual = $emailTemplate->generateFieldDefsJS(); // $this->assertSame($expected, $actual); - $this->assertGreaterThan(0, strlen($actual)); + self::assertGreaterThan(0, strlen($actual)); } - public function testget_summary_text() + public function testget_summary_text(): void { $emailTemplate = BeanFactory::newBean('EmailTemplates'); // test without setting name - $this->assertEquals(null, $emailTemplate->get_summary_text()); + self::assertEquals(null, $emailTemplate->get_summary_text()); // test with name set $emailTemplate->name = 'test'; - $this->assertEquals('test', $emailTemplate->get_summary_text()); + self::assertEquals('test', $emailTemplate->get_summary_text()); } - public function testcreate_export_query() + public function testcreate_export_query(): void { $emailTemplate = BeanFactory::newBean('EmailTemplates'); // test with empty string params $expected = " SELECT email_templates.* , jt0.user_name assigned_user_name , jt0.created_by assigned_user_name_owner , 'Users' assigned_user_name_mod FROM email_templates LEFT JOIN users jt0 ON email_templates.assigned_user_id=jt0.id AND jt0.deleted=0\n\n AND jt0.deleted=0 where email_templates.deleted=0"; $actual = $emailTemplate->create_export_query('', ''); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); // test with valid string params $expected = " SELECT email_templates.* , jt0.user_name assigned_user_name , jt0.created_by assigned_user_name_owner , 'Users' assigned_user_name_mod FROM email_templates LEFT JOIN users jt0 ON email_templates.assigned_user_id=jt0.id AND jt0.deleted=0\n\n AND jt0.deleted=0 where (email_templates.name=\"\") AND email_templates.deleted=0"; $actual = $emailTemplate->create_export_query('email_templates.id', 'email_templates.name=""'); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } - public function testfill_in_additional_list_fields() + public function testfill_in_additional_list_fields(): void { $emailTemplate = BeanFactory::newBean('EmailTemplates'); // Execute the method and test that it works and doesn't throw an exception. try { $emailTemplate->fill_in_additional_list_fields(); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } } - public function testfill_in_additional_detail_fields() + public function testfill_in_additional_detail_fields(): void { $emailTemplate = BeanFactory::newBean('EmailTemplates'); @@ -199,65 +196,65 @@ class EmailTemplateTest extends SuitePHPUnitFrameworkTestCase $emailTemplate->fill_in_additional_detail_fields(); - $this->assertEquals('Administrator', $emailTemplate->created_by_name); - $this->assertEquals('Administrator', $emailTemplate->modified_by_name); - $this->assertEquals('Administrator', $emailTemplate->assigned_user_name); - $this->assertEquals('some html text', $emailTemplate->body); + self::assertEquals('Administrator', $emailTemplate->created_by_name); + self::assertEquals('Administrator', $emailTemplate->modified_by_name); + self::assertEquals('Administrator', $emailTemplate->assigned_user_name); + self::assertEquals('some html text', $emailTemplate->body); } - public function testfill_in_additional_detail_fields_body_to_text() + public function testfill_in_additional_detail_fields_body_to_text(): void { // simple examples $emailTemplate = BeanFactory::newBean('EmailTemplates'); $emailTemplate->body_html = htmlentities('

Hello


text'); $emailTemplate->fill_in_additional_detail_fields(); - $this->assertEquals("Hello\n\n[text](https://suitecrm.com)", $emailTemplate->body); + self::assertEquals("Hello\n\n[text](https://suitecrm.com)", $emailTemplate->body); // entities and tags $emailTemplate = BeanFactory::newBean('EmailTemplates'); $emailTemplate->body_html = htmlentities('<a>'); $emailTemplate->fill_in_additional_detail_fields(); - $this->assertEquals("", $emailTemplate->body); + self::assertEquals("", $emailTemplate->body); // invalid html $emailTemplate = BeanFactory::newBean('EmailTemplates'); $emailTemplate->body_html = htmlentities('foofill_in_additional_detail_fields(); - $this->assertEquals("foo", $emailTemplate->body); + self::assertEquals("foo", $emailTemplate->body); // variables $emailTemplate = BeanFactory::newBean('EmailTemplates'); $emailTemplate->body_html = htmlentities('Hello $foobar'); $emailTemplate->fill_in_additional_detail_fields(); - $this->assertEquals('Hello $foo bar', $emailTemplate->body); + self::assertEquals('Hello $foo bar', $emailTemplate->body); // variables in URLs (opt-in confirmation emails etc) $emailTemplate = BeanFactory::newBean('EmailTemplates'); $emailTemplate->body_html = htmlentities('text'); $emailTemplate->fill_in_additional_detail_fields(); - $this->assertEquals('[text]($url/index.php?foo=$bar&quux=$baz)', $emailTemplate->body); + self::assertEquals('[text]($url/index.php?foo=$bar&quux=$baz)', $emailTemplate->body); // decoding latin-1 html $emailTemplate = BeanFactory::newBean('EmailTemplates'); $emailTemplate->body_html = htmlentities('' . "\xe4", ENT_QUOTES, "ISO-8859-1"); $emailTemplate->fill_in_additional_detail_fields(); - $this->assertEquals("\xc3\xa4", $emailTemplate->body); + self::assertEquals("\xc3\xa4", $emailTemplate->body); } - public function testfill_in_additional_parent_fields() + public function testfill_in_additional_parent_fields(): void { $emailTemplate = BeanFactory::newBean('EmailTemplates'); // Execute the method and test that it works and doesn't throw an exception. try { $emailTemplate->fill_in_additional_parent_fields(); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } } - public function testget_list_view_data() + public function testget_list_view_data(): void { $emailTemplate = BeanFactory::newBean('EmailTemplates'); @@ -267,10 +264,10 @@ class EmailTemplateTest extends SuitePHPUnitFrameworkTestCase ); $actual = $emailTemplate->get_list_view_data(); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } - public function testparse_email_templateAndParse_tracker_urls() + public function testparse_email_templateAndParse_tracker_urls(): void { $emailTemplate = BeanFactory::newBean('EmailTemplates'); @@ -282,7 +279,7 @@ class EmailTemplateTest extends SuitePHPUnitFrameworkTestCase 'subject' => 'test subject', 'body_html' => 'test html', 'body' => 'test body text', ); $actual = $emailTemplate->parse_email_template(array('subject' => 'test subject', 'body_html' => 'test html', 'body' => 'test body text'), 'Accounts', $account, $macro_nv); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); // test parse_tracker_urls $tracker_url_template = 'localhost/index.php?entryPoint=campaign_trackerv2&track=%s&identifier=tracker_key'; @@ -290,16 +287,16 @@ class EmailTemplateTest extends SuitePHPUnitFrameworkTestCase $tracker_urls = array(); $result = $emailTemplate->parse_tracker_urls($actual, $tracker_url_template, $tracker_urls, $removeme_url_template); - $this->assertSame($expected, $result); + self::assertSame($expected, $result); } - public function test_convertToType() + public function test_convertToType(): void { $emailTemplate = BeanFactory::newBean('EmailTemplates'); - $this->assertEquals(10, $emailTemplate->_convertToType('float', 10)); - $this->assertEquals('test text', $emailTemplate->_convertToType('text', 'test text')); - $this->assertEquals('$10.00', $emailTemplate->_convertToType('currency', 10)); + self::assertEquals(10, $emailTemplate->_convertToType('float', 10)); + self::assertEquals('test text', $emailTemplate->_convertToType('text', 'test text')); + self::assertEquals('$10.00', $emailTemplate->_convertToType('currency', 10)); } /** @@ -310,7 +307,7 @@ class EmailTemplateTest extends SuitePHPUnitFrameworkTestCase * contact_user_deleted, contact_user_portal_only, contact_user_show_on_employees * */ - public function test_parseUserValues() + public function test_parseUserValues(): void { /* $emailTemplate = BeanFactory::newBean('EmailTemplates'); @@ -388,10 +385,10 @@ class EmailTemplateTest extends SuitePHPUnitFrameworkTestCase $actual = $emailTemplate->_parseUserValues($repl_arr, $user); $this->assertSame($expected, $actual); */ - $this->markTestIncomplete("Different values for php5 and php7"); + self::markTestIncomplete("Different values for php5 and php7"); } - public function testparse_template_bean() + public function testparse_template_bean(): void { $emailTemplate = BeanFactory::newBean('EmailTemplates'); $contact = BeanFactory::newBean('Contacts'); @@ -403,44 +400,44 @@ class EmailTemplateTest extends SuitePHPUnitFrameworkTestCase // test with empty string $actual = $emailTemplate->parse_template_bean('', 'Contacts', $contact); - $this->assertEquals('', $actual); + self::assertEquals('', $actual); // test with valid string $actual = $emailTemplate->parse_template_bean('test', 'Users', $user); - $this->assertEquals('test', $actual); + self::assertEquals('test', $actual); // test with empty string and different module $actual = $emailTemplate->parse_template_bean('', 'Accounts', $account); - $this->assertEquals('', $actual); + self::assertEquals('', $actual); } - public function testparse_template() + public function testparse_template(): void { $emailTemplate = BeanFactory::newBean('EmailTemplates'); $bean_arr = array('Users' => 1, 'Leads' => 1); // test with empty string $result = $emailTemplate->parse_template('', $bean_arr); - $this->assertEquals('', $result); + self::assertEquals('', $result); // test with valid string $result = $emailTemplate->parse_template('some value', $bean_arr); - $this->assertEquals('some value', $result); + self::assertEquals('some value', $result); } - public function testbean_implements() + public function testbean_implements(): void { $emailTemplate = BeanFactory::newBean('EmailTemplates'); // test with blank value - $this->assertEquals(false, $emailTemplate->bean_implements('')); + self::assertEquals(false, $emailTemplate->bean_implements('')); // test with invalid value - $this->assertEquals(false, $emailTemplate->bean_implements('test')); + self::assertEquals(false, $emailTemplate->bean_implements('test')); // test with valid value - $this->assertEquals(true, $emailTemplate->bean_implements('ACL')); + self::assertEquals(true, $emailTemplate->bean_implements('ACL')); } - public function testgetTypeOptionsForSearch() + public function testgetTypeOptionsForSearch(): void { // execute the method and verify that it returns expected results $expected = [ @@ -450,32 +447,32 @@ class EmailTemplateTest extends SuitePHPUnitFrameworkTestCase 'event' => 'Event' ]; $actual = EmailTemplate::getTypeOptionsForSearch(); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } - public function testis_used_by_email_marketing() + public function testis_used_by_email_marketing(): void { $emailTemplate = BeanFactory::newBean('EmailTemplates'); // test without id attribute - $this->assertEquals(false, $emailTemplate->is_used_by_email_marketing()); + self::assertEquals(false, $emailTemplate->is_used_by_email_marketing()); // test with id attribute $emailTemplate->id = 1; - $this->assertEquals(false, $emailTemplate->is_used_by_email_marketing()); + self::assertEquals(false, $emailTemplate->is_used_by_email_marketing()); } - public function testcleanBean() + public function testcleanBean(): void { $emailTemplate = BeanFactory::newBean('EmailTemplates'); // test without body_html attribute $emailTemplate->cleanBean(); - $this->assertEquals('', $emailTemplate->body_html); + self::assertEquals('', $emailTemplate->body_html); // test with body_html attribute $emailTemplate->body_html = '

text

'; $emailTemplate->cleanBean(); - $this->assertEquals('<h1>text</h1>', $emailTemplate->body_html); + self::assertEquals('<h1>text</h1>', $emailTemplate->body_html); } } diff --git a/tests/unit/phpunit/modules/EmailText/EmailTextTest.php b/tests/unit/phpunit/modules/EmailText/EmailTextTest.php index 0bfdeb185..4d5bc21d2 100644 --- a/tests/unit/phpunit/modules/EmailText/EmailTextTest.php +++ b/tests/unit/phpunit/modules/EmailText/EmailTextTest.php @@ -4,20 +4,19 @@ use SuiteCRM\Test\SuitePHPUnitFrameworkTestCase; class EmailTextTest extends SuitePHPUnitFrameworkTestCase { - public function testEmailText() + public function testEmailText(): void { // Execute the constructor and check for the Object type and attributes $emailText = BeanFactory::newBean('EmailText'); - $this->assertInstanceOf('EmailText', $emailText); - $this->assertInstanceOf('SugarBean', $emailText); + self::assertInstanceOf('EmailText', $emailText); + self::assertInstanceOf('SugarBean', $emailText); - $this->assertAttributeEquals('EmailText', 'module_dir', $emailText); - $this->assertAttributeEquals('EmailText', 'module_name', $emailText); - $this->assertAttributeEquals('EmailText', 'object_name', $emailText); - $this->assertAttributeEquals('emails_text', 'table_name', $emailText); - - $this->assertAttributeEquals(true, 'disable_row_level_security', $emailText); - $this->assertAttributeEquals(true, 'disable_custom_fields', $emailText); + self::assertEquals('EmailText', $emailText->module_dir); + self::assertEquals('EmailText', $emailText->module_name); + self::assertEquals('EmailText', $emailText->object_name); + self::assertEquals('emails_text', $emailText->table_name); + self::assertEquals(true, $emailText->disable_row_level_security); + self::assertEquals(true, $emailText->disable_custom_fields); } } diff --git a/tests/unit/phpunit/modules/Emails/EmailFromValidatorTest.php b/tests/unit/phpunit/modules/Emails/EmailFromValidatorTest.php index 499b2fa74..146d78ed8 100644 --- a/tests/unit/phpunit/modules/Emails/EmailFromValidatorTest.php +++ b/tests/unit/phpunit/modules/Emails/EmailFromValidatorTest.php @@ -54,11 +54,11 @@ require_once __DIR__ . '/../../../../../modules/Emails/EmailFromValidator.php'; class EmailFromValidatorTest extends SuitePHPUnitFrameworkTestCase { // TODO: !@# Needs more test... - public function testValidateWrongFromAddr() + public function testValidateWrongFromAddr(): void { $email = BeanFactory::newBean('Emails'); $validator = new EmailFromValidator(); - + // from_addr is not set $email->From = 'gusta@yammee.org'; unset($email->from_addr); @@ -67,51 +67,51 @@ class EmailFromValidatorTest extends SuitePHPUnitFrameworkTestCase $email->from_addr_name = 'Mr. Wee Gusta '; $valid = $validator->isValid($email); $errors = $validator->getErrors(); - $this->assertFalse($valid); - $this->assertEquals([ + self::assertFalse($valid); + self::assertEquals([ EmailFromValidator::ERR_FIELD_FROM_ADDR_IS_NOT_SET, ], $errors); - - + + // from_addr is empty $email->from_addr = ''; $valid = $validator->isValid($email); $errors = $validator->getErrors(); - $this->assertFalse($valid); - $this->assertEquals([ + self::assertFalse($valid); + self::assertEquals([ EmailFromValidator::ERR_FIELD_FROM_ADDR_IS_EMPTY, EmailFromValidator::ERR_FIELD_FROM_ADDR_NAME_INVALID_EMAIL_PART_TO_FIELD_FROM_ADDR, EmailFromValidator::ERR_FIELD_FROM_ADDR_NAME_IS_INVALID, ], $errors); - - + + // from_addr is invalid $email->from_addr = 'gustayammee'; $valid = $validator->isValid($email); $errors = $validator->getErrors(); - $this->assertFalse($valid); - $this->assertEquals([ + self::assertFalse($valid); + self::assertEquals([ EmailFromValidator::ERR_FIELD_FROM_ADDR_IS_INVALID, EmailFromValidator::ERR_FIELD_FROM_ADDR_NAME_INVALID_EMAIL_PART_TO_FIELD_FROM_ADDR, EmailFromValidator::ERR_FIELD_FROM_ADDR_NAME_IS_INVALID, ], $errors); - + // from_addr is not match to From and/or from_addr_name - address part $email->from_addr = 'langusta@yammee.org'; $valid = $validator->isValid($email); $errors = $validator->getErrors(); - $this->assertFalse($valid); - $this->assertEquals([ + self::assertFalse($valid); + self::assertEquals([ EmailFromValidator::ERR_FIELD_FROM_ADDR_NAME_INVALID_EMAIL_PART_TO_FIELD_FROM_ADDR, EmailFromValidator::ERR_FIELD_FROM_ADDR_NAME_IS_INVALID, ], $errors); } - - public function testValidateWrongFrom() + + public function testValidateWrongFrom(): void { $email = BeanFactory::newBean('Emails'); $validator = new EmailFromValidator(); - + // From is not set unset($email->From); $email->from_addr = 'gusta@yammee.org'; @@ -120,51 +120,51 @@ class EmailFromValidatorTest extends SuitePHPUnitFrameworkTestCase $email->from_addr_name = 'Mr. Wee Gusta '; $valid = $validator->isValid($email); $errors = $validator->getErrors(); - $this->assertFalse($valid); - $this->assertEquals([ + self::assertFalse($valid); + self::assertEquals([ EmailFromValidator::ERR_FIELD_FROM_IS_NOT_SET, ], $errors); - - + + // From is empty $email->From = ''; $valid = $validator->isValid($email); $errors = $validator->getErrors(); - $this->assertFalse($valid); - $this->assertEquals([ + self::assertFalse($valid); + self::assertEquals([ EmailFromValidator::ERR_FIELD_FROM_IS_EMPTY, EmailFromValidator::ERR_FIELD_FROM_ADDR_NAME_INVALID_EMAIL_PART_TO_FIELD_FROM, EmailFromValidator::ERR_FIELD_FROM_ADDR_NAME_IS_INVALID, ], $errors); - - + + // From is invalid $email->From = 'gustayammee'; $valid = $validator->isValid($email); $errors = $validator->getErrors(); - $this->assertFalse($valid); - $this->assertEquals([ + self::assertFalse($valid); + self::assertEquals([ EmailFromValidator::ERR_FIELD_FROM_IS_INVALID, EmailFromValidator::ERR_FIELD_FROM_ADDR_NAME_INVALID_EMAIL_PART_TO_FIELD_FROM, EmailFromValidator::ERR_FIELD_FROM_ADDR_NAME_IS_INVALID, ], $errors); - + // From is not match to from_addr and/or from_addr_name - address part $email->From = 'langusta@yammee.org'; $valid = $validator->isValid($email); $errors = $validator->getErrors(); - $this->assertFalse($valid); - $this->assertEquals([ + self::assertFalse($valid); + self::assertEquals([ EmailFromValidator::ERR_FIELD_FROM_ADDR_NAME_INVALID_EMAIL_PART_TO_FIELD_FROM, EmailFromValidator::ERR_FIELD_FROM_ADDR_NAME_IS_INVALID, ], $errors); } - - public function testValidateOk() + + public function testValidateOk(): void { $email = BeanFactory::newBean('Emails'); $validator = new EmailFromValidator(); - + $email->From = 'gusta@yammee.org'; $email->from_addr = 'gusta@yammee.org'; $email->FromName = 'Mr. Wee Gusta'; @@ -172,7 +172,7 @@ class EmailFromValidatorTest extends SuitePHPUnitFrameworkTestCase $email->from_addr_name = 'Mr. Wee Gusta '; $valid = $validator->isValid($email); $errors = $validator->getErrors(); - $this->assertTrue($valid); - $this->assertEmpty($errors); + self::assertTrue($valid); + self::assertEmpty($errors); } } diff --git a/tests/unit/phpunit/modules/Emails/EmailMock.php b/tests/unit/phpunit/modules/Emails/EmailMock.php index 69a6ee5e8..8f9a195b9 100644 --- a/tests/unit/phpunit/modules/Emails/EmailMock.php +++ b/tests/unit/phpunit/modules/Emails/EmailMock.php @@ -5,7 +5,7 @@ * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. * * SuiteCRM is an extension to SugarCRM Community Edition developed by SalesAgility Ltd. - * Copyright (C) 2011 - 2018 SalesAgility Ltd. + * Copyright (C) 2011 - 2021 SalesAgility Ltd. * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU Affero General Public License version 3 as published by the @@ -50,12 +50,12 @@ if (!defined('sugarEntry') || !sugarEntry) { class EmailMock extends Email { /** - * - * @param int $err + * @param $err + * @throws EmailException */ - public function setLastSaveAndStoreInSentErrorPublic($err) + public function setLastSaveAndStoreInSentErrorPublic($err): void { - return parent::setLastSaveAndStoreInSentError($err); + $this->setLastSaveAndStoreInSentError($err); } /** @@ -63,11 +63,11 @@ class EmailMock extends Email * @param object $mail SugarPHPMailer object * @param string $mailer_id * @param string $ieId - * @global $current_user * @return object mail SugarPHPMailer object + * @global $current_user */ - public function setMailer($mail, $mailer_id = '', $ieId = '') + public function setMailer($mail, $mailer_id = '', $ieId = ''): object { - return $mail; // skipp oe settings + return $mail; } } diff --git a/tests/unit/phpunit/modules/Emails/EmailTest.php b/tests/unit/phpunit/modules/Emails/EmailTest.php index c5f4cec66..eff56598d 100644 --- a/tests/unit/phpunit/modules/Emails/EmailTest.php +++ b/tests/unit/phpunit/modules/Emails/EmailTest.php @@ -5,7 +5,7 @@ * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. * * SuiteCRM is an extension to SugarCRM Community Edition developed by SalesAgility Ltd. - * Copyright (C) 2011 - 2019 SalesAgility Ltd. + * Copyright (C) 2011 - 2021 SalesAgility Ltd. * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU Affero General Public License version 3 as published by the @@ -60,13 +60,13 @@ class EmailTest extends SuitePHPUnitFrameworkTestCase $GLOBALS['mod_strings'] = return_module_language($GLOBALS['current_language'], 'Emails'); } - public function testSendSaveAndStoreInSentOk() + public function testSendSaveAndStoreInSentOk(): void { // handle non-gmail sent folder (mailbox is set) $mailer = new SugarPHPMailerMock(); $ie = BeanFactory::newBean('InboundEmail'); $ieId = $ie->save(); - $this->assertTrue((bool)$ieId); + self::assertTrue((bool)$ieId); $_REQUEST['inbound_email_id'] = $ieId; $email = new EmailMock(); $email->to_addrs_arr = ['foo@bazz.bar']; @@ -79,20 +79,20 @@ class EmailTest extends SuitePHPUnitFrameworkTestCase $mailer->oe->mail_smtptype = 'foomail'; $ret = $email->send($mailer, $nonGmailSentFolder, $ie); - $this->assertTrue($ret); - $this->assertNull($email->getLastSaveAndStoreInSentError()); - $this->assertNull($email->getNonGmailSentFolderHandler()); - $this->assertNull($email->getTempEmailAtSend()->getNonGmailSentFolderHandler()->getLastError()); - $this->assertEquals(Email::NO_ERROR, $email->getTempEmailAtSend()->getLastSaveAndStoreInSentError()); + self::assertTrue($ret); + self::assertNull($email->getLastSaveAndStoreInSentError()); + self::assertNull($email->getNonGmailSentFolderHandler()); + self::assertNull($email->getTempEmailAtSend()->getNonGmailSentFolderHandler()->getLastError()); + self::assertEquals(Email::NO_ERROR, $email->getTempEmailAtSend()->getLastSaveAndStoreInSentError()); } - public function testSendSaveAndStoreInSentOkButIEDoesntMatch() + public function testSendSaveAndStoreInSentOkButIEDoesntMatch(): void { // handle non-gmail sent folder (mailbox is set) $mailer = new SugarPHPMailerMock(); $ie = BeanFactory::newBean('InboundEmail'); $ieId = $ie->save(); - $this->assertTrue((bool)$ieId); + self::assertTrue((bool)$ieId); $_REQUEST['inbound_email_id'] = $ieId; $email = new EmailMock(); $email->to_addrs_arr = ['foo@bazz.bar']; @@ -105,20 +105,20 @@ class EmailTest extends SuitePHPUnitFrameworkTestCase $mailer->oe->mail_smtptype = 'foomail'; $ret = $email->send($mailer, $nonGmailSentFolder, $ie); - $this->assertTrue($ret); - $this->assertNull($email->getLastSaveAndStoreInSentError()); - $this->assertNull($email->getNonGmailSentFolderHandler()); - $this->assertNull($email->getTempEmailAtSend()->getNonGmailSentFolderHandler()->getLastError()); - $this->assertEquals(Email::NO_ERROR, $email->getTempEmailAtSend()->getLastSaveAndStoreInSentError()); + self::assertTrue($ret); + self::assertNull($email->getLastSaveAndStoreInSentError()); + self::assertNull($email->getNonGmailSentFolderHandler()); + self::assertNull($email->getTempEmailAtSend()->getNonGmailSentFolderHandler()->getLastError()); + self::assertEquals(Email::NO_ERROR, $email->getTempEmailAtSend()->getLastSaveAndStoreInSentError()); } - public function testSendSaveAndStoreInSentNoSentFolder() + public function testSendSaveAndStoreInSentNoSentFolder(): void { // handle non-gmail sent folder (mailbox is set but no ie stored option: sentFolder) $mailer = new SugarPHPMailerMock(); $ie = BeanFactory::newBean('InboundEmail'); $ieId = $ie->save(); - $this->assertTrue((bool)$ieId); + self::assertTrue((bool)$ieId); $_REQUEST['inbound_email_id'] = $ieId; $email = new EmailMock(); $email->to_addrs_arr = ['foo@bazz.bar']; @@ -128,23 +128,22 @@ class EmailTest extends SuitePHPUnitFrameworkTestCase $mailer->oe->mail_smtptype = 'foomail'; $ret = $email->send($mailer, $nonGmailSentFolder, $ie); - $this->assertTrue($ret); - $this->assertNull($email->getLastSaveAndStoreInSentError()); - $this->assertNull($email->getNonGmailSentFolderHandler()); - $this->assertEquals(Email::ERR_NOT_STORED_AS_SENT, $email->getTempEmailAtSend()->getLastSaveAndStoreInSentError()); - $this->assertEquals( + self::assertTrue($ret); + self::assertNull($email->getLastSaveAndStoreInSentError()); + self::assertNull($email->getNonGmailSentFolderHandler()); + self::assertEquals(Email::ERR_NOT_STORED_AS_SENT, $email->getTempEmailAtSend()->getLastSaveAndStoreInSentError()); + self::assertEquals( NonGmailSentFolderHandler::ERR_NO_STORED_SENT_FOLDER, $email->getTempEmailAtSend()->getNonGmailSentFolderHandler()->getLastError() ); } - public function testSendSaveAndStoreInSentNoMailbox() + public function testSendSaveAndStoreInSentNoMailbox(): void { // mailbox is not set $mailer = new SugarPHPMailerMock(); - $ie = BeanFactory::newBean('InboundEmail'); - $ieId = $ie->save(); - $this->assertTrue((bool)$ieId); + $ieId = BeanFactory::newBean('InboundEmail')->save(); + self::assertTrue((bool)$ieId); $_REQUEST['inbound_email_id'] = $ieId; $email = new EmailMock(); $email->to_addrs_arr = ['foo@bazz.bar']; @@ -152,14 +151,14 @@ class EmailTest extends SuitePHPUnitFrameworkTestCase $mailer->oe->mail_smtptype = 'foomail'; $ret = $email->send($mailer); - $this->assertTrue($ret); - $this->assertNull($email->getLastSaveAndStoreInSentError()); - $this->assertNull($email->getNonGmailSentFolderHandler()); - $this->assertEquals(Email::ERR_NOT_STORED_AS_SENT, $email->getTempEmailAtSend()->getLastSaveAndStoreInSentError()); - $this->assertEquals(NonGmailSentFolderHandler::ERR_EMPTY_MAILBOX, $email->getTempEmailAtSend()->getNonGmailSentFolderHandler()->getLastError()); + self::assertTrue($ret); + self::assertNull($email->getLastSaveAndStoreInSentError()); + self::assertNull($email->getNonGmailSentFolderHandler()); + self::assertEquals(Email::ERR_NOT_STORED_AS_SENT, $email->getTempEmailAtSend()->getLastSaveAndStoreInSentError()); + self::assertEquals(NonGmailSentFolderHandler::ERR_EMPTY_MAILBOX, $email->getTempEmailAtSend()->getNonGmailSentFolderHandler()->getLastError()); } - public function testSendSaveAndStoreInSentNoIE() + public function testSendSaveAndStoreInSentNoIE(): void { // no IE $mailer = new SugarPHPMailerMock(); @@ -169,14 +168,14 @@ class EmailTest extends SuitePHPUnitFrameworkTestCase $email->saved_attachments = []; $ret = $email->send($mailer); - $this->assertTrue($ret); - $this->assertNull($email->getLastSaveAndStoreInSentError()); - $this->assertNull($email->getNonGmailSentFolderHandler()); - $this->assertEquals(Email::ERR_IE_RETRIEVE, $email->getTempEmailAtSend()->getLastSaveAndStoreInSentError()); - $this->assertNull($email->getTempEmailAtSend()->getNonGmailSentFolderHandler()); + self::assertTrue($ret); + self::assertNull($email->getLastSaveAndStoreInSentError()); + self::assertNull($email->getNonGmailSentFolderHandler()); + self::assertEquals(Email::ERR_IE_RETRIEVE, $email->getTempEmailAtSend()->getLastSaveAndStoreInSentError()); + self::assertNull($email->getTempEmailAtSend()->getNonGmailSentFolderHandler()); } - public function testSendSaveAndStoreInSentSendFailedButItsOk() + public function testSendSaveAndStoreInSentSendFailedButItsOk(): void { // should send successfully $mailer = new SugarPHPMailerMock(); @@ -185,13 +184,13 @@ class EmailTest extends SuitePHPUnitFrameworkTestCase $email->saved_attachments = []; $ret = $email->send($mailer); - $this->assertTrue($ret); - $this->assertNull($email->getLastSaveAndStoreInSentError()); - $this->assertNull($email->getNonGmailSentFolderHandler()); - $this->assertNull($email->getTempEmailAtSend()); + self::assertTrue($ret); + self::assertNull($email->getLastSaveAndStoreInSentError()); + self::assertNull($email->getNonGmailSentFolderHandler()); + self::assertNull($email->getTempEmailAtSend()); } - public function testSendSaveAndStoreInSentSendFailed() + public function testSendSaveAndStoreInSentSendFailed(): void { // sending should failing $email = BeanFactory::newBean('Emails'); @@ -199,49 +198,51 @@ class EmailTest extends SuitePHPUnitFrameworkTestCase $email->saved_attachments = []; $ret = $email->send(); - $this->assertFalse($ret); - $this->assertNull($email->getLastSaveAndStoreInSentError()); - $this->assertNull($email->getNonGmailSentFolderHandler()); - $this->assertNull($email->getTempEmailAtSend()); + self::assertFalse($ret); + self::assertNull($email->getLastSaveAndStoreInSentError()); + self::assertNull($email->getNonGmailSentFolderHandler()); + self::assertNull($email->getTempEmailAtSend()); } - public function testSendSaveAndStoreInSentSendNoAttachment() + public function testSendSaveAndStoreInSentSendNoAttachment(): void { // attachenemt error $email = BeanFactory::newBean('Emails'); $email->to_addrs_arr = ['foo@bazz.bar']; $ret = $email->send(); - $this->assertFalse($ret); - $this->assertNull($email->getLastSaveAndStoreInSentError()); - $this->assertNull($email->getNonGmailSentFolderHandler()); - $this->assertNull($email->getTempEmailAtSend()); + self::assertFalse($ret); + self::assertNull($email->getLastSaveAndStoreInSentError()); + self::assertNull($email->getNonGmailSentFolderHandler()); + self::assertNull($email->getTempEmailAtSend()); } - public function testSendSaveAndStoreInSentSendNoTo() + public function testSendSaveAndStoreInSentSendNoTo(): void { // "to" array is required $email = BeanFactory::newBean('Emails'); $ret = $email->send(); - $this->assertFalse($ret); - $this->assertNull($email->getLastSaveAndStoreInSentError()); - $this->assertNull($email->getNonGmailSentFolderHandler()); - $this->assertNull($email->getTempEmailAtSend()); + self::assertFalse($ret); + self::assertNull($email->getLastSaveAndStoreInSentError()); + self::assertNull($email->getNonGmailSentFolderHandler()); + self::assertNull($email->getTempEmailAtSend()); } - public function testSetLastSaveAndStoreInSentErrorNo() + public function testSetLastSaveAndStoreInSentErrorNo(): void { $email = new EmailMock(); try { $email->setLastSaveAndStoreInSentErrorPublic(null); - $this->assertTrue(false); + self::assertTrue(false); } catch (InvalidArgumentException $e) { - $this->assertEquals(Email::ERR_CODE_SHOULD_BE_INT, $e->getCode()); + self::assertEquals(Email::ERR_CODE_SHOULD_BE_INT, $e->getCode()); + } catch (EmailException $e) { + self::assertEquals(Email::UNHANDLED_LAST_ERROR, $e->getCode()); } } - public function testSaveAndStoreInSentFolderIfNoGmailWithNoIE() + public function testSaveAndStoreInSentFolderIfNoGmailWithNoIE(): void { $email = BeanFactory::newBean('Emails'); $ie = BeanFactory::newBean('InboundEmail'); @@ -250,60 +251,58 @@ class EmailTest extends SuitePHPUnitFrameworkTestCase $nonGmailSentFolder = new NonGmailSentFolderHandler(); $ret = $email->saveAndStoreInSentFolderIfNoGmail($ie, $ieId, $mail, $nonGmailSentFolder); - $this->assertNull($ret); - $this->assertEquals(Email::ERR_IE_RETRIEVE, $email->getLastSaveAndStoreInSentError()); + self::assertNull($ret); + self::assertEquals(Email::ERR_IE_RETRIEVE, $email->getLastSaveAndStoreInSentError()); } - public function testEmail() + public function testEmail(): void { // Execute the constructor and check for the Object type and attributes $email = BeanFactory::newBean('Emails'); - $this->assertInstanceOf('Email', $email); - $this->assertInstanceOf('SugarBean', $email); + self::assertInstanceOf('Email', $email); + self::assertInstanceOf('SugarBean', $email); - $this->assertAttributeEquals('Emails', 'module_dir', $email); - $this->assertAttributeEquals('Email', 'object_name', $email); - $this->assertAttributeEquals('emails', 'table_name', $email); - $this->assertAttributeEquals('Emails', 'module_name', $email); - - $this->assertAttributeEquals(true, 'new_schema', $email); - $this->assertAttributeEquals('archived', 'type', $email); + self::assertEquals('Emails', $email->module_dir); + self::assertEquals('Email', $email->object_name); + self::assertEquals('emails', $email->table_name); + self::assertEquals('Emails', $email->module_name); + self::assertEquals(true, $email->new_schema); + self::assertEquals('archived', $email->type); } - public function testemail2init() + public function testemail2init(): void { $email = BeanFactory::newBean('Emails'); $email->email2init(); - $this->assertInstanceOf('EmailUI', $email->et); + self::assertInstanceOf('EmailUI', $email->et); } - public function testbean_implements() + public function testbean_implements(): void { // test $email = BeanFactory::newBean('Emails'); - $this->assertEquals(false, $email->bean_implements('')); //test with blank value - $this->assertEquals(false, $email->bean_implements('test')); //test with invalid value - $this->assertEquals(true, $email->bean_implements('ACL')); //test with valid value + self::assertEquals(false, $email->bean_implements('')); //test with blank value + self::assertEquals(false, $email->bean_implements('test')); //test with invalid value + self::assertEquals(true, $email->bean_implements('ACL')); //test with valid value } - public function testemail2saveAttachment() + public function testemail2saveAttachment(): void { - $email = BeanFactory::newBean('Emails'); - $result = $email->email2saveAttachment(); - $this->assertTrue(is_array($result)); + $result = BeanFactory::newBean('Emails')->email2saveAttachment(); + self::assertIsArray($result); } - public function testsafeAttachmentName() + public function testsafeAttachmentName(): void { $email = BeanFactory::newBean('Emails'); - $this->assertEquals(false, $email->safeAttachmentName('test.ext')); - $this->assertEquals(false, $email->safeAttachmentName('test.exe')); - $this->assertEquals(true, $email->safeAttachmentName('test.cgi')); + self::assertEquals(false, $email->safeAttachmentName('test.ext')); + self::assertEquals(false, $email->safeAttachmentName('test.exe')); + self::assertEquals(true, $email->safeAttachmentName('test.cgi')); } - public function testemail2ParseAddresses() + public function testemail2ParseAddresses(): void { $email = BeanFactory::newBean('Emails'); @@ -315,132 +314,78 @@ class EmailTest extends SuitePHPUnitFrameworkTestCase ); $result = $email->email2ParseAddresses($addresses); - $this->assertSame($expected, $result); + self::assertSame($expected, $result); } - public function testemail2ParseAddressesForAddressesOnly() + public function testemail2ParseAddressesForAddressesOnly(): void { $email = BeanFactory::newBean('Emails'); //test with simplest format $addresses = 'abc@xyz.com,xyz@abc.com'; $result = $email->email2ParseAddressesForAddressesOnly($addresses); - $this->assertEquals(array('abc@xyz.com', 'xyz@abc.com'), $result); + self::assertEquals(array('abc@xyz.com', 'xyz@abc.com'), $result); //test with more used format $addresses = 'abc,xyz'; $result = $email->email2ParseAddressesForAddressesOnly($addresses); - $this->assertEquals(array('abc@xyz.com', 'xyz@abc.com'), $result); + self::assertEquals(array('abc@xyz.com', 'xyz@abc.com'), $result); } - public function testemail2GetMime() + public function testemail2GetMime(): void { - $email = BeanFactory::newBean('Emails'); - //test with a filename - $result = $email->email2GetMime('config.php'); - $this->assertEquals('text/x-php', $result); + $result = BeanFactory::newBean('Emails')->email2GetMime('config.php'); + self::assertEquals('text/x-php', $result); } - public function testdecodeDuringSend() + public function testdecodeDuringSend(): void { $email = BeanFactory::newBean('Emails'); - $this->assertEquals('some text', $email->decodeDuringSend('some text')); - $this->assertEquals( + self::assertEquals('some text', $email->decodeDuringSend('some text')); + self::assertEquals( '< some text >', $email->decodeDuringSend('sugarLessThan some text sugarGreaterThan') ); } - public function testisDraftEmail() + public function testisDraftEmail(): void { $email = BeanFactory::newBean('Emails'); //test with required parametr set - $this->assertEquals(true, $email->isDraftEmail(array('saveDraft' => '1'))); + self::assertEquals(true, $email->isDraftEmail(array('saveDraft' => '1'))); //test with one of required attribute set $email->type = 'draft'; - $this->assertEquals(false, $email->isDraftEmail(array())); + self::assertEquals(false, $email->isDraftEmail(array())); //test with both of required attribute set $email->status = 'draft'; - $this->assertEquals(true, $email->isDraftEmail(array())); + self::assertEquals(true, $email->isDraftEmail(array())); } - public function testgetNamePlusEmailAddressesForCompose() + public function testgetNamePlusEmailAddressesForCompose(): void { - $email = BeanFactory::newBean('Emails'); - - $result = $email->getNamePlusEmailAddressesForCompose('Users', array(1)); - $this->assertGreaterThanOrEqual(0, strlen($result)); + $result = BeanFactory::newBean('Emails')->getNamePlusEmailAddressesForCompose('Users', array(1)); + self::assertGreaterThanOrEqual(0, strlen($result)); } - public function test_arrayToDelimitedString() + public function test_arrayToDelimitedString(): void { $email = BeanFactory::newBean('Emails'); //test with empty array $result = $email->_arrayToDelimitedString(array()); - $this->assertEquals('', $result); + self::assertEquals('', $result); //test with valid array $result = $email->_arrayToDelimitedString(array('value1', 'value2')); - $this->assertEquals('value1,value2', $result); + self::assertEquals('value1,value2', $result); } - public function testsendEmailTest() - { - $this->markTestIncomplete('Not testing sending email currently'); - /* - $email = BeanFactory::newBean('Emails'); - - $result = $email->sendEmailTest('mail.someserver.com', 25, 425, false, '', '', 'admin@email.com', 'abc@email.com', 'smtp', 'admin'); - - $expected = array( "status"=>false, "errorMessage"=> "Error:SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting"); - $this->assertSame($expected, $result); - */ - } - - public function testemail2Send() - { - $this->markTestIncomplete('Not testing sending email currently'); - /* $email = BeanFactory::newBean('Emails'); - - $_REQUEST['sendSubject'] = "test subject"; - $_REQUEST['sendDescription'] = "test text"; - $_REQUEST['fromAccount'] = "from@email.com"; - $_REQUEST['setEditor'] = 1; - $_REQUEST['description_html'] = "test html"; - $_REQUEST['sendTo'] = "abc@email.com"; - - $result = $email->email2Send($_REQUEST); - - $this->assertEquals(false, $result); - */ - } - - public function testsend() - { - $this->markTestIncomplete('Not testing sending email currently'); - /* - $email = BeanFactory::newBean('Emails'); - - $email->to_addrs_arr = array('email' =>'abc@xyz.com', 'display' => 'abc'); - $email->cc_addrs_arr = array('email' =>'abc@xyz.com', 'display' => 'abc'); - $email->bcc_addrs_arr = array('email' =>'abc@xyz.com', 'display' => 'abc'); - - $email->from_addr = "abc@xyz.com"; - $email->from_name = "abc"; - $email->reply_to_name = "xyz"; - - $result = $email->send(); - $this->assertEquals(false, $result); - */ - } - - public function testsaveAndOthers() + public function testsaveAndOthers(): void { // test $email = BeanFactory::newBean('Emails'); @@ -462,8 +407,8 @@ class EmailTest extends SuitePHPUnitFrameworkTestCase $result = $email->save(); //test for record ID to verify that record is saved - $this->assertTrue(isset($email->id)); - $this->assertEquals(36, strlen($email->id)); + self::assertTrue(isset($email->id)); + self::assertEquals(36, strlen($email->id)); //test retrieve method $this->retrieve($email->id); @@ -487,25 +432,23 @@ class EmailTest extends SuitePHPUnitFrameworkTestCase $this->delete($email->id); } - public function retrieve($id) + public function retrieve($id): void { - $email = BeanFactory::newBean('Emails'); + $result = BeanFactory::newBean('Emails')->retrieve($id); - $result = $email->retrieve($id); + self::assertTrue(isset($result->id)); + self::assertEquals(36, strlen($result->id)); - $this->assertTrue(isset($result->id)); - $this->assertEquals(36, strlen($result->id)); + self::assertTrue(isset($result->from_addr_name)); + self::assertTrue(isset($result->to_addrs_names)); + self::assertTrue(isset($result->cc_addrs_names)); + self::assertTrue(isset($result->bcc_addrs_names)); - $this->assertTrue(isset($result->from_addr_name)); - $this->assertTrue(isset($result->to_addrs_names)); - $this->assertTrue(isset($result->cc_addrs_names)); - $this->assertTrue(isset($result->bcc_addrs_names)); - - $this->assertTrue(isset($result->raw_source)); - $this->assertTrue(isset($result->description_html)); + self::assertTrue(isset($result->raw_source)); + self::assertTrue(isset($result->description_html)); } - public function saveEmailAddresses($id) + public function saveEmailAddresses($id): void { $email = BeanFactory::newBean('Emails'); @@ -520,26 +463,26 @@ class EmailTest extends SuitePHPUnitFrameworkTestCase //retrieve and verify that email addresses were saved properly $email->retrieveEmailAddresses(); - $this->assertNotSame(false, strpos($email->from_addr, 'from_test@email.com')); - $this->assertNotSame(false, strpos($email->to_addrs, 'to_test@email.com')); - $this->assertNotSame(false, strpos($email->cc_addrs, 'cc_test@email.com')); - $this->assertNotSame(false, strpos($email->bcc_addrs, 'bcc_test@email.com')); + self::assertNotFalse(strpos($email->from_addr, 'from_test@email.com')); + self::assertNotFalse(strpos($email->to_addrs, 'to_test@email.com')); + self::assertNotFalse(strpos($email->cc_addrs, 'cc_test@email.com')); + self::assertNotFalse(strpos($email->bcc_addrs, 'bcc_test@email.com')); } - public function retrieveEmailAddresses($id) + public function retrieveEmailAddresses($id): void { $email = BeanFactory::newBean('Emails'); $email->id = $id; $email->retrieveEmailAddresses(); - $this->assertTrue(isset($email->from_addr_name)); - $this->assertTrue(isset($email->to_addrs_names)); - $this->assertTrue(isset($email->cc_addrs_names)); - $this->assertTrue(isset($email->bcc_addrs_names)); + self::assertTrue(isset($email->from_addr_name)); + self::assertTrue(isset($email->to_addrs_names)); + self::assertTrue(isset($email->cc_addrs_names)); + self::assertTrue(isset($email->bcc_addrs_names)); } - public function linkEmailToAddress($id) + public function linkEmailToAddress($id): void { $email = BeanFactory::newBean('Emails'); @@ -547,11 +490,11 @@ class EmailTest extends SuitePHPUnitFrameworkTestCase $result = $email->linkEmailToAddress(1, 'from'); - $this->assertTrue(isset($result)); - $this->assertEquals(36, strlen($result)); + self::assertTrue(isset($result)); + self::assertEquals(36, strlen($result)); } - public function retrieveEmailText($id) + public function retrieveEmailText($id): void { $email = BeanFactory::newBean('Emails'); @@ -559,17 +502,17 @@ class EmailTest extends SuitePHPUnitFrameworkTestCase $email->retrieveEmailText(); - $this->assertTrue(isset($email->from_addr_name)); - $this->assertTrue(isset($email->reply_to_addr)); - $this->assertTrue(isset($email->to_addrs_names)); - $this->assertTrue(isset($email->cc_addrs_names)); - $this->assertTrue(isset($email->bcc_addrs_names)); + self::assertTrue(isset($email->from_addr_name)); + self::assertTrue(isset($email->reply_to_addr)); + self::assertTrue(isset($email->to_addrs_names)); + self::assertTrue(isset($email->cc_addrs_names)); + self::assertTrue(isset($email->bcc_addrs_names)); - $this->assertTrue(isset($email->raw_source)); - $this->assertTrue(isset($email->description_html)); + self::assertTrue(isset($email->raw_source)); + self::assertTrue(isset($email->description_html)); } - public function handleAttachments($id) + public function handleAttachments($id): void { $email = BeanFactory::newBean('Emails'); @@ -581,20 +524,20 @@ class EmailTest extends SuitePHPUnitFrameworkTestCase $email->handleAttachments(); - $this->assertTrue(is_array($email->attachments)); + self::assertIsArray($email->attachments); } - public function delete($id) + public function delete($id): void { $email = BeanFactory::newBean('Emails'); $email->delete($id); $result = $email->retrieve($id); - $this->assertEquals(null, $result); + self::assertEquals(null, $result); } - public function testSaveTempNoteAttachmentsAndGetNotesAndDoesImportedEmailHaveAttachment() + public function testSaveTempNoteAttachmentsAndGetNotesAndDoesImportedEmailHaveAttachment(): void { $email = BeanFactory::newBean('Emails'); @@ -605,43 +548,43 @@ class EmailTest extends SuitePHPUnitFrameworkTestCase //test doesImportedEmailHaveAttachment method to verify note created. $result = $email->doesImportedEmailHaveAttachment($email->id); - $this->assertEquals(0, $result); + self::assertEquals(0, $result); //test getNotes method and verify that it retrieves the created note. $email->getNotes($email->id); - $this->assertTrue(is_array($email->attachments)); + self::assertIsArray($email->attachments); foreach ($email->attachments as $note) { - $this->assertTrue(isset($note)); - $this->assertInstanceOf('Note', $note); + self::assertTrue(isset($note)); + self::assertInstanceOf('Note', $note); } //finally cleanup $email->delete($email->id); } - public function testgetNotesSqlEscape() + public function testgetNotesSqlEscape(): void { $email = BeanFactory::newBean('Emails'); $email->getNotes("'="); - $this->assertFalse(DBManagerFactory::getInstance()->lastError()); + self::assertFalse(DBManagerFactory::getInstance()->lastError()); } - public function testcleanEmails() + public function testcleanEmails(): void { $email = BeanFactory::newBean('Emails'); //test with simplest format $addresses = 'abc@xyz.com,xyz@abc.com'; $result = $email->cleanEmails($addresses); - $this->assertEquals('abc@xyz.com, xyz@abc.com', $result); + self::assertEquals('abc@xyz.com, xyz@abc.com', $result); //test with more used format $addresses = 'abc,xyz'; $result = $email->cleanEmails($addresses); - $this->assertEquals('abc , xyz ', $result); + self::assertEquals('abc , xyz ', $result); } - public function testgetForwardHeader() + public function testgetForwardHeader(): void { $email = BeanFactory::newBean('Emails'); @@ -654,10 +597,10 @@ class EmailTest extends SuitePHPUnitFrameworkTestCase $expected = '

> From: from test
> Date Sent/Received: 2016-01-01
> To: to@email.com
> Cc: cc@email.com
> Subject: test
>
'; $actual = $email->getForwardHeader(); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } - public function testgetReplyHeader() + public function testgetReplyHeader(): void { $email = BeanFactory::newBean('Emails'); @@ -668,65 +611,65 @@ class EmailTest extends SuitePHPUnitFrameworkTestCase $expected = '
On 2016-01-01, 01:01:00, from test wrote:'; $actual = $email->getReplyHeader(); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } - public function testquotePlainTextEmail() + public function testquotePlainTextEmail(): void { $email = BeanFactory::newBean('Emails'); //test with plain string containing no line breaks $expected = "\n> some text\r"; $actual = $email->quotePlainTextEmail('some text'); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); //test with string containing line breaks $expected = "\n> some\r> text\r> with\r> new\r> lines\r"; $actual = $email->quotePlainTextEmail("some\ntext\nwith\nnew\nlines"); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } - public function testquoteHtmlEmail() + public function testquoteHtmlEmail(): void { $email = BeanFactory::newBean('Emails'); //test with empty string $expected = ''; $actual = $email->quoteHtmlEmail(''); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); //test with plain string $expected = "
some test
"; $actual = $email->quoteHtmlEmail('some test'); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); //test with string containing special charecters $expected = "
some test with <&
"; $actual = $email->quoteHtmlEmail('some test with <&'); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } - public function testquoteHtmlEmailForNewEmailUI() + public function testquoteHtmlEmailForNewEmailUI(): void { $email = BeanFactory::newBean('Emails'); //test with empty string $expected = ''; $actual = $email->quoteHtmlEmailForNewEmailUI(''); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); //test with plain string $expected = "
some test
"; $actual = $email->quoteHtmlEmailForNewEmailUI('some test'); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); //test with string containing special charecters $expected = "
some test with
"; $actual = $email->quoteHtmlEmailForNewEmailUI("some test with \n"); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } - public function testcheck_email_settings() + public function testcheck_email_settings(): void { global $current_user; @@ -734,23 +677,21 @@ class EmailTest extends SuitePHPUnitFrameworkTestCase //test without a valid current user $result = $email->check_email_settings(); - $this->assertEquals(false, $result); + self::assertEquals(false, $result); //test with a valid current user $current_user = new User(1); $result = $email->check_email_settings(); - $this->assertEquals(false, $result); + self::assertEquals(false, $result); } - public function testjs_set_archived() + public function testjs_set_archived(): void { - $email = BeanFactory::newBean('Emails'); - - $actual = $email->js_set_archived(); - $this->assertGreaterThan(0, strlen($actual)); + $actual = BeanFactory::newBean('Emails')->js_set_archived(); + self::assertGreaterThan(0, strlen($actual)); } - public function testu_get_clear_form_js() + public function testu_get_clear_form_js(): void { self::markTestIncomplete('environment dependency (CRLF?)'); $email = BeanFactory::newBean('Emails'); @@ -766,15 +707,15 @@ class EmailTest extends SuitePHPUnitFrameworkTestCase } // End -->"; $actual = $email->u_get_clear_form_js('', '', ''); - $this->assertSame($expected, $actual, "exp:[" . print_r($expected, true) . "] act:[" . print_r($actual, true) . "]"); + self::assertSame($expected, $actual, "exp:[" . print_r($expected, true) . "] act:[" . print_r($actual, true) . "]"); //with valid params $expected = "\n "; $actual = $email->u_get_clear_form_js('out', '', '1'); - $this->assertSame($expected, $actual, "exp:[" . print_r($expected, true) . "] act:[" . print_r($actual, true) . "]"); + self::assertSame($expected, $actual, "exp:[" . print_r($expected, true) . "] act:[" . print_r($actual, true) . "]"); } - public function testpickOneButton() + public function testpickOneButton(): void { $email = BeanFactory::newBean('Emails'); @@ -785,18 +726,16 @@ class EmailTest extends SuitePHPUnitFrameworkTestCase style=\"margin-bottom:2px\" value=\" Take from Group \">
"; $actual = $email->pickOneButton(); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } - public function testgetUserEditorPreference() + public function testgetUserEditorPreference(): void { - $email = BeanFactory::newBean('Emails'); - - $result = $email->getUserEditorPreference(); - $this->assertEquals('html', $result); + $result = BeanFactory::newBean('Emails')->getUserEditorPreference(); + self::assertEquals('html', $result); } - public function testparse_addrs() + public function testparse_addrs(): void { $email = BeanFactory::newBean('Emails'); @@ -812,10 +751,10 @@ class EmailTest extends SuitePHPUnitFrameworkTestCase $actual = $email->parse_addrs($addrs, $addrs_ids, $addrs_names, $addrs_emails); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } - public function testremove_empty_fields() + public function testremove_empty_fields(): void { $email = BeanFactory::newBean('Emails'); @@ -823,16 +762,16 @@ class EmailTest extends SuitePHPUnitFrameworkTestCase $expected = array('val1', 'val2'); $fields = array('val1', ' ', 'val2'); $actual = $email->remove_empty_fields($fields); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); //test for array without empty values $expected = array('val1', 'val2'); $fields = array('val1', 'val2'); $actual = $email->remove_empty_fields($fields); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } - public function testhasSignatureInBody() + public function testhasSignatureInBody(): void { $email = BeanFactory::newBean('Emails'); @@ -842,26 +781,26 @@ class EmailTest extends SuitePHPUnitFrameworkTestCase //test for strings with signature present $sig = array('signature_html' => 'sign', 'signature' => 'sign'); $result = $email->hasSignatureInBody($sig); - $this->assertEquals(true, $result); + self::assertEquals(true, $result); //test for strings with signature absent $sig = array('signature_html' => 'signature', 'signature' => 'signature'); $result = $email->hasSignatureInBody($sig); - $this->assertEquals(false, $result); + self::assertEquals(false, $result); } - public function testremoveAllNewlines() + public function testremoveAllNewlines(): void { $email = BeanFactory::newBean('Emails'); - $this->assertEquals('', $email->removeAllNewlines('')); - $this->assertEquals('some text', $email->removeAllNewlines('some text')); - $this->assertEquals('some text', $email->removeAllNewlines('some text
')); - $this->assertEquals('some text', $email->removeAllNewlines("some\n text\n")); - $this->assertEquals('some text', $email->removeAllNewlines("some\r\n text\r\n")); + self::assertEquals('', $email->removeAllNewlines('')); + self::assertEquals('some text', $email->removeAllNewlines('some text')); + self::assertEquals('some text', $email->removeAllNewlines('some text
')); + self::assertEquals('some text', $email->removeAllNewlines("some\n text\n")); + self::assertEquals('some text', $email->removeAllNewlines("some\r\n text\r\n")); } - public function testgetStartPage() + public function testgetStartPage(): void { $email = BeanFactory::newBean('Emails'); @@ -878,7 +817,7 @@ class EmailTest extends SuitePHPUnitFrameworkTestCase 'return_module' => 'Users', ); $actual = $email->getStartPage($url); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); //test with assigned_user_id in url $url = 'index.php?module=Users&offset=6&stamp=1453274421025259800&return_module=Users&action=DetailView&record=seed_max_id&assigned_user_id=1'; @@ -895,20 +834,18 @@ class EmailTest extends SuitePHPUnitFrameworkTestCase 'current_view' => 'DetailView&module=Users&assigned_user_id=1&type=', ); $actual = $email->getStartPage($url); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } - public function testsetMailer() + public function testsetMailer(): void { - $email = BeanFactory::newBean('Emails'); + $result = BeanFactory::newBean('Emails')->setMailer(new SugarPHPMailer(), '', ''); - $result = $email->setMailer(new SugarPHPMailer(), '', ''); - - $this->assertInstanceOf('SugarPHPMailer', $result); - $this->assertInstanceOf('OutboundEmail', $result->oe); + self::assertInstanceOf('SugarPHPMailer', $result); + self::assertInstanceOf('OutboundEmail', $result->oe); } - public function testhandleBody() + public function testhandleBody(): void { $email = BeanFactory::newBean('Emails'); @@ -917,10 +854,10 @@ class EmailTest extends SuitePHPUnitFrameworkTestCase $result = $email->handleBody(new SugarPHPMailer()); $expected = "some email description containing email text & ' \n "; $actual = $email->description; - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); $expected = 'SugarPHPMailer'; $actual = $result; - $this->assertInstanceOf($expected, $result); + self::assertInstanceOf($expected, $result); // TODO: TASK: UNDEFINED - Refactor html body //test with REQUEST parameters set @@ -936,7 +873,7 @@ class EmailTest extends SuitePHPUnitFrameworkTestCase // $this->assertInstanceOf('SugarPHPMailer', $result); } - public function testhandleBodyInHTMLformat() + public function testhandleBodyInHTMLformat(): void { // TODO: TASK: UNDEFINED - Refactor html body // $email = BeanFactory::newBean('Emails'); @@ -950,7 +887,7 @@ class EmailTest extends SuitePHPUnitFrameworkTestCase // $this->assertEquals("some email description containing email text & '
", $mailer->Body); } - public function testlistviewACLHelper() + public function testlistviewACLHelper(): void { self::markTestIncomplete('environment dependency (span os a?)'); @@ -960,35 +897,35 @@ class EmailTest extends SuitePHPUnitFrameworkTestCase $expected = array('MAIN' => 'span', 'PARENT' => 'a', 'CONTACT' => 'span'); $actual = $email->listviewACLHelper(); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } - public function testgetSystemDefaultEmail() + public function testgetSystemDefaultEmail(): void { $email = BeanFactory::newBean('Emails'); $expected = array('email', 'name'); $actual = array_keys($email->getSystemDefaultEmail()); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } - public function testcreate_new_list_query() + public function testcreate_new_list_query(): void { $email = BeanFactory::newBean('Emails'); //test with empty string params $expected = "SELECT emails.*, users.user_name as assigned_user_name\n FROM emails\n LEFT JOIN users ON emails.assigned_user_id=users.id \nWHERE emails.deleted=0 \n ORDER BY date_sent_received DESC"; $actual = $email->create_new_list_query('', ''); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); //test with valid string params $expected = "SELECT emails.*, users.user_name as assigned_user_name\n FROM emails\n LEFT JOIN users ON emails.assigned_user_id=users.id \nWHERE users.user_name = \"\" AND emails.deleted=0 \n ORDER BY emails.id"; $actual = $email->create_new_list_query('emails.id', 'users.user_name = ""'); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } - public function testfill_in_additional_list_fields() + public function testfill_in_additional_list_fields(): void { $email = BeanFactory::newBean('Emails'); @@ -998,11 +935,11 @@ class EmailTest extends SuitePHPUnitFrameworkTestCase $email->fill_in_additional_list_fields(); - $this->assertEquals('DetailView', $email->link_action); - $this->assertEquals('', $email->attachment_image); + self::assertEquals('DetailView', $email->link_action); + self::assertEquals('', $email->attachment_image); } - public function testfill_in_additional_detail_fields() + public function testfill_in_additional_detail_fields(): void { $email = BeanFactory::newBean('Emails'); @@ -1013,29 +950,29 @@ class EmailTest extends SuitePHPUnitFrameworkTestCase $email->fill_in_additional_list_fields(); - $this->assertEquals('Administrator', $email->created_by_name); - $this->assertEquals('Administrator', $email->modified_by_name); - $this->assertEquals('Send Error', $email->type_name); - $this->assertEquals('(no subject)', $email->name); - $this->assertEquals('DetailView', $email->link_action); + self::assertEquals('Administrator', $email->created_by_name); + self::assertEquals('Administrator', $email->modified_by_name); + self::assertEquals('Send Error', $email->type_name); + self::assertEquals('(no subject)', $email->name); + self::assertEquals('DetailView', $email->link_action); } - public function testcreate_export_query() + public function testcreate_export_query(): void { $email = BeanFactory::newBean('Emails'); //test with empty string params $expected = 'SELECT emails.* FROM emails where emails.deleted=0 ORDER BY emails.name'; $actual = $email->create_export_query('', ''); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); //test with valid string params $expected = 'SELECT emails.* FROM emails where users.user_name = "" AND emails.deleted=0 ORDER BY emails.id'; $actual = $email->create_export_query('emails.id', 'users.user_name = ""'); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } - public function testget_list_view_data() + public function testget_list_view_data(): void { // TODO: TASK: UNDEFINED - Update to handle new list view // $email = BeanFactory::newBean('Emails'); @@ -1072,38 +1009,36 @@ class EmailTest extends SuitePHPUnitFrameworkTestCase // $this->assertSame($expected[$expectedKey], $actual[$expectedKey]); // } // } - $this->markTestIncomplete('Need to be updated'); + self::markTestIncomplete('Need to be updated'); } - public function testquickCreateForm() + public function testquickCreateForm(): void { $email = BeanFactory::newBean('Emails'); $expected = '~/images/advanced_search~'; $actual = $email->quickCreateForm(); - $this->assertRegExp($expected, $actual); + self::assertMatchesRegularExpression($expected, $actual); } - public function testsearchImportedEmails() + public function testsearchImportedEmails(): void { - $email = BeanFactory::newBean('Emails'); - - $actual = $email->searchImportedEmails(); - $this->assertTrue(is_array($actual)); + $actual = BeanFactory::newBean('Emails')->searchImportedEmails(); + self::assertIsArray($actual); } - public function test_genereateSearchImportedEmailsQuery() + public function test_genereateSearchImportedEmailsQuery(): void { $email = BeanFactory::newBean('Emails'); $expected = "SELECT emails.id , emails.mailbox_id, emails.name, emails.date_sent_received, emails.status, emails.type, emails.flagged, emails.reply_to_status, emails_text.from_addr, emails_text.to_addrs FROM emails JOIN emails_text on emails.id = emails_text.email_id WHERE (emails.type= 'inbound' OR emails.type='archived' OR emails.type='out') AND emails.deleted = 0 "; $actual = $email->_genereateSearchImportedEmailsQuery(); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } - public function test_generateSearchImportWhereClause() + public function test_generateSearchImportWhereClause(): void { // test $email = BeanFactory::newBean('Emails'); @@ -1111,20 +1046,20 @@ class EmailTest extends SuitePHPUnitFrameworkTestCase //test without request params $expected = ''; $actual = $email->_generateSearchImportWhereClause(); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); //test with searchDateFrom request param only $_REQUEST['searchDateFrom'] = '2015-01-01 00:00:00'; $expected = "emails.date_sent_received >= '' "; $actual = $email->_generateSearchImportWhereClause(); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); //test with searchDateTo request param only $_REQUEST['searchDateFrom'] = ''; $_REQUEST['searchDateTo'] = '2015-01-01 00:00:00'; $expected = "emails.date_sent_received <= '' "; $actual = $email->_generateSearchImportWhereClause(); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); //test with both request params $_REQUEST['searchDateFrom'] = '2015-01-01 00:00:00'; @@ -1132,37 +1067,37 @@ class EmailTest extends SuitePHPUnitFrameworkTestCase $expected = "( emails.date_sent_received >= '' AND emails.date_sent_received <= '' )"; $actual = $email->_generateSearchImportWhereClause(); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } - public function testtrimLongTo() + public function testtrimLongTo(): void { $email = BeanFactory::newBean('Emails'); - $this->assertEquals('test string', $email->trimLongTo('test string')); //test without any separator - $this->assertEquals( + self::assertEquals('test string', $email->trimLongTo('test string')); //test without any separator + self::assertEquals( 'test string 1...', $email->trimLongTo('test string 1, test string2') ); //test with , separator - $this->assertEquals( + self::assertEquals( 'test string 1...', $email->trimLongTo('test string 1; test string2') );//test with ; separator } - public function testget_summary_text() + public function testget_summary_text(): void { $email = BeanFactory::newBean('Emails'); //test without setting name - $this->assertEquals(null, $email->get_summary_text()); + self::assertEquals(null, $email->get_summary_text()); //test with name set $email->name = 'test'; - $this->assertEquals('test', $email->get_summary_text()); + self::assertEquals('test', $email->get_summary_text()); } - public function testdistributionForm() + public function testdistributionForm(): void { // test require_once 'include/utils/layout_utils.php'; @@ -1170,22 +1105,20 @@ class EmailTest extends SuitePHPUnitFrameworkTestCase //test with empty string $result = $email->distributionForm(''); - $this->assertGreaterThan(0, strlen($result)); + self::assertGreaterThan(0, strlen($result)); //test with valid string $result = $email->distributionForm('test'); - $this->assertGreaterThan(0, strlen($result)); + self::assertGreaterThan(0, strlen($result)); } - public function testuserSelectTable() + public function testuserSelectTable(): void { - $email = BeanFactory::newBean('Emails'); - - $result = $email->userSelectTable(); - $this->assertGreaterThan(0, strlen($result)); + $result = BeanFactory::newBean('Emails')->userSelectTable(); + self::assertGreaterThan(0, strlen($result)); } - public function testcheckInbox() + public function testcheckInbox(): void { $email = BeanFactory::newBean('Emails'); @@ -1197,7 +1130,7 @@ class EmailTest extends SuitePHPUnitFrameworkTestCase style=\"margin-bottom:2px\" value=\" Check Mail \">
"; $actual = $email->checkInbox(''); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); //test with valid string $expected = "
"; $actual = $email->checkInbox('test'); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } - public function testfillPrimaryParentFields() + public function testfillPrimaryParentFields(): void { $email = BeanFactory::newBean('Emails'); // Execute the method and test that it works and doesn't throw an exception. try { $email->fillPrimaryParentFields(); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } } - public function testcid2Link() + public function testcid2Link(): void { $email = BeanFactory::newBean('Emails'); @@ -1233,13 +1166,13 @@ class EmailTest extends SuitePHPUnitFrameworkTestCase // Execute the method and test that it works and doesn't throw an exception. try { $email->cid2Link('1', 'image/png'); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } } - public function testcids2Links() + public function testcids2Links(): void { $email = BeanFactory::newBean('Emails'); @@ -1249,35 +1182,35 @@ class EmailTest extends SuitePHPUnitFrameworkTestCase // Execute the method and test that it works and doesn't throw an exception. try { $email->cids2Links(); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } } - public function testsetFieldNullable() + public function testsetFieldNullable(): void { $email = BeanFactory::newBean('Emails'); // Execute the method and test that it works and doesn't throw an exception. try { $email->setFieldNullable('description'); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } } - public function testrevertFieldNullable() + public function testrevertFieldNullable(): void { $email = BeanFactory::newBean('Emails'); // Execute the method and test that it works and doesn't throw an exception. try { $email->revertFieldNullable('description'); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } } } diff --git a/tests/unit/phpunit/modules/Emails/NonGmailSentFolderHandlerMock.php b/tests/unit/phpunit/modules/Emails/NonGmailSentFolderHandlerMock.php index 4b476d551..9501177c7 100644 --- a/tests/unit/phpunit/modules/Emails/NonGmailSentFolderHandlerMock.php +++ b/tests/unit/phpunit/modules/Emails/NonGmailSentFolderHandlerMock.php @@ -57,6 +57,7 @@ class NonGmailSentFolderHandlerMock extends NonGmailSentFolderHandler * @param SugarPHPMailer $mail * @param string $sentFolder * @return bool + * @noinspection ReturnTypeCanBeDeclaredInspection */ protected function connectToNonGmailServer(InboundEmail $ie, SugarPHPMailer $mail, $sentFolder, $options = "\\Seen") { @@ -70,7 +71,7 @@ class NonGmailSentFolderHandlerMock extends NonGmailSentFolderHandler * @param SugarPHPMailer $mail * @return string */ - public function getProblemOfStoringInNonGmailSentFolderPublic(InboundEmail $ie, SugarPHPMailer $mail) + public function getProblemOfStoringInNonGmailSentFolderPublic(InboundEmail $ie, SugarPHPMailer $mail): string { return parent::getProblemOfStoringInNonGmailSentFolder($ie, $mail); } @@ -82,7 +83,7 @@ class NonGmailSentFolderHandlerMock extends NonGmailSentFolderHandler * @param string $sentFolder * @return bool */ - public function connectToNonGmailServerPublic(InboundEmail $ie, SugarPHPMailer $mail, $sentFolder, $options = "\\Seen") + public function connectToNonGmailServerPublic(InboundEmail $ie, SugarPHPMailer $mail, $sentFolder, $options = "\\Seen"): bool { return parent::connectToNonGmailServer($ie, $mail, $sentFolder, $options); } diff --git a/tests/unit/phpunit/modules/Emails/NonGmailSentFolderHandlerTest.php b/tests/unit/phpunit/modules/Emails/NonGmailSentFolderHandlerTest.php index 151842f50..ae40f15e3 100644 --- a/tests/unit/phpunit/modules/Emails/NonGmailSentFolderHandlerTest.php +++ b/tests/unit/phpunit/modules/Emails/NonGmailSentFolderHandlerTest.php @@ -53,54 +53,54 @@ require_once __DIR__ . '/InboundEmailMock.php'; */ class NonGmailSentFolderHandlerTest extends SuitePHPUnitFrameworkTestCase { - public function testClearLastError() + public function testClearLastError(): void { $handler = new NonGmailSentFolderHandler(); $handler->clearLastError(); $err = $handler->getLastError(); - $this->assertNull($err); + self::assertNull($err); } - public function testSetLastErrorNoInt() + public function testSetLastErrorNoInt(): void { $handler = new NonGmailSentFolderHandler(); try { $handler->setLastError(null); - $this->assertTrue(false); + self::assertTrue(false); } catch (InvalidArgumentException $e) { - $this->assertEquals(NonGmailSentFolderHandler::ERR_SHOULD_BE_INT, $e->getCode()); + self::assertEquals(NonGmailSentFolderHandler::ERR_SHOULD_BE_INT, $e->getCode()); } } - public function storeInSentFolderNoIEIsNull() + public function storeInSentFolderNoIEIsNull(): void { $handler = new NonGmailSentFolderHandler(); $ret = $handler->storeInSentFolder(null, null); - $this->assertFalse($ret); - $this->assertEquals(NonGmailSentFolderHandler::ERR_NO_IE_FOUND, $handler->getLastError()); + self::assertFalse($ret); + self::assertEquals(NonGmailSentFolderHandler::ERR_NO_IE_FOUND, $handler->getLastError()); } - public function storeInSentFolderNoIE() + public function storeInSentFolderNoIE(): void { $handler = new NonGmailSentFolderHandler(); $ret = $handler->storeInSentFolder(BeanFactory::newBean('InboundEmail'), null); - $this->assertFalse($ret); - $this->assertEquals(NonGmailSentFolderHandler::ERR_NO_IE_FOUND, $handler->getLastError()); + self::assertFalse($ret); + self::assertEquals(NonGmailSentFolderHandler::ERR_NO_IE_FOUND, $handler->getLastError()); } - public function storeInSentFolderIsPop3() + public function storeInSentFolderIsPop3(): void { $handler = new NonGmailSentFolderHandler(); $ie = BeanFactory::newBean('InboundEmail'); $ie->id = '123'; $ie->protocol = 'pop3'; $ret = $handler->storeInSentFolder($ie, null); - $this->assertFalse($ret); - $this->assertEquals(NonGmailSentFolderHandler::ERR_IS_POP3, $handler->getLastError()); + self::assertFalse($ret); + self::assertEquals(NonGmailSentFolderHandler::ERR_IS_POP3, $handler->getLastError()); } - public function storeInSentFolderIsGmail() + public function storeInSentFolderIsGmail(): void { $handler = new NonGmailSentFolderHandler(); $ie = BeanFactory::newBean('InboundEmail'); @@ -109,11 +109,11 @@ class NonGmailSentFolderHandlerTest extends SuitePHPUnitFrameworkTestCase $mail = new SugarPHPMailer(); $mail->oe->mail_smtptype = 'gmail'; $ret = $handler->storeInSentFolder($ie, $mail); - $this->assertFalse($ret); - $this->assertEquals(NonGmailSentFolderHandler::ERR_IS_GMAIL, $handler->getLastError()); + self::assertFalse($ret); + self::assertEquals(NonGmailSentFolderHandler::ERR_IS_GMAIL, $handler->getLastError()); } - public function storeInSentFolderOk() + public function storeInSentFolderOk(): void { $handler = new NonGmailSentFolderHandler(); $ie = BeanFactory::newBean('InboundEmail'); @@ -122,31 +122,31 @@ class NonGmailSentFolderHandlerTest extends SuitePHPUnitFrameworkTestCase $mail = new SugarPHPMailer(); $mail->oe->mail_smtptype = 'foo'; $ret = $handler->storeInSentFolder($ie, $mail); - $this->assertFalse($ret); - $this->assertEquals(NonGmailSentFolderHandler::NO_ERROR, $handler->getLastError()); + self::assertFalse($ret); + self::assertEquals(NonGmailSentFolderHandler::NO_ERROR, $handler->getLastError()); } - public function testGetProblemOfStoringInNonGmailSentFolderNoIEID() + public function testGetProblemOfStoringInNonGmailSentFolderNoIEID(): void { $handler = new NonGmailSentFolderHandlerMock(); $ie = BeanFactory::newBean('InboundEmail'); $mail = new SugarPHPMailer(); unset($ie->id); $ret = $handler->getProblemOfStoringInNonGmailSentFolderPublic($ie, $mail); - $this->assertContains('IE ID is not set.', $ret); + self::assertStringContainsString('IE ID is not set.', $ret); } - public function testGetProblemOfStoringInNonGmailSentFolderNoIEIDValue() + public function testGetProblemOfStoringInNonGmailSentFolderNoIEIDValue(): void { $handler = new NonGmailSentFolderHandlerMock(); $ie = BeanFactory::newBean('InboundEmail'); $mail = new SugarPHPMailer(); $ie->id = ''; $ret = $handler->getProblemOfStoringInNonGmailSentFolderPublic($ie, $mail); - $this->assertContains('IE ID is set but no value.', $ret); + self::assertStringContainsString('IE ID is set but no value.', $ret); } - public function testGetProblemOfStoringInNonGmailSentFolderIsPop3() + public function testGetProblemOfStoringInNonGmailSentFolderIsPop3(): void { $handler = new NonGmailSentFolderHandlerMock(); $ie = BeanFactory::newBean('InboundEmail'); @@ -154,10 +154,10 @@ class NonGmailSentFolderHandlerTest extends SuitePHPUnitFrameworkTestCase $ie->id = 123; $ie->protocol = 'pop3'; $ret = $handler->getProblemOfStoringInNonGmailSentFolderPublic($ie, $mail); - $this->assertContains('It is a pop3 protocoll.', $ret); + self::assertStringContainsString('It is a pop3 protocoll.', $ret); } - public function testGetProblemOfStoringInNonGmailSentFolderIsGmail() + public function testGetProblemOfStoringInNonGmailSentFolderIsGmail(): void { $handler = new NonGmailSentFolderHandlerMock(); $ie = BeanFactory::newBean('InboundEmail'); @@ -166,10 +166,10 @@ class NonGmailSentFolderHandlerTest extends SuitePHPUnitFrameworkTestCase $ie->protocol = 'pop3'; $mail->oe->mail_smtptype = 'gmail'; $ret = $handler->getProblemOfStoringInNonGmailSentFolderPublic($ie, $mail); - $this->assertContains('It is a gmail.', $ret); + self::assertStringContainsString('It is a gmail.', $ret); } - public function testConnectToNonGmailServer() + public function testConnectToNonGmailServer(): void { $handler = new NonGmailSentFolderHandlerMock(); $ie = BeanFactory::newBean('InboundEmail'); @@ -177,17 +177,17 @@ class NonGmailSentFolderHandlerTest extends SuitePHPUnitFrameworkTestCase $sentFolder = null; try { $handler->connectToNonGmailServerPublic($ie, $mail, $sentFolder); - $this->assertTrue(false); + self::assertTrue(false); } catch (InvalidArgumentException $e) { - $this->assertEquals(NonGmailSentFolderHandler::ERR_SHOULD_BE_STRING, $e->getCode()); + self::assertEquals(NonGmailSentFolderHandler::ERR_SHOULD_BE_STRING, $e->getCode()); } - - + + // positive test imposible until using imap_xxx fucntions.. (valid imap resource needed) // $sentFolder = 'foo'; // $ret = $handler->connectToNonGmailServerPublic($ie, $mail, $sentFolder); // $this->assertFalse($ret); - + // $ie = new InboundEmailMock(); // $ret = $handler->connectToNonGmailServerPublic($ie, $mail, $sentFolder); // $this->assertTrue($ret); diff --git a/tests/unit/phpunit/modules/Emails/SugarPHPMailerMock.php b/tests/unit/phpunit/modules/Emails/SugarPHPMailerMock.php index 0f2992a7f..95a1693a9 100644 --- a/tests/unit/phpunit/modules/Emails/SugarPHPMailerMock.php +++ b/tests/unit/phpunit/modules/Emails/SugarPHPMailerMock.php @@ -52,8 +52,8 @@ require_once __DIR__ . '/../../../../../include/SugarPHPMailer.php'; class SugarPHPMailerMock extends SugarPHPMailer { /** - * * @return bool + * @noinspection ReturnTypeCanBeDeclaredInspection */ public function send() { diff --git a/tests/unit/phpunit/modules/Employees/EmployeeTest.php b/tests/unit/phpunit/modules/Employees/EmployeeTest.php index 18592f32e..bd2bc23a8 100644 --- a/tests/unit/phpunit/modules/Employees/EmployeeTest.php +++ b/tests/unit/phpunit/modules/Employees/EmployeeTest.php @@ -13,75 +13,75 @@ class EmployeeTest extends SuitePHPUnitFrameworkTestCase $current_user = BeanFactory::newBean('Users'); } - public function testEmployee() + public function testEmployee(): void { // Execute the constructor and check for the Object type and attributes $employee = BeanFactory::newBean('Employees'); - $this->assertInstanceOf('Employee', $employee); - $this->assertInstanceOf('Person', $employee); - $this->assertInstanceOf('SugarBean', $employee); + self::assertInstanceOf('Employee', $employee); + self::assertInstanceOf('Person', $employee); + self::assertInstanceOf('SugarBean', $employee); - $this->assertAttributeEquals('Employees', 'module_dir', $employee); - $this->assertAttributeEquals('Employee', 'object_name', $employee); - $this->assertAttributeEquals('users', 'table_name', $employee); - $this->assertAttributeEquals(true, 'new_schema', $employee); + self::assertEquals('Employees', $employee->module_dir); + self::assertEquals('Employee', $employee->object_name); + self::assertEquals('users', $employee->table_name); + self::assertEquals(true, $employee->new_schema); } - public function testget_summary_text() + public function testget_summary_text(): void { $employee = BeanFactory::newBean('Employees'); //test without setting name - $this->assertEquals(' ', $employee->get_summary_text()); + self::assertEquals(' ', $employee->get_summary_text()); //test with name set $employee->retrieve(1); - $this->assertEquals('Administrator', $employee->get_summary_text()); + self::assertEquals('Administrator', $employee->get_summary_text()); } - public function testfill_in_additional_list_fields() + public function testfill_in_additional_list_fields(): void { $employee = BeanFactory::newBean('Employees'); // Execute the method and test that it works and doesn't throw an exception. try { $employee->fill_in_additional_list_fields(); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } } - public function testfill_in_additional_detail_fields() + public function testfill_in_additional_detail_fields(): void { $employee = BeanFactory::newBean('Employees'); //test with a empty employee bean $employee->fill_in_additional_detail_fields(); - $this->assertEquals("", $employee->reports_to_name); + self::assertEquals("", $employee->reports_to_name); //test with a valid employee bean $employee->retrieve(1); $employee->fill_in_additional_detail_fields(); - $this->assertEquals("", $employee->reports_to_name); + self::assertEquals("", $employee->reports_to_name); } - public function testretrieve_employee_id() + public function testretrieve_employee_id(): void { $employee = BeanFactory::newBean('Employees'); //$this->assertEquals('1' ,$employee->retrieve_employee_id('admin')); - $this->markTestSkipped('Bug in query: employee_name parameter is wrongly used as user_name'); + self::markTestSkipped('Bug in query: employee_name parameter is wrongly used as user_name'); } - public function testverify_data() + public function testverify_data(): void { $employee = BeanFactory::newBean('Employees'); - $this->assertEquals(true, $employee->verify_data()); + self::assertEquals(true, $employee->verify_data()); } - public function testget_list_view_data() + public function testget_list_view_data(): void { $employee = BeanFactory::newBean('Employees'); @@ -107,10 +107,10 @@ class EmployeeTest extends SuitePHPUnitFrameworkTestCase ); $actual = $employee->get_list_view_data(); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } - public function testlist_view_parse_additional_sections() + public function testlist_view_parse_additional_sections(): void { $employee = BeanFactory::newBean('Employees'); @@ -118,44 +118,44 @@ class EmployeeTest extends SuitePHPUnitFrameworkTestCase try { $ss = new Sugar_Smarty(); $employee->list_view_parse_additional_sections($ss, null); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } } - public function testcreate_export_query() + public function testcreate_export_query(): void { $employee = BeanFactory::newBean('Employees'); //test with empty string params $expected = "SELECT id, user_name, first_name, last_name, description, date_entered, date_modified, modified_user_id, created_by, title, department, is_admin, phone_home, phone_mobile, phone_work, phone_other, phone_fax, address_street, address_city, address_state, address_postalcode, address_country, reports_to_id, portal_only, status, receive_notifications, employee_status, messenger_id, messenger_type, is_group FROM users WHERE users.deleted = 0 ORDER BY users.user_name"; $actual = $employee->create_export_query('', ''); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); //test with valid string params $expected = "SELECT id, user_name, first_name, last_name, description, date_entered, date_modified, modified_user_id, created_by, title, department, is_admin, phone_home, phone_mobile, phone_work, phone_other, phone_fax, address_street, address_city, address_state, address_postalcode, address_country, reports_to_id, portal_only, status, receive_notifications, employee_status, messenger_id, messenger_type, is_group FROM users WHERE users.user_name=\"\" AND users.deleted = 0 ORDER BY users.id"; $actual = $employee->create_export_query('users.id', 'users.user_name=""'); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } - public function testpreprocess_fields_on_save() + public function testpreprocess_fields_on_save(): void { $employee = BeanFactory::newBean('Employees'); // Execute the method and test that it works and doesn't throw an exception. try { $employee->preprocess_fields_on_save(); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } } /** * @todo: NEEDS FIXING! */ - public function testcreate_new_list_query() + public function testcreate_new_list_query(): void { /* $employee = BeanFactory::newBean('Employees'); @@ -174,19 +174,18 @@ class EmployeeTest extends SuitePHPUnitFrameworkTestCase self::markTestIncomplete(); } - public function testhasCustomFields() + public function testhasCustomFields(): void { - $employee = BeanFactory::newBean('Employees'); - $result = $employee->hasCustomFields(); - $this->assertEquals(false, $result); + $result = BeanFactory::newBean('Employees')->hasCustomFields(); + self::assertEquals(false, $result); } - public function testError() + public function testError(): void { global $app_strings; // setup - $this->assertTrue(!isset($app_strings['TEST_ERROR_MESSAGE'])); + self::assertNotTrue(isset($app_strings['TEST_ERROR_MESSAGE'])); // test if there is no error @@ -195,19 +194,19 @@ class EmployeeTest extends SuitePHPUnitFrameworkTestCase $contents = ob_get_contents(); ob_end_clean(); $expected = '

' . "\n" . $app_strings['NTC_CLICK_BACK'] . '
'; - $this->assertContains($expected, $contents); + self::assertStringContainsStringIgnoringCase($expected, $contents); // test if there is an error $app_strings['TEST_ERROR_MESSAGE'] = 'Hello error'; $request['error_string'] = 'TEST_ERROR_MESSAGE'; - $this->assertEquals($request['error_string'], 'TEST_ERROR_MESSAGE'); + self::assertEquals('TEST_ERROR_MESSAGE', $request['error_string']); ob_start(); include __DIR__ . '/../../../../../modules/Employees/Error.php'; $contents = ob_get_contents(); ob_end_clean(); $expected = 'Hello error

' . "\n" . $app_strings['NTC_CLICK_BACK'] . '
'; - $this->assertContains($expected, $contents); + self::assertStringContainsStringIgnoringCase($expected, $contents); unset($app_strings['TEST_ERROR_MESSAGE']); } diff --git a/tests/unit/phpunit/modules/FP_Event_Locations/FP_Event_LocationsTest.php b/tests/unit/phpunit/modules/FP_Event_Locations/FP_Event_LocationsTest.php index 7e6858e19..7f796fa4a 100644 --- a/tests/unit/phpunit/modules/FP_Event_Locations/FP_Event_LocationsTest.php +++ b/tests/unit/phpunit/modules/FP_Event_Locations/FP_Event_LocationsTest.php @@ -4,19 +4,19 @@ use SuiteCRM\Test\SuitePHPUnitFrameworkTestCase; class FP_Event_LocationsTest extends SuitePHPUnitFrameworkTestCase { - public function testFP_Event_Locations() + public function testFP_Event_Locations(): void { // Execute the constructor and check for the Object type and attributes $fpEventLoc = BeanFactory::newBean('FP_Event_Locations'); - $this->assertInstanceOf('FP_Event_Locations', $fpEventLoc); - $this->assertInstanceOf('Basic', $fpEventLoc); - $this->assertInstanceOf('SugarBean', $fpEventLoc); + self::assertInstanceOf('FP_Event_Locations', $fpEventLoc); + self::assertInstanceOf('Basic', $fpEventLoc); + self::assertInstanceOf('SugarBean', $fpEventLoc); - $this->assertAttributeEquals('FP_Event_Locations', 'module_dir', $fpEventLoc); - $this->assertAttributeEquals('FP_Event_Locations', 'object_name', $fpEventLoc); - $this->assertAttributeEquals('fp_event_locations', 'table_name', $fpEventLoc); - $this->assertAttributeEquals(true, 'new_schema', $fpEventLoc); - $this->assertAttributeEquals(false, 'importable', $fpEventLoc); - $this->assertAttributeEquals(true, 'disable_row_level_security', $fpEventLoc); + self::assertEquals('FP_Event_Locations', $fpEventLoc->module_dir); + self::assertEquals('FP_Event_Locations', $fpEventLoc->object_name); + self::assertEquals('fp_event_locations', $fpEventLoc->table_name); + self::assertEquals(true, $fpEventLoc->new_schema); + self::assertEquals(false, $fpEventLoc->importable); + self::assertEquals(true, $fpEventLoc->disable_row_level_security); } } diff --git a/tests/unit/phpunit/modules/FP_events/FP_eventsTest.php b/tests/unit/phpunit/modules/FP_events/FP_eventsTest.php index f72aec413..0a9ec7da2 100644 --- a/tests/unit/phpunit/modules/FP_events/FP_eventsTest.php +++ b/tests/unit/phpunit/modules/FP_events/FP_eventsTest.php @@ -1,30 +1,69 @@ assertInstanceOf('FP_events', $fpEvents); - $this->assertInstanceOf('Basic', $fpEvents); - $this->assertInstanceOf('SugarBean', $fpEvents); + self::assertInstanceOf('FP_events', $fpEvents); + self::assertInstanceOf('Basic', $fpEvents); + self::assertInstanceOf('SugarBean', $fpEvents); - $this->assertAttributeEquals('FP_events', 'module_dir', $fpEvents); - $this->assertAttributeEquals('FP_events', 'object_name', $fpEvents); - $this->assertAttributeEquals('fp_events', 'table_name', $fpEvents); - $this->assertAttributeEquals(true, 'new_schema', $fpEvents); - $this->assertAttributeEquals(true, 'importable', $fpEvents); - $this->assertAttributeEquals(true, 'disable_row_level_security', $fpEvents); + self::assertEquals('FP_events', $fpEvents->module_dir); + self::assertEquals('FP_events', $fpEvents->object_name); + self::assertEquals('fp_events', $fpEvents->table_name); + self::assertEquals(true, $fpEvents->new_schema); + self::assertEquals(true, $fpEvents->importable); + self::assertEquals(true, $fpEvents->disable_row_level_security); } - public function testemail_templates() + public function testemail_templates(): void { global $app_list_strings; $fpEvents = BeanFactory::newBean('FP_events'); $fpEvents->email_templates(); - $this->assertInternalType('array', $app_list_strings['emailTemplates_type_list']); + self::assertIsArray($app_list_strings['emailTemplates_type_list']); } } diff --git a/tests/unit/phpunit/modules/Favorites/FavoritesTest.php b/tests/unit/phpunit/modules/Favorites/FavoritesTest.php index 50d689f01..73acd58d9 100644 --- a/tests/unit/phpunit/modules/Favorites/FavoritesTest.php +++ b/tests/unit/phpunit/modules/Favorites/FavoritesTest.php @@ -4,52 +4,50 @@ use SuiteCRM\Test\SuitePHPUnitFrameworkTestCase; class FavoritesTest extends SuitePHPUnitFrameworkTestCase { - public function testFavorites() + public function testFavorites(): void { // Execute the constructor and check for the Object type and attributes $favorites = BeanFactory::newBean('Favorites'); - $this->assertInstanceOf('Favorites', $favorites); - $this->assertInstanceOf('Basic', $favorites); - $this->assertInstanceOf('SugarBean', $favorites); + self::assertInstanceOf('Favorites', $favorites); + self::assertInstanceOf('Basic', $favorites); + self::assertInstanceOf('SugarBean', $favorites); - $this->assertAttributeEquals('Favorites', 'module_dir', $favorites); - $this->assertAttributeEquals('Favorites', 'object_name', $favorites); - $this->assertAttributeEquals('favorites', 'table_name', $favorites); - $this->assertAttributeEquals(true, 'new_schema', $favorites); + self::assertEquals('Favorites', $favorites->module_dir); + self::assertEquals('Favorites', $favorites->object_name); + self::assertEquals('favorites', $favorites->table_name); + self::assertEquals(true, $favorites->new_schema); } - public function testdeleteFavorite() + public function testdeleteFavorite(): void { - $favorites = BeanFactory::newBean('Favorites'); - //testing with an empty ID - $result = $favorites->deleteFavorite(''); - $this->assertEquals(false, $result); + $result = BeanFactory::newBean('Favorites')->deleteFavorite(''); + self::assertEquals(false, $result); } - public function testgetFavoriteID() + public function testgetFavoriteID(): void { $favorites = BeanFactory::newBean('Favorites'); //test with blank string parameters $result = $favorites->getFavoriteID('', ''); - $this->assertEquals(false, $result); + self::assertEquals(false, $result); //test with string parameters $result = $favorites->getFavoriteID('Accounts', '1'); - $this->assertEquals(false, $result); + self::assertEquals(false, $result); } - public function testgetCurrentUserSidebarFavorites() + public function testgetCurrentUserSidebarFavorites(): void { $favorites = BeanFactory::newBean('Favorites'); //test with empty string parameter $result = $favorites->getCurrentUserSidebarFavorites(); - $this->assertTrue(is_array($result)); + self::assertIsArray($result); //test with string $result = $favorites->getCurrentUserSidebarFavorites('1'); - $this->assertTrue(is_array($result)); + self::assertIsArray($result); } } diff --git a/tests/unit/phpunit/modules/Groups/GroupTest.php b/tests/unit/phpunit/modules/Groups/GroupTest.php index 408396096..404b0d912 100644 --- a/tests/unit/phpunit/modules/Groups/GroupTest.php +++ b/tests/unit/phpunit/modules/Groups/GroupTest.php @@ -13,20 +13,20 @@ class GroupTest extends SuitePHPUnitFrameworkTestCase get_sugar_config_defaults(); } - public function testGroup() + public function testGroup(): void { //execute the constructor and check for the Object type and attributes $group = BeanFactory::newBean('Groups'); - $this->assertInstanceOf('Group', $group); - $this->assertInstanceOf('User', $group); - $this->assertInstanceOf('SugarBean', $group); + self::assertInstanceOf('Group', $group); + self::assertInstanceOf('User', $group); + self::assertInstanceOf('SugarBean', $group); - $this->assertAttributeEquals('Group', 'status', $group); - $this->assertAttributeEquals('', 'password', $group); - $this->assertAttributeEquals(false, 'importable', $group); + self::assertEquals('Group', $group->status); + self::assertEquals('', $group->password); + self::assertEquals(false, $group->importable); } - public function testmark_deleted() + public function testmark_deleted(): void { self::markTestIncomplete('environment dependency (php7: Incorrect state hash: Hash doesn\'t match at key "database::users".)'); @@ -35,24 +35,24 @@ class GroupTest extends SuitePHPUnitFrameworkTestCase // Execute the method and test that it works and doesn't throw an exception. try { $group->mark_deleted(''); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } } - public function testcreate_export_query() + public function testcreate_export_query(): void { $group = BeanFactory::newBean('Groups'); //test with empty string params $expected = 'SELECT users.* FROM users WHERE users.deleted = 0 ORDER BY users.user_name'; $actual = $group->create_export_query('', ''); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); //test with valid string params $expected = 'SELECT users.* FROM users WHERE users.user_name="" AND users.deleted = 0 ORDER BY users.id'; $actual = $group->create_export_query('users.id', 'users.user_name=""'); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } } diff --git a/tests/unit/phpunit/modules/InboundEmail/InboundEmailTest.php b/tests/unit/phpunit/modules/InboundEmail/InboundEmailTest.php index 46285a1dc..8ea4605fb 100644 --- a/tests/unit/phpunit/modules/InboundEmail/InboundEmailTest.php +++ b/tests/unit/phpunit/modules/InboundEmail/InboundEmailTest.php @@ -37,7 +37,7 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase $GLOBALS['mod_strings'] = return_module_language($GLOBALS['current_language'], 'InboundEmail'); } - public function testConnectMailServerFolderInboundForceFirstMailbox() + public function testConnectMailServerFolderInboundForceFirstMailbox(): void { $fake = new ImapHandlerFakeData(); $fake->add('isAvailable', null, [true]); @@ -57,10 +57,10 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase $_REQUEST['folder_name'] = []; $ie->mailboxarray = ['first']; $ret = $ie->connectMailserver(false, true); - $this->assertEquals('true', $ret); + self::assertEquals('true', $ret); } - public function testConnectMailServerFolderInboundForceTestFolder() + public function testConnectMailServerFolderInboundForceTestFolder(): void { $fake = new ImapHandlerFakeData(); $fake->add('isAvailable', null, [true]); @@ -79,11 +79,11 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase $_REQUEST['folder'] = 'inbound'; $_REQUEST['folder_name'] = 'test'; $ret = $ie->connectMailserver(false, true); - $this->assertEquals('true', $ret); + self::assertEquals('true', $ret); } - public function testConnectMailServerFolderInboundForce() + public function testConnectMailServerFolderInboundForce(): void { $fake = new ImapHandlerFakeData(); $fake->add('isAvailable', null, [true]); @@ -101,10 +101,10 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase $ie = new InboundEmail($imap); $_REQUEST['folder'] = 'inbound'; $ret = $ie->connectMailserver(false, true); - $this->assertEquals('true', $ret); + self::assertEquals('true', $ret); } - public function testConnectMailServerFolderSentForce() + public function testConnectMailServerFolderSentForce(): void { $fake = new ImapHandlerFakeData(); $fake->add('isAvailable', null, [true]); @@ -122,10 +122,10 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase $ie = new InboundEmail($imap); $_REQUEST['folder'] = 'sent'; $ret = $ie->connectMailserver(false, true); - $this->assertEquals('true', $ret); + self::assertEquals('true', $ret); } - public function testConnectMailserverNoGood() + public function testConnectMailserverNoGood(): void { $fake = new ImapHandlerFakeData(); $fake->add('isAvailable', null, [true]); @@ -150,12 +150,11 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase $_REQUEST['ssl'] = 1; - $ie = new InboundEmail($imap); - $ret = $ie->connectMailserver(true); - $this->assertEquals('Login or Password Incorrect', $ret); + $ret = (new InboundEmail($imap))->connectMailserver(true); + self::assertEquals('Login or Password Incorrect', $ret); } - public function testConnectMailserverUseSsl() + public function testConnectMailserverUseSsl(): void { $fake = new ImapHandlerFakeData(); $fake->add('isAvailable', null, [true]); @@ -173,23 +172,21 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase $_REQUEST['ssl'] = 1; - $ie = new InboundEmail($imap); - $ret = $ie->connectMailserver(); - $this->assertEquals('true', $ret); + $ret = (new InboundEmail($imap))->connectMailserver(); + self::assertEquals('true', $ret); } - public function testConnectMailserverNoImap() + public function testConnectMailserverNoImap(): void { $fake = new ImapHandlerFakeData(); $fake->add('isAvailable', null, [false]); $imap = new ImapHandlerFake($fake); - $ie = new InboundEmail($imap); - $ret = $ie->connectMailserver(); - $this->assertEquals('Inbound Email cannot function without the IMAP c-client libraries enabled/compiled with the PHP module. Please contact your administrator to resolve this issue.', $ret); + $ret = (new InboundEmail($imap))->connectMailserver(); + self::assertEquals('Inbound Email cannot function without the IMAP c-client libraries enabled/compiled with the PHP module. Please contact your administrator to resolve this issue.', $ret); } - public function testFindOptimumSettingsFalsePositive() + public function testFindOptimumSettingsFalsePositive(): void { $fake = new ImapHandlerFakeData(); $fake->add('isAvailable', null, [true]); // <-- when the code calls ImapHandlerInterface::isAvailable([null]), it will return true @@ -216,16 +213,16 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase $imap = new ImapHandlerFake($fake); $inboundEmail = new InboundEmail($imap); $ret = $inboundEmail->findOptimumSettings(); - $this->assertEquals($exp, $ret); + self::assertEquals($exp, $ret); // other errors also cause same results.. $fake->add('getLastError', null, ["Mailbox is empty"]); $ret = $inboundEmail->findOptimumSettings(); - $this->assertEquals($exp, $ret); + self::assertEquals($exp, $ret); } - public function testFindOptimumSettingsFail() + public function testFindOptimumSettingsFail(): void { $fake = new ImapHandlerFakeData(); $fake->add('isAvailable', null, [true]); // <-- when the code calls ImapHandlerInterface::isAvailable([null]), it will return true @@ -253,24 +250,24 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase $imap = new ImapHandlerFake($fake); $inboundEmail = new InboundEmail($imap); $ret = $inboundEmail->findOptimumSettings(); - $this->assertEquals($exp, $ret); + self::assertEquals($exp, $ret); // other errors also cause same results.. $fake->add('getLastError', null, ['[CLOSED] IMAP connection broken (server response)']); $ret = $inboundEmail->findOptimumSettings(); - $this->assertEquals($exp, $ret); + self::assertEquals($exp, $ret); $fake->add('getLastError', null, ['[AUTHENTICATIONFAILED]']); $ret = $inboundEmail->findOptimumSettings(); - $this->assertEquals($exp, $ret); + self::assertEquals($exp, $ret); $fake->add('getLastError', null, ['something.. AUTHENTICATE .. something .. failed .. something']); $ret = $inboundEmail->findOptimumSettings(); - $this->assertEquals($exp, $ret); + self::assertEquals($exp, $ret); } - public function testFindOptimumSettingsOk() + public function testFindOptimumSettingsOk(): void { $fake = new ImapHandlerFakeData(); $fake->add('isAvailable', null, [true]); // <-- when the code calls ImapHandlerInterface::isAvailable([null]), it will return true @@ -290,30 +287,28 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase $fake->add('close', null, [null]); $imap = new ImapHandlerFake($fake); - $inboundEmail = new InboundEmail($imap); - $ret = $inboundEmail->findOptimumSettings(); - $this->assertEquals([ + $ret = (new InboundEmail($imap))->findOptimumSettings(); + self::assertEquals([ 'serial' => '::::::::novalidate-cert::notls::secure', 'service' => 'foo/notls/novalidate-cert/secure', ], $ret); } - public function testFindOptimumSettingsNoImap() + public function testFindOptimumSettingsNoImap(): void { $fake = new ImapHandlerFakeData(); $fake->add('isAvailable', null, [false]); $imap = new ImapHandlerFake($fake); - $ie = new InboundEmail($imap); - $ret = $ie->findOptimumSettings(); - $this->assertEquals([ + $ret = (new InboundEmail($imap))->findOptimumSettings(); + self::assertEquals([ 'good' => [], 'bad' => [], 'err' => ['No IMAP libraries found. Please resolve this before continuing with Inbound Email'], ], $ret); } - public function testFindOptimumSettingsUseSsl() + public function testFindOptimumSettingsUseSsl(): void { $fake = new ImapHandlerFakeData(); $fake->add('isAvailable', null, [true]); @@ -336,9 +331,8 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase $_REQUEST['ssl'] = 1; - $ie = new InboundEmail($imap); - $ret = $ie->findOptimumSettings(); - $this->assertEquals([ + $ret = (new InboundEmail($imap))->findOptimumSettings(); + self::assertEquals([ 'serial' => 'tls::::ssl::::::::secure', 'service' => 'foo/ssl/tls/validate-cert/secure', ], $ret); @@ -348,39 +342,34 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase // ----- FOLLOWIN TESTS ARE USING REAL IMAP SO SHOULD FAIL ---- // ----------------------------------------------------------------> - public function testInboundEmail() + public function testInboundEmail(): void { // Execute the constructor and check for the Object type and attributes $inboundEmail = BeanFactory::newBean('InboundEmail'); - $this->assertInstanceOf('InboundEmail', $inboundEmail); - $this->assertInstanceOf('SugarBean', $inboundEmail); + self::assertInstanceOf('InboundEmail', $inboundEmail); + self::assertInstanceOf('SugarBean', $inboundEmail); - $this->assertAttributeEquals('InboundEmail', 'module_dir', $inboundEmail); - $this->assertAttributeEquals('InboundEmail', 'object_name', $inboundEmail); - $this->assertAttributeEquals('inbound_email', 'table_name', $inboundEmail); - - $this->assertAttributeEquals(true, 'new_schema', $inboundEmail); - $this->assertAttributeEquals(true, 'process_save_dates', $inboundEmail); - - $this->assertAttributeEquals('defaultIEAccount', 'keyForUsersDefaultIEAccount', $inboundEmail); - $this->assertAttributeEquals(10, 'defaultEmailNumAutoreplies24Hours', $inboundEmail); - $this->assertAttributeEquals(10, 'maxEmailNumAutoreplies24Hours', $inboundEmail); - - $this->assertAttributeEquals('InboundEmail.cache.php', 'InboundEmailCacheFile', $inboundEmail); - - $this->assertAttributeEquals('date', 'defaultSort', $inboundEmail); - $this->assertAttributeEquals('DESC', 'defaultDirection', $inboundEmail); - $this->assertAttributeEquals('F', 'iconFlagged', $inboundEmail); - $this->assertAttributeEquals('D', 'iconDraft', $inboundEmail); - $this->assertAttributeEquals('A', 'iconAnswered', $inboundEmail); - $this->assertAttributeEquals('del', 'iconDeleted', $inboundEmail); - $this->assertAttributeEquals(false, 'isAutoImport', $inboundEmail); - - $this->assertAttributeEquals(0, 'attachmentCount', $inboundEmail); + self::assertEquals('InboundEmail', $inboundEmail->module_dir); + self::assertEquals('InboundEmail', $inboundEmail->object_name); + self::assertEquals('inbound_email', $inboundEmail->table_name); + self::assertEquals(true, $inboundEmail->new_schema); + self::assertEquals(true, $inboundEmail->process_save_dates); + self::assertEquals('defaultIEAccount', $inboundEmail->keyForUsersDefaultIEAccount); + self::assertEquals(10, $inboundEmail->defaultEmailNumAutoreplies24Hours); + self::assertEquals(10, $inboundEmail->maxEmailNumAutoreplies24Hours); + self::assertEquals('InboundEmail.cache.php', $inboundEmail->InboundEmailCacheFile); + self::assertEquals('date', $inboundEmail->defaultSort); + self::assertEquals('DESC', $inboundEmail->defaultDirection); + self::assertEquals('F', $inboundEmail->iconFlagged); + self::assertEquals('D', $inboundEmail->iconDraft); + self::assertEquals('A', $inboundEmail->iconAnswered); + self::assertEquals('del', $inboundEmail->iconDeleted); + self::assertEquals(false, $inboundEmail->isAutoImport); + self::assertEquals(0, $inboundEmail->attachmentCount); } - public function testsaveAndOthers() + public function testsaveAndOthers(): void { //unset and reconnect Db to resolve mysqli fetch exeception $db = DBManagerFactory::getInstance(); @@ -399,8 +388,8 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase $inboundEmail->save(); //test for record ID to verify that record is saved - $this->assertTrue(isset($inboundEmail->id)); - $this->assertEquals(36, strlen($inboundEmail->id)); + self::assertTrue(isset($inboundEmail->id)); + self::assertEquals(36, strlen($inboundEmail->id)); //test getCorrectMessageNoForPop3 method $this->getCorrectMessageNoForPop3($inboundEmail->id); @@ -439,7 +428,7 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase $this->hardDelete($inboundEmail->id); } - public function getSingularRelatedId() + public function getSingularRelatedId(): void { //unset and reconnect Db to resolve mysqli fetch exeception $db = DBManagerFactory::getInstance(); @@ -449,93 +438,87 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase $inboundEmail = BeanFactory::newBean('InboundEmail'); $result = $inboundEmail->getSingularRelatedId('test', 'inbound_email'); - $this->assertEquals(false, $result); + self::assertEquals(false, $result); $result = $inboundEmail->getSingularRelatedId('invalid test', 'inbound_email'); - $this->assertEquals(null, $result); + self::assertEquals(null, $result); } - public function getCorrectMessageNoForPop3($id) + public function getCorrectMessageNoForPop3($id): void { $inboundEmail = BeanFactory::newBean('InboundEmail'); $inboundEmail->retrieve($id); $result = $inboundEmail->getCorrectMessageNoForPop3('100'); - $this->assertEquals(-1, $result); + self::assertEquals(-1, $result); $result = $inboundEmail->getCorrectMessageNoForPop3('1'); - $this->assertEquals(-1, $result); + self::assertEquals(-1, $result); } - public function retrieve($id) + public function retrieve($id): void { $inboundEmail = BeanFactory::newBean('InboundEmail'); $inboundEmail->retrieve($id); - $this->assertEquals('test', $inboundEmail->name); - $this->assertEquals('Active', $inboundEmail->status); - $this->assertEquals('testuser', $inboundEmail->email_user); - $this->assertEquals('testpass', $inboundEmail->email_password); + self::assertEquals('test', $inboundEmail->name); + self::assertEquals('Active', $inboundEmail->status); + self::assertEquals('testuser', $inboundEmail->email_user); + self::assertEquals('testpass', $inboundEmail->email_password); } - public function retrieveByGroupId($group_id) + public function retrieveByGroupId($group_id): void { - $inboundEmail = BeanFactory::newBean('InboundEmail'); + $result = BeanFactory::newBean('InboundEmail')->retrieveByGroupId($group_id); - $result = $inboundEmail->retrieveByGroupId($group_id); - - $this->assertTrue(is_array($result)); + self::assertIsArray($result); foreach ($result as $ie) { - $this->assertInstanceOf('InboundEmail', $ie); + self::assertInstanceOf('InboundEmail', $ie); } } - public function retrieveAllByGroupId($group_id) + public function retrieveAllByGroupId($group_id): void { - $inboundEmail = BeanFactory::newBean('InboundEmail'); + $result = BeanFactory::newBean('InboundEmail')->retrieveAllByGroupId($group_id); - $result = $inboundEmail->retrieveAllByGroupId($group_id); - - $this->assertTrue(is_array($result)); + self::assertIsArray($result); foreach ($result as $ie) { - $this->assertInstanceOf('InboundEmail', $ie); + self::assertInstanceOf('InboundEmail', $ie); } } - public function retrieveAllByGroupIdWithGroupAccounts($group_id) + public function retrieveAllByGroupIdWithGroupAccounts($group_id): void { - $inboundEmail = BeanFactory::newBean('InboundEmail'); + $result = BeanFactory::newBean('InboundEmail')->retrieveAllByGroupIdWithGroupAccounts($group_id); - $result = $inboundEmail->retrieveAllByGroupIdWithGroupAccounts($group_id); - - $this->assertTrue(is_array($result)); + self::assertIsArray($result); foreach ($result as $ie) { - $this->assertInstanceOf('InboundEmail', $ie); + self::assertInstanceOf('InboundEmail', $ie); } } - public function renameFolder($id) + public function renameFolder($id): void { $inboundEmail = BeanFactory::newBean('InboundEmail'); $inboundEmail->retrieve($id); - $this->assertFalse((bool)$inboundEmail->conn); + self::assertFalse((bool)$inboundEmail->conn); // Execute the method and test that it works and doesn't throw an exception. try { $success = $inboundEmail->renameFolder('mailbox1', 'new_mailbox'); - $this->assertFalse((bool)$success); + self::assertFalse((bool)$success); } catch (Exception $e) { - $this->fail("\nException: " . get_class($e) . ": " . $e->getMessage() . "\nin " . $e->getFile() . ':' . $e->getLine() . "\nTrace:\n" . $e->getTraceAsString() . "\n"); + self::fail("\nException: " . get_class($e) . ": " . $e->getMessage() . "\nin " . $e->getFile() . ':' . $e->getLine() . "\nTrace:\n" . $e->getTraceAsString() . "\n"); } } - public function search($id) + public function search($id): void { $inboundEmail = BeanFactory::newBean('InboundEmail'); @@ -543,12 +526,12 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase $result = $inboundEmail->search($id); - $this->assertTrue(is_array($result)); - $this->assertEquals('Search Results', $result['mbox']); - $this->assertEquals($id, $result['ieId']); + self::assertIsArray($result); + self::assertEquals('Search Results', $result['mbox']); + self::assertEquals($id, $result['ieId']); } - public function saveMailBoxFolders($id) + public function saveMailBoxFolders($id): void { $inboundEmail = BeanFactory::newBean('InboundEmail'); @@ -556,14 +539,14 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase //execute he method and verify attributes $inboundEmail->saveMailBoxFolders('INBOX,TRASH'); - $this->assertEquals(array('INBOX', 'TRASH'), $inboundEmail->mailboxarray); + self::assertEquals(array('INBOX', 'TRASH'), $inboundEmail->mailboxarray); //retrieve it back and verify the updates $inboundEmail->retrieve($id); - $this->assertEquals('INBOX,TRASH', $inboundEmail->mailbox); + self::assertEquals('INBOX,TRASH', $inboundEmail->mailbox); } - public function saveMailBoxValueOfInboundEmail($id) + public function saveMailBoxValueOfInboundEmail($id): void { $inboundEmail = BeanFactory::newBean('InboundEmail'); @@ -573,52 +556,50 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase //retrieve it back and verify the updates $inboundEmail->retrieve($id); - $this->assertEquals('INBOX,TRASH', $inboundEmail->mailbox); + self::assertEquals('INBOX,TRASH', $inboundEmail->mailbox); } - public function mark_deleted($id) + public function mark_deleted($id): void { $inboundEmail = BeanFactory::newBean('InboundEmail'); $inboundEmail->mark_deleted($id); $result = $inboundEmail->retrieve($id); - $this->assertEquals(null, $result); + self::assertEquals(null, $result); } - public function hardDelete($id) + public function hardDelete($id): void { $inboundEmail = BeanFactory::newBean('InboundEmail'); $inboundEmail->hardDelete($id); $result = $inboundEmail->retrieve($id); - $this->assertEquals(null, $result); + self::assertEquals(null, $result); } - public function testcustomGetMessageText() + public function testcustomGetMessageText(): void { - $inboundEmail = BeanFactory::newBean('InboundEmail'); - - $result = $inboundEmail->customGetMessageText('some message'); - $this->assertEquals('some message', $result); + $result = BeanFactory::newBean('InboundEmail')->customGetMessageText('some message'); + self::assertEquals('some message', $result); } - public function testgetFormattedRawSource() + public function testgetFormattedRawSource(): void { $inboundEmail = BeanFactory::newBean('InboundEmail'); //test without ID $result = $inboundEmail->getFormattedRawSource('1'); - $this->assertEquals('This information is not available', $result); + self::assertEquals('This information is not available', $result); //test with ID $inboundEmail->id = 1; $result = $inboundEmail->getFormattedRawSource('1'); - $this->assertEquals('', $result); + self::assertEquals('', $result); } - public function testfilterMailBoxFromRaw() + public function testfilterMailBoxFromRaw(): void { //unset and reconnect Db to resolve mysqli fetch exeception $db = DBManagerFactory::getInstance(); @@ -629,35 +610,34 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase //test with array having common element $result = $inboundEmail->filterMailBoxFromRaw(array('mailbox1', 'mailbox2', 'mailbox3'), array('mailbox1')); - $this->assertSame(array('mailbox1'), $result); + self::assertSame(array('mailbox1'), $result); //test with array having nothing common $result = $inboundEmail->filterMailBoxFromRaw(array('mailbox1', 'mailbox2'), array('mailbox4')); - $this->assertSame(array(), $result); + self::assertSame(array(), $result); } - public function testconvertToUtf8() + public function testconvertToUtf8(): void { - $inboundEmail = BeanFactory::newBean('InboundEmail'); - $result = $inboundEmail->convertToUtf8('some text with non UTF8 chars'); - $this->assertSame('some text with non UTF8 chars', $result); + $result = BeanFactory::newBean('InboundEmail')->convertToUtf8('some text with non UTF8 chars'); + self::assertSame('some text with non UTF8 chars', $result); } - public function testgetFormattedHeaders() + public function testgetFormattedHeaders(): void { $inboundEmail = BeanFactory::newBean('InboundEmail'); //test for default/imap $result = $inboundEmail->getFormattedHeaders(1); - $this->assertSame(null, $result); + self::assertNull($result); //test for pop3 $inboundEmail->protocol = 'pop3'; $result = $inboundEmail->getFormattedHeaders(1); - $this->assertSame(null, $result); + self::assertNull($result); } - public function testsetAndgetCacheTimestamp() + public function testsetAndgetCacheTimestamp(): void { $inboundEmail = BeanFactory::newBean('InboundEmail'); @@ -668,7 +648,7 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase //test getCacheTimestamp method $result = $inboundEmail->getCacheTimestamp('INBOX'); - $this->assertGreaterThan(0, strlen($result)); + self::assertGreaterThan(0, strlen($result)); } private function setDummyCacheValue() @@ -697,69 +677,67 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase return $inboundEmail; } - public function testsetCacheValue() + public function testsetCacheValue(): void { - $inboundEmail = $this->setDummyCacheValue(); - //retrieve back to verify the records created - $result = $inboundEmail->getCacheValue('INBOX'); + $result = $this->setDummyCacheValue()->getCacheValue('INBOX'); - $this->assertGreaterThan(0, count((array)$result['retArr'][0])); - $this->assertEquals(1, $result['retArr'][0]->message_id); + self::assertGreaterThan(0, count((array)$result['retArr'][0])); + self::assertEquals(1, $result['retArr'][0]->message_id); } - public function testgetCacheValueForUIDs() + public function testgetCacheValueForUIDs(): void { $inboundEmail = BeanFactory::newBean('InboundEmail'); //test wih default protocol $result = $inboundEmail->getCacheValueForUIDs('INBOX', array(1, 2, 3, 4, 5)); - $this->assertTrue(is_array($result)); - $this->assertTrue(is_array($result['uids'])); - $this->assertTrue(is_array($result['retArr'])); + self::assertIsArray($result); + self::assertIsArray($result['uids']); + self::assertIsArray($result['retArr']); //test wih pop3 protocol $inboundEmail->protocol = 'pop3'; $result = $inboundEmail->getCacheValueForUIDs('INBOX', array(1, 2, 3, 4, 5)); - $this->assertTrue(is_array($result)); - $this->assertTrue(is_array($result['uids'])); - $this->assertTrue(is_array($result['retArr'])); + self::assertIsArray($result); + self::assertIsArray($result['uids']); + self::assertIsArray($result['retArr']); } - public function testgetCacheValue() + public function testgetCacheValue(): void { $inboundEmail = BeanFactory::newBean('InboundEmail'); //test wih default protocol $result = $inboundEmail->getCacheValue('INBOX'); - $this->assertTrue(is_array($result)); - $this->assertTrue(is_array($result['uids'])); - $this->assertTrue(is_array($result['retArr'])); + self::assertIsArray($result); + self::assertIsArray($result['uids']); + self::assertIsArray($result['retArr']); //test wih pop3 protocol $inboundEmail->protocol = 'pop3'; $result = $inboundEmail->getCacheValue('INBOX'); - $this->assertTrue(is_array($result)); - $this->assertTrue(is_array($result['uids'])); - $this->assertTrue(is_array($result['retArr'])); + self::assertIsArray($result); + self::assertIsArray($result['uids']); + self::assertIsArray($result['retArr']); } - public function testValidCacheExists() + public function testValidCacheExists(): void { $inboundEmail = BeanFactory::newBean('InboundEmail'); //test without a valid id $result = $inboundEmail->validCacheExists(''); - $this->assertEquals(false, $result); + self::assertEquals(false, $result); //test with a valid id set $inboundEmail = $this->setDummyCacheValue(); $result = $inboundEmail->validCacheExists(''); - $this->assertEquals(true, $result); + self::assertEquals(true, $result); $inserts = []; @@ -779,10 +757,10 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase $inboundEmail->setCacheValue('INBOX', $inserts); $result = $inboundEmail->validCacheExists('INBOX'); - $this->assertEquals(true, $result); + self::assertEquals(true, $result); } - public function testdisplayFetchedSortedListXML() + public function testdisplayFetchedSortedListXML(): void { $inboundEmail = BeanFactory::newBean('InboundEmail'); @@ -792,10 +770,10 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase //use the cache values array as parameter and verify that it returns an array $result = $inboundEmail->displayFetchedSortedListXML($ret, 'INBOX'); - $this->assertTrue(is_array($result)); + self::assertIsArray($result); } - public function testgetCacheUnreadCount() + public function testgetCacheUnreadCount(): void { $inboundEmail = $this->setDummyCacheValue(); @@ -818,14 +796,14 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase //test with invalid mailbox $result = $inboundEmail->getCacheUnreadCount('OUTBOX'); - $this->assertEquals(0, $result); + self::assertEquals(0, $result); //test with valid mailbox $result = $inboundEmail->getCacheUnreadCount('INBOX'); - $this->assertGreaterThanOrEqual(1, $result); + self::assertGreaterThanOrEqual(1, $result); } - public function testgetCacheCount() + public function testgetCacheCount(): void { $inboundEmail = $this->setDummyCacheValue(); @@ -848,16 +826,16 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase //test with invalid mailbox $result = $inboundEmail->getCacheCount('OUTBOX'); - $this->assertEquals(0, $result); + self::assertEquals(0, $result); //test with valid mailbox $result = $inboundEmail->getCacheCount('INBOX'); - $this->assertGreaterThanOrEqual(1, $result); - + self::assertGreaterThanOrEqual(1, $result); + } - public function testgetCacheUnread() + public function testgetCacheUnread(): void { // test $inboundEmail = $this->setDummyCacheValue(); @@ -881,14 +859,14 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase //test with invalid mailbox $result = $inboundEmail->getCacheUnread('OUTBOX'); - $this->assertEquals(0, $result); + self::assertEquals(0, $result); //test with valid mailbox $result = $inboundEmail->getCacheUnread('INBOX'); - $this->assertGreaterThanOrEqual(1, $result); + self::assertGreaterThanOrEqual(1, $result); } - public function testmark_answered() + public function testmark_answered(): void { $inboundEmail = $this->setDummyCacheValue(); @@ -915,10 +893,10 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase //retrieve back to verify the records updated $result = $inboundEmail->getCacheValue('INBOX'); - $this->assertEquals(1, $result['retArr'][0]->answered); + self::assertEquals(1, $result['retArr'][0]->answered); } - public function testpop3_shiftCache() + public function testpop3_shiftCache(): void { $inboundEmail = $this->setDummyCacheValue(); @@ -944,11 +922,11 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase //retrieve back to verify the records updated $result = $inboundEmail->getCacheValue('INBOX'); - $this->assertEquals(1, $result['retArr'][0]->imap_uid); - $this->assertEquals(1, $result['retArr'][0]->msgno); + self::assertEquals(1, $result['retArr'][0]->imap_uid); + self::assertEquals(1, $result['retArr'][0]->msgno); } - public function testgetUIDLForMessage() + public function testgetUIDLForMessage(): void { $inboundEmail = $this->setDummyCacheValue(); @@ -956,10 +934,10 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase //test with invalid msgNo $result = $inboundEmail->getUIDLForMessage('2'); - $this->assertEquals('', $result); + self::assertEquals('', $result); } - public function testgetMsgnoForMessageID() + public function testgetMsgnoForMessageID(): void { $inboundEmail = BeanFactory::newBean('InboundEmail'); @@ -984,70 +962,24 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase //test with invalid msgNo $result = $inboundEmail->getMsgnoForMessageID('2'); - $this->assertEquals('', $result); + self::assertEquals('', $result); //test with valid msgNo but most probably it will never work because of wrong column name in return statement $result = $inboundEmail->getMsgnoForMessageID('1'); - $this->assertEquals('', $result); + self::assertEquals('', $result); } - public function testpop3_getCacheUidls() + public function testpop3_getCacheUidls(): void { $inboundEmail = $this->setDummyCacheValue(); $inboundEmail->pop3_shiftCache(array('1' => '1'), array('1')); $result = $inboundEmail->pop3_getCacheUidls(); - $this->assertEquals(array('1' => '1'), $result); + self::assertEquals(array('1' => '1'), $result); } - /** - * @todo: NEEDS REVISION - */ - public function testsetStatuses() - { -// $this->markTestIncomplete("Different results for php5 and php7"); -// /* -// $inboundEmail = BeanFactory::newBean('InboundEmail'); -// -// $inboundEmail->id = 1; -// $inboundEmail->mailbox = 'INBOX'; -// -// //execute the method -// $inboundEmail->setStatuses('1', 'message_id', '123'); -// -// //retrieve back to verify the records created -// $result = $inboundEmail->getCacheValueForUIDs('INBOX', array(1)); -// -// $this->assertTrue(is_array($result)); -// $this->assertEquals('123', $result['retArr'][0]->message_id); -// */ - } - - /** - * @todo: NEEDS REVISION - */ - public function testdeleteMessageFromCache() - { -// $this->markTestIncomplete("Unable to test until testsetStatuses is re-enabled"); -// /* -// $inboundEmail = BeanFactory::newBean('InboundEmail'); -// -// $inboundEmail->id = 1; -// $inboundEmail->mailbox = 'INBOX'; -// $inboundEmail->protocol = 'pop3'; -// -// $inboundEmail->deleteMessageFromCache('123'); -// -// //retrieve back to verify the records deleted -// $result = $inboundEmail->getCacheValueForUIDs('INBOX', array(1)); -// -// $this->assertTrue(is_array($result)); -// $this->assertEquals(0, count($result['retArr'])); -// */ - } - - public function testemptyTrash() + public function testemptyTrash(): void { $inboundEmail = BeanFactory::newBean('InboundEmail'); @@ -1073,10 +1005,10 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase $inboundEmail->emptyTrash(); $result = $inboundEmail->getCacheValue('INBOX.Trash'); - $this->assertEquals(0, count($result['retArr'])); + self::assertCount(0, $result['retArr']); } - public function testdeleteCache() + public function testdeleteCache(): void { $inboundEmail = BeanFactory::newBean('InboundEmail'); @@ -1102,10 +1034,10 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase $inboundEmail->deleteCache(); $result = $inboundEmail->getCacheValue('INBOX'); - $this->assertEquals(0, count($result['retArr'])); + self::assertCount(0, $result['retArr']); } - public function testdeletePop3Cache() + public function testdeletePop3Cache(): void { $inboundEmail = BeanFactory::newBean('InboundEmail'); @@ -1114,13 +1046,13 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase // Execute the method and test that it works and doesn't throw an exception. try { $inboundEmail->deletePop3Cache(); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail("\nException: " . get_class($e) . ": " . $e->getMessage() . "\nin " . $e->getFile() . ':' . $e->getLine() . "\nTrace:\n" . $e->getTraceAsString() . "\n"); + self::fail("\nException: " . get_class($e) . ": " . $e->getMessage() . "\nin " . $e->getFile() . ':' . $e->getLine() . "\nTrace:\n" . $e->getTraceAsString() . "\n"); } } - public function testpop3_open() + public function testpop3_open(): void { $inboundEmail = BeanFactory::newBean('InboundEmail'); @@ -1128,10 +1060,10 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase $result = $inboundEmail->pop3_open(); - $this->assertEquals(false, $result); + self::assertEquals(false, $result); } - public function testpop3_cleanUp() + public function testpop3_cleanUp(): void { $inboundEmail = BeanFactory::newBean('InboundEmail'); @@ -1140,13 +1072,13 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase // Execute the method and test that it works and doesn't throw an exception. try { $inboundEmail->pop3_cleanUp(); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail("\nException: " . get_class($e) . ": " . $e->getMessage() . "\nin " . $e->getFile() . ':' . $e->getLine() . "\nTrace:\n" . $e->getTraceAsString() . "\n"); + self::fail("\nException: " . get_class($e) . ": " . $e->getMessage() . "\nin " . $e->getFile() . ':' . $e->getLine() . "\nTrace:\n" . $e->getTraceAsString() . "\n"); } } - public function testpop3_sendCommand() + public function testpop3_sendCommand(): void { $inboundEmail = BeanFactory::newBean('InboundEmail'); @@ -1154,10 +1086,10 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase $result = $inboundEmail->pop3_sendCommand('get'); - $this->assertEquals('', $result); + self::assertEquals('', $result); } - public function testgetPop3NewMessagesToDownload() + public function testgetPop3NewMessagesToDownload(): void { $inboundEmail = BeanFactory::newBean('InboundEmail'); @@ -1165,10 +1097,10 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase $result = $inboundEmail->getPop3NewMessagesToDownload(); - $this->assertTrue(is_array($result)); + self::assertIsArray($result); } - public function testgetPop3NewMessagesToDownloadForCron() + public function testgetPop3NewMessagesToDownloadForCron(): void { $inboundEmail = BeanFactory::newBean('InboundEmail'); @@ -1176,10 +1108,10 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase $result = $inboundEmail->getPop3NewMessagesToDownloadForCron(); - $this->assertTrue(is_array($result)); + self::assertIsArray($result); } - public function testpop3_getUIDL() + public function testpop3_getUIDL(): void { $inboundEmail = BeanFactory::newBean('InboundEmail'); @@ -1188,10 +1120,10 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase $result = $inboundEmail->getPop3NewMessagesToDownloadForCron(); - $this->assertTrue(is_array($result)); + self::assertIsArray($result); } - public function testpop3_checkPartialEmail() + public function testpop3_checkPartialEmail(): void { $inboundEmail = BeanFactory::newBean('InboundEmail'); @@ -1201,15 +1133,15 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase // Execute the method and test that it works and doesn't throw an exception. try { $result = $inboundEmail->pop3_checkPartialEmail(); - $this->assertEquals('could not open socket connection to POP3 server', $result); + self::assertEquals('could not open socket connection to POP3 server', $result); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail("\nException: " . get_class($e) . ": " . $e->getMessage() . "\nin " . $e->getFile() . ':' . $e->getLine() . "\nTrace:\n" . $e->getTraceAsString() . "\n"); + self::fail("\nException: " . get_class($e) . ": " . $e->getMessage() . "\nin " . $e->getFile() . ':' . $e->getLine() . "\nTrace:\n" . $e->getTraceAsString() . "\n"); } } - public function testpop3_checkEmail() + public function testpop3_checkEmail(): void { $inboundEmail = BeanFactory::newBean('InboundEmail'); @@ -1219,15 +1151,15 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase // Execute the method and test that it works and doesn't throw an exception. try { $result = $inboundEmail->pop3_checkEmail(); - $this->assertEquals(false, $result); + self::assertEquals(false, $result); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail("\nException: " . get_class($e) . ": " . $e->getMessage() . "\nin " . $e->getFile() . ':' . $e->getLine() . "\nTrace:\n" . $e->getTraceAsString() . "\n"); + self::fail("\nException: " . get_class($e) . ": " . $e->getMessage() . "\nin " . $e->getFile() . ':' . $e->getLine() . "\nTrace:\n" . $e->getTraceAsString() . "\n"); } } - public function testgetMessagesInEmailCache() + public function testgetMessagesInEmailCache(): void { $inboundEmail = BeanFactory::newBean('InboundEmail'); @@ -1237,9 +1169,9 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase // Execute the method and test that it works and doesn't throw an exception. try { $result = $inboundEmail->getMessagesInEmailCache(0, 1); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail("\nException: " . get_class($e) . ": " . $e->getMessage() . "\nin " . $e->getFile() . ':' . $e->getLine() . "\nTrace:\n" . $e->getTraceAsString() . "\n"); + self::fail("\nException: " . get_class($e) . ": " . $e->getMessage() . "\nin " . $e->getFile() . ':' . $e->getLine() . "\nTrace:\n" . $e->getTraceAsString() . "\n"); } //test for pop3 @@ -1247,25 +1179,13 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase // Execute the method and test that it works and doesn't throw an exception. try { $result = $inboundEmail->getMessagesInEmailCache(1, 0); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail("\nException: " . get_class($e) . ": " . $e->getMessage() . "\nin " . $e->getFile() . ':' . $e->getLine() . "\nTrace:\n" . $e->getTraceAsString() . "\n"); + self::fail("\nException: " . get_class($e) . ": " . $e->getMessage() . "\nin " . $e->getFile() . ':' . $e->getLine() . "\nTrace:\n" . $e->getTraceAsString() . "\n"); } } - public function testcheckEmailOneMailbox() - { -// $this->markTestIncomplete('this test failing only on php 7.2'); -// -// $inboundEmail = BeanFactory::newBean('InboundEmail'); -// -// $inboundEmail->mailbox = 'INBOX,OUTBOX'; -// -// $result = $inboundEmail->checkEmailOneMailbox('INBOX'); -// $this->assertEquals(1, $result); - } - - public function testcheckEmailOneMailboxPartial() + public function testcheckEmailOneMailboxPartial(): void { $inboundEmail = BeanFactory::newBean('InboundEmail'); @@ -1273,10 +1193,10 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase $result = $inboundEmail->checkEmailOneMailboxPartial('INBOX'); - $this->assertEquals(array('status' => 'done'), $result); + self::assertEquals(array('status' => 'done'), $result); } - public function testgetCachedIMAPSearch() + public function testgetCachedIMAPSearch(): void { $inboundEmail = BeanFactory::newBean('InboundEmail'); @@ -1284,10 +1204,10 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase $result = $inboundEmail->getCachedIMAPSearch('test'); - $this->assertTrue(is_array($result)); + self::assertIsArray($result); } - public function testcheckEmailIMAPPartial() + public function testcheckEmailIMAPPartial(): void { $inboundEmail = BeanFactory::newBean('InboundEmail'); @@ -1295,10 +1215,10 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase $result = $inboundEmail->checkEmailIMAPPartial(); - $this->assertTrue(is_array($result)); + self::assertIsArray($result); } - public function testcheckEmail2_meta() + public function testcheckEmail2_meta(): void { $inboundEmail = BeanFactory::newBean('InboundEmail'); @@ -1306,20 +1226,18 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase $result = $inboundEmail->checkEmail2_meta(); - $this->assertTrue(is_array($result)); - $this->assertEquals(array('mailboxes' => array('INBOX' => 0), 'processCount' => 0), $result); + self::assertIsArray($result); + self::assertEquals(array('mailboxes' => array('INBOX' => 0), 'processCount' => 0), $result); } - public function testgetMailboxProcessCount() + public function testgetMailboxProcessCount(): void { - $inboundEmail = BeanFactory::newBean('InboundEmail'); + $result = BeanFactory::newBean('InboundEmail')->getMailboxProcessCount('INBOX'); - $result = $inboundEmail->getMailboxProcessCount('INBOX'); - - $this->assertEquals(0, $result); + self::assertEquals(0, $result); } - public function testcheckEmail() + public function testcheckEmail(): void { $inboundEmail = BeanFactory::newBean('InboundEmail'); @@ -1327,9 +1245,9 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase // Execute the method and test that it works and doesn't throw an exception. try { $inboundEmail->checkEmail('INBOX'); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail("\nException: " . get_class($e) . ": " . $e->getMessage() . "\nin " . $e->getFile() . ':' . $e->getLine() . "\nTrace:\n" . $e->getTraceAsString() . "\n"); + self::fail("\nException: " . get_class($e) . ": " . $e->getMessage() . "\nin " . $e->getFile() . ':' . $e->getLine() . "\nTrace:\n" . $e->getTraceAsString() . "\n"); } //test for pop3 @@ -1338,13 +1256,13 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase // Execute the method and test that it works and doesn't throw an exception. try { $inboundEmail->checkEmail('INBOX'); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail("\nException: " . get_class($e) . ": " . $e->getMessage() . "\nin " . $e->getFile() . ':' . $e->getLine() . "\nTrace:\n" . $e->getTraceAsString() . "\n"); + self::fail("\nException: " . get_class($e) . ": " . $e->getMessage() . "\nin " . $e->getFile() . ':' . $e->getLine() . "\nTrace:\n" . $e->getTraceAsString() . "\n"); } } - public function testsyncEmail() + public function testsyncEmail(): void { global $current_user; $current_user = new User('1'); @@ -1354,13 +1272,13 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase // Execute the method and test that it works and doesn't throw an exception. try { $inboundEmail->syncEmail(); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail("\nException: " . get_class($e) . ": " . $e->getMessage() . "\nin " . $e->getFile() . ':' . $e->getLine() . "\nTrace:\n" . $e->getTraceAsString() . "\n"); + self::fail("\nException: " . get_class($e) . ": " . $e->getMessage() . "\nin " . $e->getFile() . ':' . $e->getLine() . "\nTrace:\n" . $e->getTraceAsString() . "\n"); } } - public function testdeleteCachedMessages() + public function testdeleteCachedMessages(): void { $inboundEmail = BeanFactory::newBean('InboundEmail'); @@ -1369,65 +1287,20 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase // Execute the method and test that it works and doesn't throw an exception. try { $inboundEmail->deleteCachedMessages('1,2', 'test'); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail("\nException: " . get_class($e) . ": " . $e->getMessage() . "\nin " . $e->getFile() . ':' . $e->getLine() . "\nTrace:\n" . $e->getTraceAsString() . "\n"); + self::fail("\nException: " . get_class($e) . ": " . $e->getMessage() . "\nin " . $e->getFile() . ':' . $e->getLine() . "\nTrace:\n" . $e->getTraceAsString() . "\n"); } } - public function testgetOverviewsFromCacheFile() + public function testgetOverviewsFromCacheFile(): void { - $inboundEmail = BeanFactory::newBean('InboundEmail'); + $result = BeanFactory::newBean('InboundEmail')->getOverviewsFromCacheFile('1,2', 'INBOX'); - $result = $inboundEmail->getOverviewsFromCacheFile('1,2', 'INBOX'); - - $this->assertTrue(is_array($result)); + self::assertIsArray($result); } - /** - * @todo: NEEDS REVISION - */ - public function testupdateOverviewCacheFile() - { -// $this->markTestIncomplete("Different results for php5 and php7"); -// /* -// $inboundEmail = BeanFactory::newBean('InboundEmail'); -// -// $inboundEmail->id = 1; -// $inboundEmail->mailbox = 'INBOX'; -// -// $overview = new Overview(); -// $overview->subject = 'subject 1'; -// $overview->size = '10001'; -// $overview->uid = '1'; -// -// $overviews = array($overview); -// -// $inboundEmail->updateOverviewCacheFile($overviews); -// -// //retrieve back to verify the records created -// $result = $inboundEmail->getCacheValue('INBOX'); -// $this->assertGreaterThan(0, count($result['retArr'][0])); -// $this->assertEquals('subject 1', $result['retArr'][0]->subject); -// */ - } - - public function testsetReadFlagOnFolderCache() - { -// $this->markTestIncomplete('Undefined offset: 0'); -//// -//// $inboundEmail = BeanFactory::newBean('InboundEmail'); -//// -//// $inboundEmail->id = 1; -//// -//// $inboundEmail->setReadFlagOnFolderCache('INBOX', '1'); -//// -//// //retrieve back to verify the records updated -//// $result = $inboundEmail->getCacheValue('INBOX'); -//// $this->assertEquals(0, $result['retArr'][0]->seen); - } - - public function testfetchCheckedEmails() + public function testfetchCheckedEmails(): void { //unset and reconnect Db to resolve mysqli fetch exeception $db = DBManagerFactory::getInstance(); @@ -1447,7 +1320,7 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase $fetchedOverviews = array($overview1); $result = $inboundEmail->fetchCheckedEmails($fetchedOverviews); - $this->assertEquals(false, $result); + self::assertEquals(false, $result); //test with size less than 1000 and imap_uid set $overview2 = new Overview(); @@ -1458,10 +1331,10 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase $fetchedOverviews = array($overview2); $result = $inboundEmail->fetchCheckedEmails($fetchedOverviews); - $this->assertEquals(true, $result); + self::assertEquals(true, $result); } - public function testmarkEmails() + public function testmarkEmails(): void { $inboundEmail = BeanFactory::newBean('InboundEmail'); @@ -1473,13 +1346,13 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase $inboundEmail->markEmails('1', 'unflagged'); $inboundEmail->markEmails('1', 'answered'); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail("\nException: " . get_class($e) . ": " . $e->getMessage() . "\nin " . $e->getFile() . ':' . $e->getLine() . "\nTrace:\n" . $e->getTraceAsString() . "\n"); + self::fail("\nException: " . get_class($e) . ": " . $e->getMessage() . "\nin " . $e->getFile() . ':' . $e->getLine() . "\nTrace:\n" . $e->getTraceAsString() . "\n"); } } - public function testdeleteFolder() + public function testdeleteFolder(): void { $inboundEmail = BeanFactory::newBean('InboundEmail'); @@ -1487,37 +1360,35 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase $result = $inboundEmail->deleteFolder('INBOX'); - $this->assertSame(['status', 'errorMessage'], array_keys($result)); - $this->assertFalse($result['status']); + self::assertSame(['status', 'errorMessage'], array_keys($result)); + self::assertFalse($result['status']); } - public function testsaveNewFolder() + public function testsaveNewFolder(): void { - $inboundEmail = BeanFactory::newBean('InboundEmail'); + $result = BeanFactory::newBean('InboundEmail')->saveNewFolder('TEST', 'INBOX'); - $result = $inboundEmail->saveNewFolder('TEST', 'INBOX'); - - $this->assertEquals(false, $result); + self::assertEquals(false, $result); } - public function testgetImapMboxFromSugarProprietary() + public function testgetImapMboxFromSugarProprietary(): void { $inboundEmail = BeanFactory::newBean('InboundEmail'); //test with invalid format string $result = $inboundEmail->getImapMboxFromSugarProprietary('INBOX.TRASH'); - $this->assertEquals('', $result); + self::assertEquals('', $result); //test with valid format but shorter string $result = $inboundEmail->getImapMboxFromSugarProprietary('INBOX::TRASH'); - $this->assertEquals('', $result); + self::assertEquals('', $result); //test with valid format longer string $result = $inboundEmail->getImapMboxFromSugarProprietary('INBOX::TRASH::TEST'); - $this->assertEquals('TEST', $result); + self::assertEquals('TEST', $result); } - public function testrepairAccount() + public function testrepairAccount(): void { $inboundEmail = BeanFactory::newBean('InboundEmail'); @@ -1525,28 +1396,10 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase $result = $inboundEmail->repairAccount(); - $this->assertEquals(false, $result); + self::assertEquals(false, $result); } - public function testgetTeamSetIdForTeams() - { -// $this->markTestIncomplete("Fatal error: Class 'Team' not found"); -//// -//// //unset and reconnect Db to resolve mysqli fetch exeception -//// $db = DBManagerFactory::getInstance(); -//// unset($db->database); -//// $db->checkConnection(); -//// -//// $inboundEmail = BeanFactory::newBean('InboundEmail'); -//// -//// //$result = $inboundEmail->getTeamSetIdForTeams("1"); -//// -//// //test for record ID to verify that record is saved -//// //$this->assertTrue(isset($result)); -//// //$this->assertEquals(36, strlen($result)); - } - - public function testsavePersonalEmailAccountAndOthers() + public function testsavePersonalEmailAccountAndOthers(): void { $inboundEmail = BeanFactory::newBean('InboundEmail'); @@ -1559,8 +1412,8 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase $result = $inboundEmail->savePersonalEmailAccount(1, 'admin', true); - $this->assertTrue(isset($inboundEmail->id)); - $this->assertEquals(36, strlen($inboundEmail->id)); + self::assertTrue(isset($inboundEmail->id)); + self::assertEquals(36, strlen($inboundEmail->id)); //test handleIsPersonal method $this->handleIsPersonal($inboundEmail->id); @@ -1578,172 +1431,164 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase $this->deletePersonalEmailAccount($inboundEmail->id); } - public function handleIsPersonal($id) + public function handleIsPersonal($id): void { $inboundEmail = BeanFactory::newBean('InboundEmail'); //test with a invalid group_id $inboundEmail->group_id = 2; $result = $inboundEmail->handleIsPersonal(); - $this->assertEquals(false, $result); + self::assertEquals(false, $result); //test with a valid group_id $inboundEmail->retrieve($id); $result = $inboundEmail->handleIsPersonal(); - $this->assertEquals(true, $result); + self::assertEquals(true, $result); } - public function getUserPersonalAccountCount() + public function getUserPersonalAccountCount(): void { $inboundEmail = BeanFactory::newBean('InboundEmail'); //test with invalid user id $user = BeanFactory::newBean('Users'); $result = $inboundEmail->getUserPersonalAccountCount($user); - $this->assertEquals(0, $result); + self::assertEquals(0, $result); //test with valid user id $user->id = 1; $result = $inboundEmail->getUserPersonalAccountCount($user); - $this->assertGreaterThan(0, $result); + self::assertGreaterThan(0, $result); } - public function retrieveByGroupFolderId() + public function retrieveByGroupFolderId(): void { $inboundEmail = BeanFactory::newBean('InboundEmail'); //test with invalid groupfolder id $result = $inboundEmail->retrieveByGroupFolderId('1'); - $this->assertTrue(is_array($result)); - $this->assertEquals(0, count($result)); + self::assertIsArray($result); + self::assertCount(0, $result); //test with valid groupfolder id $result = $inboundEmail->retrieveByGroupFolderId(''); - $this->assertTrue(is_array($result)); + self::assertIsArray($result); foreach ($result as $ie) { - $this->assertInstanceOf('InboundEmail', $ie); + self::assertInstanceOf('InboundEmail', $ie); } } - public function getUserNameFromGroupId($id) + public function getUserNameFromGroupId($id): void { $inboundEmail = BeanFactory::newBean('InboundEmail'); //test with a invalid group_id $inboundEmail->group_id = 2; $result = $inboundEmail->getUserNameFromGroupId(); - $this->assertEquals('', $result); + self::assertEquals('', $result); //test with a valid group_id $inboundEmail->retrieve($id); $result = $inboundEmail->getUserNameFromGroupId(); - $this->assertEquals('admin', $result); + self::assertEquals('admin', $result); } - public function deletePersonalEmailAccount($id) + public function deletePersonalEmailAccount($id): void { $inboundEmail = BeanFactory::newBean('InboundEmail'); //test with invalid username $result = $inboundEmail->deletePersonalEmailAccount($id, 'test'); - $this->assertEquals(false, $result); + self::assertEquals(false, $result); //test with valid username $result = $inboundEmail->deletePersonalEmailAccount($id, 'admin'); - $this->assertEquals(true, $result); + self::assertEquals(true, $result); } - public function testgetFoldersListForMailBox() + public function testgetFoldersListForMailBox(): void { - $inboundEmail = BeanFactory::newBean('InboundEmail'); - - $result = $inboundEmail->getFoldersListForMailBox(); - $this->assertTrue(is_array($result)); + $result = BeanFactory::newBean('InboundEmail')->getFoldersListForMailBox(); + self::assertIsArray($result); } - public function testfindOptimumSettings() + public function testfindOptimumSettings(): void { $inboundEmail = BeanFactory::newBean('InboundEmail'); //test with different parameters, it will always return false because we do not have a mail server to connect. $ret = $inboundEmail->findOptimumSettings(); - $this->assertEquals(false, $ret); + self::assertEquals(false, $ret); - $this->assertEquals(false, $inboundEmail->findOptimumSettings(true)); + self::assertEquals(false, $inboundEmail->findOptimumSettings(true)); - $this->assertEquals(false, $inboundEmail->findOptimumSettings(false, 'test', 'test', '', '', 'INBOX')); + self::assertEquals(false, $inboundEmail->findOptimumSettings(false, 'test', 'test', '', '', 'INBOX')); } - public function testgetSessionConnectionString() + public function testgetSessionConnectionString(): void { $inboundEmail = BeanFactory::newBean('InboundEmail'); //test without setting session key $result = $inboundEmail->getSessionConnectionString('mail.google.com', 'test', 22, 'IMAP'); - $this->assertEquals('', $result); + self::assertEquals('', $result); //test with session key set $_SESSION['mail.google.comtest22IMAP'] = 'test connection string'; $result = $inboundEmail->getSessionConnectionString('mail.google.com', 'test', 22, 'IMAP'); - $this->assertEquals('test connection string', $result); + self::assertEquals('test connection string', $result); } - public function testsetSessionConnectionString() + public function testsetSessionConnectionString(): void { - $inboundEmail = BeanFactory::newBean('InboundEmail'); - - $result = $inboundEmail->setSessionConnectionString('mail.google.com', 'test', 22, 'IMAP', 'test connection'); - $this->assertEquals('test connection', $_SESSION['mail.google.comtest22IMAP']); + $result = BeanFactory::newBean('InboundEmail')->setSessionConnectionString('mail.google.com', 'test', 22, 'IMAP', 'test connection'); + self::assertEquals('test connection', $_SESSION['mail.google.comtest22IMAP']); } - public function testgetSessionInboundDelimiterString() + public function testgetSessionInboundDelimiterString(): void { $inboundEmail = BeanFactory::newBean('InboundEmail'); //test without setting session key $result = $inboundEmail->getSessionInboundDelimiterString('mail.google.com', 'test', 22, 'IMAP'); - $this->assertEquals('', $result); + self::assertEquals('', $result); //test with session key set $_SESSION['mail.google.comtest22IMAPdelimiter'] = 'delimit string'; $result = $inboundEmail->getSessionInboundDelimiterString('mail.google.com', 'test', 22, 'IMAP'); - $this->assertEquals('delimit string', $result); + self::assertEquals('delimit string', $result); } - public function testsetSessionInboundDelimiterString() + public function testsetSessionInboundDelimiterString(): void { - $inboundEmail = BeanFactory::newBean('InboundEmail'); - - $result = $inboundEmail->setSessionInboundDelimiterString('mail.google.com', 'test', 22, 'IMAP', 'test string'); - $this->assertEquals('test string', $_SESSION['mail.google.comtest22IMAPdelimiter']); + $result = BeanFactory::newBean('InboundEmail')->setSessionInboundDelimiterString('mail.google.com', 'test', 22, 'IMAP', 'test string'); + self::assertEquals('test string', $_SESSION['mail.google.comtest22IMAPdelimiter']); } - public function testgetSessionInboundFoldersString() + public function testgetSessionInboundFoldersString(): void { $inboundEmail = BeanFactory::newBean('InboundEmail'); //test without setting session key $result = $inboundEmail->getSessionInboundFoldersString('mail.google.com', 'test', 22, 'IMAP'); - $this->assertEquals('', $result); + self::assertEquals('', $result); //test with session key set $_SESSION['mail.google.comtest22IMAPfoldersList'] = 'foldersList string'; $result = $inboundEmail->getSessionInboundFoldersString('mail.google.com', 'test', 22, 'IMAP'); - $this->assertEquals('foldersList string', $result); + self::assertEquals('foldersList string', $result); } - public function testsetSessionInboundFoldersString() + public function testsetSessionInboundFoldersString(): void { - $inboundEmail = BeanFactory::newBean('InboundEmail'); - - $result = $inboundEmail->setSessionInboundFoldersString('mail.google.com', 'test', 22, 'IMAP', 'foldersList string'); - $this->assertEquals('foldersList string', $_SESSION['mail.google.comtest22IMAPfoldersList']); + $result = BeanFactory::newBean('InboundEmail')->setSessionInboundFoldersString('mail.google.com', 'test', 22, 'IMAP', 'foldersList string'); + self::assertEquals('foldersList string', $_SESSION['mail.google.comtest22IMAPfoldersList']); } - public function testgroupUserDupeCheck() + public function testgroupUserDupeCheck(): void { //unset and reconnect Db to resolve mysqli fetch exeception $db = DBManagerFactory::getInstance(); @@ -1754,15 +1599,15 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase //test without name i-e user_name in query $result = $inboundEmail->groupUserDupeCheck(); - $this->assertEquals(false, $result); + self::assertEquals(false, $result); //test with name i-e user_name in query $inboundEmail->name = 'admin'; $result = $inboundEmail->groupUserDupeCheck(); - $this->assertEquals(false, $result); + self::assertEquals(false, $result); } - public function testgetGroupsWithSelectOptions() + public function testgetGroupsWithSelectOptions(): void { //unset and reconnect Db to resolve mysqli fetch exeception $db = DBManagerFactory::getInstance(); @@ -1774,14 +1619,14 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase $inboundEmail->group_id = 1; $result = $inboundEmail->getGroupsWithSelectOptions(); - $this->assertEquals('', $result); + self::assertEquals('', $result); $expected = "\n\n\n"; $result = $inboundEmail->getGroupsWithSelectOptions(array(1, 2, 3)); - $this->assertEquals($expected, $result); + self::assertEquals($expected, $result); } - public function testhandleAutoresponse() + public function testhandleAutoresponse(): void { //unset and reconnect Db to resolve mysqli fetch exeception $db = DBManagerFactory::getInstance(); @@ -1799,13 +1644,13 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase // Execute the method and test that it works and doesn't throw an exception. try { $result = $inboundEmail->handleAutoresponse($email, $contactAddr); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail("\nException: " . get_class($e) . ": " . $e->getMessage() . "\nin " . $e->getFile() . ':' . $e->getLine() . "\nTrace:\n" . $e->getTraceAsString() . "\n"); + self::fail("\nException: " . get_class($e) . ": " . $e->getMessage() . "\nin " . $e->getFile() . ':' . $e->getLine() . "\nTrace:\n" . $e->getTraceAsString() . "\n"); } } - public function testhandleCaseAssignment() + public function testhandleCaseAssignment(): void { //unset and reconnect Db to resolve mysqli fetch exeception $db = DBManagerFactory::getInstance(); @@ -1818,10 +1663,10 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase $email->name = 'test'; $result = $inboundEmail->handleCaseAssignment($email); - $this->assertEquals(false, $result); + self::assertEquals(false, $result); } - public function testhandleMailboxType() + public function testhandleMailboxType(): void { //unset and reconnect Db to resolve mysqli fetch exeception $db = DBManagerFactory::getInstance(); @@ -1838,13 +1683,13 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase // Execute the method and test that it works and doesn't throw an exception. try { $inboundEmail->handleMailboxType($email, $header); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail("\nException: " . get_class($e) . ": " . $e->getMessage() . "\nin " . $e->getFile() . ':' . $e->getLine() . "\nTrace:\n" . $e->getTraceAsString() . "\n"); + self::fail("\nException: " . get_class($e) . ": " . $e->getMessage() . "\nin " . $e->getFile() . ':' . $e->getLine() . "\nTrace:\n" . $e->getTraceAsString() . "\n"); } } - public function testisMailBoxTypeCreateCase() + public function testisMailBoxTypeCreateCase(): void { //unset and reconnect Db to resolve mysqli fetch exeception $db = DBManagerFactory::getInstance(); @@ -1855,17 +1700,17 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase //test without setting attributes $result = $inboundEmail->isMailBoxTypeCreateCase(); - $this->assertEquals(false, $result); + self::assertEquals(false, $result); //test with attributes set $inboundEmail->mailbox_type = 'createcase'; $inboundEmail->groupfolder_id = 1; $result = $inboundEmail->isMailBoxTypeCreateCase(); - $this->assertEquals(true, $result); + self::assertEquals(true, $result); } - public function testhandleCreateCase() + public function testhandleCreateCase(): void { //unset and reconnect Db to resolve mysqli fetch exeception $db = DBManagerFactory::getInstance(); @@ -1880,13 +1725,13 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase // Execute the method and test that it works and doesn't throw an exception. try { $inboundEmail->handleCreateCase($email, 1); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail("\nException: " . get_class($e) . ": " . $e->getMessage() . "\nin " . $e->getFile() . ':' . $e->getLine() . "\nTrace:\n" . $e->getTraceAsString() . "\n"); + self::fail("\nException: " . get_class($e) . ": " . $e->getMessage() . "\nin " . $e->getFile() . ':' . $e->getLine() . "\nTrace:\n" . $e->getTraceAsString() . "\n"); } } - public function testhandleLinking() + public function testhandleLinking(): void { //unset and reconnect Db to resolve mysqli fetch exeception $db = DBManagerFactory::getInstance(); @@ -1899,30 +1744,10 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase $email->from_addr = 'test@from.com'; $result = $inboundEmail->handleLinking($email); - $this->assertEquals($email->from_addr, $result); + self::assertEquals($email->from_addr, $result); } - public function testgetEncodingFromBreadCrumb() - { -// $this->markTestIncomplete('errors in method'); -//// -//// //unset and reconnect Db to resolve mysqli fetch exeception -//// $db = DBManagerFactory::getInstance(); -//// unset($db->database); -//// $db->checkConnection(); -//// -//// $inboundEmail = BeanFactory::newBean('InboundEmail'); -//// -//// $parts = array( -//// (Object) array('encoding' => 'utf-8', 'parts' => array((Object) array('encoding' => 'utf-8', 'parts' => array((Object) array('encoding' => 'utf-8', 'parts' => 'dummy parts 2'))))), -//// ); -//// -//// //$result = $inboundEmail->getEncodingFromBreadCrumb("1.2.3", $parts); -//// -//// //$this->assertEqilas('utf-8', $result); - } - - public function testgetCharsetFromBreadCrumb() + public function testgetCharsetFromBreadCrumb(): void { $inboundEmail = BeanFactory::newBean('InboundEmail'); @@ -1932,30 +1757,10 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase $result = $inboundEmail->getCharsetFromBreadCrumb('1.2.3', $parts); - $this->assertEquals('default', $result); + self::assertEquals('default', $result); } - public function testgetMessageTextFromSingleMimePart() - { -// $this->markTestIncomplete('Exception: PHPUnit_Framework_Error_Notice: Undefined variable: structure'); -//// -//// //unset and reconnect Db to resolve mysqli fetch exeception -//// $db = DBManagerFactory::getInstance(); -//// unset($db->database); -//// $db->checkConnection(); -//// -//// $inboundEmail = BeanFactory::newBean('InboundEmail'); -//// -//// // Execute the method and test that it works and doesn't throw an exception. -//// try { -//// $result = $inboundEmail->getMessageTextFromSingleMimePart(1, 1, $structure); -//// $this->assertTrue(true); -//// } catch (Exception $e) { -//// $this->fail("\nException: " . get_class($e) . ": " . $e->getMessage() . "\nin " . $e->getFile() . ':' . $e->getLine() . "\nTrace:\n" . $e->getTraceAsString() . "\n"); -//// } - } - - public function testaddBreadCrumbOffset() + public function testaddBreadCrumbOffset(): void { //unset and reconnect Db to resolve mysqli fetch exeception $db = DBManagerFactory::getInstance(); @@ -1966,39 +1771,18 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase //test with empty offset string $result = $inboundEmail->addBreadCrumbOffset('1.1.1', ''); - $this->assertEquals('1.1.1', $result); + self::assertEquals('1.1.1', $result); //test with empty bread crumb string $result = $inboundEmail->addBreadCrumbOffset('', '1.1.1'); - $this->assertEquals('1.1.1', $result); + self::assertEquals('1.1.1', $result); //test with shorter bread crumb string $result = $inboundEmail->addBreadCrumbOffset('1.1.1', '2.2.2.2'); - $this->assertEquals('3.3.3.2', $result); + self::assertEquals('3.3.3.2', $result); } - public function testgetMessageText() - { -// $this->markTestIncomplete('Exception: PHPUnit_Framework_Error_Notice: Undefined variable: structure'); -// -//// -//// //unset and reconnect Db to resolve mysqli fetch exeception -//// $db = DBManagerFactory::getInstance(); -//// unset($db->database); -//// $db->checkConnection(); -//// -//// $inboundEmail = BeanFactory::newBean('InboundEmail'); -//// -//// // Execute the method and test that it works and doesn't throw an exception. -//// try { -//// $result = $inboundEmail->getMessageText(1, 'PLAIN', $structure, $fullHeader); -//// $this->assertTrue(true); -//// } catch (Exception $e) { -//// $this->fail("\nException: " . get_class($e) . ": " . $e->getMessage() . "\nin " . $e->getFile() . ':' . $e->getLine() . "\nTrace:\n" . $e->getTraceAsString() . "\n"); -//// } - } - - public function testdecodeHeader() + public function testdecodeHeader(): void { //unset and reconnect Db to resolve mysqli fetch exeception $db = DBManagerFactory::getInstance(); @@ -2019,10 +1803,10 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase $header = "From: Media Temple user (mt.kb.user@gmail.com)\r\nSubject: article: How to Trace a Email\r\nDate: January 25, 2011 3:30:58 PM PDT\r\nTo: user@example.com\r\nReturn-Path: \r\nEnvelope-To: user@example.com\r\nDelivery-Date: Tue, 25 Jan 2011 15:31:01 -0700"; $result = $inboundEmail->decodeHeader($header); - $this->assertEquals($expected, $result); + self::assertEquals($expected, $result); } - public function testhandleCharsetTranslation() + public function testhandleCharsetTranslation(): void { //unset and reconnect Db to resolve mysqli fetch exeception $db = DBManagerFactory::getInstance(); @@ -2033,14 +1817,14 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase //test with default $result = $inboundEmail->handleCharsetTranslation('sample text', 'default'); - $this->assertEquals('sample text', $result); + self::assertEquals('sample text', $result); //test with ISO-8859-8 $result = $inboundEmail->handleCharsetTranslation('sample text', 'ISO-8859-8'); - $this->assertEquals('sample text', $result); + self::assertEquals('sample text', $result); } - public function testbuildBreadCrumbs() + public function testbuildBreadCrumbs(): void { //unset and reconnect Db to resolve mysqli fetch exeception $db = DBManagerFactory::getInstance(); @@ -2052,13 +1836,13 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase // Execute the method and test that it works and doesn't throw an exception. try { $result = $inboundEmail->buildBreadCrumbs(array(), 'ALTERNATIVE', '1'); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail("\nException: " . get_class($e) . ": " . $e->getMessage() . "\nin " . $e->getFile() . ':' . $e->getLine() . "\nTrace:\n" . $e->getTraceAsString() . "\n"); + self::fail("\nException: " . get_class($e) . ": " . $e->getMessage() . "\nin " . $e->getFile() . ':' . $e->getLine() . "\nTrace:\n" . $e->getTraceAsString() . "\n"); } } - public function testbuildBreadCrumbsHTML() + public function testbuildBreadCrumbsHTML(): void { //unset and reconnect Db to resolve mysqli fetch exeception $db = DBManagerFactory::getInstance(); @@ -2070,13 +1854,13 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase // Execute the method and test that it works and doesn't throw an exception. try { $inboundEmail->buildBreadCrumbsHTML(array()); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail("\nException: " . get_class($e) . ": " . $e->getMessage() . "\nin " . $e->getFile() . ':' . $e->getLine() . "\nTrace:\n" . $e->getTraceAsString() . "\n"); + self::fail("\nException: " . get_class($e) . ": " . $e->getMessage() . "\nin " . $e->getFile() . ':' . $e->getLine() . "\nTrace:\n" . $e->getTraceAsString() . "\n"); } } - public function testconvertImapToSugarEmailAddress() + public function testconvertImapToSugarEmailAddress(): void { //unset and reconnect Db to resolve mysqli fetch exeception $db = DBManagerFactory::getInstance(); @@ -2089,10 +1873,21 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase $inboundEmail->host = 'mail.google.com'; $result = $inboundEmail->convertImapToSugarEmailAddress(array($inboundEmail)); - $this->assertEquals('INBOX@mail.google.com', $result); + self::assertEquals('INBOX@mail.google.com', $result); } - public function testhandleEncodedFilename() + public function testhandleEncodedFilename(): void + { + //unset and reconnect Db to resolve mysqli fetch exeception + $db = DBManagerFactory::getInstance(); + unset($db->database); + $db->checkConnection(); + + $result = BeanFactory::newBean('InboundEmail')->handleEncodedFilename('attachment1.pdf'); + self::assertEquals('attachment1.pdf', $result); + } + + public function testgetMimeType(): void { //unset and reconnect Db to resolve mysqli fetch exeception $db = DBManagerFactory::getInstance(); @@ -2101,25 +1896,12 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase $inboundEmail = BeanFactory::newBean('InboundEmail'); - $result = $inboundEmail->handleEncodedFilename('attachment1.pdf'); - $this->assertEquals('attachment1.pdf', $result); + self::assertEquals('text/plain', $inboundEmail->getMimeType(0, 'plain')); + self::assertEquals('multipart/binary', $inboundEmail->getMimeType(1, 'binary')); + self::assertEquals('other/subtype', $inboundEmail->getMimeType('test', 'subtype')); } - public function testgetMimeType() - { - //unset and reconnect Db to resolve mysqli fetch exeception - $db = DBManagerFactory::getInstance(); - unset($db->database); - $db->checkConnection(); - - $inboundEmail = BeanFactory::newBean('InboundEmail'); - - $this->assertEquals('text/plain', $inboundEmail->getMimeType(0, 'plain')); - $this->assertEquals('multipart/binary', $inboundEmail->getMimeType(1, 'binary')); - $this->assertEquals('other/subtype', $inboundEmail->getMimeType('test', 'subtype')); - } - - public function testsaveAttachments() + public function testsaveAttachments(): void { //unset and reconnect Db to resolve mysqli fetch exeception $db = DBManagerFactory::getInstance(); @@ -2131,24 +1913,22 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase // Execute the method and test that it works and doesn't throw an exception. try { $inboundEmail->saveAttachments('1', array(), '1', '0', true); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail("\nException: " . get_class($e) . ": " . $e->getMessage() . "\nin " . $e->getFile() . ':' . $e->getLine() . "\nTrace:\n" . $e->getTraceAsString() . "\n"); + self::fail("\nException: " . get_class($e) . ": " . $e->getMessage() . "\nin " . $e->getFile() . ':' . $e->getLine() . "\nTrace:\n" . $e->getTraceAsString() . "\n"); } } - public function testgetNoteBeanForAttachment() + public function testgetNoteBeanForAttachment(): void { - $inboundEmail = BeanFactory::newBean('InboundEmail'); + $result = BeanFactory::newBean('InboundEmail')->getNoteBeanForAttachment('1'); - $result = $inboundEmail->getNoteBeanForAttachment('1'); - - $this->assertInstanceOf('Note', $result); - $this->assertAttributeEquals('1', 'parent_id', $result); - $this->assertAttributeEquals('Emails', 'parent_type', $result); + self::assertInstanceOf('Note', $result); + self::assertEquals('1', $result->parent_id); + self::assertEquals('Emails', $result->parent_type); } - public function testretrieveAttachmentNameFromStructure() + public function testretrieveAttachmentNameFromStructure(): void { $inboundEmail = BeanFactory::newBean('InboundEmail'); @@ -2158,7 +1938,7 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase ); $result = $inboundEmail->retrieveAttachmentNameFromStructure($part); - $this->assertEquals('test1.txt', $result); + self::assertEquals('test1.txt', $result); //test with no filename attribute $part = (Object) array('dparameters' => array((Object) array('attribute' => 'name', 'value' => 'test1.txt')), @@ -2167,10 +1947,10 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase ); $result = $inboundEmail->retrieveAttachmentNameFromStructure($part); - $this->assertEquals('test1', $result); + self::assertEquals('test1', $result); } - public function testsaveAttachmentBinaries() + public function testsaveAttachmentBinaries(): void { //unset and reconnect Db to resolve mysqli fetch exeception $db = DBManagerFactory::getInstance(); @@ -2184,22 +1964,22 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase // Execute the method and test that it works and doesn't throw an exception. try { $inboundEmail->saveAttachmentBinaries(BeanFactory::newBean('Notes'), '1', '1.1', $part, 1); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail("\nException: " . get_class($e) . ": " . $e->getMessage() . "\nin " . $e->getFile() . ':' . $e->getLine() . "\nTrace:\n" . $e->getTraceAsString() . "\n"); + self::fail("\nException: " . get_class($e) . ": " . $e->getMessage() . "\nin " . $e->getFile() . ':' . $e->getLine() . "\nTrace:\n" . $e->getTraceAsString() . "\n"); } } - public function testhandleTranserEncoding() + public function testhandleTranserEncoding(): void { $inboundEmail = BeanFactory::newBean('InboundEmail'); - $this->assertEquals('test', $inboundEmail->handleTranserEncoding('test')); - $this->assertEquals('test', $inboundEmail->handleTranserEncoding('dGVzdA==', 3)); - $this->assertEquals('test', $inboundEmail->handleTranserEncoding('test', 4)); + self::assertEquals('test', $inboundEmail->handleTranserEncoding('test')); + self::assertEquals('test', $inboundEmail->handleTranserEncoding('dGVzdA==', 3)); + self::assertEquals('test', $inboundEmail->handleTranserEncoding('test', 4)); } - public function testgetMessageId() + public function testgetMessageId(): void { $inboundEmail = BeanFactory::newBean('InboundEmail'); @@ -2207,38 +1987,34 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase $result = $inboundEmail->getMessageId($header); - $this->assertEquals('21c65f7db176f0bd93768214b00ae397', $result); + self::assertEquals('21c65f7db176f0bd93768214b00ae397', $result); } - public function testimportDupeCheck() + public function testimportDupeCheck(): void { $inboundEmail = BeanFactory::newBean('InboundEmail'); $textHeader = "From: Media Temple user (mt.kb.user@gmail.com)\r\nSubject: article: How to Trace a Email\r\nDate: January 25, 2011 3:30:58 PM PDT\r\nTo: user@example.com\r\nReturn-Path: \r\nEnvelope-To: user@example.com\r\nDelivery-Date: Tue, 25 Jan 2011 15:31:01 -0700"; $result = $inboundEmail->importDupeCheck('1', $textHeader, $textHeader); - $this->assertEquals(true, $result); + self::assertEquals(true, $result); } - public function testhandleMimeHeaderDecode() + public function testhandleMimeHeaderDecode(): void { - $inboundEmail = BeanFactory::newBean('InboundEmail'); + $result = BeanFactory::newBean('InboundEmail')->handleMimeHeaderDecode('Subject: article: How to Trace a Email'); - $result = $inboundEmail->handleMimeHeaderDecode('Subject: article: How to Trace a Email'); - - $this->assertEquals('Subject: article: How to Trace a Email', $result); + self::assertEquals('Subject: article: How to Trace a Email', $result); } - public function testgetUnixHeaderDate() + public function testgetUnixHeaderDate(): void { - $inboundEmail = BeanFactory::newBean('InboundEmail'); + $result = BeanFactory::newBean('InboundEmail')->handleMimeHeaderDecode('Date: January 25, 2011 3:30:58 PM PDT'); - $result = $inboundEmail->handleMimeHeaderDecode('Date: January 25, 2011 3:30:58 PM PDT'); - - $this->assertEquals('Date: January 25, 2011 3:30:58 PM PDT', $result); + self::assertEquals('Date: January 25, 2011 3:30:58 PM PDT', $result); } - public function testgetDuplicateEmailId() + public function testgetDuplicateEmailId(): void { //unset and reconnect Db to resolve mysqli fetch exeception $db = DBManagerFactory::getInstance(); @@ -2250,13 +2026,13 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase // Execute the method and test that it works and doesn't throw an exception. try { $result = $inboundEmail->getDuplicateEmailId('1', '1'); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail("\nException: " . get_class($e) . ": " . $e->getMessage() . "\nin " . $e->getFile() . ':' . $e->getLine() . "\nTrace:\n" . $e->getTraceAsString() . "\n"); + self::fail("\nException: " . get_class($e) . ": " . $e->getMessage() . "\nin " . $e->getFile() . ':' . $e->getLine() . "\nTrace:\n" . $e->getTraceAsString() . "\n"); } } - public function testimportOneEmail() + public function testimportOneEmail(): void { $inboundEmail = BeanFactory::newBean('InboundEmail'); @@ -2266,22 +2042,22 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase // Execute the method and test that it works and doesn't throw an exception. try { $result = $inboundEmail->importOneEmail('1', '1'); - $this->assertEquals(false, $result); + self::assertEquals(false, $result); } catch (Exception $e) { - $this->fail("\nException: " . get_class($e) . ": " . $e->getMessage() . "\nin " . $e->getFile() . ':' . $e->getLine() . "\nTrace:\n" . $e->getTraceAsString() . "\n"); + self::fail("\nException: " . get_class($e) . ": " . $e->getMessage() . "\nin " . $e->getFile() . ':' . $e->getLine() . "\nTrace:\n" . $e->getTraceAsString() . "\n"); } } - public function testisUuencode() + public function testisUuencode(): void { $inboundEmail = BeanFactory::newBean('InboundEmail'); - $this->assertEquals(false, $inboundEmail->isUuencode('test')); + self::assertEquals(false, $inboundEmail->isUuencode('test')); - $this->assertEquals(false, $inboundEmail->isUuencode("begin 0744 odt_uuencoding_file.dat\r+=&5S=\"!S=')I;F<`\r`\rend")); + self::assertEquals(false, $inboundEmail->isUuencode("begin 0744 odt_uuencoding_file.dat\r+=&5S=\"!S=')I;F<`\r`\rend")); } - public function testhandleUUEncodedEmailBody() + public function testhandleUUEncodedEmailBody(): void { $inboundEmail = BeanFactory::newBean('InboundEmail'); @@ -2289,29 +2065,10 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase $result = $inboundEmail->handleUUEncodedEmailBody($raw, 1); - $this->assertEquals("\n".$raw, $result); + self::assertEquals("\n".$raw, $result); } - public function testhandleUUDecode() - { -// $this->markTestIncomplete('Uncaught require_once(include/PHP_Compat/convert_uudecode.php)'); -// /* -// //unset and reconnect Db to resolve mysqli fetch exeception -// $db = DBManagerFactory::getInstance(); -// unset ($db->database); -// $db->checkConnection(); -// -// -// $inboundEmail = BeanFactory::newBean('InboundEmail'); -// -// $raw = "\nMessage Body: This is a KnowledgeBase article that provides information on how to find email headers and use the data to trace a email."; -// -// $inboundEmail->handleUUDecode("1", "handleUUDecode_test", $raw); -// -// */ - } - - public function testcheckFilterDomain() + public function testcheckFilterDomain(): void { //unset and reconnect Db to resolve mysqli fetch exeception $db = DBManagerFactory::getInstance(); @@ -2325,10 +2082,10 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase $email->from_addr = 'from@gmail.com'; $result = $inboundEmail->checkFilterDomain($email); - $this->assertEquals(true, $result); + self::assertEquals(true, $result); } - public function testcheckOutOfOffice() + public function testcheckOutOfOffice(): void { //unset and reconnect Db to resolve mysqli fetch exeception $db = DBManagerFactory::getInstance(); @@ -2337,11 +2094,11 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase $inboundEmail = BeanFactory::newBean('InboundEmail'); - $this->assertEquals(false, $inboundEmail->checkOutOfOffice('currently Out of Office, will reply later')); - $this->assertEquals(true, $inboundEmail->checkOutOfOffice('test subject')); + self::assertEquals(false, $inboundEmail->checkOutOfOffice('currently Out of Office, will reply later')); + self::assertEquals(true, $inboundEmail->checkOutOfOffice('test subject')); } - public function testsetAndgetAutoreplyStatus() + public function testsetAndgetAutoreplyStatus(): void { //unset and reconnect Db to resolve mysqli fetch exeception $db = DBManagerFactory::getInstance(); @@ -2357,10 +2114,10 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase //test with and invalid email. it will return true as well because it's stil under max limit. $result = $inboundEmail->getAutoreplyStatus('invalid@email.com'); - $this->assertEquals(true, $result); + self::assertEquals(true, $result); } - public function testsaveInboundEmailSystemSettings() + public function testsaveInboundEmailSystemSettings(): void { global $sugar_config, $db; @@ -2374,193 +2131,132 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase $inboundEmail->saveInboundEmailSystemSettings('test', 'test_macro'); //verify the key created - $this->assertEquals('test_macro', $sugar_config['inbound_email_test_subject_macro']); + self::assertEquals('test_macro', $sugar_config['inbound_email_test_subject_macro']); } - public function testgetSystemSettingsForm() + public function testgetCaseIdFromCaseNumber(): void { -// $this->markTestIncomplete("It should be an acceptance test"); -// -// -// $inboundEmail = BeanFactory::newBean('InboundEmail'); -// -// $expected = "
-// -// -// -// -//
-

{$MOD.LBL_SEARCH_MODULES}

-
{$MOD.LBL_SEARCH_MODULES_HELP}

@@ -58,40 +51,28 @@ -
- - - -
- - - - - -
-
-
-
-
+
+
+
{$MOD.LBL_SEARCH_MODULES}
+

{$MOD.LBL_SEARCH_MODULES_HELP}

+
+
+ + + + + +
+
+
+
+
+
+
+
- - - - -
- - - -
- - -
-
-
-
 {$MOD.LBL_DELETE_FTS_DATA}
-
-
- diff --git a/modules/Administration/Search/MVC/View.php b/modules/Administration/Search/MVC/View.php index 509319e0a..27aa7847a 100644 --- a/modules/Administration/Search/MVC/View.php +++ b/modules/Administration/Search/MVC/View.php @@ -58,7 +58,7 @@ abstract class View extends BaseView * * Extend to assign more variable. */ - public function preDisplay() + public function preDisplay(): void { global $mod_strings; global $app_list_strings; @@ -74,10 +74,10 @@ abstract class View extends BaseView $this->smarty->assign('error', $errors); $this->smarty->assign('BUTTONS', $this->getButtons()); - if (!isset($sugar_config['search']) || !$sugar_config['search']) { + if (!empty($sugar_config['search'])) { LoggerManager::getLogger()->warn('Configuration does not contains default search settings.'); } - $search = isset($sugar_config['search']) ? $sugar_config['search'] : null; + $search = $sugar_config['search'] ?? null; $this->smarty->assign('config', $search); } @@ -86,7 +86,7 @@ abstract class View extends BaseView * * @return string */ - protected function getButtons() + protected function getButtons(): string { global $mod_strings; global $app_strings; @@ -113,7 +113,7 @@ EOQ; * * @return array */ - protected function getEngines() + protected function getEngines(): array { $engines = []; diff --git a/modules/Administration/Search/View.php b/modules/Administration/Search/View.php index 1ad4bae24..8f60dff58 100644 --- a/modules/Administration/Search/View.php +++ b/modules/Administration/Search/View.php @@ -4,7 +4,7 @@ * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. * * SuiteCRM is an extension to SugarCRM Community Edition developed by SalesAgility Ltd. - * Copyright (C) 2011 - 2018 SalesAgility Ltd. + * Copyright (C) 2011 - 2021 SalesAgility Ltd. * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU Affero General Public License version 3 as published by the @@ -43,30 +43,61 @@ if (!defined('sugarEntry') || !sugarEntry) { die('Not A Valid Entry Point'); } +use SuiteCRM\Search\SearchModules; use SuiteCRM\Search\SearchWrapper; +use SuiteCRM\Modules\Administration\Search\MVC\View as AbstractView; /** * Class View renders the Search settings. */ -class View extends MVC\View +class View extends AbstractView { public function __construct() { parent::__construct(__DIR__ . '/view.tpl'); } - public function preDisplay() + public function preDisplay(): void { parent::preDisplay(); $this->smarty->assign('selectedController', SearchWrapper::getController()); $this->smarty->assign('selectedEngine', SearchWrapper::getDefaultEngine()); + + $legacyEngines = [ + 'BasicSearchEngine' => translate('LBL_BASIC_SEARCH_ENGINE'), + 'BasicAndAodEngine' => translate('LBL_BASIC_AND_AOD_ENGINE'), + ]; + + $engines = $this->getEngines(); + $engines = array_merge($legacyEngines, $engines); + unset($engines['LuceneSearchEngine']); + $this->smarty->assign('engines', [ - translate('LBL_LEGACY_SEARCH_ENGINES') => [ - 'BasicSearchEngine' => translate('LBL_BASIC_SEARCH_ENGINE'), - 'BasicAndAodEngine' => translate('LBL_BASIC_AND_AOD_ENGINE'), - ], - translate('LBL_SEARCH_WRAPPER_ENGINES') => $this->getEngines(), + translate('LBL_SEARCH_WRAPPER_ENGINES') => $engines ]); } + + /** + * @see SugarView::display() + */ + public function display(): void + { + global $mod_strings, $app_strings; + + $this->smarty->assign('APP', $app_strings); + $this->smarty->assign('MOD', $mod_strings); + + $modules = SearchModules::getAllModules(); + + $this->smarty->assign('enabled_modules', json_encode($modules['enabled'], JSON_THROW_ON_ERROR)); + $this->smarty->assign('disabled_modules', json_encode($modules['disabled'], JSON_THROW_ON_ERROR)); + + $template = $this->templateFile; + if (file_exists('custom/' . $this->templateFile)) { + $template = 'custom/' . $this->templateFile; + } + + $this->smarty->display($template); + } } diff --git a/modules/Administration/Search/view.tpl b/modules/Administration/Search/view.tpl index 75d26f317..9b209e6fd 100644 --- a/modules/Administration/Search/view.tpl +++ b/modules/Administration/Search/view.tpl @@ -3,7 +3,7 @@ * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. * * SuiteCRM is an extension to SugarCRM Community Edition developed by SalesAgility Ltd. - * Copyright (C) 2011 - 2018 SalesAgility Ltd. + * Copyright (C) 2011 - 2021 SalesAgility Ltd. * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU Affero General Public License version 3 as published by the @@ -42,46 +42,48 @@ class="detail-view" enctype='multipart/form-data' method="POST" - action="index.php?module=Administration&action=SearchSettings&do=Save"> + action="index.php?module=Administration&action=SearchSettings&do=Save" + onsubmit="SUGAR.saveGlobalSearchSettings();"> - - - - + + - - {*search engine*} - - - -
-

{sugar_translate label="LBL_SEARCH_INTERFACE"}

-
-
-
- - {sugar_help text=$MOD.LBL_SEARCH_ENGINE_TOOLTIP} -
-
- {sugar_translate label="LBL_SEARCH_ENGINE_HELP"} +
+
+
{$MOD.LBL_SEARCH_INTERFACE}
+
+
+
+
+
+ + {sugar_help text=$MOD.LBL_SEARCH_ENGINE_TOOLTIP} +
+
+ {sugar_translate label="LBL_SEARCH_ENGINE_HELP"} +
+
-
- {html_options - options=$engines - selected=$selectedEngine - id="search-engine" - name="search-engine" - class="form-control" - } -
+
+ {html_options + options=$engines + selected=$selectedEngine + id="search-engine" + name="search-engine" + class="form-control" + } +
+
+ + + + {include file='modules/Administration/Search/GlobalSearchSettings.tpl'} + + {$JAVASCRIPT}
{$BUTTONS}
- - {$JAVASCRIPT} - - - + diff --git a/modules/Administration/language/en_us.lang.php b/modules/Administration/language/en_us.lang.php index 13eba5830..c45394d1d 100755 --- a/modules/Administration/language/en_us.lang.php +++ b/modules/Administration/language/en_us.lang.php @@ -860,10 +860,6 @@ $mod_strings = array( 'LBL_AOP_ADD_STATUS' => 'Add', 'LBL_AOP_REMOVE_STATUS' => 'Remove', - 'LBL_AOD_ADMIN_MANAGE_AOD' => 'Advanced OpenDiscovery Settings', - 'LBL_AOD_ENABLE' => 'Enable AOD', - 'LBL_AOD_SETTINGS' => 'AOD Settings', - 'LBL_AOS_ADMIN_CONTRACT_SETTINGS' => 'Contract Settings', 'LBL_AOS_ADMIN_CONTRACT_RENEWAL_REMINDER' => 'Renewal Reminder period', 'LBL_AOS_ADMIN_MANAGE_AOS' => 'Advanced OpenSales Settings', @@ -961,13 +957,13 @@ $mod_strings = array( 'LBL_SEARCH_ENGINE' => 'Search Engine', 'LBL_SEARCH_ENGINE_HELP' => 'Configure the default search engine used by the search.', 'LBL_SEARCH_ENGINE_TOOLTIP' => 'Select a search engine for the Global Search.', + 'LBL_SEARCH_GENERAL' => 'General', 'LBL_SEARCH_MODULES' => 'Search Modules', 'LBL_SEARCH_MODULES_HELP' => 'Select the module(s) that users will be able to search against using the Global Search.', // Search Engines Translations - 'LBL_LEGACY_SEARCH_ENGINES' => 'Legacy Search', - 'LBL_SEARCH_WRAPPER_ENGINES' => 'Search Engines (new)', + 'LBL_SEARCH_WRAPPER_ENGINES' => 'Search Engines', 'LBL_BASIC_SEARCH_ENGINE' => 'Basic Search', 'LBL_BASIC_AND_AOD_ENGINE' => 'Basic + Advanced Search', 'LBL_ELASTIC_SEARCH_ENGINE' => 'Elasticsearch Engine', diff --git a/modules/Administration/metadata/adminpaneldefs.php b/modules/Administration/metadata/adminpaneldefs.php index 701d79b20..12d143235 100755 --- a/modules/Administration/metadata/adminpaneldefs.php +++ b/modules/Administration/metadata/adminpaneldefs.php @@ -71,8 +71,6 @@ $admin_option_defs['Administration']['languages']= array('Currencies','LBL_MANAG $admin_option_defs['Administration']['repair']= array('Repair','LBL_UPGRADE_TITLE','LBL_UPGRADE','./index.php?module=Administration&action=Upgrade', 'repair'); -$admin_option_defs['Administration']['global_search']=array('icon_SearchForm','LBL_GLOBAL_SEARCH_SETTINGS','LBL_GLOBAL_SEARCH_SETTINGS_DESC','./index.php?module=Administration&action=GlobalSearchSettings', 'global-search'); - if (!isset($GLOBALS['sugar_config']['hide_admin_diagnostics']) || !$GLOBALS['sugar_config']['hide_admin_diagnostics']) { $admin_option_defs['Administration']['diagnostic']= array('Diagnostic','LBL_DIAGNOSTIC_TITLE','LBL_DIAGNOSTIC_DESC','./index.php?module=Administration&action=Diagnostic', 'diagnostic'); } @@ -227,13 +225,6 @@ $admin_option_defs['Administration']['aos'] = array( 'aos-settings' ); -$admin_option_defs['Administration']['aod'] = array( - 'AOD', - 'LBL_AOD_SETTINGS', - 'LBL_CHANGE_SETTINGS_AOD', - './index.php?module=Administration&action=AODAdmin', - 'aod-settings' -); $admin_option_defs['Administration']['aop'] = array( 'AOP', 'LBL_AOP_SETTINGS', @@ -269,14 +260,6 @@ $admin_option_defs['Administration']['search_wrapper'] = [ 'global-search' ]; -$admin_option_defs['Administration']['global_search'] = [ - 'icon_SearchForm', - 'LBL_SEARCH_MODULES', - 'LBL_SEARCH_MODULES_HELP', - './index.php?module=Administration&action=GlobalSearchSettings', - 'global-search' -]; - $admin_option_defs['Administration']['elastic_search'] = [ 'ElasticSearchIndexerSettings', 'LBL_ELASTIC_SEARCH_SETTINGS', diff --git a/modules/Home/Search.php b/modules/Home/Search.php index b278baacb..dc2acd89c 100644 --- a/modules/Home/Search.php +++ b/modules/Home/Search.php @@ -4,7 +4,7 @@ * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. * * SuiteCRM is an extension to SugarCRM Community Edition developed by SalesAgility Ltd. - * Copyright (C) 2011 - 2018 SalesAgility Ltd. + * Copyright (C) 2011 - 2021 SalesAgility Ltd. * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU Affero General Public License version 3 as published by the @@ -62,7 +62,7 @@ try { * @param Throwable $throwable * @param SearchQuery $query */ -function handleThrowable($throwable, SearchQuery $query) +function handleThrowable(Throwable $throwable, SearchQuery $query) { $handler = new SearchThrowableHandler($throwable, $query); $handler->handle(); diff --git a/modules/Home/UnifiedSearch.php b/modules/Home/UnifiedSearch.php index 62cd7e328..a1ed47e06 100755 --- a/modules/Home/UnifiedSearch.php +++ b/modules/Home/UnifiedSearch.php @@ -5,7 +5,7 @@ * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. * * SuiteCRM is an extension to SugarCRM Community Edition developed by SalesAgility Ltd. - * Copyright (C) 2011 - 2018 SalesAgility Ltd. + * Copyright (C) 2011 - 2021 SalesAgility Ltd. * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU Affero General Public License version 3 as published by the @@ -38,281 +38,4 @@ * display the words "Powered by SugarCRM" and "Supercharged by SuiteCRM". */ -$queryString = ! empty($_REQUEST['query_string']) ? $_REQUEST['query_string'] : ''; - -$luceneSearch = !empty($sugar_config['aod']['enable_aod']); - -if (array_key_exists('showGSDiv', $_REQUEST) || !empty($_REQUEST['search_fallback'])) { - //Search from vanilla sugar search or request for the same - $luceneSearch = false; -} - -if (!$luceneSearch) { - if (!empty($sugar_config['aod']['enable_aod'])) { - echo "".translate("LBL_USE_AOD_SEARCH", "AOD_Index").""; - } - require_once('modules/Home/UnifiedSearchAdvanced.php'); - global $mod_strings, $modListHeader, $app_strings, $beanList, $beanFiles; - $usa = new UnifiedSearchAdvanced(); - $usa->search(); - return; -} -require_once('include/utils.php'); -echo "".translate("LBL_USE_VANILLA_SEARCH", "AOD_Index").""; - -$index = BeanFactory::getBean("AOD_Index")->getIndex(); -$hits = array(); -$start = 0; -$amount = 20; -$total = 0; -if (!empty($_REQUEST['start'])) { - $start = $_REQUEST['start']; -} -if (!empty($_REQUEST['total'])) { - $total = $_REQUEST['total']; -} -if (array_key_exists('listViewStartButton', $_REQUEST)) { - $start = 0; -} elseif (array_key_exists('listViewPrevButton', $_REQUEST)) { - $start = max($start - $amount, 0); -} elseif (array_key_exists('listViewNextButton', $_REQUEST)) { - $start = min($start + $amount, $total); -} elseif (array_key_exists('listViewEndButton', $_REQUEST)) { - $start = floor($total / $amount) * $amount; -} -if ($queryString) { - $res = doSearch($index, $queryString, $start, $amount); - $total = $res['total']; - $hits = $res['hits']; -} - - -?> -
- - - - ">  -
- - - - - - - - - - - - - - " - ."" - ."" - ."" - ."" - ."" - ."" - .""; -} -?> -
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
-
- -
-
-
- -
-
-
- -
-
".$hit->label."".$hit->name."".$hit->summary."".$hit->date_entered."".$hit->date_modified."".getScoreDisplay($hit)."
- -".translate("LBL_SEARCH_RESULT_EMPTY", "AOD_Index")."

"; - } -?> - -module_dir])) { - if (file_exists('custom/modules/'.$bean->module_dir.'/metadata/listviewdefs.php')) { - require('custom/modules/'.$bean->module_dir.'/metadata/listviewdefs.php'); - } else { - if (file_exists('modules/'.$bean->module_dir.'/metadata/listviewdefs.php')) { - require('modules/'.$bean->module_dir.'/metadata/listviewdefs.php'); - } - } - } - if (!isset($listViewDefs) || !isset($listViewDefs[$bean->module_dir])) { - return $bean->get_summary_text(); - } - $summary = array(); - ; - foreach ($listViewDefs[$bean->module_dir] as $key => $entry) { - if (empty($entry['default'])) { - continue; - } - $key = strtolower($key); - - if (in_array($key, array('date_entered','date_modified','name'))) { - continue; - } - $summary[] = $bean->$key; - } - $summary = array_filter($summary); - return implode(' || ', $summary); -} -function getScoreDisplay($hit) -{ - return number_format(100*$hit->score, 2); -} -function unCamelCase($input, $sep = " ") -{ - $output = preg_replace(array('/(?<=[^A-Z])([A-Z])/', '/(?<=[^0-9])([0-9])/'), $sep.'$0', $input); - return ucwords($output); -} -function getModuleLabel($module) -{ - return translate('LBL_MODULE_NAME', $module); -} -function cacheQuery($queryString, $resArray) -{ - $file = create_cache_directory('modules/AOD_Index/QueryCache/' . md5($queryString)); - $out = serialize($resArray); - sugar_file_put_contents_atomic($file, $out); -} - -function getCorrectMTime($filePath) -{ - $time = filemtime($filePath); - $isDST = (date('I', $time) == 1); - $systemDST = (date('I') == 1); - $adjustment = 0; - if ($isDST == false && $systemDST == true) { - $adjustment = 3600; - } elseif ($isDST == true && $systemDST == false) { - $adjustment = -3600; - } else { - $adjustment = 0; - } - return ($time + $adjustment); -} - -function doSearch($index, $queryString, $start = 0, $amount = 20) -{ - global $current_user; - $cachePath = 'cache/modules/AOD_Index/QueryCache/' . md5($queryString); - if (is_file($cachePath)) { - $mTime = getCorrectMTime($cachePath); - if ($mTime > (time() - 5*60)) { - $hits = unserialize(sugar_file_get_contents($cachePath)); - } - } - if (!isset($hits)) { - $tmphits = $index->find($queryString); - $hits = array(); - foreach ($tmphits as $hit) { - $bean = BeanFactory::getBean($hit->record_module, $hit->record_id); - if (empty($bean)) { - continue; - } - if ($bean->bean_implements('ACL') && !is_admin($current_user)) { - //Annoyingly can't use the following as it always passes true for is_owner checks on list - //$bean->ACLAccess('list'); - $in_group = SecurityGroup::groupHasAccess($bean->module_dir, $bean->id, 'list'); - $is_owner = $bean->isOwner($current_user->id); - $access = ACLController::checkAccess($bean->module_dir, 'list', $is_owner, 'module', $in_group); - if (!$access) { - continue; - } - } - $newHit = new stdClass; - $newHit->record_module = $hit->record_module; - $newHit->record_id = $hit->record_id; - $newHit->score = $hit->score; - $newHit->label = getModuleLabel($bean->module_name); - $newHit->name = $bean->get_summary_text(); - $newHit->summary = getRecordSummary($bean); - $newHit->date_entered = $bean->date_entered; - $newHit->date_modified = $bean->date_modified; - $hits[] = $newHit; - } - //Cache results so pagination is nice and snappy. - cacheQuery($queryString, $hits); - } - - $total = count($hits); - $hits = array_slice($hits, $start, $amount); - $res = array('total'=>$total,'hits' => $hits); - return $res; -} - -function getPaginateHTML($queryString, $start, $amount, $total) -{ - $first = !$start; - $last = ($start + $amount) > $total; - if ($first) { - $startImage = SugarThemeRegistry::current()->getImageURL('start_off.gif'); - $prevImage = SugarThemeRegistry::current()->getImageURL('previous_off.gif'); - } else { - $startImage = SugarThemeRegistry::current()->getImageURL('start.gif'); - $prevImage = SugarThemeRegistry::current()->getImageURL('previous.gif'); - } - if ($last) { - $endImage = SugarThemeRegistry::current()->getImageURL('end_off.gif'); - $nextImage = SugarThemeRegistry::current()->getImageURL('next_off.gif'); - } else { - $endImage = SugarThemeRegistry::current()->getImageURL('end.gif'); - $nextImage = SugarThemeRegistry::current()->getImageURL('next.gif'); - } ?> -
-
- - - - - - - - ( - of ) - - -
-
-// -// -// -//
-// -//
-// -// -// -// -// -// -// -//
-// -// : -// -// -// -// -// -// -// -//
-// -//
-//
-//"; -// $result = $inboundEmail->getSystemSettingsForm(); -// -// $this->assertSame($expected, $result); + $result = BeanFactory::newBean('InboundEmail')->getCaseIdFromCaseNumber('test', BeanFactory::newBean('Cases')); + self::assertEquals(false, $result); } - public function testgetCaseIdFromCaseNumber() - { - $inboundEmail = BeanFactory::newBean('InboundEmail'); - - $result = $inboundEmail->getCaseIdFromCaseNumber('test', BeanFactory::newBean('Cases')); - $this->assertEquals(false, $result); - } - - public function testget_stored_options() + public function testget_stored_options(): void { $inboundEmail = BeanFactory::newBean('InboundEmail'); $result = $inboundEmail->get_stored_options('test', ''); - $this->assertEquals('', $result); + self::assertEquals('', $result); $result = $inboundEmail->get_stored_options('test', 'default_option'); - $this->assertEquals('default_option', $result); + self::assertEquals('default_option', $result); } - public function testSetStoredOptions() + public function testSetStoredOptions(): void { $ie = BeanFactory::newBean('InboundEmail'); $so = $ie->getStoredOptions(); $so['something'] = 'testinfo'; $ie->setStoredOptions($so); $ret = $ie->getStoredOptions(); - $this->assertEquals('testinfo', $ret['something']); + self::assertEquals('testinfo', $ret['something']); } - public function testgetRelatedId() - { -// $this->markTestIncomplete('Undefined variable: result'); -//// -//// //unset and reconnect Db to resolve mysqli fetch exeception -//// $db = DBManagerFactory::getInstance(); -//// unset($db->database); -//// $db->checkConnection(); -//// -//// $inboundEmail = BeanFactory::newBean('InboundEmail'); -//// -//// //test with Users module -//// $inboundEmail->getRelatedId('getRelatedId@email.com', 'Users'); -//// $this->assertEquals(false, $result); -//// -//// //test with Contacts module -//// $inboundEmail->getRelatedId('getRelatedId@email.com', 'Contacts'); -//// $this->assertEquals(false, $result); - } - - public function testgetNewMessageIds() + public function testgetRelatedId(): void { $inboundEmail = BeanFactory::newBean('InboundEmail'); - $result = $inboundEmail->getNewMessageIds(); + // Test with Users module + $result = $inboundEmail->getRelatedId('getRelatedId@email.com', 'Users'); + self::assertEquals(false, $result); - $this->assertEquals(null, $result); + // Test with Contacts module + $result = $inboundEmail->getRelatedId('getRelatedId@email.com', 'Contacts'); + self::assertEquals(false, $result); } - public function testgetConnectString() + public function testgetNewMessageIds(): void + { + $result = BeanFactory::newBean('InboundEmail')->getNewMessageIds(); + + self::assertEquals(null, $result); + } + + public function testgetConnectString(): void { $inboundEmail = BeanFactory::newBean('InboundEmail'); - $this->assertEquals('{:/service=}', $inboundEmail->getConnectString()); //test with default options - $this->assertEquals('{:/service=mail.google.com}INBOX', $inboundEmail->getConnectString('mail.google.com', 'INBOX'));//test with includeMbox true - $this->assertEquals('{:/service=mail.google.com}', $inboundEmail->getConnectString('mail.google.com', 'INBOX', false));//test with includeMbox false + self::assertEquals('{:/service=}', $inboundEmail->getConnectString()); //test with default options + self::assertEquals('{:/service=mail.google.com}INBOX', $inboundEmail->getConnectString('mail.google.com', 'INBOX'));//test with includeMbox true + self::assertEquals('{:/service=mail.google.com}', $inboundEmail->getConnectString('mail.google.com', 'INBOX', false));//test with includeMbox false } - public function testdisconnectMailserver() + public function testdisconnectMailserver(): void { $inboundEmail = BeanFactory::newBean('InboundEmail'); // Execute the method and test that it works and doesn't throw an exception. try { $inboundEmail->disconnectMailserver(); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail("\nException: " . get_class($e) . ": " . $e->getMessage() . "\nin " . $e->getFile() . ':' . $e->getLine() . "\nTrace:\n" . $e->getTraceAsString() . "\n"); + self::fail("\nException: " . get_class($e) . ": " . $e->getMessage() . "\nin " . $e->getFile() . ':' . $e->getLine() . "\nTrace:\n" . $e->getTraceAsString() . "\n"); } } - public function testconnectMailserver() + public function testconnectMailserver(): void { $inboundEmail = BeanFactory::newBean('InboundEmail'); //test with default parameters $result = $inboundEmail->connectMailserver(); - $this->assertEquals('false', $result); + self::assertEquals('false', $result); //test with test and force true $result = $inboundEmail->connectMailserver(true, true); - $this->assertEquals("Can't open mailbox {:/service=}: invalid remote specification

Please check your settings and try again.", $result); + self::assertEquals("Can't open mailbox {:/service=}: invalid remote specification

Please check your settings and try again.", $result); } - public function testcheckImap() + public function testcheckImap(): void { $inboundEmail = BeanFactory::newBean('InboundEmail'); // Execute the method and test that it works and doesn't throw an exception. try { $inboundEmail->checkImap(); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail("\nException: " . get_class($e) . ": " . $e->getMessage() . "\nin " . $e->getFile() . ':' . $e->getLine() . "\nTrace:\n" . $e->getTraceAsString() . "\n"); + self::fail("\nException: " . get_class($e) . ": " . $e->getMessage() . "\nin " . $e->getFile() . ':' . $e->getLine() . "\nTrace:\n" . $e->getTraceAsString() . "\n"); } } - public function testget_summary_text() + public function testget_summary_text(): void { $inboundEmail = BeanFactory::newBean('InboundEmail'); //test without setting name - $this->assertEquals(null, $inboundEmail->get_summary_text()); + self::assertEquals(null, $inboundEmail->get_summary_text()); //test with name set $inboundEmail->name = 'test'; - $this->assertEquals('test', $inboundEmail->get_summary_text()); + self::assertEquals('test', $inboundEmail->get_summary_text()); } - public function testcreate_export_query() + public function testcreate_export_query(): void { $inboundEmail = BeanFactory::newBean('InboundEmail'); //test with empty string params $expected = " SELECT inbound_email.* , jt0.user_name created_by_name , jt0.created_by created_by_name_owner , 'Users' created_by_name_mod FROM inbound_email LEFT JOIN users jt0 ON jt0.id=inbound_email.created_by AND jt0.deleted=0\n AND jt0.deleted=0 where inbound_email.deleted=0"; $actual = $inboundEmail->create_export_query('', ''); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); //test with valid string params $expected = " SELECT inbound_email.* , jt0.user_name created_by_name , jt0.created_by created_by_name_owner , 'Users' created_by_name_mod FROM inbound_email LEFT JOIN users jt0 ON jt0.id=inbound_email.created_by AND jt0.deleted=0\n AND jt0.deleted=0 where (jt0.user_name=\"\") AND inbound_email.deleted=0 ORDER BY inbound_email.id"; $actual = $inboundEmail->create_export_query('id', 'jt0.user_name=""'); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } - public function testget_list_view_data() + public function testget_list_view_data(): void { $inboundEmail = BeanFactory::newBean('InboundEmail'); @@ -2579,13 +2275,13 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase 'GLOBAL_PERSONAL_STRING' => 'group', ); - $this->assertTrue(is_array($result)); - $this->assertEquals($expected, $result); + self::assertIsArray($result); + self::assertEquals($expected, $result); $result = $inboundEmail->get_list_view_data(); } - public function testfill_in_additional_list_fields() + public function testfill_in_additional_list_fields(): void { $inboundEmail = BeanFactory::newBean('InboundEmail'); @@ -2593,13 +2289,13 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase $result = $inboundEmail->fill_in_additional_list_fields(); - $this->assertEquals($inboundEmail->tls, 'tls'); - $this->assertEquals($inboundEmail->ca, 'ca'); - $this->assertEquals($inboundEmail->ssl, 'ssl'); - $this->assertEquals($inboundEmail->protocol, 'protocol'); + self::assertEquals('tls', $inboundEmail->tls); + self::assertEquals('ca', $inboundEmail->ca); + self::assertEquals('ssl', $inboundEmail->ssl); + self::assertEquals('protocol', $inboundEmail->protocol); } - public function testfill_in_additional_detail_fields() + public function testfill_in_additional_detail_fields(): void { $inboundEmail = BeanFactory::newBean('InboundEmail'); @@ -2607,13 +2303,13 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase $result = $inboundEmail->fill_in_additional_detail_fields(); - $this->assertEquals($inboundEmail->tls, 'tls'); - $this->assertEquals($inboundEmail->ca, 'ca'); - $this->assertEquals($inboundEmail->ssl, 'ssl'); - $this->assertEquals($inboundEmail->protocol, 'protocol'); + self::assertEquals('tls', $inboundEmail->tls); + self::assertEquals('ca', $inboundEmail->ca); + self::assertEquals('ssl', $inboundEmail->ssl); + self::assertEquals('protocol', $inboundEmail->protocol); } - public function testisAutoImport() + public function testisAutoImport(): void { $inboundEmail = BeanFactory::newBean('InboundEmail'); @@ -2621,114 +2317,53 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase //test with invalid user $result = $inboundEmail->isAutoImport($user); - $this->assertEquals(false, $result); + self::assertEquals(false, $result); //test with default user $user->retrieve('1'); $result = $inboundEmail->isAutoImport($user); - $this->assertEquals(false, $result); + self::assertEquals(false, $result); } - public function testcleanOutCache() + public function testcleanOutCache(): void { $inboundEmail = BeanFactory::newBean('InboundEmail'); // Execute the method and test that it works and doesn't throw an exception. try { $inboundEmail->cleanOutCache(); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail("\nException: " . get_class($e) . ": " . $e->getMessage() . "\nin " . $e->getFile() . ':' . $e->getLine() . "\nTrace:\n" . $e->getTraceAsString() . "\n"); + self::fail("\nException: " . get_class($e) . ": " . $e->getMessage() . "\nin " . $e->getFile() . ':' . $e->getLine() . "\nTrace:\n" . $e->getTraceAsString() . "\n"); } } - public function testcopyEmails() - { -// $this->markTestIncomplete('Propably an error level changed in the code?'); -// -// -// $inboundEmail = BeanFactory::newBean('InboundEmail'); -// -// $inboundEmail->id = 1; -// -// // Execute the method and test that it works and doesn't throw an exception. -// try { -// $result = $inboundEmail->copyEmails(1, 'INBOX', 1, 'TRASH', array(1)); -// $this->assertTrue(true); -// } catch (Exception $e) { -// $this->fail("\nException: " . get_class($e) . ": " . $e->getMessage() . "\nin " . $e->getFile() . ':' . $e->getLine() . "\nTrace:\n" . $e->getTraceAsString() . "\n"); -// } - } - - public function testmoveEmails() - { -// $this->markTestIncomplete('Propably an error level changed in the code?'); -// -// -// $inboundEmail = BeanFactory::newBean('InboundEmail'); -// -// $inboundEmail->id = 1; -// -// $result = $inboundEmail->moveEmails(1, 'INBOX', 1, 'TRASH', array(1)); -// $this->assertEquals(false, $result); -// -// $result = $inboundEmail->moveEmails(1, 'INBOX', 2, 'TRASH', array(1)); -// $this->assertEquals(false, $result); - } - - public function testgetTempFilename() - { -// $this->markTestIncomplete('Propably an error level changed in the code?'); -// $inboundEmail = BeanFactory::newBean('InboundEmail'); -// -// $inboundEmail->compoundMessageId = 'cmid'; -// -// //test with default false -// $result = $inboundEmail->getTempFilename(); -// $this->assertEquals('cmid0', $result); -// -// //test with true -// $result = $inboundEmail->getTempFilename(true); -// $this->assertEquals('cmid', $result); - } - - public function testdeleteMessageOnMailServer() - { -// $this->markTestIncomplete('Deprecated way to check imap'); -// -// $inboundEmail = BeanFactory::newBean('InboundEmail'); -// -// $result = $inboundEmail->deleteMessageOnMailServer('1'); -// -// $this->assertEquals(false, $result); - } - - public function testdeleteMessageOnMailServerForPop3() + public function testdeleteMessageOnMailServerForPop3(): void { $inboundEmail = BeanFactory::newBean('InboundEmail'); // Execute the method and test that it works and doesn't throw an exception. try { $inboundEmail->deleteMessageOnMailServerForPop3('1'); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail("\nException: " . get_class($e) . ": " . $e->getMessage() . "\nin " . $e->getFile() . ':' . $e->getLine() . "\nTrace:\n" . $e->getTraceAsString() . "\n"); + self::fail("\nException: " . get_class($e) . ": " . $e->getMessage() . "\nin " . $e->getFile() . ':' . $e->getLine() . "\nTrace:\n" . $e->getTraceAsString() . "\n"); } } - public function testisPop3Protocol() + public function testisPop3Protocol(): void { $inboundEmail = BeanFactory::newBean('InboundEmail'); //test without setting protocol - $this->assertEquals(false, $inboundEmail->isPop3Protocol()); + self::assertEquals(false, $inboundEmail->isPop3Protocol()); //test with pop3 protocol $inboundEmail->protocol = 'pop3'; - $this->assertEquals(true, $inboundEmail->isPop3Protocol()); + self::assertEquals(true, $inboundEmail->isPop3Protocol()); } - public function testSetAndGetUsersDefaultOutboundServerId() + public function testSetAndGetUsersDefaultOutboundServerId(): void { $inboundEmail = BeanFactory::newBean('InboundEmail'); @@ -2742,29 +2377,10 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase $result = $inboundEmail->getUsersDefaultOutboundServerId($user); $isValidator = new SuiteCRM\Utility\SuiteValidator(); - $this->assertTrue($isValidator->isValidId($result)); + self::assertTrue($isValidator->isValidId($result)); } - public function testsetEmailForDisplay() - { -// $this->markTestIncomplete('Deprecated pop3 test'); -// -// $inboundEmail = BeanFactory::newBean('InboundEmail'); -// -// $result = $inboundEmail->setEmailForDisplay(''); -// $this->assertEquals('NOOP', $result); -// -// //test with pop3 protocol and default parameters -// $inboundEmail->protocol = 'pop3'; -// $result = $inboundEmail->setEmailForDisplay('1'); -// $this->assertEquals('error', $result); -// -// //test with pop3 protocol and all parameters true -// $result = $inboundEmail->setEmailForDisplay('1', true, true, true); -// $this->assertEquals('error', $result); - } - - public function testdisplayOneEmail() + public function testdisplayOneEmail(): void { $inboundEmail = BeanFactory::newBean('InboundEmail'); @@ -2783,10 +2399,10 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase ); $result = $inboundEmail->displayOneEmail(1, 'INBOX'); - $this->assertEquals($expected, $result); + self::assertEquals($expected, $result); } - public function testcollapseLongMailingList() + public function testcollapseLongMailingList(): void { $inboundEmail = BeanFactory::newBean('InboundEmail'); @@ -2796,10 +2412,10 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase $actual = $inboundEmail->collapseLongMailingList($emails); - $this->assertEquals($expected, $actual); + self::assertEquals($expected, $actual); } - public function testsortFetchedOverview() + public function testsortFetchedOverview(): void { $inboundEmail = BeanFactory::newBean('InboundEmail'); @@ -2826,14 +2442,14 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase //execute the method to sort the objects array descending and verify the order $result = $inboundEmail->sortFetchedOverview($arr, 3, 'DESC'); - $this->assertEquals('subject 2', $result['retArr'][0]->subject); + self::assertEquals('subject 2', $result['retArr'][0]->subject); //execute the method to sort the objects array ascending and verify the order $result = $inboundEmail->sortFetchedOverview($arr, 3, 'ASC'); - $this->assertEquals('subject 1', $result['retArr'][0]->subject); + self::assertEquals('subject 1', $result['retArr'][0]->subject); } - public function testdisplayFolderContents() + public function testdisplayFolderContents(): void { $inboundEmail = BeanFactory::newBean('InboundEmail'); @@ -2843,28 +2459,10 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase $result = $inboundEmail->displayFolderContents('INBOX', 'false', 1); - $this->assertEquals($expected, $result); + self::assertEquals($expected, $result); } - public function testcreateUserSubscriptionsForGroupAccount() - { -// $this->markTestIncomplete("Fatal error: Class 'Team' not found"); -// -//// -//// -//// //unset and reconnect Db to resolve mysqli fetch exeception -//// $db = DBManagerFactory::getInstance(); -//// unset($db->database); -//// $db->checkConnection(); -//// -//// $inboundEmail = BeanFactory::newBean('InboundEmail'); -//// -//// //$inboundEmail->createUserSubscriptionsForGroupAccount(); -//// -//// - } - - public function testcreateAutoImportSugarFolder() + public function testcreateAutoImportSugarFolder(): void { //unset and reconnect Db to resolve mysqli fetch exeception $db = DBManagerFactory::getInstance(); @@ -2878,11 +2476,11 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase $result = $inboundEmail->createAutoImportSugarFolder(); //test for record ID to verify that record is saved - $this->assertTrue(isset($result)); - $this->assertEquals(36, strlen($result)); + self::assertTrue(isset($result)); + self::assertEquals(36, strlen($result)); } - public function testgetMailboxes() + public function testgetMailboxes(): void { $inboundEmail = BeanFactory::newBean('InboundEmail'); @@ -2891,14 +2489,14 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase //test with justRaw default/false $result = $inboundEmail->getMailboxes(); - $this->assertEquals($expected, $result); + self::assertEquals($expected, $result); //test with justRaw true $result = $inboundEmail->getMailboxes(true); - $this->assertEquals($inboundEmail->mailboxarray, $result); + self::assertEquals($inboundEmail->mailboxarray, $result); } - public function testgetMailBoxesForGroupAccount() + public function testgetMailBoxesForGroupAccount(): void { $inboundEmail = BeanFactory::newBean('InboundEmail'); @@ -2908,10 +2506,10 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase $result = $inboundEmail->getMailBoxesForGroupAccount(); - $this->assertEquals($expected, $result); + self::assertEquals($expected, $result); } - public function testretrieveMailBoxFolders() + public function testretrieveMailBoxFolders(): void { $inboundEmail = BeanFactory::newBean('InboundEmail'); @@ -2919,10 +2517,10 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase $inboundEmail->retrieveMailBoxFolders(); - $this->assertEquals(array('INBOX', 'OUTBOX', 'TRASH'), $inboundEmail->mailboxarray); + self::assertEquals(array('INBOX', 'OUTBOX', 'TRASH'), $inboundEmail->mailboxarray); } - public function testinsertMailBoxFolders() + public function testinsertMailBoxFolders(): void { $inboundEmail = BeanFactory::newBean('InboundEmail'); @@ -2931,22 +2529,20 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase // Execute the method and test that it works and doesn't throw an exception. try { $inboundEmail->insertMailBoxFolders(array('INBOX', 'OUTBOX')); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail("\nException: " . get_class($e) . ": " . $e->getMessage() . "\nin " . $e->getFile() . ':' . $e->getLine() . "\nTrace:\n" . $e->getTraceAsString() . "\n"); + self::fail("\nException: " . get_class($e) . ": " . $e->getMessage() . "\nin " . $e->getFile() . ':' . $e->getLine() . "\nTrace:\n" . $e->getTraceAsString() . "\n"); } } - public function testretrieveDelimiter() + public function testretrieveDelimiter(): void { - $inboundEmail = BeanFactory::newBean('InboundEmail'); + $result = BeanFactory::newBean('InboundEmail')->retrieveDelimiter(); - $result = $inboundEmail->retrieveDelimiter(); - - $this->assertEquals('.', $result); + self::assertEquals('.', $result); } - public function testgenerateFlatArrayFromMultiDimArray() + public function testgenerateFlatArrayFromMultiDimArray(): void { $inboundEmail = BeanFactory::newBean('InboundEmail'); @@ -2956,10 +2552,10 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase $result = $inboundEmail->generateFlatArrayFromMultiDimArray($arraymbox, '.'); - $this->assertEquals($expected, $result); + self::assertEquals($expected, $result); } - public function testgenerateMultiDimArrayFromFlatArray() + public function testgenerateMultiDimArrayFromFlatArray(): void { $inboundEmail = BeanFactory::newBean('InboundEmail'); @@ -2967,10 +2563,10 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase $result = $inboundEmail->generateMultiDimArrayFromFlatArray(array('INBOX.TRASH', 'OUTBOX.TRASH'), '.'); - $this->assertEquals($expected, $result); + self::assertEquals($expected, $result); } - public function testgenerateArrayData() + public function testgenerateArrayData(): void { $inboundEmail = BeanFactory::newBean('InboundEmail'); @@ -2980,21 +2576,19 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase $inboundEmail->generateArrayData('MAIN', $arraymbox, $result, '.'); - $this->assertEquals($expected, $result); + self::assertEquals($expected, $result); } - public function testsortMailboxes() + public function testsortMailboxes(): void { - $inboundEmail = BeanFactory::newBean('InboundEmail'); - - $result = $inboundEmail->sortMailboxes('INBOX.TRASH', array()); + $result = BeanFactory::newBean('InboundEmail')->sortMailboxes('INBOX.TRASH', array()); $expected = array('INBOX' => array('TRASH' => 'TRASH')); - $this->assertEquals($expected, $result); + self::assertEquals($expected, $result); } - public function testgetServiceString() + public function testgetServiceString(): void { $inboundEmail = BeanFactory::newBean('InboundEmail'); @@ -3002,23 +2596,23 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase $result = $inboundEmail->getServiceString(); - $this->assertEquals('/tls/ca/ssl/protocol', $result); + self::assertEquals('/tls/ca/ssl/protocol', $result); } - public function testgetNewEmailsForSyncedMailbox() + public function testgetNewEmailsForSyncedMailbox(): void { $inboundEmail = BeanFactory::newBean('InboundEmail'); // Execute the method and test that it works and doesn't throw an exception. try { $inboundEmail->getNewEmailsForSyncedMailbox(); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail("\nException: " . get_class($e) . ": " . $e->getMessage() . "\nin " . $e->getFile() . ':' . $e->getLine() . "\nTrace:\n" . $e->getTraceAsString() . "\n"); + self::fail("\nException: " . get_class($e) . ": " . $e->getMessage() . "\nin " . $e->getFile() . ':' . $e->getLine() . "\nTrace:\n" . $e->getTraceAsString() . "\n"); } } - public function testimportMessages() + public function testimportMessages(): void { $inboundEmail = BeanFactory::newBean('InboundEmail'); @@ -3027,23 +2621,18 @@ class InboundEmailTest extends SuitePHPUnitFrameworkTestCase $inboundEmail->protocol = 'pop3'; $inboundEmail->importMessages(); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail("\nException: " . get_class($e) . ": " . $e->getMessage() . "\nin " . $e->getFile() . ':' . $e->getLine() . "\nTrace:\n" . $e->getTraceAsString() . "\n"); + self::fail("\nException: " . get_class($e) . ": " . $e->getMessage() . "\nin " . $e->getFile() . ':' . $e->getLine() . "\nTrace:\n" . $e->getTraceAsString() . "\n"); } } - public function testOverview() + public function testOverview(): void { -// $this->markTestIncomplete('Fatal error: Class \'Overview\' not found'); -//// -//// -//// // Execute the constructor and check for the Object type and attributes -//// $overview = new Overview(); -//// -//// $this->assertInstanceOf('Overview', $overview); -//// -//// $this->assertTrue(is_array($overview->fieldDefs)); -//// $this->assertTrue(is_array($overview->indices)); + $overview = new Overview(); + + self::assertInstanceOf('Overview', $overview); + self::assertIsArray($overview->fieldDefs); + self::assertIsArray($overview->indices); } } diff --git a/tests/unit/phpunit/modules/Leads/LeadTest.php b/tests/unit/phpunit/modules/Leads/LeadTest.php index ab9e64cd2..976861999 100644 --- a/tests/unit/phpunit/modules/Leads/LeadTest.php +++ b/tests/unit/phpunit/modules/Leads/LeadTest.php @@ -14,90 +14,90 @@ class LeadTest extends SuitePHPUnitFrameworkTestCase $GLOBALS['mod_strings'] = return_module_language($GLOBALS['current_language'], 'Leads'); } - public function testLead() + public function testLead(): void { // Execute the constructor and check for the Object type and attributes $lead = BeanFactory::getBean('Leads'); - $this->assertInstanceOf('Lead', $lead); - $this->assertInstanceOf('Person', $lead); - $this->assertInstanceOf('SugarBean', $lead); + self::assertInstanceOf('Lead', $lead); + self::assertInstanceOf('Person', $lead); + self::assertInstanceOf('SugarBean', $lead); - $this->assertAttributeEquals('Leads', 'module_dir', $lead); - $this->assertAttributeEquals('Lead', 'object_name', $lead); - $this->assertAttributeEquals('Leads', 'object_names', $lead); - $this->assertAttributeEquals('leads', 'table_name', $lead); + self::assertEquals('Leads', $lead->module_dir); + self::assertEquals('Lead', $lead->object_name); + self::assertEquals('Leads', $lead->object_names); + self::assertEquals('leads', $lead->table_name); - $this->assertAttributeEquals(true, 'new_schema', $lead); - $this->assertAttributeEquals(true, 'importable', $lead); + self::assertEquals(true, $lead->new_schema); + self::assertEquals(true, $lead->importable); } - public function testget_account() + public function testget_account(): void { $lead = BeanFactory::getBean('Leads'); //test without pre settting attributes $result = $lead->get_account(); - $this->assertEquals(null, $result); + self::assertEquals(null, $result); //test with required attributes preset $lead->account_id = 1; $result = $lead->get_account(); - $this->assertEquals(null, $result); + self::assertEquals(null, $result); } - public function testget_opportunity() + public function testget_opportunity(): void { $lead = BeanFactory::getBean('Leads'); //test without pre settting attributes $result = $lead->get_opportunity(); - $this->assertEquals(null, $result); + self::assertEquals(null, $result); //test with required attributes preset $lead->opportunity_id = 1; $result = $lead->get_opportunity(); - $this->assertEquals(null, $result); + self::assertEquals(null, $result); } - public function testget_contact() + public function testget_contact(): void { $lead = BeanFactory::getBean('Leads'); //test without pre settting attributes $result = $lead->get_contact(); - $this->assertEquals(null, $result); + self::assertEquals(null, $result); //test with required attributes preset $lead->contact_id = 1; $result = $lead->get_contact(); - $this->assertEquals(null, $result); + self::assertEquals(null, $result); } - public function testcreate_list_query() + public function testcreate_list_query(): void { - $this->markTestIncomplete('Breaks on php 7.1'); + self::markTestIncomplete('Breaks on php 7.1'); $lead = BeanFactory::getBean('Leads'); //test with empty string params $expected = "SELECT leads.*, users.user_name assigned_user_name,leads_cstm.* FROM leads LEFT JOIN users\n ON leads.assigned_user_id=users.id LEFT JOIN email_addr_bean_rel eabl ON eabl.bean_id = leads.id AND eabl.bean_module = 'Leads' and eabl.primary_address = 1 and eabl.deleted=0 LEFT JOIN email_addresses ea ON (ea.id = eabl.email_address_id) LEFT JOIN leads_cstm ON leads.id = leads_cstm.id_c where leads.deleted=0 "; $actual = $lead->create_list_query('', ''); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); //test with valid string params $expected = "SELECT leads.*, users.user_name assigned_user_name,leads_cstm.* FROM leads LEFT JOIN users\n ON leads.assigned_user_id=users.id LEFT JOIN email_addr_bean_rel eabl ON eabl.bean_id = leads.id AND eabl.bean_module = 'Leads' and eabl.primary_address = 1 and eabl.deleted=0 LEFT JOIN email_addresses ea ON (ea.id = eabl.email_address_id) LEFT JOIN leads_cstm ON leads.id = leads_cstm.id_c where (users.user_name=\"\") AND leads.deleted=0 ORDER BY leads.id"; $actual = $lead->create_list_query('leads.id', 'users.user_name=""'); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } /** * @todo: NEEDS FIXING! */ - public function testcreate_new_list_query() + public function testcreate_new_list_query(): void { /* $lead = BeanFactory::getBean('Leads'); @@ -113,12 +113,12 @@ class LeadTest extends SuitePHPUnitFrameworkTestCase $actual = $lead->create_new_list_query('leads.id','users.user_name=""'); $this->assertSame($expected,$actual); */ - $this->assertTrue(true, "NEEDS FIXING!"); + self::assertTrue(true, "NEEDS FIXING!"); } - public function testSaveAndConverted_lead() + public function testSaveAndConverted_lead(): void { - $this->markTestSkipped("converted_lead: Error in query, id's not properly escaped "); + self::markTestSkipped("converted_lead: Error in query, id's not properly escaped "); $lead = BeanFactory::getBean('Leads'); @@ -129,9 +129,9 @@ class LeadTest extends SuitePHPUnitFrameworkTestCase $result = $lead->save(); //test for record ID to verify that record is saved - $this->assertTrue(isset($lead->id)); - $this->assertEquals(36, strlen($lead->id)); - $this->assertEquals("New", $lead->status); + self::assertTrue(isset($lead->id)); + self::assertEquals(36, strlen($lead->id)); + self::assertEquals("New", $lead->status); //test converted_lead method after saving @@ -149,10 +149,10 @@ class LeadTest extends SuitePHPUnitFrameworkTestCase //mark the record as deleted and verify that this record cannot be retrieved anymore. $lead->mark_deleted($lead->id); $result = $lead->retrieve($lead->id); - $this->assertEquals(null, $result); + self::assertEquals(null, $result); } - public function testfill_in_additional_list_fields() + public function testfill_in_additional_list_fields(): void { $lead = BeanFactory::newBean('Leads'); @@ -161,10 +161,10 @@ class LeadTest extends SuitePHPUnitFrameworkTestCase $lead->fill_in_additional_list_fields(); - $this->assertEquals("firstn lastn", $lead->name); + self::assertEquals("firstn lastn", $lead->name); } - public function testfill_in_additional_detail_fields() + public function testfill_in_additional_detail_fields(): void { $lead = BeanFactory::getBean('Leads'); @@ -173,10 +173,10 @@ class LeadTest extends SuitePHPUnitFrameworkTestCase $lead->fill_in_additional_detail_fields(); - $this->assertEquals("firstn lastn", $lead->name); + self::assertEquals("firstn lastn", $lead->name); } - public function testget_list_view_data() + public function testget_list_view_data(): void { $lead = BeanFactory::getBean('Leads'); @@ -199,14 +199,14 @@ class LeadTest extends SuitePHPUnitFrameworkTestCase $actual = $lead->get_list_view_data(); //$this->assertSame($expected, $actual); - $this->assertEquals($expected['NAME'], $actual['NAME']); - $this->assertEquals($expected['DELETED'], $actual['DELETED']); - $this->assertEquals($expected['FULL_NAME'], $actual['FULL_NAME']); - $this->assertEquals($expected['DO_NOT_CALL'], $actual['DO_NOT_CALL']); - $this->assertEquals($expected['EMAIL1_LINK'], $actual['EMAIL1_LINK']); + self::assertEquals($expected['NAME'], $actual['NAME']); + self::assertEquals($expected['DELETED'], $actual['DELETED']); + self::assertEquals($expected['FULL_NAME'], $actual['FULL_NAME']); + self::assertEquals($expected['DO_NOT_CALL'], $actual['DO_NOT_CALL']); + self::assertEquals($expected['EMAIL1_LINK'], $actual['EMAIL1_LINK']); } - public function testget_linked_fields() + public function testget_linked_fields(): void { $lead = BeanFactory::getBean('Leads'); @@ -234,14 +234,14 @@ class LeadTest extends SuitePHPUnitFrameworkTestCase 'SecurityGroups', ); $actual = $lead->get_linked_fields(); - $this->assertTrue(is_array($actual)); + self::assertIsArray($actual); sort($expected); $actualKeys = array_keys($actual); sort($actualKeys); - $this->assertSame($expected, $actualKeys); + self::assertSame($expected, $actualKeys); } - public function testbuild_generic_where_clause() + public function testbuild_generic_where_clause(): void { self::markTestSkipped('State dependecy'); @@ -250,16 +250,16 @@ class LeadTest extends SuitePHPUnitFrameworkTestCase //test with empty string params $expected = "leads.last_name like '%' or leads.account_name like '%' or leads.first_name like '%' or ea.email_address like '%'"; $actual = $lead->build_generic_where_clause(""); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); //test with valid string params $expected = "leads.last_name like '%' or leads.account_name like '%' or leads.first_name like '%' or ea.email_address like '%'"; $actual = $lead->build_generic_where_clause("123"); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } - public function testset_notification_body() + public function testset_notification_body(): void { $lead = BeanFactory::getBean('Leads'); @@ -274,31 +274,31 @@ class LeadTest extends SuitePHPUnitFrameworkTestCase $result = $lead->set_notification_body(new Sugar_Smarty(), $lead); - $this->assertEquals("Mr firstn lastn", $result->_tpl_vars['LEAD_NAME']); - $this->assertEquals($lead->lead_source, $result->_tpl_vars['LEAD_SOURCE']); - $this->assertEquals($lead->status, $result->_tpl_vars['LEAD_STATUS']); - $this->assertEquals($lead->description, $result->_tpl_vars['LEAD_DESCRIPTION']); + self::assertEquals("Mr firstn lastn", $result->_tpl_vars['LEAD_NAME']); + self::assertEquals($lead->lead_source, $result->_tpl_vars['LEAD_SOURCE']); + self::assertEquals($lead->status, $result->_tpl_vars['LEAD_STATUS']); + self::assertEquals($lead->description, $result->_tpl_vars['LEAD_DESCRIPTION']); } - public function testbean_implements() + public function testbean_implements(): void { $lead = BeanFactory::getBean('Leads'); - $this->assertEquals(false, $lead->bean_implements('')); //test with blank value - $this->assertEquals(false, $lead->bean_implements('test')); //test with invalid value - $this->assertEquals(true, $lead->bean_implements('ACL')); //test with valid value + self::assertEquals(false, $lead->bean_implements('')); //test with blank value + self::assertEquals(false, $lead->bean_implements('test')); //test with invalid value + self::assertEquals(true, $lead->bean_implements('ACL')); //test with valid value } - public function testlistviewACLHelper() + public function testlistviewACLHelper(): void { $lead = BeanFactory::getBean('Leads'); $expected = array("MAIN" => "a", "ACCOUNT" => "a", "OPPORTUNITY" => "a", "CONTACT" => "a"); $actual = $lead->listviewACLHelper(); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } - public function testconvertCustomFieldsForm() + public function testconvertCustomFieldsForm(): void { $lead = BeanFactory::getBean('Leads'); @@ -308,11 +308,11 @@ class LeadTest extends SuitePHPUnitFrameworkTestCase $result = $lead->convertCustomFieldsForm($form, $tempBean, $prefix); - $this->assertEquals(true, $result); - $this->assertgreaterThanOrEqual("", $form); //no filed with source = custom_fields + self::assertEquals(true, $result); + self::assertgreaterThanOrEqual("", $form); //no filed with source = custom_fields } - public function testget_unlinked_email_query() + public function testget_unlinked_email_query(): void { $lead = BeanFactory::getBean('Leads'); @@ -324,10 +324,10 @@ class LeadTest extends SuitePHPUnitFrameworkTestCase (select eb.email_id from emails_beans eb where eb.bean_module ='Leads' and eb.bean_id = '') ) derivedemails on derivedemails.email_id = emails.id"; $actual = $lead->get_unlinked_email_query(); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } - public function testget_old_related_calls() + public function testget_old_related_calls(): void { $lead = BeanFactory::getBean('Leads'); @@ -340,19 +340,19 @@ class LeadTest extends SuitePHPUnitFrameworkTestCase $expected['join_tables'][0] = ''; $actual = $lead->get_old_related_calls(); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } - public function testgetActivitiesOptions() + public function testGetActivitiesOptions(): void { $lead = BeanFactory::getBean('Leads'); - $expected = array("copy" => "Copy", "move" => "Move", "donothing" => "Do Nothing"); - $actual = $lead->getActivitiesOptions(); - $this->assertSame($expected, $actual); + $expected = ["copy" => "Copy", "move" => "Move", "donothing" => "Do Nothing"]; + $actual = $lead::getActivitiesOptions(); + self::assertSame($expected, $actual); } - public function testget_old_related_meetings() + public function testget_old_related_meetings(): void { $lead = BeanFactory::getBean('Leads'); @@ -365,6 +365,6 @@ class LeadTest extends SuitePHPUnitFrameworkTestCase $expected['join_tables'][0] = ''; $actual = $lead->get_old_related_meetings(); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } } diff --git a/tests/unit/phpunit/modules/Meetings/MeetingTest.php b/tests/unit/phpunit/modules/Meetings/MeetingTest.php index 9da268db2..56641b8e4 100644 --- a/tests/unit/phpunit/modules/Meetings/MeetingTest.php +++ b/tests/unit/phpunit/modules/Meetings/MeetingTest.php @@ -13,57 +13,56 @@ class MeetingTest extends SuitePHPUnitFrameworkTestCase $current_user = BeanFactory::newBean('Users'); } - public function testMeeting() + public function testMeeting(): void { // Execute the constructor and check for the Object type and attributes $meeting = BeanFactory::newBean('Meetings'); - $this->assertInstanceOf('Meeting', $meeting); - $this->assertInstanceOf('SugarBean', $meeting); + self::assertInstanceOf('Meeting', $meeting); + self::assertInstanceOf('SugarBean', $meeting); - $this->assertAttributeEquals('Meetings', 'module_dir', $meeting); - $this->assertAttributeEquals('Meeting', 'object_name', $meeting); - $this->assertAttributeEquals('meetings', 'table_name', $meeting); + self::assertEquals('Meetings', $meeting->module_dir); + self::assertEquals('Meeting', $meeting->object_name); + self::assertEquals('meetings', $meeting->table_name); - $this->assertAttributeEquals(true, 'new_schema', $meeting); - $this->assertAttributeEquals(true, 'importable', $meeting); - $this->assertAttributeEquals(false, 'syncing', $meeting); - $this->assertAttributeEquals(true, 'update_vcal', $meeting); + self::assertEquals(true, $meeting->new_schema); + self::assertEquals(true, $meeting->importable); + self::assertEquals(false, $meeting->syncing); + self::assertEquals(true, $meeting->update_vcal); - $this->assertAttributeEquals('meetings_users', 'rel_users_table', $meeting); - $this->assertAttributeEquals('meetings_contacts', 'rel_contacts_table', $meeting); - $this->assertAttributeEquals('meetings_leads', 'rel_leads_table', $meeting); + self::assertEquals('meetings_users', $meeting->rel_users_table); + self::assertEquals('meetings_contacts', $meeting->rel_contacts_table); + self::assertEquals('meetings_leads', $meeting->rel_leads_table); - $this->assertAttributeEquals(null, 'cached_get_users', $meeting); - $this->assertAttributeEquals(false, 'date_changed', $meeting); + self::assertEquals(null, $meeting->cached_get_users); + self::assertEquals(false, $meeting->date_changed); } - public function testACLAccess() + public function testACLAccess(): void { $meeting = BeanFactory::newBean('Meetings'); //test without recurring_source - $this->assertEquals(true, $meeting->ACLAccess('edit')); - $this->assertEquals(true, $meeting->ACLAccess('save')); - $this->assertEquals(true, $meeting->ACLAccess('editview')); - $this->assertEquals(true, $meeting->ACLAccess('delete')); + self::assertEquals(true, $meeting->ACLAccess('edit')); + self::assertEquals(true, $meeting->ACLAccess('save')); + self::assertEquals(true, $meeting->ACLAccess('editview')); + self::assertEquals(true, $meeting->ACLAccess('delete')); //test with recurring_source $meeting->recurring_source = 'test'; - $this->assertEquals(false, $meeting->ACLAccess('edit')); - $this->assertEquals(false, $meeting->ACLAccess('save')); - $this->assertEquals(false, $meeting->ACLAccess('editview')); - $this->assertEquals(false, $meeting->ACLAccess('delete')); + self::assertEquals(false, $meeting->ACLAccess('edit')); + self::assertEquals(false, $meeting->ACLAccess('save')); + self::assertEquals(false, $meeting->ACLAccess('editview')); + self::assertEquals(false, $meeting->ACLAccess('delete')); } - public function testhasIntegratedMeeting() + public function testhasIntegratedMeeting(): void { - $meeting = BeanFactory::newBean('Meetings'); - $result = $meeting->hasIntegratedMeeting(); - $this->assertEquals(false, $result); + $result = BeanFactory::newBean('Meetings')->hasIntegratedMeeting(); + self::assertEquals(false, $result); } - public function testSaveAndMarkdeletedAndSetAcceptStatus() + public function testSaveAndMarkdeletedAndSetAcceptStatus(): void { $meeting = BeanFactory::newBean('Meetings'); @@ -79,8 +78,8 @@ class MeetingTest extends SuitePHPUnitFrameworkTestCase $meeting->save(); //test for record ID to verify that record is saved - $this->assertTrue(isset($meeting->id)); - $this->assertEquals(36, strlen($meeting->id)); + self::assertTrue(isset($meeting->id)); + self::assertEquals(36, strlen($meeting->id)); /* Test set_accept_status method */ @@ -102,27 +101,22 @@ class MeetingTest extends SuitePHPUnitFrameworkTestCase //mark the record as deleted and verify that this record cannot be retrieved anymore. $meeting->mark_deleted($meeting->id); $result = $meeting->retrieve($meeting->id); - $this->assertEquals(null, $result); + self::assertEquals(null, $result); } - public function testget_summary_text() + public function testget_summary_text(): void { $meeting = BeanFactory::newBean('Meetings'); //test without setting name - $this->assertEquals(null, $meeting->get_summary_text()); + self::assertEquals(null, $meeting->get_summary_text()); //test with name set $meeting->name = 'test'; - $this->assertEquals('test', $meeting->get_summary_text()); + self::assertEquals('test', $meeting->get_summary_text()); } - public function testcreate_export_query() - { -// $this->markTestIncomplete('export query produces queries which fields chagne order in different enironments'); - } - - public function testfill_in_additional_detail_fields() + public function testfill_in_additional_detail_fields(): void { $meeting = BeanFactory::newBean('Meetings'); @@ -135,23 +129,23 @@ class MeetingTest extends SuitePHPUnitFrameworkTestCase $meeting->fill_in_additional_detail_fields(); //verify effected atributes - $this->assertEquals('Administrator', $meeting->assigned_user_name); - $this->assertEquals('Administrator', $meeting->created_by_name); - $this->assertEquals('Administrator', $meeting->modified_by_name); - $this->assertTrue(isset($meeting->time_start_hour)); - $this->assertTrue(isset($meeting->date_start)); - $this->assertTrue(isset($meeting->time_start)); - $this->assertTrue(isset($meeting->duration_hours)); - $this->assertTrue(isset($meeting->duration_minutes)); - $this->assertEquals(-1, $meeting->reminder_time); - $this->assertTrue(isset($meeting->reminder_time)); - $this->assertEquals(false, $meeting->reminder_checked); - $this->assertEquals(-1, $meeting->email_reminder_time); - $this->assertEquals(false, $meeting->email_reminder_checked); - $this->assertEquals('Accounts', $meeting->parent_type); + self::assertEquals('Administrator', $meeting->assigned_user_name); + self::assertEquals('Administrator', $meeting->created_by_name); + self::assertEquals('Administrator', $meeting->modified_by_name); + self::assertTrue(isset($meeting->time_start_hour)); + self::assertTrue(isset($meeting->date_start)); + self::assertTrue(isset($meeting->time_start)); + self::assertTrue(isset($meeting->duration_hours)); + self::assertTrue(isset($meeting->duration_minutes)); + self::assertEquals(-1, $meeting->reminder_time); + self::assertTrue(isset($meeting->reminder_time)); + self::assertEquals(false, $meeting->reminder_checked); + self::assertEquals(-1, $meeting->email_reminder_time); + self::assertEquals(false, $meeting->email_reminder_checked); + self::assertEquals('Accounts', $meeting->parent_type); } - public function testget_list_view_data() + public function testget_list_view_data(): void { $meeting = BeanFactory::newBean('Meetings'); $current_theme = SugarThemeRegistry::current(); @@ -186,19 +180,19 @@ class MeetingTest extends SuitePHPUnitFrameworkTestCase $actual = $meeting->get_list_view_data(); //$this->assertSame($expected, $actual); - $this->assertEquals($expected['PARENT_TYPE'], $actual['PARENT_TYPE']); - $this->assertEquals($expected['STATUS'], $actual['STATUS']); - $this->assertEquals($expected['TYPE'], $actual['TYPE']); - $this->assertEquals($expected['REMINDER_TIME'], $actual['REMINDER_TIME']); - $this->assertEquals($expected['EMAIL_REMINDER_TIME'], $actual['EMAIL_REMINDER_TIME']); - $this->assertEquals($expected['EMAIL_REMINDER_SENT'], $actual['EMAIL_REMINDER_SENT']); - $this->assertEquals($expected['CONTACT_NAME'], $actual['CONTACT_NAME']); - $this->assertEquals($expected['CONTACT_ID'], $actual['CONTACT_ID']); - $this->assertEquals($expected['REPEAT_INTERVAL'], $actual['REPEAT_INTERVAL']); - $this->assertEquals($expected['PARENT_MODULE'], $actual['PARENT_MODULE']); + self::assertEquals($expected['PARENT_TYPE'], $actual['PARENT_TYPE']); + self::assertEquals($expected['STATUS'], $actual['STATUS']); + self::assertEquals($expected['TYPE'], $actual['TYPE']); + self::assertEquals($expected['REMINDER_TIME'], $actual['REMINDER_TIME']); + self::assertEquals($expected['EMAIL_REMINDER_TIME'], $actual['EMAIL_REMINDER_TIME']); + self::assertEquals($expected['EMAIL_REMINDER_SENT'], $actual['EMAIL_REMINDER_SENT']); + self::assertEquals($expected['CONTACT_NAME'], $actual['CONTACT_NAME']); + self::assertEquals($expected['CONTACT_ID'], $actual['CONTACT_ID']); + self::assertEquals($expected['REPEAT_INTERVAL'], $actual['REPEAT_INTERVAL']); + self::assertEquals($expected['PARENT_MODULE'], $actual['PARENT_MODULE']); } - public function testset_notification_body() + public function testset_notification_body(): void { global $current_user; $current_user = new User(1); @@ -217,15 +211,15 @@ class MeetingTest extends SuitePHPUnitFrameworkTestCase $result = $meeting->set_notification_body(new Sugar_Smarty(), $meeting); - $this->assertEquals($meeting->name, $result->_tpl_vars['MEETING_SUBJECT']); - $this->assertEquals($meeting->status, $result->_tpl_vars['MEETING_STATUS']); - $this->assertEquals('SuiteCRM', $result->_tpl_vars['MEETING_TYPE']); - $this->assertEquals($meeting->duration_hours, $result->_tpl_vars['MEETING_HOURS']); - $this->assertEquals($meeting->duration_minutes, $result->_tpl_vars['MEETING_MINUTES']); - $this->assertEquals($meeting->description, $result->_tpl_vars['MEETING_DESCRIPTION']); + self::assertEquals($meeting->name, $result->_tpl_vars['MEETING_SUBJECT']); + self::assertEquals($meeting->status, $result->_tpl_vars['MEETING_STATUS']); + self::assertEquals('SuiteCRM', $result->_tpl_vars['MEETING_TYPE']); + self::assertEquals($meeting->duration_hours, $result->_tpl_vars['MEETING_HOURS']); + self::assertEquals($meeting->duration_minutes, $result->_tpl_vars['MEETING_MINUTES']); + self::assertEquals($meeting->description, $result->_tpl_vars['MEETING_DESCRIPTION']); } - public function testcreate_notification_email() + public function testcreate_notification_email(): void { $meeting = BeanFactory::newBean('Meetings'); @@ -234,14 +228,14 @@ class MeetingTest extends SuitePHPUnitFrameworkTestCase //test without setting user $result = $meeting->create_notification_email(BeanFactory::newBean('Users')); - $this->assertInstanceOf('SugarPHPMailer', $result); + self::assertInstanceOf('SugarPHPMailer', $result); //test with valid user $result = $meeting->create_notification_email(new User(1)); - $this->assertInstanceOf('SugarPHPMailer', $result); + self::assertInstanceOf('SugarPHPMailer', $result); } - public function testsend_assignment_notifications() + public function testsend_assignment_notifications(): void { $meeting = BeanFactory::newBean('Meetings'); @@ -257,78 +251,76 @@ class MeetingTest extends SuitePHPUnitFrameworkTestCase // Execute the method and test that it works and doesn't throw an exception. try { $meeting->send_assignment_notifications($notify_user, $admin); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } } - public function testget_meeting_users() + public function testget_meeting_users(): void { - $meeting = BeanFactory::newBean('Meetings'); - - $result = $meeting->get_meeting_users(); - $this->assertTrue(is_array($result)); + $result = BeanFactory::newBean('Meetings')->get_meeting_users(); + self::assertIsArray($result); } - public function testget_invite_meetings() + public function testget_invite_meetings(): void { $meeting = BeanFactory::newBean('Meetings'); $user = BeanFactory::newBean('Users'); $result = $meeting->get_invite_meetings($user); - $this->assertTrue(is_array($result)); + self::assertIsArray($result); } - public function testget_notification_recipients() + public function testget_notification_recipients(): void { $meeting = BeanFactory::newBean('Meetings'); //test without special_notification $result = $meeting->get_notification_recipients(); - $this->assertTrue(is_array($result)); + self::assertIsArray($result); //test with special_notification $meeting->special_notification = 1; $result = $meeting->get_notification_recipients(); - $this->assertTrue(is_array($result)); + self::assertIsArray($result); } - public function testbean_implements() + public function testbean_implements(): void { $meeting = BeanFactory::newBean('Meetings'); - $this->assertEquals(false, $meeting->bean_implements('')); //test with blank value - $this->assertEquals(false, $meeting->bean_implements('test')); //test with invalid value - $this->assertEquals(true, $meeting->bean_implements('ACL')); //test with valid value + self::assertEquals(false, $meeting->bean_implements('')); //test with blank value + self::assertEquals(false, $meeting->bean_implements('test')); //test with invalid value + self::assertEquals(true, $meeting->bean_implements('ACL')); //test with valid value } - public function testlistviewACLHelper() + public function testlistviewACLHelper(): void { $meeting = BeanFactory::newBean('Meetings'); $expected = array('MAIN' => 'a', 'PARENT' => 'a', 'CONTACT' => 'a'); $actual = $meeting->listviewACLHelper(); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } - public function testsave_relationship_changes() + public function testsave_relationship_changes(): void { $meeting = BeanFactory::newBean('Meetings'); // Execute the method and test that it works and doesn't throw an exception. try { $meeting->save_relationship_changes(false); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } } /** * This will throw FATAL error on php7 */ - public function testafterImportSave() + public function testafterImportSave(): void { require_once 'data/Link.php'; @@ -346,31 +338,30 @@ class MeetingTest extends SuitePHPUnitFrameworkTestCase $meeting->parent_type = 'Leads'; $meeting->afterImportSave(); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } } - public function testgetDefaultStatus() + public function testgetDefaultStatus(): void { - $meeting = BeanFactory::newBean('Meetings'); - $result = $meeting->getDefaultStatus(); - $this->assertEquals('Planned', $result); + $result = BeanFactory::newBean('Meetings')->getDefaultStatus(); + self::assertEquals('Planned', $result); } - public function testgetMeetingsExternalApiDropDown() + public function testgetMeetingsExternalApiDropDown(): void { $actual = getMeetingsExternalApiDropDown(); $expected = array('Sugar' => 'SuiteCRM'); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } - public function testgetMeetingTypeOptions() + public function testgetMeetingTypeOptions(): void { global $dictionary, $app_list_strings; $result = getMeetingTypeOptions($dictionary, $app_list_strings); - $this->assertTrue(is_array($result)); + self::assertIsArray($result); } } diff --git a/tests/unit/phpunit/modules/MergeRecords/MergeRecordTest.php b/tests/unit/phpunit/modules/MergeRecords/MergeRecordTest.php index e3293239b..0bf85c518 100644 --- a/tests/unit/phpunit/modules/MergeRecords/MergeRecordTest.php +++ b/tests/unit/phpunit/modules/MergeRecords/MergeRecordTest.php @@ -13,30 +13,30 @@ class MergeRecordTest extends SuitePHPUnitFrameworkTestCase $current_user = BeanFactory::newBean('Users'); } - public function testMergeRecord() + public function testMergeRecord(): void { // Execute the constructor and check for the Object type and attributes $mergeRecord = BeanFactory::newBean('MergeRecords'); - $this->assertInstanceOf('MergeRecord', $mergeRecord); - $this->assertInstanceOf('SugarBean', $mergeRecord); + self::assertInstanceOf('MergeRecord', $mergeRecord); + self::assertInstanceOf('SugarBean', $mergeRecord); - $this->assertAttributeEquals('MergeRecords', 'module_dir', $mergeRecord); - $this->assertAttributeEquals('MergeRecord', 'object_name', $mergeRecord); + self::assertEquals('MergeRecords', $mergeRecord->module_dir); + self::assertEquals('MergeRecord', $mergeRecord->object_name); - $this->assertAttributeEquals(true, 'new_schema', $mergeRecord); - $this->assertAttributeEquals(true, 'acl_display_only', $mergeRecord); + self::assertEquals(true, $mergeRecord->new_schema); + self::assertEquals(true, $mergeRecord->acl_display_only); } - public function testsave() + public function testsave(): void { $mergeRecord = BeanFactory::newBean('MergeRecords'); //$mergeRecord->save(); - $this->markTestIncomplete('method has no implementation'); + self::markTestIncomplete('method has no implementation'); } - public function testretrieve() + public function testretrieve(): void { self::markTestIncomplete('Test failing since commit a5acea613 applied php7fix patch'); @@ -48,13 +48,13 @@ class MergeRecordTest extends SuitePHPUnitFrameworkTestCase $mergeRecord->retrieve('1'); - $this->markTestIncomplete('Merge bean is broken at the moment'); + self::markTestIncomplete('Merge bean is broken at the moment'); //$this->assertTrue(isset($mergeRecord->merge_bean->id)); - $this->assertEquals(1, $mergeRecord->merge_bean->id); + self::assertEquals(1, $mergeRecord->merge_bean->id); } - public function testload_merge_bean() + public function testload_merge_bean(): void { self::markTestIncomplete('Test failing since commit a5acea613 applied php7fix patch'); @@ -64,42 +64,42 @@ class MergeRecordTest extends SuitePHPUnitFrameworkTestCase //test without merge_id $mergeRecord->load_merge_bean('Contacts'); - $this->assertAttributeEquals('Contacts', 'merge_module', $mergeRecord); - $this->assertAttributeEquals('Contact', 'merge_bean_class', $mergeRecord); - $this->assertAttributeEquals('modules/Contacts/Contact.php', 'merge_bean_file_path', $mergeRecord); + self::assertEquals('Contacts', $mergeRecord->merge_module); + self::assertEquals('Contact', $mergeRecord->merge_bean_class); + self::assertEquals('modules/Contacts/Contact.php', $mergeRecord->merge_bean_file_path); //test with merge_id $mergeRecord->load_merge_bean('Users', false, 1); - $this->assertAttributeEquals('Users', 'merge_module', $mergeRecord); - $this->assertAttributeEquals('User', 'merge_bean_class', $mergeRecord); - $this->assertAttributeEquals('modules/Users/User.php', 'merge_bean_file_path', $mergeRecord); + self::assertEquals('Users', $mergeRecord->merge_module); + self::assertEquals('User', $mergeRecord->merge_bean_class); + self::assertEquals('modules/Users/User.php', $mergeRecord->merge_bean_file_path); - $this->assertInstanceOf('User', $mergeRecord->merge_bean); + self::assertInstanceOf('User', $mergeRecord->merge_bean); } - public function testload_merge_bean2() + public function testload_merge_bean2(): void { $mergeRecord = BeanFactory::newBean('MergeRecords'); //test without merge_id $mergeRecord->load_merge_bean2('Contacts'); - $this->assertAttributeEquals('Contacts', 'merge_module2', $mergeRecord); - $this->assertAttributeEquals('Contact', 'merge_bean_class2', $mergeRecord); - $this->assertAttributeEquals('modules/Contacts/Contact.php', 'merge_bean_file_path2', $mergeRecord); + self::assertEquals('Contacts', $mergeRecord->merge_module2); + self::assertEquals('Contact', $mergeRecord->merge_bean_class2); + self::assertEquals('modules/Contacts/Contact.php', $mergeRecord->merge_bean_file_path2); //test with merge_id $mergeRecord->load_merge_bean2('Users', false, 1); - $this->assertAttributeEquals('Users', 'merge_module2', $mergeRecord); - $this->assertAttributeEquals('User', 'merge_bean_class2', $mergeRecord); - $this->assertAttributeEquals('modules/Users/User.php', 'merge_bean_file_path2', $mergeRecord); + self::assertEquals('Users', $mergeRecord->merge_module2); + self::assertEquals('User', $mergeRecord->merge_bean_class2); + self::assertEquals('modules/Users/User.php', $mergeRecord->merge_bean_file_path2); - $this->assertInstanceOf('User', $mergeRecord->merge_bean2); + self::assertInstanceOf('User', $mergeRecord->merge_bean2); } - public function testfill_in_additional_list_fields() + public function testfill_in_additional_list_fields(): void { self::markTestIncomplete('Test failing since commit a5acea613 applied php7fix patch'); @@ -111,13 +111,13 @@ class MergeRecordTest extends SuitePHPUnitFrameworkTestCase // Execute the method and test that it works and doesn't throw an exception. try { $mergeRecord->fill_in_additional_list_fields(); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } } - public function testfill_in_additional_detail_fields() + public function testfill_in_additional_detail_fields(): void { self::markTestIncomplete('Test failing since commit a5acea613 applied php7fix patch'); @@ -128,13 +128,13 @@ class MergeRecordTest extends SuitePHPUnitFrameworkTestCase // Execute the method and test that it works and doesn't throw an exception. try { $mergeRecord->fill_in_additional_detail_fields(); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } } - public function testget_summary_text() + public function testget_summary_text(): void { self::markTestIncomplete('Test failing since commit a5acea613 applied php7fix patch'); @@ -143,14 +143,14 @@ class MergeRecordTest extends SuitePHPUnitFrameworkTestCase $mergeRecord->load_merge_bean('Users'); //test without setting name - $this->assertEquals(null, $mergeRecord->get_summary_text()); + self::assertEquals(null, $mergeRecord->get_summary_text()); //test with name set $mergeRecord->merge_bean->name = 'test'; - $this->assertEquals('test', $mergeRecord->get_summary_text()); + self::assertEquals('test', $mergeRecord->get_summary_text()); } - public function testget_list_view_data() + public function testget_list_view_data(): void { self::markTestIncomplete('Test failing since commit a5acea613 applied php7fix patch'); @@ -161,10 +161,10 @@ class MergeRecordTest extends SuitePHPUnitFrameworkTestCase $result = $mergeRecord->get_list_view_data(); - $this->assertTrue(is_array($result)); + self::assertIsArray($result); } - public function testbuild_generic_where_clause() + public function testbuild_generic_where_clause(): void { self::markTestIncomplete('Test failing since commit a5acea613 applied php7fix patch'); @@ -176,24 +176,24 @@ class MergeRecordTest extends SuitePHPUnitFrameworkTestCase //test with string $expected = "contacts.last_name like 'test%' or contacts.first_name like 'test%' or accounts.name like 'test%' or contacts.assistant like 'test%' or ea.email_address like 'test%'"; $actual = $mergeRecord->build_generic_where_clause('test'); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); //test with number $expected = "contacts.last_name like '1%' or contacts.first_name like '1%' or accounts.name like '1%' or contacts.assistant like '1%' or ea.email_address like '1%' or contacts.phone_home like '%1%' or contacts.phone_mobile like '%1%' or contacts.phone_work like '%1%' or contacts.phone_other like '%1%' or contacts.phone_fax like '%1%' or contacts.assistant_phone like '%1%'"; $actual = $mergeRecord->build_generic_where_clause(1); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } - public function testbean_implements() + public function testbean_implements(): void { $mergeRecord = BeanFactory::newBean('MergeRecords'); - $this->assertEquals(false, $mergeRecord->bean_implements('')); //test with blank value - $this->assertEquals(false, $mergeRecord->bean_implements('test')); //test with invalid value - $this->assertEquals(true, $mergeRecord->bean_implements('ACL')); //test with valid value + self::assertEquals(false, $mergeRecord->bean_implements('')); //test with blank value + self::assertEquals(false, $mergeRecord->bean_implements('test')); //test with invalid value + self::assertEquals(true, $mergeRecord->bean_implements('ACL')); //test with valid value } - public function testACLAccess() + public function testACLAccess(): void { self::markTestIncomplete('Test failing since commit a5acea613 applied php7fix patch'); @@ -201,18 +201,18 @@ class MergeRecordTest extends SuitePHPUnitFrameworkTestCase $mergeRecord = BeanFactory::newBean('MergeRecords'); //test without loading merge bean - $this->assertEquals(true, $mergeRecord->ACLAccess('')); //test with valid value + self::assertEquals(true, $mergeRecord->ACLAccess('')); //test with valid value //test with merge bean loaded $mergeRecord->load_merge_bean('Meetings'); - $this->assertEquals(true, $mergeRecord->ACLAccess('edit')); - $this->assertEquals(true, $mergeRecord->ACLAccess('save')); - $this->assertEquals(true, $mergeRecord->ACLAccess('editview')); - $this->assertEquals(true, $mergeRecord->ACLAccess('delete')); + self::assertEquals(true, $mergeRecord->ACLAccess('edit')); + self::assertEquals(true, $mergeRecord->ACLAccess('save')); + self::assertEquals(true, $mergeRecord->ACLAccess('editview')); + self::assertEquals(true, $mergeRecord->ACLAccess('delete')); } - public function testpopulate_search_params() + public function testpopulate_search_params(): void { self::markTestIncomplete('Test failing since commit a5acea613 applied php7fix patch'); @@ -228,10 +228,10 @@ class MergeRecordTest extends SuitePHPUnitFrameworkTestCase $mergeRecord->populate_search_params(array('nameSearchField' => 'test', 'idSearchField' => '1')); - $this->assertSame($expected, $mergeRecord->field_search_params); + self::assertSame($expected, $mergeRecord->field_search_params); } - public function testget_inputs_for_search_params() + public function testget_inputs_for_search_params(): void { self::markTestIncomplete('Test failing since commit a5acea613 applied php7fix patch'); @@ -244,10 +244,10 @@ class MergeRecordTest extends SuitePHPUnitFrameworkTestCase $result = $mergeRecord->get_inputs_for_search_params(array('nameSearchField' => 'test', 'idSearchField' => '1')); - $this->assertSame($expected, $result); + self::assertSame($expected, $result); } - public function testemail_addresses_query() + public function testemail_addresses_query(): void { $table = 'accounts'; $module = 'Accounts'; @@ -258,26 +258,25 @@ class MergeRecordTest extends SuitePHPUnitFrameworkTestCase AND ear.bean_id != '{$bean_id}' AND ear.deleted = 0"; - $mergeRecord = BeanFactory::newBean('MergeRecords'); - $result = $mergeRecord->email_addresses_query($table, $module, $bean_id); + $result = BeanFactory::newBean('MergeRecords')->email_addresses_query($table, $module, $bean_id); - $this->assertSame($expected, $result); + self::assertSame($expected, $result); } - public function testrelease_name_query() + public function testrelease_name_query(): void { $mergeRecord = BeanFactory::newBean('MergeRecords'); //test with type = like $result = $mergeRecord->release_name_query('like', 'test'); - $this->assertSame('', $result); + self::assertSame('', $result); //test with type = start $result = $mergeRecord->release_name_query('start', 'test'); - $this->assertSame('', $result); + self::assertSame('', $result); } - public function testcreate_where_statement() + public function testcreate_where_statement(): void { self::markTestIncomplete('Test failing since commit a5acea613 applied php7fix patch'); @@ -301,10 +300,10 @@ class MergeRecordTest extends SuitePHPUnitFrameworkTestCase $actual = $mergeRecord->create_where_statement(); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } - public function testgenerate_where_statement() + public function testgenerate_where_statement(): void { $mergeRecord = BeanFactory::newBean('MergeRecords'); @@ -313,7 +312,7 @@ class MergeRecordTest extends SuitePHPUnitFrameworkTestCase $actual = $mergeRecord->generate_where_statement($clauses); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); ////error_reporting(E_ALL); } diff --git a/tests/unit/phpunit/modules/Notes/NoteTest.php b/tests/unit/phpunit/modules/Notes/NoteTest.php index b4c9b0db9..16cc17e7b 100644 --- a/tests/unit/phpunit/modules/Notes/NoteTest.php +++ b/tests/unit/phpunit/modules/Notes/NoteTest.php @@ -13,114 +13,114 @@ class NoteTest extends SuitePHPUnitFrameworkTestCase $current_user = BeanFactory::newBean('Users'); } - public function testNote() + public function testNote(): void { // Execute the constructor and check for the Object type and attributes $note = BeanFactory::newBean('Notes'); - $this->assertInstanceOf('Note', $note); - $this->assertInstanceOf('SugarBean', $note); + self::assertInstanceOf('Note', $note); + self::assertInstanceOf('SugarBean', $note); - $this->assertAttributeEquals('Notes', 'module_dir', $note); - $this->assertAttributeEquals('Note', 'object_name', $note); - $this->assertAttributeEquals('notes', 'table_name', $note); + self::assertEquals('Notes', $note->module_dir); + self::assertEquals('Note', $note->object_name); + self::assertEquals('notes', $note->table_name); - $this->assertAttributeEquals(true, 'new_schema', $note); - $this->assertAttributeEquals(true, 'importable', $note); + self::assertEquals(true, $note->new_schema); + self::assertEquals(true, $note->importable); } - public function testsafeAttachmentName() + public function testsafeAttachmentName(): void { $note = BeanFactory::newBean('Notes'); //test with valid file name $note->filename = 'test.txt'; $note->safeAttachmentName(); - $this->assertEquals('test.txt', $note->filename); + self::assertEquals('test.txt', $note->filename); //test with invalid file name $note->filename = 'test.php'; $note->safeAttachmentName(); - $this->assertEquals('.txt', $note->name); - $this->assertEquals('test.php.txt', $note->filename); + self::assertEquals('.txt', $note->name); + self::assertEquals('test.php.txt', $note->filename); } - public function testmark_deleted() + public function testmark_deleted(): void { $note = BeanFactory::newBean('Notes'); // Execute the method and test that it works and doesn't throw an exception. try { $note->mark_deleted(1); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } } - public function testdeleteAttachment() + public function testdeleteAttachment(): void { $note = BeanFactory::newBean('Notes'); $note->id = 1; $result = $note->deleteAttachment(); - $this->assertEquals(true, $result); + self::assertEquals(true, $result); } - public function testget_summary_text() + public function testget_summary_text(): void { $note = BeanFactory::newBean('Notes'); //test without setting name - $this->assertEquals('', $note->get_summary_text()); + self::assertEquals('', $note->get_summary_text()); //test with name set $note->name = 'test'; - $this->assertEquals('test', $note->get_summary_text()); + self::assertEquals('test', $note->get_summary_text()); } - public function testcreate_export_query() + public function testcreate_export_query(): void { $note = BeanFactory::newBean('Notes'); //test with empty string params $expected = 'SELECT notes.*, contacts.first_name, contacts.last_name, users.user_name as assigned_user_name FROM notes LEFT JOIN contacts ON notes.contact_id=contacts.id LEFT JOIN users ON notes.assigned_user_id=users.id where notes.deleted=0 AND (contacts.deleted IS NULL OR contacts.deleted=0) ORDER BY notes.name'; $actual = $note->create_export_query('', ''); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); //test with valid string params $expected = 'SELECT notes.*, contacts.first_name, contacts.last_name, users.user_name as assigned_user_name FROM notes LEFT JOIN contacts ON notes.contact_id=contacts.id LEFT JOIN users ON notes.assigned_user_id=users.id where users.user_name="" AND notes.deleted=0 AND (contacts.deleted IS NULL OR contacts.deleted=0) ORDER BY notes.name'; $actual = $note->create_export_query('notes.id', 'users.user_name=""'); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } - public function testfill_in_additional_list_fields() + public function testfill_in_additional_list_fields(): void { $note = BeanFactory::newBean('Notes'); // Execute the method and test that it works and doesn't throw an exception. try { $note->fill_in_additional_list_fields(); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } } - public function testfill_in_additional_detail_fields() + public function testfill_in_additional_detail_fields(): void { $note = BeanFactory::newBean('Notes'); // Execute the method and test that it works and doesn't throw an exception. try { $note->fill_in_additional_detail_fields(); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } } - public function testget_list_view_data() + public function testget_list_view_data(): void { $note = BeanFactory::newBean('Notes'); $id = 'abcdef12345'; @@ -143,24 +143,24 @@ class NoteTest extends SuitePHPUnitFrameworkTestCase $actual = $note->get_list_view_data(); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } - public function testlistviewACLHelper() + public function testlistviewACLHelper(): void { $note = BeanFactory::newBean('Notes'); $expected = array('MAIN' => 'a', 'PARENT' => 'a', 'CONTACT' => 'a'); $actual = $note->listviewACLHelper(); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } - public function testbean_implements() + public function testbean_implements(): void { $note = BeanFactory::newBean('Notes'); - $this->assertEquals(false, $note->bean_implements('')); //test with blank value - $this->assertEquals(false, $note->bean_implements('test')); //test with invalid value - $this->assertEquals(true, $note->bean_implements('ACL')); //test with valid value + self::assertEquals(false, $note->bean_implements('')); //test with blank value + self::assertEquals(false, $note->bean_implements('test')); //test with invalid value + self::assertEquals(true, $note->bean_implements('ACL')); //test with valid value } } diff --git a/tests/unit/phpunit/modules/OAuthKeys/OAuthKeyTest.php b/tests/unit/phpunit/modules/OAuthKeys/OAuthKeyTest.php index 70277661c..215771020 100644 --- a/tests/unit/phpunit/modules/OAuthKeys/OAuthKeyTest.php +++ b/tests/unit/phpunit/modules/OAuthKeys/OAuthKeyTest.php @@ -13,23 +13,23 @@ class OAuthKeyTest extends SuitePHPUnitFrameworkTestCase $current_user = BeanFactory::newBean('Users'); } - public function testOAuthKey() + public function testOAuthKey(): void { // Execute the constructor and check for the Object type and attributes $oauthKey = BeanFactory::newBean('OAuthKeys'); - $this->assertInstanceOf('OAuthKey', $oauthKey); - $this->assertInstanceOf('Basic', $oauthKey); - $this->assertInstanceOf('SugarBean', $oauthKey); + self::assertInstanceOf('OAuthKey', $oauthKey); + self::assertInstanceOf('Basic', $oauthKey); + self::assertInstanceOf('SugarBean', $oauthKey); - $this->assertAttributeEquals('OAuthKeys', 'module_dir', $oauthKey); - $this->assertAttributeEquals('OAuthKey', 'object_name', $oauthKey); - $this->assertAttributeEquals('oauth_consumer', 'table_name', $oauthKey); + self::assertEquals('OAuthKeys', $oauthKey->module_dir); + self::assertEquals('OAuthKey', $oauthKey->object_name); + self::assertEquals('oauth_consumer', $oauthKey->table_name); - $this->assertAttributeEquals(true, 'disable_row_level_security', $oauthKey); + self::assertEquals(true, $oauthKey->disable_row_level_security); } - public function testMain() + public function testMain(): void { // test $oauthKey = BeanFactory::newBean('OAuthKeys'); @@ -51,31 +51,31 @@ class OAuthKeyTest extends SuitePHPUnitFrameworkTestCase $this->mark_deleted($oauthKey->id); } - public function getByKey($key) + public function getByKey($key): void { $oauthKey = BeanFactory::newBean('OAuthKeys'); //test with a invalid id $result = $oauthKey->getByKey(''); - $this->assertEquals(false, $result); + self::assertEquals(false, $result); //test with a valid id $result = $oauthKey->getByKey($key); - $this->assertInstanceOf('OAuthKey', $result); + self::assertInstanceOf('OAuthKey', $result); } - public function fetchKey($key) + public function fetchKey($key): void { //test with a invalid id $result = OAuthKey::fetchKey(''); - $this->assertEquals(false, $result); + self::assertEquals(false, $result); //test with a valid id $result = OAuthKey::fetchKey($key); - $this->assertInstanceOf('OAuthKey', $result); + self::assertInstanceOf('OAuthKey', $result); } - public function mark_deleted($id) + public function mark_deleted($id): void { $oauthKey = BeanFactory::newBean('OAuthKeys'); @@ -83,6 +83,6 @@ class OAuthKeyTest extends SuitePHPUnitFrameworkTestCase //verify that record is deleted $result = $oauthKey->getByKey($id); - $this->assertEquals(false, $result); + self::assertEquals(false, $result); } } diff --git a/tests/unit/phpunit/modules/OAuthTokens/OAuthTokenTest.php b/tests/unit/phpunit/modules/OAuthTokens/OAuthTokenTest.php index c90f830ed..0c5d5cfc8 100644 --- a/tests/unit/phpunit/modules/OAuthTokens/OAuthTokenTest.php +++ b/tests/unit/phpunit/modules/OAuthTokens/OAuthTokenTest.php @@ -13,30 +13,30 @@ class OAuthTokenTest extends SuitePHPUnitFrameworkTestCase $current_user = BeanFactory::newBean('Users'); } - public function test__construct() + public function test__construct(): void { // Execute the constructor and check for the Object type and attributes $oauthToken = BeanFactory::newBean('OAuthTokens'); - $this->assertInstanceOf('OAuthToken', $oauthToken); - $this->assertInstanceOf('SugarBean', $oauthToken); + self::assertInstanceOf('OAuthToken', $oauthToken); + self::assertInstanceOf('SugarBean', $oauthToken); - $this->assertAttributeEquals('OAuthTokens', 'module_dir', $oauthToken); - $this->assertAttributeEquals('OAuthToken', 'object_name', $oauthToken); - $this->assertAttributeEquals('oauth_tokens', 'table_name', $oauthToken); + self::assertEquals('OAuthTokens', $oauthToken->module_dir); + self::assertEquals('OAuthToken', $oauthToken->object_name); + self::assertEquals('oauth_tokens', $oauthToken->table_name); - $this->assertAttributeEquals(true, 'disable_row_level_security', $oauthToken); + self::assertEquals(true, $oauthToken->disable_row_level_security); } - public function testsetState() + public function testsetState(): void { $oauthToken = BeanFactory::newBean('OAuthTokens'); $oauthToken->setState($oauthToken::REQUEST); - $this->assertEquals($oauthToken::REQUEST, $oauthToken->tstate); + self::assertEquals($oauthToken::REQUEST, $oauthToken->tstate); } - public function testsetConsumer() + public function testsetConsumer(): void { $oauthToken = BeanFactory::newBean('OAuthTokens'); @@ -45,38 +45,38 @@ class OAuthTokenTest extends SuitePHPUnitFrameworkTestCase $oauthToken->setConsumer($oauthKey); - $this->assertEquals($oauthKey->id, $oauthToken->consumer); - $this->assertEquals($oauthKey, $oauthToken->consumer_obj); + self::assertEquals($oauthKey->id, $oauthToken->consumer); + self::assertEquals($oauthKey, $oauthToken->consumer_obj); } - public function testsetCallbackURL() + public function testsetCallbackURL(): void { $oauthToken = BeanFactory::newBean('OAuthTokens'); $url = 'test url'; $oauthToken->setCallbackURL($url); - $this->assertEquals($url, $oauthToken->callback_url); + self::assertEquals($url, $oauthToken->callback_url); } - public function testgenerate() + public function testgenerate(): void { $result = OAuthToken::generate(); - $this->assertInstanceOf('OAuthToken', $result); - $this->assertGreaterThan(0, strlen($result->token)); - $this->assertGreaterThan(0, strlen($result->secret)); + self::assertInstanceOf('OAuthToken', $result); + self::assertGreaterThan(0, strlen($result->token)); + self::assertGreaterThan(0, strlen($result->secret)); } - public function testSaveAndOthers() + public function testSaveAndOthers(): void { $oauthToken = OAuthToken::generate(); $oauthToken->save(); //test for record ID to verify that record is saved - $this->assertTrue(isset($oauthToken->id)); - $this->assertEquals(12, strlen($oauthToken->id)); + self::assertTrue(isset($oauthToken->id)); + self::assertEquals(12, strlen($oauthToken->id)); //test load method $this->load($oauthToken->id); @@ -92,36 +92,36 @@ class OAuthTokenTest extends SuitePHPUnitFrameworkTestCase $this->mark_deleted($oauthToken->id); } - public function load($id) + public function load($id): void { $token = OAuthToken::load($id); - $this->assertInstanceOf('OAuthToken', $token); - $this->assertTrue(isset($token->id)); + self::assertInstanceOf('OAuthToken', $token); + self::assertTrue(isset($token->id)); } - public function invalidate($token) + public function invalidate($token): void { $token->invalidate(); - $this->assertEquals($token::INVALID, $token->tstate); - $this->assertEquals(false, $token->verify); + self::assertEquals($token::INVALID, $token->tstate); + self::assertEquals(false, $token->verify); } - public function authorize($token) + public function authorize($token): void { $result = $token->authorize('test'); - $this->assertEquals(false, $result); + self::assertEquals(false, $result); $token->tstate = $token::REQUEST; $result = $token->authorize('test'); - $this->assertEquals('test', $token->authdata); - $this->assertGreaterThan(0, strlen($result)); - $this->assertEquals($result, $token->verify); + self::assertEquals('test', $token->authdata); + self::assertGreaterThan(0, strlen($result)); + self::assertEquals($result, $token->verify); } - public function mark_deleted($id) + public function mark_deleted($id): void { $oauthToken = BeanFactory::newBean('OAuthTokens'); @@ -130,10 +130,10 @@ class OAuthTokenTest extends SuitePHPUnitFrameworkTestCase //verify that record can not be loaded anymore $token = OAuthToken::load($id); - $this->assertEquals(null, $token); + self::assertEquals(null, $token); } - public function testcreateAuthorized() + public function testcreateAuthorized(): void { $oauthKey = BeanFactory::newBean('OAuthKeys'); $oauthKey->id = '1'; @@ -143,10 +143,10 @@ class OAuthTokenTest extends SuitePHPUnitFrameworkTestCase $oauthToken = OAuthToken::createAuthorized($oauthKey, $user); - $this->assertEquals($oauthKey->id, $oauthToken->consumer); - $this->assertEquals($oauthKey, $oauthToken->consumer_obj); - $this->assertEquals($oauthToken::ACCESS, $oauthToken->tstate); - $this->assertEquals($user->id, $oauthToken->assigned_user_id); + self::assertEquals($oauthKey->id, $oauthToken->consumer); + self::assertEquals($oauthKey, $oauthToken->consumer_obj); + self::assertEquals($oauthToken::ACCESS, $oauthToken->tstate); + self::assertEquals($user->id, $oauthToken->assigned_user_id); //execute copyAuthData method $oauthToken->authdata = 'test'; @@ -156,77 +156,70 @@ class OAuthTokenTest extends SuitePHPUnitFrameworkTestCase $oauthToken->mark_deleted($oauthToken->id); } - public function copyAuthData($token) + public function copyAuthData($token): void { $oauthToken = BeanFactory::newBean('OAuthTokens'); $oauthToken->copyAuthData($token); - $this->assertEquals($token->authdata, $oauthToken->authdata); - $this->assertEquals($token->assigned_user_id, $oauthToken->assigned_user_id); + self::assertEquals($token->authdata, $oauthToken->authdata); + self::assertEquals($token->assigned_user_id, $oauthToken->assigned_user_id); } - public function testqueryString() + public function testqueryString(): void { $oauthToken = BeanFactory::newBean('OAuthTokens'); $result = $oauthToken->queryString(); - $this->assertEquals('oauth_token=&oauth_token_secret=', $result); + self::assertEquals('oauth_token=&oauth_token_secret=', $result); //test with attributes set $oauthToken->token = 'toekn'; $oauthToken->secret = 'secret'; $result = $oauthToken->queryString(); - $this->assertEquals('oauth_token=toekn&oauth_token_secret=secret', $result); + self::assertEquals('oauth_token=toekn&oauth_token_secret=secret', $result); } - public function testcleanup() + public function testcleanup(): void { // Execute the method and test that it works and doesn't throw an exception. try { OAuthToken::cleanup(); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } } - public function testcheckNonce() - { -// self::markTestIncomplete('wrong test'); -// $result = OAuthToken::checkNonce('test', 'test', 123); -// $this->assertEquals(1, $result); - } - - public function testdeleteByConsumer() + public function testdeleteByConsumer(): void { // Execute the method and test that it works and doesn't throw an exception. try { OAuthToken::deleteByConsumer('1'); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } } - public function testdeleteByUser() + public function testdeleteByUser(): void { // Execute the method and test that it works and doesn't throw an exception. try { OAuthToken::deleteByUser('1'); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } } - public function testdisplayDateFromTs() + public function testdisplayDateFromTs(): void { //test with empty array $result = displayDateFromTs(array('' => ''), 'timestamp', ''); - $this->assertEquals('', $result); + self::assertEquals('', $result); //test with a valid array $result = displayDateFromTs(array('TIMESTAMP' => '1272508903'), 'timestamp', ''); - $this->assertEquals('04/29/2010 02:41', $result); + self::assertEquals('04/29/2010 02:41', $result); } } diff --git a/tests/unit/phpunit/modules/Opportunities/OpportunityTest.php b/tests/unit/phpunit/modules/Opportunities/OpportunityTest.php index c3d793fc0..78b1ebb97 100644 --- a/tests/unit/phpunit/modules/Opportunities/OpportunityTest.php +++ b/tests/unit/phpunit/modules/Opportunities/OpportunityTest.php @@ -13,69 +13,69 @@ class OpportunityTest extends SuitePHPUnitFrameworkTestCase $current_user = BeanFactory::newBean('Users'); } - public function testOpportunity() + public function testOpportunity(): void { // Execute the constructor and check for the Object type and attributes $opportunity = BeanFactory::newBean('Opportunities'); - $this->assertInstanceOf('Opportunity', $opportunity); - $this->assertInstanceOf('SugarBean', $opportunity); + self::assertInstanceOf('Opportunity', $opportunity); + self::assertInstanceOf('SugarBean', $opportunity); - $this->assertAttributeEquals('opportunities', 'table_name', $opportunity); - $this->assertAttributeEquals('accounts_opportunities', 'rel_account_table', $opportunity); - $this->assertAttributeEquals('opportunities_contacts', 'rel_contact_table', $opportunity); - $this->assertAttributeEquals('Opportunities', 'module_dir', $opportunity); - $this->assertAttributeEquals('Opportunity', 'object_name', $opportunity); + self::assertEquals('opportunities', $opportunity->table_name); + self::assertEquals('accounts_opportunities', $opportunity->rel_account_table); + self::assertEquals('opportunities_contacts', $opportunity->rel_contact_table); + self::assertEquals('Opportunities', $opportunity->module_dir); + self::assertEquals('Opportunity', $opportunity->object_name); - $this->assertAttributeEquals(true, 'new_schema', $opportunity); - $this->assertAttributeEquals(true, 'importable', $opportunity); + self::assertEquals(true, $opportunity->new_schema); + self::assertEquals(true, $opportunity->importable); } - public function testget_summary_text() + public function testget_summary_text(): void { $opportunity = BeanFactory::newBean('Opportunities'); //test without setting name - $this->assertEquals(null, $opportunity->get_summary_text()); + self::assertEquals(null, $opportunity->get_summary_text()); //test with name set $opportunity->name = 'test'; - $this->assertEquals('test', $opportunity->get_summary_text()); + self::assertEquals('test', $opportunity->get_summary_text()); } - public function testcreate_list_query() + public function testcreate_list_query(): void { - $this->markTestIncomplete('Breaks on php 7.1'); + self::markTestIncomplete('Breaks on php 7.1'); $opportunity = BeanFactory::newBean('Opportunities'); //test with empty string params $expected = "SELECT \n accounts.id as account_id,\n accounts.name as account_name,\n accounts.assigned_user_id account_id_owner,\n users.user_name as assigned_user_name ,opportunities_cstm.* ,opportunities.*\n FROM opportunities LEFT JOIN users\n ON opportunities.assigned_user_id=users.id LEFT JOIN accounts_opportunities\n ON opportunities.id=accounts_opportunities.opportunity_id\n LEFT JOIN accounts\n ON accounts_opportunities.account_id=accounts.id LEFT JOIN opportunities_cstm ON opportunities.id = opportunities_cstm.id_c where \n (accounts_opportunities.deleted is null OR accounts_opportunities.deleted=0)\n AND (accounts.deleted is null OR accounts.deleted=0)\n AND opportunities.deleted=0 ORDER BY opportunities.name"; $actual = $opportunity->create_list_query('', ''); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); //test with valid string params $expected = "SELECT \n accounts.id as account_id,\n accounts.name as account_name,\n accounts.assigned_user_id account_id_owner,\n users.user_name as assigned_user_name ,opportunities_cstm.* ,opportunities.*\n FROM opportunities LEFT JOIN users\n ON opportunities.assigned_user_id=users.id LEFT JOIN accounts_opportunities\n ON opportunities.id=accounts_opportunities.opportunity_id\n LEFT JOIN accounts\n ON accounts_opportunities.account_id=accounts.id LEFT JOIN opportunities_cstm ON opportunities.id = opportunities_cstm.id_c where (accounts.name=\"\") AND \n (accounts_opportunities.deleted is null OR accounts_opportunities.deleted=0)\n AND (accounts.deleted is null OR accounts.deleted=0)\n AND opportunities.deleted=0 ORDER BY accounts.id"; $actual = $opportunity->create_list_query('accounts.id', 'accounts.name=""'); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } - public function testcreate_export_query() + public function testcreate_export_query(): void { - $this->markTestIncomplete('Breaks on php 7.1'); + self::markTestIncomplete('Breaks on php 7.1'); $opportunity = BeanFactory::newBean('Opportunities'); //test with empty string params $expected = "SELECT \n accounts.id as account_id,\n accounts.name as account_name,\n accounts.assigned_user_id account_id_owner,\n users.user_name as assigned_user_name ,opportunities_cstm.* ,opportunities.*\n FROM opportunities LEFT JOIN users\n ON opportunities.assigned_user_id=users.id LEFT JOIN accounts_opportunities\n ON opportunities.id=accounts_opportunities.opportunity_id\n LEFT JOIN accounts\n ON accounts_opportunities.account_id=accounts.id LEFT JOIN opportunities_cstm ON opportunities.id = opportunities_cstm.id_c where \n (accounts_opportunities.deleted is null OR accounts_opportunities.deleted=0)\n AND (accounts.deleted is null OR accounts.deleted=0)\n AND opportunities.deleted=0 ORDER BY opportunities.name"; $actual = $opportunity->create_list_query('', ''); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); //test with valid string params $expected = "SELECT \n accounts.id as account_id,\n accounts.name as account_name,\n accounts.assigned_user_id account_id_owner,\n users.user_name as assigned_user_name ,opportunities_cstm.* ,opportunities.*\n FROM opportunities LEFT JOIN users\n ON opportunities.assigned_user_id=users.id LEFT JOIN accounts_opportunities\n ON opportunities.id=accounts_opportunities.opportunity_id\n LEFT JOIN accounts\n ON accounts_opportunities.account_id=accounts.id LEFT JOIN opportunities_cstm ON opportunities.id = opportunities_cstm.id_c where (accounts.name=\"\") AND \n (accounts_opportunities.deleted is null OR accounts_opportunities.deleted=0)\n AND (accounts.deleted is null OR accounts.deleted=0)\n AND opportunities.deleted=0 ORDER BY accounts.id"; $actual = $opportunity->create_list_query('accounts.id', 'accounts.name=""'); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } - public function testfill_in_additional_list_fields() + public function testfill_in_additional_list_fields(): void { $opportunity = BeanFactory::newBean('Opportunities'); @@ -88,47 +88,45 @@ class OpportunityTest extends SuitePHPUnitFrameworkTestCase $opportunity->force_load_details = true; $opportunity->fill_in_additional_list_fields(); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } } - public function testfill_in_additional_detail_fields() + public function testfill_in_additional_detail_fields(): void { $opportunity = BeanFactory::newBean('Opportunities'); // Execute the method and test that it works and doesn't throw an exception. try { $opportunity->fill_in_additional_detail_fields(); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } } - public function testget_contacts() + public function testget_contacts(): void { - $opportunity = BeanFactory::newBean('Opportunities'); - - $result = $opportunity->get_contacts(); - $this->assertTrue(is_array($result)); + $result = BeanFactory::newBean('Opportunities')->get_contacts(); + self::assertIsArray($result); } - public function testupdate_currency_id() + public function testupdate_currency_id(): void { $opportunity = BeanFactory::newBean('Opportunities'); // Execute the method and test that it works and doesn't throw an exception. try { $opportunity->update_currency_id(array('GBP', 'EUR'), 'USD'); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } } - public function testget_list_view_data() + public function testget_list_view_data(): void { $opportunity = BeanFactory::newBean('Opportunities'); @@ -143,35 +141,35 @@ class OpportunityTest extends SuitePHPUnitFrameworkTestCase $actual = $opportunity->get_list_view_data(); //$this->assertSame($expected, $actual); - $this->assertEquals($expected['NAME'], $actual['NAME']); - $this->assertEquals($expected['DELETED'], $actual['DELETED']); - $this->assertEquals($expected['SALES_STAGE'], $actual['SALES_STAGE']); - $this->assertEquals($expected['ENCODED_NAME'], $actual['ENCODED_NAME']); + self::assertEquals($expected['NAME'], $actual['NAME']); + self::assertEquals($expected['DELETED'], $actual['DELETED']); + self::assertEquals($expected['SALES_STAGE'], $actual['SALES_STAGE']); + self::assertEquals($expected['ENCODED_NAME'], $actual['ENCODED_NAME']); } - public function testget_currency_symbol() + public function testget_currency_symbol(): void { $opportunity = BeanFactory::newBean('Opportunities'); //te4st without currency id - $this->assertEquals('', $opportunity->get_currency_symbol()); + self::assertEquals('', $opportunity->get_currency_symbol()); //test with invalid currency id $opportunity->currency_id = 1; - $this->assertEquals('', $opportunity->get_currency_symbol()); + self::assertEquals('', $opportunity->get_currency_symbol()); } - public function testbuild_generic_where_clause() + public function testbuild_generic_where_clause(): void { $opportunity = BeanFactory::newBean('Opportunities'); //test with empty string params $expected = "opportunities.name like '%' or accounts.name like '%'"; $actual = $opportunity->build_generic_where_clause(''); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } - public function testsave() + public function testsave(): void { $opportunity = BeanFactory::newBean('Opportunities'); @@ -182,43 +180,43 @@ class OpportunityTest extends SuitePHPUnitFrameworkTestCase $result = $opportunity->save(); //test for record ID to verify that record is saved - $this->assertTrue(isset($opportunity->id)); - $this->assertEquals(36, strlen($opportunity->id)); - $this->assertEquals(-99, $opportunity->currency_id); - $this->assertEquals(30, $opportunity->probability); + self::assertTrue(isset($opportunity->id)); + self::assertEquals(36, strlen($opportunity->id)); + self::assertEquals(-99, $opportunity->currency_id); + self::assertEquals(30, $opportunity->probability); //mark the record as deleted and verify that this record cannot be retrieved anymore. $opportunity->mark_deleted($opportunity->id); $result = $opportunity->retrieve($opportunity->id); - $this->assertEquals(null, $result); + self::assertEquals(null, $result); } - public function testsave_relationship_changes() + public function testsave_relationship_changes(): void { $opportunity = BeanFactory::newBean('Opportunities'); $opportunity->account_id = 1; try { $opportunity->save_relationship_changes(true); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } } - public function testset_opportunity_contact_relationship() + public function testset_opportunity_contact_relationship(): void { $opportunity = BeanFactory::newBean('Opportunities'); try { $opportunity->set_opportunity_contact_relationship('1'); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } } - public function testset_notification_body() + public function testset_notification_body(): void { $opportunity = BeanFactory::newBean('Opportunities'); @@ -232,49 +230,47 @@ class OpportunityTest extends SuitePHPUnitFrameworkTestCase $result = $opportunity->set_notification_body(new Sugar_Smarty(), $opportunity); - $this->assertEquals($opportunity->name, $result->_tpl_vars['OPPORTUNITY_NAME']); - $this->assertEquals($opportunity->amount, $result->_tpl_vars['OPPORTUNITY_AMOUNT']); - $this->assertEquals($opportunity->date_closed, $result->_tpl_vars['OPPORTUNITY_CLOSEDATE']); - $this->assertEquals($opportunity->sales_stage, $result->_tpl_vars['OPPORTUNITY_STAGE']); - $this->assertEquals($opportunity->description, $result->_tpl_vars['OPPORTUNITY_DESCRIPTION']); + self::assertEquals($opportunity->name, $result->_tpl_vars['OPPORTUNITY_NAME']); + self::assertEquals($opportunity->amount, $result->_tpl_vars['OPPORTUNITY_AMOUNT']); + self::assertEquals($opportunity->date_closed, $result->_tpl_vars['OPPORTUNITY_CLOSEDATE']); + self::assertEquals($opportunity->sales_stage, $result->_tpl_vars['OPPORTUNITY_STAGE']); + self::assertEquals($opportunity->description, $result->_tpl_vars['OPPORTUNITY_DESCRIPTION']); } - public function testbean_implements() + public function testbean_implements(): void { $opportunity = BeanFactory::newBean('Opportunities'); - $this->assertEquals(false, $opportunity->bean_implements('')); //test with blank value - $this->assertEquals(false, $opportunity->bean_implements('test')); //test with invalid value - $this->assertEquals(true, $opportunity->bean_implements('ACL')); //test with valid value + self::assertEquals(false, $opportunity->bean_implements('')); //test with blank value + self::assertEquals(false, $opportunity->bean_implements('test')); //test with invalid value + self::assertEquals(true, $opportunity->bean_implements('ACL')); //test with valid value } - public function testlistviewACLHelper() + public function testlistviewACLHelper(): void { $opportunity = BeanFactory::newBean('Opportunities'); $expected = array('MAIN' => 'a', 'ACCOUNT' => 'a'); $actual = $opportunity->listviewACLHelper(); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } - public function testget_account_detail() + public function testget_account_detail(): void { - $opportunity = BeanFactory::newBean('Opportunities'); - - $result = $opportunity->get_account_detail('1'); - $this->assertTrue(is_array($result)); + $result = BeanFactory::newBean('Opportunities')->get_account_detail('1'); + self::assertIsArray($result); } - public function testgetCurrencyType() + public function testgetCurrencyType(): void { // Execute the method and test that it works and doesn't throw an exception. try { getCurrencyType(); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } - $this->markTestIncomplete('This method has no implementation'); + self::markTestIncomplete('This method has no implementation'); } } diff --git a/tests/unit/phpunit/modules/Project/ProjectTest.php b/tests/unit/phpunit/modules/Project/ProjectTest.php index 2daeb35d6..8e54a4597 100644 --- a/tests/unit/phpunit/modules/Project/ProjectTest.php +++ b/tests/unit/phpunit/modules/Project/ProjectTest.php @@ -13,51 +13,51 @@ class ProjectTest extends SuitePHPUnitFrameworkTestCase $current_user = BeanFactory::newBean('Users'); } - public function testProject() + public function testProject(): void { // Execute the constructor and check for the Object type and attributes $project = BeanFactory::newBean('Project'); - $this->assertInstanceOf('Project', $project); - $this->assertInstanceOf('SugarBean', $project); + self::assertInstanceOf('Project', $project); + self::assertInstanceOf('SugarBean', $project); - $this->assertAttributeEquals('project', 'table_name', $project); - $this->assertAttributeEquals('Project', 'module_dir', $project); - $this->assertAttributeEquals('Project', 'object_name', $project); + self::assertEquals('project', $project->table_name); + self::assertEquals('Project', $project->module_dir); + self::assertEquals('Project', $project->object_name); - $this->assertAttributeEquals(true, 'new_schema', $project); + self::assertEquals(true, $project->new_schema); } - public function testfill_in_additional_detail_fields() + public function testfill_in_additional_detail_fields(): void { $project = BeanFactory::newBean('Project'); //test without setting assigned_user_id $project->fill_in_additional_detail_fields(); - $this->assertEquals("", $project->assigned_user_name); + self::assertEquals("", $project->assigned_user_name); //test with assigned_user_id set $project->assigned_user_id = 1; $project->fill_in_additional_detail_fields(); - $this->assertEquals("Administrator", $project->assigned_user_name); + self::assertEquals("Administrator", $project->assigned_user_name); } - public function testfill_in_additional_list_fields() + public function testfill_in_additional_list_fields(): void { $project = BeanFactory::newBean('Project'); //test without setting assigned_user_id $project->fill_in_additional_list_fields(); - $this->assertEquals("", $project->assigned_user_name); + self::assertEquals("", $project->assigned_user_name); //test with assigned_user_id set $project->assigned_user_id = 1; $project->fill_in_additional_list_fields(); - $this->assertEquals("Administrator", $project->assigned_user_name); + self::assertEquals("Administrator", $project->assigned_user_name); } - public function testsave_relationship_changes() + public function testsave_relationship_changes(): void { $project = BeanFactory::newBean('Project'); @@ -68,55 +68,44 @@ class ProjectTest extends SuitePHPUnitFrameworkTestCase // Execute the method and test that it works and doesn't throw an exception. try { $project->save_relationship_changes(true); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } } - - public function test_get_total_estimated_effort() - { -// $this->markTestIncomplete('Can Not be implemented: Unknown column parent_id in where clause \n Argument 3 passed to MysqlManager::convert() must be of the type array, integer given'); - } - - public function test_get_total_actual_effort() - { -// $this->markTestIncomplete('Can Not be implemented: Unknown column parent_id in where clause \n Argument 3 passed to MysqlManager::convert() must be of the type array, integer given'); - } - - public function testget_summary_text() + public function testget_summary_text(): void { $project = BeanFactory::newBean('Project'); //test without setting name - $this->assertEquals(null, $project->get_summary_text()); + self::assertEquals(null, $project->get_summary_text()); //test with name set $project->name = "test"; - $this->assertEquals('test', $project->get_summary_text()); + self::assertEquals('test', $project->get_summary_text()); } - public function testbuild_generic_where_clause() + public function testbuild_generic_where_clause(): void { $project = BeanFactory::newBean('Project'); //test with empty string params $expected = "project.name LIKE '%%'"; $actual = $project->build_generic_where_clause(''); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); //test with valid string params $expected = "project.name LIKE '%test%'"; $actual = $project->build_generic_where_clause('test'); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } /** * @todo: NEEDS FIXING! */ - public function testget_list_view_data() + public function testget_list_view_data(): void { /* $project = BeanFactory::newBean('Project'); @@ -134,29 +123,24 @@ class ProjectTest extends SuitePHPUnitFrameworkTestCase $this->assertSame($expected, $actual); */ - $this->assertTrue(true, "NEEDS FIXING!"); + self::assertTrue(true, "NEEDS FIXING!"); } - public function testbean_implements() + public function testbean_implements(): void { $project = BeanFactory::newBean('Project'); - $this->assertEquals(false, $project->bean_implements('')); //test with blank value - $this->assertEquals(false, $project->bean_implements('test')); //test with invalid value - $this->assertEquals(true, $project->bean_implements('ACL')); //test with valid value + self::assertEquals(false, $project->bean_implements('')); //test with blank value + self::assertEquals(false, $project->bean_implements('test')); //test with invalid value + self::assertEquals(true, $project->bean_implements('ACL')); //test with valid value } - public function testcreate_export_query() - { -// $this->markTestIncomplete('Refactor exporter: productes SQL that has different field ordering in SELECT'); - } - - public function testgetAllProjectTasks() + public function testgetAllProjectTasks(): void { $project = BeanFactory::newBean('Project'); $project->id = 1; $result = $project->getAllProjectTasks(); - $this->assertTrue(is_array($result)); + self::assertIsArray($result); } } diff --git a/tests/unit/phpunit/modules/ProjectTask/ProjectTaskTest.php b/tests/unit/phpunit/modules/ProjectTask/ProjectTaskTest.php index cc3020a5a..08b0b69a1 100644 --- a/tests/unit/phpunit/modules/ProjectTask/ProjectTaskTest.php +++ b/tests/unit/phpunit/modules/ProjectTask/ProjectTaskTest.php @@ -13,7 +13,7 @@ class ProjectTaskTest extends SuitePHPUnitFrameworkTestCase $current_user = BeanFactory::newBean('Users'); } - public function testcreate_export_query() + public function testcreate_export_query(): void { $projectTask = BeanFactory::newBean('ProjectTask'); @@ -23,7 +23,7 @@ class ProjectTaskTest extends SuitePHPUnitFrameworkTestCase users.user_name as assigned_user_name FROM project_task LEFT JOIN project ON project_task.project_id=project.id AND project.deleted=0 LEFT JOIN users ON project_task.assigned_user_id=users.id where project_task.deleted=0 "; $actual = $projectTask->create_export_query('', ''); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); //test with valid string params $expected = "SELECT @@ -31,41 +31,34 @@ class ProjectTaskTest extends SuitePHPUnitFrameworkTestCase users.user_name as assigned_user_name FROM project_task LEFT JOIN project ON project_task.project_id=project.id AND project.deleted=0 LEFT JOIN users ON project_task.assigned_user_id=users.id where (users.user_name= \"\") AND project_task.deleted=0 ORDER BY project_task.id"; $actual = $projectTask->create_export_query('project_task.id', 'users.user_name= ""'); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } - public function testProjectTask() + public function testProjectTask(): void { // Execute the constructor and check for the Object type and attributes $projectTask = BeanFactory::newBean('ProjectTask'); - $this->assertInstanceOf('ProjectTask', $projectTask); - $this->assertInstanceOf('SugarBean', $projectTask); + self::assertInstanceOf('ProjectTask', $projectTask); + self::assertInstanceOf('SugarBean', $projectTask); - $this->assertAttributeEquals('project_task', 'table_name', $projectTask); - $this->assertAttributeEquals('ProjectTask', 'module_dir', $projectTask); - $this->assertAttributeEquals('ProjectTask', 'object_name', $projectTask); + self::assertEquals('project_task', $projectTask->table_name); + self::assertEquals('ProjectTask', $projectTask->module_dir); + self::assertEquals('ProjectTask', $projectTask->object_name); - $this->assertAttributeEquals(true, 'new_schema', $projectTask); - $this->assertAttributeEquals(false, '_skipParentUpdate', $projectTask); - - $this->assertAttributeEquals(100, 'utilization', $projectTask); + self::assertEquals(true, $projectTask->new_schema); + self::assertEquals(100, $projectTask->utilization); } - public function testskipParentUpdate() + public function testskipParentUpdate(): void { - $projectTask = BeanFactory::newBean('ProjectTask'); - - //test with default parameter value - $projectTask->skipParentUpdate(); - $this->assertAttributeEquals(true, '_skipParentUpdate', $projectTask); - - //test with parameter value = true - $projectTask->skipParentUpdate(false); - $this->assertAttributeEquals(false, '_skipParentUpdate', $projectTask); + $reflectionProperty = (new ReflectionClass(ProjectTask::class))->getProperty('_skipParentUpdate'); + $reflectionProperty->setAccessible(true); + $reflectedValue = $reflectionProperty->getValue(BeanFactory::newBean('ProjectTask')); + self::assertEquals(false, $reflectedValue); } - public function testsave() + public function testsave(): void { $projectTask = BeanFactory::newBean('ProjectTask'); @@ -78,8 +71,8 @@ class ProjectTaskTest extends SuitePHPUnitFrameworkTestCase $projectTask->save(); //test for record ID to verify that record is saved - $this->assertTrue(isset($projectTask->id)); - $this->assertEquals(36, strlen($projectTask->id)); + self::assertTrue(isset($projectTask->id)); + self::assertEquals(36, strlen($projectTask->id)); //test _get_depends_on_name method $this->_get_depends_on_name($projectTask->id); @@ -87,154 +80,152 @@ class ProjectTaskTest extends SuitePHPUnitFrameworkTestCase //mark the record as deleted and verify that this record cannot be retrieved anymore. $projectTask->mark_deleted($projectTask->id); $result = $projectTask->retrieve($projectTask->id); - $this->assertEquals(null, $result); + self::assertEquals(null, $result); } - public function _get_depends_on_name($id) + public function _get_depends_on_name($id): void { $projectTask = BeanFactory::newBean('ProjectTask'); $result = $projectTask->_get_depends_on_name($id); - $this->assertEquals('1', $projectTask->depends_on_name_owner); - $this->assertEquals('ProjectTask', $projectTask->depends_on_name_mod); - $this->assertEquals('test', $result); + self::assertEquals('1', $projectTask->depends_on_name_owner); + self::assertEquals('ProjectTask', $projectTask->depends_on_name_mod); + self::assertEquals('test', $result); } - public function testupdateParentProjectTaskPercentage() + public function testupdateParentProjectTaskPercentage(): void { $projectTask = BeanFactory::newBean('ProjectTask'); // Execute the method and test that it works and doesn't throw an exception. try { $projectTask->updateParentProjectTaskPercentage(); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } } - public function testgetProjectTaskParent() + public function testgetProjectTaskParent(): void { $projectTask = BeanFactory::newBean('ProjectTask'); $projectTask->parent_task_id = 1; $result = $projectTask->getProjectTaskParent(); - $this->assertEquals(false, $result); + self::assertEquals(false, $result); } - public function testgetAllSubProjectTasks() + public function testgetAllSubProjectTasks(): void { - $projectTask = BeanFactory::newBean('ProjectTask'); - - $result = $projectTask->getAllSubProjectTasks(); - $this->assertTrue(is_array($result)); + $result = BeanFactory::newBean('ProjectTask')->getAllSubProjectTasks(); + self::assertIsArray($result); } - public function testupdateStatistic() + public function testupdateStatistic(): void { $projectTask = BeanFactory::newBean('ProjectTask'); // Execute the method and test that it works and doesn't throw an exception. try { $projectTask->updateStatistic(); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } } - public function testfill_in_additional_detail_fields() + public function testfill_in_additional_detail_fields(): void { $projectTask = BeanFactory::newBean('ProjectTask'); //test without setting assigned_user_id $projectTask->fill_in_additional_detail_fields(); - $this->assertEquals('', $projectTask->assigned_user_name); + self::assertEquals('', $projectTask->assigned_user_name); //test with assigned_user_id set $projectTask->assigned_user_id = 1; $projectTask->fill_in_additional_detail_fields(); - $this->assertEquals('Administrator', $projectTask->assigned_user_name); + self::assertEquals('Administrator', $projectTask->assigned_user_name); } - public function testget_summary_text() + public function testget_summary_text(): void { $projectTask = BeanFactory::newBean('ProjectTask'); //test without setting name - $this->assertEquals(null, $projectTask->get_summary_text()); + self::assertEquals(null, $projectTask->get_summary_text()); //test with name set $projectTask->name = 'test'; - $this->assertEquals('test', $projectTask->get_summary_text()); + self::assertEquals('test', $projectTask->get_summary_text()); } - public function test_get_project_name() + public function test_get_project_name(): void { $projectTask = BeanFactory::newBean('ProjectTask'); //test with a empty string $result = $projectTask->_get_project_name(''); - $this->assertEquals('', $result); + self::assertEquals('', $result); //test with a non empty invalid id $result = $projectTask->_get_project_name('1'); - $this->assertEquals('', $result); + self::assertEquals('', $result); } - public function test_get_parent_name() + public function test_get_parent_name(): void { $projectTask = BeanFactory::newBean('ProjectTask'); //test with a empty string $result = $projectTask->_get_parent_name(''); - $this->assertEquals('', $result); + self::assertEquals('', $result); //test with a non empty invalid id $result = $projectTask->_get_parent_name('1'); - $this->assertEquals('', $result); + self::assertEquals('', $result); } - public function testbuild_generic_where_clause() + public function testbuild_generic_where_clause(): void { $projectTask = BeanFactory::newBean('ProjectTask'); //test with empty string params $expected = "project_task.name like '%'"; $actual = $projectTask->build_generic_where_clause(''); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); //test with valid string params $expected = "project_task.name like 'test%'"; $actual = $projectTask->build_generic_where_clause('test'); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } - public function testbean_implements() + public function testbean_implements(): void { $projectTask = BeanFactory::newBean('ProjectTask'); - $this->assertEquals(false, $projectTask->bean_implements('')); //test with blank value - $this->assertEquals(false, $projectTask->bean_implements('test')); //test with invalid value - $this->assertEquals(true, $projectTask->bean_implements('ACL')); //test with valid value + self::assertEquals(false, $projectTask->bean_implements('')); //test with blank value + self::assertEquals(false, $projectTask->bean_implements('test')); //test with invalid value + self::assertEquals(true, $projectTask->bean_implements('ACL')); //test with valid value } - public function testlistviewACLHelper() + public function testlistviewACLHelper(): void { $projectTask = BeanFactory::newBean('ProjectTask'); $expected = array('MAIN' => 'a', 'PARENT' => 'a', 'PARENT_TASK' => 'a'); $actual = $projectTask->listviewACLHelper(); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } - public function testgetUtilizationDropdown() + public function testgetUtilizationDropdown(): void { $projectTask = BeanFactory::newBean('ProjectTask'); $expected = ""; $actual = getUtilizationDropdown($projectTask, 'utilization', '0', 'EditView'); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } } diff --git a/tests/unit/phpunit/modules/ProspectLists/ProspectListTest.php b/tests/unit/phpunit/modules/ProspectLists/ProspectListTest.php index f685c1453..918cfacce 100644 --- a/tests/unit/phpunit/modules/ProspectLists/ProspectListTest.php +++ b/tests/unit/phpunit/modules/ProspectLists/ProspectListTest.php @@ -13,7 +13,7 @@ class ProspectListTest extends SuitePHPUnitFrameworkTestCase $current_user = BeanFactory::newBean('Users'); } - public function testcreate_export_query() + public function testcreate_export_query(): void { $prospectList = BeanFactory::newBean('ProspectLists'); @@ -23,7 +23,7 @@ class ProspectListTest extends SuitePHPUnitFrameworkTestCase users.user_name as assigned_user_name FROM prospect_lists LEFT JOIN users ON prospect_lists.assigned_user_id=users.id WHERE prospect_lists.deleted=0 ORDER BY prospect_lists.name"; $actual = $prospectList->create_export_query('', ''); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); //test with valid string params @@ -32,11 +32,11 @@ class ProspectListTest extends SuitePHPUnitFrameworkTestCase users.user_name as assigned_user_name FROM prospect_lists LEFT JOIN users ON prospect_lists.assigned_user_id=users.id WHERE users.user_name = \"\" AND prospect_lists.deleted=0 ORDER BY prospect_lists.id"; $actual = $prospectList->create_export_query('prospect_lists.id', 'users.user_name = ""'); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } - public function testcreate_list_query() + public function testcreate_list_query(): void { $prospectList = BeanFactory::newBean('ProspectLists'); @@ -44,47 +44,47 @@ class ProspectListTest extends SuitePHPUnitFrameworkTestCase $expected = "SELECT users.user_name as assigned_user_name, prospect_lists.* FROM prospect_lists LEFT JOIN users ON prospect_lists.assigned_user_id=users.id where prospect_lists.deleted=0 ORDER BY prospect_lists.name"; $actual = $prospectList->create_list_query('', ''); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); //test with valid string params $expected = "SELECT users.user_name as assigned_user_name, prospect_lists.* FROM prospect_lists LEFT JOIN users ON prospect_lists.assigned_user_id=users.id where users.user_name = \"\" AND prospect_lists.deleted=0 ORDER BY prospect_lists.id"; $actual = $prospectList->create_list_query('prospect_lists.id', 'users.user_name = ""'); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } - public function testProspectList() + public function testProspectList(): void { // Execute the constructor and check for the Object type and attributes $prospectList = BeanFactory::newBean('ProspectLists'); - $this->assertInstanceOf('ProspectList', $prospectList); - $this->assertInstanceOf('SugarBean', $prospectList); + self::assertInstanceOf('ProspectList', $prospectList); + self::assertInstanceOf('SugarBean', $prospectList); - $this->assertAttributeEquals('prospect_lists', 'table_name', $prospectList); - $this->assertAttributeEquals('ProspectLists', 'module_dir', $prospectList); - $this->assertAttributeEquals('ProspectList', 'object_name', $prospectList); + self::assertEquals('prospect_lists', $prospectList->table_name); + self::assertEquals('ProspectLists', $prospectList->module_dir); + self::assertEquals('ProspectList', $prospectList->object_name); - $this->assertAttributeEquals("prospect_lists_prospects", 'rel_prospects_table', $prospectList); + self::assertEquals("prospect_lists_prospects", $prospectList->rel_prospects_table); } - public function testget_summary_text() + public function testget_summary_text(): void { $prospectList = BeanFactory::newBean('ProspectLists'); //test without setting name - $this->assertEquals(null, $prospectList->get_summary_text()); + self::assertEquals(null, $prospectList->get_summary_text()); //test with name set $prospectList->name = "test"; - $this->assertEquals('test', $prospectList->get_summary_text()); + self::assertEquals('test', $prospectList->get_summary_text()); } /** * @todo: NEEDS FIXING! */ - public function testcreate_export_members_query() + public function testcreate_export_members_query(): void { /* $prospectList = BeanFactory::newBean('ProspectLists'); @@ -94,10 +94,10 @@ class ProspectListTest extends SuitePHPUnitFrameworkTestCase $actual = $prospectList->create_export_members_query('1'); $this->assertSame($expected,$actual); */ - $this->assertTrue(true, "NEEDS FIXING!"); + self::assertTrue(true, "NEEDS FIXING!"); } - public function testsave() + public function testsave(): void { $prospectList = BeanFactory::newBean('ProspectLists'); @@ -107,8 +107,8 @@ class ProspectListTest extends SuitePHPUnitFrameworkTestCase $result = $prospectList->save(); //test for record ID to verify that record is saved - $this->assertTrue(isset($prospectList->id)); - $this->assertEquals(36, strlen($prospectList->id)); + self::assertTrue(isset($prospectList->id)); + self::assertEquals(36, strlen($prospectList->id)); //test set_prospect_relationship method @@ -122,15 +122,15 @@ class ProspectListTest extends SuitePHPUnitFrameworkTestCase //mark the record as deleted and verify that this record cannot be retrieved anymore. $prospectList->mark_deleted($prospectList->id); $result = $prospectList->retrieve($prospectList->id); - $this->assertEquals(null, $result); + self::assertEquals(null, $result); } - public function testsave_relationship_changes() + public function testsave_relationship_changes(): void { - $this->markTestIncomplete('Error in query: columns mismatch | Error in methodd call params: 2nd param should be array but string given'); + self::markTestIncomplete('Error in query: columns mismatch | Error in methodd call params: 2nd param should be array but string given'); } - public function set_prospect_relationship($id) + public function set_prospect_relationship($id): void { $prospectList = BeanFactory::newBean('ProspectLists'); @@ -142,7 +142,7 @@ class ProspectListTest extends SuitePHPUnitFrameworkTestCase $expected_count = $prospectList->get_entry_count(); - $this->assertEquals(2, $expected_count); + self::assertEquals(2, $expected_count); //test clear_prospect_relationship method with expected counts @@ -150,7 +150,7 @@ class ProspectListTest extends SuitePHPUnitFrameworkTestCase $this->clear_prospect_relationship($id, '2'); } - public function set_prospect_relationship_single($id) + public function set_prospect_relationship_single($id): void { $prospectList = BeanFactory::newBean('ProspectLists'); @@ -159,12 +159,12 @@ class ProspectListTest extends SuitePHPUnitFrameworkTestCase $expected_count = $prospectList->get_entry_count(); - $this->assertEquals(1, $expected_count); + self::assertEquals(1, $expected_count); $this->clear_prospect_relationship($id, '3'); } - public function clear_prospect_relationship($id, $related_id) + public function clear_prospect_relationship($id, $related_id): void { $prospectList = BeanFactory::newBean('ProspectLists'); @@ -177,101 +177,99 @@ class ProspectListTest extends SuitePHPUnitFrameworkTestCase $prospectList->clear_prospect_relationship($id, $related_id, 'related'); $expected_count = (int)$prospectList->get_entry_count(); - $this->assertEquals($initial_count - 1, $expected_count); + self::assertEquals($initial_count - 1, $expected_count); } - public function testmark_relationships_deleted() + public function testmark_relationships_deleted(): void { $prospectList = BeanFactory::newBean('ProspectLists'); // Execute the method and test that it works and doesn't throw an exception. try { $prospectList->mark_relationships_deleted(''); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } - $this->markTestIncomplete('Method has no implementation'); + self::markTestIncomplete('Method has no implementation'); } - public function testfill_in_additional_list_fields() + public function testfill_in_additional_list_fields(): void { $prospectList = BeanFactory::newBean('ProspectLists'); // Execute the method and test that it works and doesn't throw an exception. try { $prospectList->fill_in_additional_list_fields(); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } - $this->markTestIncomplete('Method has no implementation'); + self::markTestIncomplete('Method has no implementation'); } - public function testfill_in_additional_detail_fields() + public function testfill_in_additional_detail_fields(): void { $prospectList = BeanFactory::newBean('ProspectLists'); $prospectList->fill_in_additional_detail_fields(); - $this->assertEquals(0, $prospectList->entry_count); + self::assertEquals(0, $prospectList->entry_count); } - public function testupdate_currency_id() + public function testupdate_currency_id(): void { $prospectList = BeanFactory::newBean('ProspectLists'); // Execute the method and test that it works and doesn't throw an exception. try { $prospectList->update_currency_id('', ''); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } - $this->markTestIncomplete('Method has no implementation'); + self::markTestIncomplete('Method has no implementation'); } - public function testget_entry_count() + public function testget_entry_count(): void { - $prospectList = BeanFactory::newBean('ProspectLists'); - - $result = $prospectList->get_entry_count(); - $this->assertEquals(0, $result); + $result = BeanFactory::newBean('ProspectLists')->get_entry_count(); + self::assertEquals(0, $result); } - public function testget_list_view_data() + public function testget_list_view_data(): void { $prospectList = BeanFactory::newBean('ProspectLists'); $expected = array( "DELETED"=> 0, "ENTRY_COUNT"=> '0' ); $actual = $prospectList->get_list_view_data(); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } - public function testbuild_generic_where_clause() + public function testbuild_generic_where_clause(): void { $prospectList = BeanFactory::newBean('ProspectLists'); //test with empty string params $expected = "prospect_lists.name like '%'"; $actual = $prospectList->build_generic_where_clause(''); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); //test with valid string params $expected = "prospect_lists.name like '1%'"; $actual = $prospectList->build_generic_where_clause('1'); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } - public function testbean_implements() + public function testbean_implements(): void { $prospectList = BeanFactory::newBean('ProspectLists'); - $this->assertEquals(false, $prospectList->bean_implements('')); //test with blank value - $this->assertEquals(false, $prospectList->bean_implements('test')); //test with invalid value - $this->assertEquals(true, $prospectList->bean_implements('ACL')); //test with valid value + self::assertEquals(false, $prospectList->bean_implements('')); //test with blank value + self::assertEquals(false, $prospectList->bean_implements('test')); //test with invalid value + self::assertEquals(true, $prospectList->bean_implements('ACL')); //test with valid value } } diff --git a/tests/unit/phpunit/modules/Prospects/ProspectTest.php b/tests/unit/phpunit/modules/Prospects/ProspectTest.php index 52aef85f4..db1b33b0d 100644 --- a/tests/unit/phpunit/modules/Prospects/ProspectTest.php +++ b/tests/unit/phpunit/modules/Prospects/ProspectTest.php @@ -13,24 +13,24 @@ class ProspectTest extends SuitePHPUnitFrameworkTestCase $current_user = BeanFactory::newBean('Users'); } - public function testProspect() + public function testProspect(): void { // Execute the constructor and check for the Object type and attributes $prospect = BeanFactory::newBean('Prospects'); - $this->assertInstanceOf('Prospect', $prospect); - $this->assertInstanceOf('Person', $prospect); - $this->assertInstanceOf('SugarBean', $prospect); + self::assertInstanceOf('Prospect', $prospect); + self::assertInstanceOf('Person', $prospect); + self::assertInstanceOf('SugarBean', $prospect); - $this->assertAttributeEquals('prospects', 'table_name', $prospect); - $this->assertAttributeEquals('Prospects', 'module_dir', $prospect); - $this->assertAttributeEquals('Prospect', 'object_name', $prospect); + self::assertEquals('prospects', $prospect->table_name); + self::assertEquals('Prospects', $prospect->module_dir); + self::assertEquals('Prospect', $prospect->object_name); - $this->assertAttributeEquals(true, 'new_schema', $prospect); - $this->assertAttributeEquals(true, 'importable', $prospect); + self::assertEquals(true, $prospect->new_schema); + self::assertEquals(true, $prospect->importable); } - public function testfill_in_additional_list_fields() + public function testfill_in_additional_list_fields(): void { $prospect = BeanFactory::newBean('Prospects'); @@ -42,11 +42,11 @@ class ProspectTest extends SuitePHPUnitFrameworkTestCase $prospect->fill_in_additional_list_fields(); - $this->assertAttributeEquals('last', 'full_name', $prospect); - $this->assertAttributeEquals('last <email1@test.com>', 'email_and_name1', $prospect); + self::assertEquals('last', $prospect->full_name); + self::assertEquals('last <email1@test.com>', $prospect->email_and_name1); } - public function testfill_in_additional_detail_fields() + public function testfill_in_additional_detail_fields(): void { $prospect = BeanFactory::newBean('Prospects'); @@ -58,65 +58,61 @@ class ProspectTest extends SuitePHPUnitFrameworkTestCase $prospect->fill_in_additional_detail_fields(); - $this->assertAttributeEquals('last', 'full_name', $prospect); + self::assertEquals('last', $prospect->full_name); } - public function testbuild_generic_where_clause() + public function testbuild_generic_where_clause(): void { $prospect = BeanFactory::newBean('Prospects'); //test with empty string params $expected = "prospects.last_name like '%' or prospects.first_name like '%' or prospects.assistant like '%'"; $actual = $prospect->build_generic_where_clause(''); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); //test with valid string params $expected = "prospects.last_name like '1%' or prospects.first_name like '1%' or prospects.assistant like '1%' or prospects.phone_home like '%1%' or prospects.phone_mobile like '%1%' or prospects.phone_work like '%1%' or prospects.phone_other like '%1%' or prospects.phone_fax like '%1%' or prospects.assistant_phone like '%1%'"; $actual = $prospect->build_generic_where_clause('1'); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } - public function testconverted_prospect() + public function testconverted_prospect(): void { $prospect = BeanFactory::newBean('Prospects'); // Execute the method and test that it works and doesn't throw an exception. try { //$prospect->converted_prospect('1', '2', '3', '4'); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } - $this->markTestIncomplete('Multiple errors in query'); + self::markTestIncomplete('Multiple errors in query'); } - public function testbean_implements() + public function testbean_implements(): void { $prospect = BeanFactory::newBean('Prospects'); - $this->assertEquals(false, $prospect->bean_implements('')); //test with blank value - $this->assertEquals(false, $prospect->bean_implements('test')); //test with invalid value - $this->assertEquals(true, $prospect->bean_implements('ACL')); //test with valid value + self::assertEquals(false, $prospect->bean_implements('')); //test with blank value + self::assertEquals(false, $prospect->bean_implements('test')); //test with invalid value + self::assertEquals(true, $prospect->bean_implements('ACL')); //test with valid value } - public function testretrieveTargetList() + public function testretrieveTargetList(): void { - $prospect = BeanFactory::newBean('Prospects'); - - $result = $prospect->retrieveTargetList('', array('id', 'first_name'), 0, 1, 1, 0, 'Accounts'); - $this->assertTrue(is_array($result)); + $result = BeanFactory::newBean('Prospects')->retrieveTargetList('', array('id', 'first_name'), 0, 1, 1, 0, 'Accounts'); + self::assertIsArray($result); } - public function testretrieveTarget() + public function testretrieveTarget(): void { - $prospect = BeanFactory::newBean('Prospects'); - - $result = $prospect->retrieveTarget(''); - $this->assertEquals(null, $result); + $result = BeanFactory::newBean('Prospects')->retrieveTarget(''); + self::assertEquals(null, $result); } - public function testget_unlinked_email_query() + public function testget_unlinked_email_query(): void { self::markTestIncomplete('environment dependency (CRLF2)'); @@ -124,6 +120,6 @@ class ProspectTest extends SuitePHPUnitFrameworkTestCase $expected = "SELECT emails.id FROM emails JOIN (select DISTINCT email_id from emails_email_addr_rel eear\n\n join email_addr_bean_rel eabr on eabr.bean_id ='' and eabr.bean_module = 'Prospects' and\n eabr.email_address_id = eear.email_address_id and eabr.deleted=0\n where eear.deleted=0 and eear.email_id not in\n (select eb.email_id from emails_beans eb where eb.bean_module ='Prospects' and eb.bean_id = '')\n ) derivedemails on derivedemails.email_id = emails.id"; $actual = $prospect->get_unlinked_email_query(); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } } diff --git a/tests/unit/phpunit/modules/Relationships/RelationshipTest.php b/tests/unit/phpunit/modules/Relationships/RelationshipTest.php index 9b01887d2..086e18fef 100644 --- a/tests/unit/phpunit/modules/Relationships/RelationshipTest.php +++ b/tests/unit/phpunit/modules/Relationships/RelationshipTest.php @@ -4,28 +4,28 @@ use SuiteCRM\Test\SuitePHPUnitFrameworkTestCase; class RelationshipTest extends SuitePHPUnitFrameworkTestCase { - public function testRelationship() + public function testRelationship(): void { // Execute the constructor and check for the Object type and attributes $relationship = BeanFactory::newBean('Relationships'); - $this->assertInstanceOf('Relationship', $relationship); - $this->assertInstanceOf('SugarBean', $relationship); + self::assertInstanceOf('Relationship', $relationship); + self::assertInstanceOf('SugarBean', $relationship); - $this->assertAttributeEquals('Relationships', 'module_dir', $relationship); - $this->assertAttributeEquals('Relationship', 'object_name', $relationship); - $this->assertAttributeEquals('relationships', 'table_name', $relationship); + self::assertEquals('Relationships', $relationship->module_dir); + self::assertEquals('Relationship', $relationship->object_name); + self::assertEquals('relationships', $relationship->table_name); - $this->assertAttributeEquals(true, 'new_schema', $relationship); + self::assertEquals(true, $relationship->new_schema); } - public function testis_self_referencing() + public function testis_self_referencing(): void { //test without setting any attributes $relationship = BeanFactory::newBean('Relationships'); $result = $relationship->is_self_referencing(); - $this->assertEquals(true, $result); + self::assertEquals(true, $result); //test with attributes set to different values $relationship = BeanFactory::newBean('Relationships'); @@ -36,7 +36,7 @@ class RelationshipTest extends SuitePHPUnitFrameworkTestCase $relationship->rhs_key = 'rhs_key'; $result = $relationship->is_self_referencing(); - $this->assertEquals(false, $result); + self::assertEquals(false, $result); //test with attributes set to same values $relationship = BeanFactory::newBean('Relationships'); @@ -47,12 +47,12 @@ class RelationshipTest extends SuitePHPUnitFrameworkTestCase $relationship->rhs_key = 'key'; $result = $relationship->is_self_referencing(); - $this->assertEquals(true, $result); + self::assertEquals(true, $result); } - public function testexists() + public function testexists(): void { - //unset and reconnect Db to resolve mysqli fetch exeception + // Unset and reconnect Db to resolve mysqli fetch exception $db = DBManagerFactory::getInstance(); $db->disconnect(); unset($db->database); @@ -61,28 +61,28 @@ class RelationshipTest extends SuitePHPUnitFrameworkTestCase $relationship = BeanFactory::newBean('Relationships'); //test with invalid relationship - $result = $relationship->exists('test_test', $db); - $this->assertEquals(false, $result); + $result = $relationship::exists('test_test', $db); + self::assertEquals(false, $result); //test with valid relationship - $result = $relationship->exists('roles_users', $db); - $this->assertEquals(true, $result); + $result = $relationship::exists('roles_users', $db); + self::assertEquals(true, $result); } - public function testdelete() + public function testdelete(): void { $db = DBManagerFactory::getInstance(); // Execute the method and test that it works and doesn't throw an exception. try { Relationship::delete('test_test', $db); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } } - public function testget_other_module() + public function testget_other_module(): void { //unset and reconnect Db to resolve mysqli fetch exeception $db = DBManagerFactory::getInstance(); @@ -94,16 +94,16 @@ class RelationshipTest extends SuitePHPUnitFrameworkTestCase //test with invalid relationship $result = $relationship->get_other_module('test_test', 'test', $db); - $this->assertEquals(false, $result); + self::assertEquals(false, $result); //test with valid relationship $result = $relationship->get_other_module('roles_users', 'Roles', $db); - $this->assertEquals('Users', $result); + self::assertEquals('Users', $result); } - public function testretrieve_by_sides() + public function testRetrieveBySides(): void { - //unset and reconnect Db to resolve mysqli fetch exeception + // Unset and reconnect Db to resolve mysqli fetch exception $db = DBManagerFactory::getInstance(); $db->disconnect(); unset($db->database); @@ -111,23 +111,23 @@ class RelationshipTest extends SuitePHPUnitFrameworkTestCase $relationship = BeanFactory::newBean('Relationships'); - //test with invalid relationship + // Test with invalid relationship $result = $relationship->retrieve_by_sides('test1', 'test2', $db); - $this->assertEquals(null, $result); + self::assertEquals(null, $result); - //test with valid relationship + // Test with valid relationship $result = $relationship->retrieve_by_sides('Roles', 'Users', $db); - $this->assertEquals('Users', $result['rhs_module']); - $this->assertEquals('Roles', $result['lhs_module']); + self::assertEquals('Users', $result['rhs_module']); + self::assertEquals('Roles', $result['lhs_module']); - $this->assertEquals('id', $result['rhs_key']); - $this->assertEquals('id', $result['lhs_key']); + self::assertEquals('id', $result['rhs_key']); + self::assertEquals('id', $result['lhs_key']); - $this->assertEquals('many-to-many', $result['relationship_type']); + self::assertEquals('many-to-many', $result['relationship_type']); } - public function testretrieve_by_modules() + public function testRetrieveByModules(): void { //unset and reconnect Db to resolve mysqli fetch exeception $db = DBManagerFactory::getInstance(); @@ -137,89 +137,88 @@ class RelationshipTest extends SuitePHPUnitFrameworkTestCase $relationship = BeanFactory::newBean('Relationships'); - //test with invalid relationship - $result = $relationship->retrieve_by_modules('test1', 'test2', $db); - $this->assertEquals(null, $result); + // Test with invalid relationship + $result = $relationship::retrieve_by_modules('test1', 'test2', $db); + self::assertEquals(null, $result); - //test with valid relationship but incorecct type - $result = $relationship->retrieve_by_modules('Roles', 'Users', $db, 'one-to-many'); - $this->assertEquals(null, $result); + // Test with valid relationship but incorrect type + $result = $relationship::retrieve_by_modules('Roles', 'Users', $db, 'one-to-many'); + self::assertEquals(null, $result); - //test with valid relationship and valid type - $result = $relationship->retrieve_by_modules('Roles', 'Users', $db, 'many-to-many'); - $this->assertEquals('roles_users', $result); + // Test with valid relationship and valid type + $result = $relationship::retrieve_by_modules('Roles', 'Users', $db, 'many-to-many'); + self::assertEquals('roles_users', $result); } - public function testretrieve_by_name() + public function testretrieve_by_name(): void { $relationship = BeanFactory::newBean('Relationships'); //test with invalid relationship $result = $relationship->retrieve_by_name('test_test'); - $this->assertEquals(false, $result); + self::assertEquals(false, $result); //test with invalid relationship unset($result); $result = $relationship->retrieve_by_name('roles_users'); - $this->assertEquals(null, $result); + self::assertEquals(null, $result); - $this->assertEquals('Users', $relationship->rhs_module); - $this->assertEquals('Roles', $relationship->lhs_module); + self::assertEquals('Users', $relationship->rhs_module); + self::assertEquals('Roles', $relationship->lhs_module); - $this->assertEquals('id', $relationship->rhs_key); - $this->assertEquals('id', $relationship->lhs_key); + self::assertEquals('id', $relationship->rhs_key); + self::assertEquals('id', $relationship->lhs_key); - $this->assertEquals('many-to-many', $relationship->relationship_type); + self::assertEquals('many-to-many', $relationship->relationship_type); } - public function testload_relationship_meta() + public function testload_relationship_meta(): void { $relationship = BeanFactory::newBean('Relationships'); $relationship->load_relationship_meta(); - $this->assertTrue(isset($GLOBALS['relationships'])); + self::assertTrue(isset($GLOBALS['relationships'])); } - public function testbuild_relationship_cache() + public function testbuild_relationship_cache(): void { $relationship = BeanFactory::newBean('Relationships'); // Execute the method and test that it works and doesn't throw an exception. try { $relationship->build_relationship_cache(); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } } - public function testcache_file_dir() + public function testcache_file_dir(): void { $result = Relationship::cache_file_dir(); - $this->assertEquals('cache/modules/Relationships', $result); + self::assertEquals('cache/modules/Relationships', $result); } - public function testcache_file_name_only() + public function testcache_file_name_only(): void { $result = Relationship::cache_file_name_only(); - $this->assertEquals('relationships.cache.php', $result); + self::assertEquals('relationships.cache.php', $result); } - public function testdelete_cache() + public function testdelete_cache(): void { // Execute the method and test that it works and doesn't throw an exception. try { Relationship::delete_cache(); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } } - public function testtrace_relationship_module() + public function testtrace_relationship_module(): void { - $relationship = BeanFactory::newBean('Relationships'); - $result = $relationship->trace_relationship_module('Roles', 'Users'); - $this->assertInstanceOf('User', $result); + $result = BeanFactory::newBean('Relationships')->trace_relationship_module('Roles', 'Users'); + self::assertInstanceOf('User', $result); } } diff --git a/tests/unit/phpunit/modules/Releases/ReleaseTest.php b/tests/unit/phpunit/modules/Releases/ReleaseTest.php index ef2a7e3ea..ce2ee22d9 100644 --- a/tests/unit/phpunit/modules/Releases/ReleaseTest.php +++ b/tests/unit/phpunit/modules/Releases/ReleaseTest.php @@ -4,73 +4,73 @@ use SuiteCRM\Test\SuitePHPUnitFrameworkTestCase; class ReleaseTest extends SuitePHPUnitFrameworkTestCase { - public function testRelease() + public function testRelease(): void { // Execute the constructor and check for the Object type and attributes $release = BeanFactory::newBean('Releases'); - $this->assertInstanceOf('Release', $release); - $this->assertInstanceOf('SugarBean', $release); + self::assertInstanceOf('Release', $release); + self::assertInstanceOf('SugarBean', $release); - $this->assertAttributeEquals('releases', 'table_name', $release); - $this->assertAttributeEquals('Releases', 'module_dir', $release); - $this->assertAttributeEquals('Release', 'object_name', $release); + self::assertEquals('releases', $release->table_name); + self::assertEquals('Releases', $release->module_dir); + self::assertEquals('Release', $release->object_name); - $this->assertAttributeEquals(true, 'new_schema', $release); + self::assertEquals(true, $release->new_schema); } - public function testget_summary_text() + public function testget_summary_text(): void { $release = BeanFactory::newBean('Releases'); //test without setting name - $this->assertEquals(null, $release->get_summary_text()); + self::assertEquals(null, $release->get_summary_text()); //test with name set $release->name = 'test'; - $this->assertEquals('test', $release->get_summary_text()); + self::assertEquals('test', $release->get_summary_text()); } - public function testget_releases() + public function testget_releases(): void { $release = BeanFactory::newBean('Releases'); //test with default params $result = $release->get_releases(); - $this->assertTrue(is_array($result)); + self::assertIsArray($result); //test with custom params $result = $release->get_releases(true, 'Hidden', 'name is not null'); - $this->assertTrue(is_array($result)); + self::assertIsArray($result); } - public function testfill_in_additional_list_fields() + public function testfill_in_additional_list_fields(): void { $release = BeanFactory::newBean('Releases'); // Execute the method and test that it works and doesn't throw an exception. try { $release->fill_in_additional_list_fields(); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } } - public function testfill_in_additional_detail_fields() + public function testfill_in_additional_detail_fields(): void { $release = BeanFactory::newBean('Releases'); // Execute the method and test that it works and doesn't throw an exception. try { $release->fill_in_additional_detail_fields(); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } } - public function testget_list_view_data() + public function testget_list_view_data(): void { $release = BeanFactory::newBean('Releases'); @@ -86,21 +86,21 @@ class ReleaseTest extends SuitePHPUnitFrameworkTestCase $actual = $release->get_list_view_data(); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } - public function testbuild_generic_where_clause() + public function testbuild_generic_where_clause(): void { $release = BeanFactory::newBean('Releases'); //test with empty string params $expected = "name like '%'"; $actual = $release->build_generic_where_clause(''); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); //test with valid string params $expected = "name like 'test%'"; $actual = $release->build_generic_where_clause('test'); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } } diff --git a/tests/unit/phpunit/modules/Roles/RoleTest.php b/tests/unit/phpunit/modules/Roles/RoleTest.php index dd046a317..656744e28 100644 --- a/tests/unit/phpunit/modules/Roles/RoleTest.php +++ b/tests/unit/phpunit/modules/Roles/RoleTest.php @@ -13,51 +13,51 @@ class RoleTest extends SuitePHPUnitFrameworkTestCase $current_user = BeanFactory::newBean('Users'); } - public function testRole() + public function testRole(): void { // Execute the constructor and check for the Object type and attributes $role = BeanFactory::newBean('Roles'); - $this->assertInstanceOf('Role', $role); - $this->assertInstanceOf('SugarBean', $role); + self::assertInstanceOf('Role', $role); + self::assertInstanceOf('SugarBean', $role); - $this->assertAttributeEquals('roles', 'table_name', $role); - $this->assertAttributeEquals('roles_modules', 'rel_module_table', $role); - $this->assertAttributeEquals('Roles', 'module_dir', $role); - $this->assertAttributeEquals('Role', 'object_name', $role); + self::assertEquals('roles', $role->table_name); + self::assertEquals('roles_modules', $role->rel_module_table); + self::assertEquals('Roles', $role->module_dir); + self::assertEquals('Role', $role->object_name); - $this->assertAttributeEquals(true, 'new_schema', $role); - $this->assertAttributeEquals(true, 'disable_row_level_security', $role); + self::assertEquals(true, $role->new_schema); + self::assertEquals(true, $role->disable_row_level_security); } - public function testget_summary_text() + public function testget_summary_text(): void { $role = BeanFactory::newBean('Roles'); //test without setting name - $this->assertEquals(null, $role->get_summary_text()); + self::assertEquals(null, $role->get_summary_text()); //test with name set $role->name = 'test'; - $this->assertEquals('test', $role->get_summary_text()); + self::assertEquals('test', $role->get_summary_text()); } - public function testcreate_export_query() + public function testcreate_export_query(): void { $role = BeanFactory::newBean('Roles'); //test with empty string params $expected = ' SELECT roles.* FROM roles where roles.deleted=0'; $actual = $role->create_export_query('', ''); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); //test with valid string params $expected = ' SELECT roles.* FROM roles where (roles.name = "") AND roles.deleted=0'; $actual = $role->create_export_query('roles.id', 'roles.name = ""'); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } - public function testSet_module_relationshipAndQuery_modules() + public function testSet_module_relationshipAndQuery_modules(): void { $role = BeanFactory::newBean('Roles'); @@ -70,13 +70,13 @@ class RoleTest extends SuitePHPUnitFrameworkTestCase //get the related records count $result = $role->query_modules(); - $this->assertGreaterThanOrEqual(2, count((array)$result)); + self::assertGreaterThanOrEqual(2, count((array)$result)); //test clear_module_relationship method $this->clear_module_relationship($role->id); } - public function clear_module_relationship($id) + public function clear_module_relationship($id): void { $role = BeanFactory::newBean('Roles'); @@ -85,10 +85,10 @@ class RoleTest extends SuitePHPUnitFrameworkTestCase //get related records count and verify that records are removed $result = $role->query_modules(); - $this->assertEquals(0, count((array)$result)); + self::assertCount(0, (array)$result); } - public function testSet_user_relationshipAndCheck_user_role_count() + public function testSet_user_relationshipAndCheck_user_role_count(): void { // test $role = BeanFactory::newBean('Roles'); @@ -101,11 +101,11 @@ class RoleTest extends SuitePHPUnitFrameworkTestCase //get the related records count $result = $role->check_user_role_count('1'); - $this->assertGreaterThanOrEqual(1, count((array)$result)); + self::assertGreaterThanOrEqual(1, count((array)$result)); //get the related records count $result = $role->check_user_role_count('2'); - $this->assertGreaterThanOrEqual(1, count((array)$result)); + self::assertGreaterThanOrEqual(1, count((array)$result)); //test get_users method $this->get_users($role->id); @@ -115,40 +115,36 @@ class RoleTest extends SuitePHPUnitFrameworkTestCase $this->clear_user_relationship($role->id, '2'); } - public function get_users($id) + public function get_users($id): void { $role = BeanFactory::newBean('Roles'); $role->id = $id; $result = $role->get_users(); - $this->assertTrue(is_array($result)); + self::assertIsArray($result); } - public function clear_user_relationship($role_id, $user_id) + public function clear_user_relationship($role_id, $user_id): void { - $role = BeanFactory::newBean('Roles'); - //get related records count and verify that records are removed - $result = $role->clear_user_relationship($role_id, $user_id); - $this->assertEquals(0, count((array)$result)); + $result = BeanFactory::newBean('Roles')->clear_user_relationship($role_id, $user_id); + self::assertCount(0, (array)$result); } - public function testquery_user_allowed_modules() + public function testquery_user_allowed_modules(): void { - $role = BeanFactory::newBean('Roles'); - - $result = $role->query_user_allowed_modules('1'); - $this->assertTrue(is_array($result)); + $result = BeanFactory::newBean('Roles')->query_user_allowed_modules('1'); + self::assertIsArray($result); } - public function testquery_user_disallowed_modules() + public function testquery_user_disallowed_modules(): void { $role = BeanFactory::newBean('Roles'); $allowed = array('Accounts' => 'Accounts', 'Leads' => 'Leads'); $result = $role->query_user_disallowed_modules(null, $allowed); - $this->assertTrue(is_array($result)); + self::assertIsArray($result); } } diff --git a/tests/unit/phpunit/modules/SavedSearch/SavedSearchTest.php b/tests/unit/phpunit/modules/SavedSearch/SavedSearchTest.php index 3310d1b4d..5b29f55cc 100644 --- a/tests/unit/phpunit/modules/SavedSearch/SavedSearchTest.php +++ b/tests/unit/phpunit/modules/SavedSearch/SavedSearchTest.php @@ -13,74 +13,40 @@ class SavedSearchTest extends SuitePHPUnitFrameworkTestCase $current_user = BeanFactory::newBean('Users'); } - public function testSavedSearch() + public function testSavedSearch(): void { // Execute the constructor and check for the Object type and attributes $savedSearch = BeanFactory::newBean('SavedSearch'); - $this->assertInstanceOf('SavedSearch', $savedSearch); - $this->assertInstanceOf('SugarBean', $savedSearch); + self::assertInstanceOf('SavedSearch', $savedSearch); + self::assertInstanceOf('SugarBean', $savedSearch); - $this->assertAttributeEquals('saved_search', 'table_name', $savedSearch); - $this->assertAttributeEquals('SavedSearch', 'module_dir', $savedSearch); - $this->assertAttributeEquals('SavedSearch', 'object_name', $savedSearch); + self::assertEquals('saved_search', $savedSearch->table_name); + self::assertEquals('SavedSearch', $savedSearch->module_dir); + self::assertEquals('SavedSearch', $savedSearch->object_name); //test with parameters - $savedSearch = new SavedSearch(array('id', 'name'), 'id', 'ASC'); + $savedSearch = new SavedSearch(['id', 'name'], 'id', 'ASC'); - $this->assertAttributeEquals(array('id', 'name'), 'columns', $savedSearch); - $this->assertAttributeEquals('id', 'orderBy', $savedSearch); - $this->assertAttributeEquals('ASC', 'sortOrder', $savedSearch); + self::assertEquals('id', $savedSearch->orderBy); + self::assertEquals('ASC', $savedSearch->sortOrder); } - public function testgetForm() + public function testgetForm(): void { - $savedSearch = new SavedSearch(array('id', 'name'), 'id', 'ASC'); - $result = $savedSearch->getForm('Leads'); + $result = (new SavedSearch(array('id', 'name'), 'id', 'ASC'))->getForm('Leads'); - $this->assertGreaterThan(0, strlen($result)); + self::assertGreaterThan(0, strlen($result)); } - public function testgetSelect() + public function testgetSelect(): void { - $savedSearch = new SavedSearch(array('id', 'name'), 'id', 'ASC'); - $result = $savedSearch->getSelect('Leads'); + $result = (new SavedSearch(array('id', 'name'), 'id', 'ASC'))->getSelect('Leads'); - $this->assertGreaterThan(0, strlen($result)); + self::assertGreaterThan(0, strlen($result)); } -// public function testMain() -// { -// $savedSearch = BeanFactory::newBean('SavedSearch'); -// -// $savedSearch->name = 'test'; -// $savedSearch->search_module = 'Leads'; -// $savedSearch->save(); -// -// //test for record ID to verify that record is saved -// $this->assertTrue(isset($savedSearch->id)); -// $this->assertEquals(36, strlen($savedSearch->id)); -// -// -// // Where is the unit test? -// // Where is the main method? -// // Why is this combined? -// // TODO: TASK: UNDEFINED - build the tests for the following methods. -// $this->markTestIncomplete(''); - //// //test handleSave method - //// $this->handleSaveAndRetrieveSavedSearch($savedSearch->id); - //// - //// //test returnSavedSearch method - //// $this->returnSavedSearch($savedSearch->id); - //// - //// //test returnSavedSearchContents method - //// $this->returnSavedSearchContents($savedSearch->id); - //// - //// //test handleDelete method - //// $this->handleDelete($savedSearch->id); -// } - - public function handleSaveAndRetrieveSavedSearch($id) + public function handleSaveAndRetrieveSavedSearch($id): void { $savedSearch = BeanFactory::newBean('SavedSearch'); $searchModuleBean = BeanFactory::newBean('Leads'); @@ -94,56 +60,56 @@ class SavedSearchTest extends SuitePHPUnitFrameworkTestCase //execute the method and then retrieve back to verify contents attribute $savedSearch->handleSave('', false, false, $id, $searchModuleBean); $savedSearch->retrieveSavedSearch($id); - $this->assertSame($expected, $savedSearch->contents); + self::assertSame($expected, $savedSearch->contents); } - public function handleDelete($id) + public function handleDelete($id): void { $savedSearch = BeanFactory::newBean('SavedSearch'); $savedSearch->handleDelete($id); $result = $savedSearch->retrieve($id); - $this->assertEquals(null, $result); + self::assertEquals(null, $result); } - public function returnSavedSearch($id) + public function returnSavedSearch($id): void { $savedSearch = BeanFactory::newBean('SavedSearch'); // Execute the method and test that it works and doesn't throw an exception. try { $savedSearch->returnSavedSearch($id); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } } - public function returnSavedSearchContents($id) + public function returnSavedSearchContents($id): void { $savedSearch = BeanFactory::newBean('SavedSearch'); // Execute the method and test that it works and doesn't throw an exception. try { $result = $savedSearch->returnSavedSearchContents($id); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } } - public function testhandleRedirect() + public function testhandleRedirect(): void { $savedSearch = BeanFactory::newBean('SavedSearch'); $search_query = '&orderBy=&sortOrder=&query=&searchFormTab=&showSSDIV='; //$savedSearch->handleRedirect("Leads", $search_query, 1, 'true'); - $this->markTestIncomplete('method uses die'); + self::markTestIncomplete('method uses die'); } - public function testfill_in_additional_list_fields() + public function testfill_in_additional_list_fields(): void { $savedSearch = BeanFactory::newBean('SavedSearch'); @@ -152,11 +118,11 @@ class SavedSearchTest extends SuitePHPUnitFrameworkTestCase $savedSearch->fill_in_additional_list_fields(); - $this->assertEquals('Leads', $savedSearch->search_module); - $this->assertEquals('Administrator', $savedSearch->assigned_user_name); + self::assertEquals('Leads', $savedSearch->search_module); + self::assertEquals('Administrator', $savedSearch->assigned_user_name); } - public function testpopulateRequest() + public function testpopulateRequest(): void { $savedSearch = BeanFactory::newBean('SavedSearch'); @@ -168,8 +134,8 @@ class SavedSearchTest extends SuitePHPUnitFrameworkTestCase $savedSearch->populateRequest(); // verify that Request parameters are set - $this->assertEquals('Accounts', $_REQUEST['search_module']); - $this->assertEquals('test text', $_REQUEST['description']); - $this->assertEquals('some content', $_REQUEST['test_content']); + self::assertEquals('Accounts', $_REQUEST['search_module']); + self::assertEquals('test text', $_REQUEST['description']); + self::assertEquals('some content', $_REQUEST['test_content']); } } diff --git a/tests/unit/phpunit/modules/Schedulers/SchedulerTest.php b/tests/unit/phpunit/modules/Schedulers/SchedulerTest.php index e9daec72c..05499ce11 100644 --- a/tests/unit/phpunit/modules/Schedulers/SchedulerTest.php +++ b/tests/unit/phpunit/modules/Schedulers/SchedulerTest.php @@ -17,35 +17,35 @@ class SchedulerTest extends SuitePHPUnitFrameworkTestCase $GLOBALS['mod_strings'] = return_module_language($GLOBALS['current_language'], 'Schedulers'); } - public function test__construct() + public function test__construct(): void { // Execute the constructor and check for the Object type and attributes $scheduler = BeanFactory::newBean('Schedulers'); - $this->assertInstanceOf('Scheduler', $scheduler); - $this->assertInstanceOf('SugarBean', $scheduler); + self::assertInstanceOf('Scheduler', $scheduler); + self::assertInstanceOf('SugarBean', $scheduler); - $this->assertAttributeEquals('schedulers', 'table_name', $scheduler); - $this->assertAttributeEquals('Schedulers', 'module_dir', $scheduler); - $this->assertAttributeEquals('Scheduler', 'object_name', $scheduler); + self::assertEquals('schedulers', $scheduler->table_name); + self::assertEquals('Schedulers', $scheduler->module_dir); + self::assertEquals('Scheduler', $scheduler->object_name); - $this->assertAttributeEquals(true, 'new_schema', $scheduler); - $this->assertAttributeEquals(true, 'process_save_dates', $scheduler); + self::assertEquals(true, $scheduler->new_schema); + self::assertEquals(true, $scheduler->process_save_dates); } - public function testinitUser() + public function testinitUser(): void { $user = Scheduler::initUser(); - $this->assertInstanceOf('User', $user); + self::assertInstanceOf('User', $user); } - public function testfireQualified() + public function testfireQualified(): void { $scheduler = BeanFactory::newBean('Schedulers'); //test without setting any attributes $result = $scheduler->fireQualified(); - $this->assertEquals(false, $result); + self::assertEquals(false, $result); //test with required attributes set $scheduler->id = 1; @@ -53,33 +53,32 @@ class SchedulerTest extends SuitePHPUnitFrameworkTestCase $scheduler->date_time_start = '2015-01-01 10:30:01'; $result = $scheduler->fireQualified(); - $this->assertEquals(true, $result); + self::assertEquals(true, $result); } - public function testcreateJob() + public function testcreateJob(): void { - $scheduler = BeanFactory::newBean('Schedulers'); - $result = $scheduler->createJob(); + $result = BeanFactory::newBean('Schedulers')->createJob(); - $this->assertInstanceOf('SchedulersJob', $result); + self::assertInstanceOf('SchedulersJob', $result); } - public function testcheckPendingJobs() + public function testcheckPendingJobs(): void { $scheduler = BeanFactory::newBean('Schedulers'); // Execute the method and test that it works and doesn't throw an exception. try { $scheduler->checkPendingJobs(new SugarJobQueue()); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } } - public function testderiveDBDateTimes() + public function testderiveDBDateTimes(): void { - $this->markTestIncomplete('Need to implement!'); + self::markTestIncomplete('Need to implement!'); // $scheduler = BeanFactory::newBean('Schedulers'); // @@ -102,19 +101,19 @@ class SchedulerTest extends SuitePHPUnitFrameworkTestCase // $this->assertEquals(false, (bool)$result); } - public function testhandleIntervalType() + public function testhandleIntervalType(): void { $scheduler = BeanFactory::newBean('Schedulers'); //execute the method with different job intervals - $this->assertEquals('On thehour', $scheduler->handleIntervalType('0', '0', '2', '2')); - $this->assertEquals('00:02', $scheduler->handleIntervalType('1', '0', '2', '2')); - $this->assertEquals('30th', $scheduler->handleIntervalType('2', '0', '2', '2')); - $this->assertEquals('December', $scheduler->handleIntervalType('3', '0', '2', '2')); - $this->assertEquals('Sunday', $scheduler->handleIntervalType('4', '0', '2', '2')); + self::assertEquals('On thehour', $scheduler->handleIntervalType('0', '0', '2', '2')); + self::assertEquals('00:02', $scheduler->handleIntervalType('1', '0', '2', '2')); + self::assertEquals('30th', $scheduler->handleIntervalType('2', '0', '2', '2')); + self::assertEquals('December', $scheduler->handleIntervalType('3', '0', '2', '2')); + self::assertEquals('Sunday', $scheduler->handleIntervalType('4', '0', '2', '2')); } - public function testsetIntervalHumanReadable() + public function testsetIntervalHumanReadable(): void { $scheduler = BeanFactory::newBean('Schedulers'); @@ -122,15 +121,15 @@ class SchedulerTest extends SuitePHPUnitFrameworkTestCase $scheduler->job_interval = '0::3::3::*::*'; $scheduler->parseInterval(); $scheduler->setIntervalHumanReadable(); - $this->assertEquals('On thehour; 03:00; 3rd', $scheduler->intervalHumanReadable); + self::assertEquals('On thehour; 03:00; 3rd', $scheduler->intervalHumanReadable); $scheduler->job_interval = '0::3::3::3::3'; $scheduler->parseInterval(); $scheduler->setIntervalHumanReadable(); - $this->assertEquals('On thehour; 03:00; 3rd; March; '. date("l", mktime(0, 0, 0, 3, 3, date("Y"))), $scheduler->intervalHumanReadable); + self::assertEquals('On thehour; 03:00; 3rd; March; '. date("l", mktime(0, 0, 0, 3, 3, date("Y"))), $scheduler->intervalHumanReadable); } - public function testsetStandardArraysAttributes() + public function testsetStandardArraysAttributes(): void { $scheduler = BeanFactory::newBean('Schedulers'); @@ -138,14 +137,14 @@ class SchedulerTest extends SuitePHPUnitFrameworkTestCase $scheduler->setStandardArraysAttributes(); - $this->assertEquals(array('*', 1, 2, 3, 4, 5, 6, 0), $scheduler->dayInt); - $this->assertEquals(array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12), $scheduler->monthsInt); - $this->assertEquals(array('', 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'), $scheduler->monthsLabel); - $this->assertEquals(array('*', '/', '-', ','), $scheduler->metricsVar); - $this->assertEquals(array(' every ', '', ' thru ', ' and '), $scheduler->metricsVal); + self::assertEquals(array('*', 1, 2, 3, 4, 5, 6, 0), $scheduler->dayInt); + self::assertEquals(array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12), $scheduler->monthsInt); + self::assertEquals(array('', 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'), $scheduler->monthsLabel); + self::assertEquals(array('*', '/', '-', ','), $scheduler->metricsVar); + self::assertEquals(array(' every ', '', ' thru ', ' and '), $scheduler->metricsVal); } - public function testparseInterval() + public function testparseInterval(): void { $scheduler = BeanFactory::newBean('Schedulers'); @@ -160,24 +159,24 @@ class SchedulerTest extends SuitePHPUnitFrameworkTestCase //execute the method and verify related attributes $scheduler->parseInterval(); - $this->assertTrue(is_array($scheduler->intervalParsed)); - $this->assertSame($expected, $scheduler->intervalParsed); + self::assertIsArray($scheduler->intervalParsed); + self::assertSame($expected, $scheduler->intervalParsed); } - public function testcheckCurl() + public function testcheckCurl(): void { $scheduler = BeanFactory::newBean('Schedulers'); // Execute the method and test that it works and doesn't throw an exception. try { $scheduler->checkCurl(); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } } - public function testdisplayCronInstructions() + public function testdisplayCronInstructions(): void { $scheduler = BeanFactory::newBean('Schedulers'); @@ -189,10 +188,10 @@ class SchedulerTest extends SuitePHPUnitFrameworkTestCase $renderedContent = ob_get_contents(); ob_end_clean(); - $this->assertGreaterThanOrEqual(0, strlen($renderedContent)); + self::assertGreaterThanOrEqual(0, strlen($renderedContent)); } - public function testrebuildDefaultSchedulers() + public function testrebuildDefaultSchedulers(): void { self::markTestIncomplete('enviroment dependency'); @@ -201,13 +200,13 @@ class SchedulerTest extends SuitePHPUnitFrameworkTestCase // Execute the method and test that it works and doesn't throw an exception. try { $scheduler->rebuildDefaultSchedulers(); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } } - public function testcreate_export_query() + public function testcreate_export_query(): void { self::markTestIncomplete('environment dependency'); $scheduler = BeanFactory::newBean('Schedulers'); @@ -215,15 +214,15 @@ class SchedulerTest extends SuitePHPUnitFrameworkTestCase //test with empty string params $expected = " SELECT schedulers.* , jt0.user_name created_by_name , jt0.created_by created_by_name_owner , 'Users' created_by_name_mod , jt1.user_name modified_by_name , jt1.created_by modified_by_name_owner , 'Users' modified_by_name_mod FROM schedulers LEFT JOIN users jt0 ON jt0.id=schedulers.created_by AND jt0.deleted=0\n AND jt0.deleted=0 LEFT JOIN users jt1 ON schedulers.modified_user_id=jt1.id AND jt1.deleted=0\n\n AND jt1.deleted=0 where schedulers.deleted=0"; $actual = $scheduler->create_export_query('', ''); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); //test with valid string params $expected = " SELECT schedulers.* , jt0.user_name created_by_name , jt0.created_by created_by_name_owner , 'Users' created_by_name_mod , jt1.user_name modified_by_name , jt1.created_by modified_by_name_owner , 'Users' modified_by_name_mod FROM schedulers LEFT JOIN users jt0 ON jt0.id=schedulers.created_by AND jt0.deleted=0\n AND jt0.deleted=0 LEFT JOIN users jt1 ON schedulers.modified_user_id=jt1.id AND jt1.deleted=0\n\n AND jt1.deleted=0 where (schedulers.name = \"\") AND schedulers.deleted=0"; $actual = $scheduler->create_export_query('schedulers.id', 'schedulers.name = ""'); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } - public function testfill_in_additional_list_fields() + public function testfill_in_additional_list_fields(): void { self::markTestIncomplete('environment dependency'); $scheduler = BeanFactory::newBean('Schedulers'); @@ -231,28 +230,28 @@ class SchedulerTest extends SuitePHPUnitFrameworkTestCase // Execute the method and test that it works and doesn't throw an exception. try { $scheduler->fill_in_additional_list_fields(); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } } - public function testfill_in_additional_detail_fields() + public function testfill_in_additional_detail_fields(): void { $scheduler = BeanFactory::newBean('Schedulers'); // Execute the method and test that it works and doesn't throw an exception. try { $scheduler->fill_in_additional_detail_fields(); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } - $this->markTestIncomplete('method has no implementation'); + self::markTestIncomplete('method has no implementation'); } - public function testget_list_view_data() + public function testget_list_view_data(): void { self::markTestIncomplete('environment dependency'); $scheduler = BeanFactory::newBean('Schedulers'); @@ -277,27 +276,27 @@ class SchedulerTest extends SuitePHPUnitFrameworkTestCase ); $actual = $scheduler->get_list_view_data(); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } - public function testget_summary_text() + public function testget_summary_text(): void { self::markTestIncomplete('environment dependency'); $scheduler = BeanFactory::newBean('Schedulers'); //test without setting name - $this->assertEquals(null, $scheduler->get_summary_text()); + self::assertEquals(null, $scheduler->get_summary_text()); //test with name set $scheduler->name = 'test'; - $this->assertEquals('test', $scheduler->get_summary_text()); + self::assertEquals('test', $scheduler->get_summary_text()); } - public function testgetJobsList() + public function testgetJobsList(): void { self::markTestIncomplete('environment dependency'); $result = Scheduler::getJobsList(); - $this->assertTrue(is_array($result)); + self::assertIsArray($result); } } diff --git a/tests/unit/phpunit/modules/SchedulersJobs/SchedulersJobTest.php b/tests/unit/phpunit/modules/SchedulersJobs/SchedulersJobTest.php index cbaccf389..84b35f8ae 100644 --- a/tests/unit/phpunit/modules/SchedulersJobs/SchedulersJobTest.php +++ b/tests/unit/phpunit/modules/SchedulersJobs/SchedulersJobTest.php @@ -13,57 +13,54 @@ class SchedulersJobTest extends SuitePHPUnitFrameworkTestCase $current_user = BeanFactory::newBean('Users'); } - public function testSchedulersJob() + public function testSchedulersJob(): void { // Execute the constructor and check for the Object type and attributes $schedulersJob = BeanFactory::newBean('SchedulersJobs'); - $this->assertInstanceOf('SchedulersJob', $schedulersJob); - $this->assertInstanceOf('Basic', $schedulersJob); - $this->assertInstanceOf('SugarBean', $schedulersJob); + self::assertInstanceOf('SchedulersJob', $schedulersJob); + self::assertInstanceOf('Basic', $schedulersJob); + self::assertInstanceOf('SugarBean', $schedulersJob); - $this->assertAttributeEquals('job_queue', 'table_name', $schedulersJob); - $this->assertAttributeEquals('SchedulersJobs', 'module_dir', $schedulersJob); - $this->assertAttributeEquals('SchedulersJob', 'object_name', $schedulersJob); + self::assertEquals('job_queue', $schedulersJob->table_name); + self::assertEquals('SchedulersJobs', $schedulersJob->module_dir); + self::assertEquals('SchedulersJob', $schedulersJob->object_name); - $this->assertAttributeEquals(true, 'new_schema', $schedulersJob); - $this->assertAttributeEquals(true, 'process_save_dates', $schedulersJob); - $this->assertAttributeEquals(30, 'min_interval', $schedulersJob); - $this->assertAttributeEquals(true, 'job_done', $schedulersJob); + self::assertEquals(true, $schedulersJob->new_schema); + self::assertEquals(true, $schedulersJob->process_save_dates); + self::assertEquals(30, $schedulersJob->min_interval); } - public function testcheck_date_relationships_load() + public function testcheck_date_relationships_load(): void { $schedulersJob = BeanFactory::newBean('SchedulersJobs'); $schedulersJob->execute_time = '2015-01-01 00:00:00'; $schedulersJob->check_date_relationships_load(); - $this->assertEquals('2015-01-01 00:00:00', $schedulersJob->execute_time_db); + self::assertEquals('2015-01-01 00:00:00', $schedulersJob->execute_time_db); } - public function testhandleDateFormat() + public function testhandleDateFormat(): void { $schedulersJob = BeanFactory::newBean('SchedulersJobs'); //test with default params $result = $schedulersJob->handleDateFormat(); - $this->assertGreaterThan(0, strlen($result)); + self::assertGreaterThan(0, strlen($result)); //test with a valid date param $result = $schedulersJob->handleDateFormat('2015-01-01'); - $this->assertEquals('2015-01-01 00:00:00', $result); + self::assertEquals('2015-01-01 00:00:00', $result); } - public function testfireUrl() + public function testfireUrl(): void { self::markTestIncomplete('environment dependency: curl_setopt(): CURLOPT_DNS_USE_GLOBAL_CACHE cannot be activated when thread safety is enabled '); - $schedulersJob = BeanFactory::newBean('SchedulersJobs'); - //test with invalid param - $result = $schedulersJob->fireUrl(''); - $this->assertEquals(false, $result); + $result = BeanFactory::newBean('SchedulersJobs')->fireUrl(''); + self::assertEquals(false, $result); //test with valid param self::markTestIncomplete(); @@ -71,7 +68,7 @@ class SchedulersJobTest extends SuitePHPUnitFrameworkTestCase //$this->assertEquals(true, $result); } - public function testget_list_view_data() + public function testget_list_view_data(): void { $schedulersJob = BeanFactory::newBean('SchedulersJobs'); @@ -87,133 +84,133 @@ class SchedulersJobTest extends SuitePHPUnitFrameworkTestCase ); $actual = $schedulersJob->get_list_view_data(); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } - public function testfill_in_additional_list_fields() + public function testfill_in_additional_list_fields(): void { $schedulersJob = BeanFactory::newBean('SchedulersJobs'); // Execute the method and test that it works and doesn't throw an exception. try { $schedulersJob->fill_in_additional_list_fields(); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } } - public function testfailJob() + public function testfailJob(): void { $schedulersJob = BeanFactory::newBean('SchedulersJobs'); $result = $schedulersJob->failJob(); - $this->assertEquals(true, $result); + self::assertEquals(true, $result); //test for record ID to verify that record is saved - $this->assertTrue(isset($schedulersJob->id)); - $this->assertEquals(36, strlen($schedulersJob->id)); + self::assertTrue(isset($schedulersJob->id)); + self::assertEquals(36, strlen($schedulersJob->id)); - $this->assertEquals(SchedulersJob::JOB_STATUS_DONE, $schedulersJob->status); - $this->assertEquals(SchedulersJob::JOB_FAILURE, $schedulersJob->resolution); + self::assertEquals(SchedulersJob::JOB_STATUS_DONE, $schedulersJob->status); + self::assertEquals(SchedulersJob::JOB_FAILURE, $schedulersJob->resolution); $schedulersJob->mark_deleted($schedulersJob->id); } - public function testsucceedJob() + public function testsucceedJob(): void { $schedulersJob = BeanFactory::newBean('SchedulersJobs'); $result = $schedulersJob->succeedJob(); - $this->assertEquals(true, $result); + self::assertEquals(true, $result); //test for record ID to verify that record is saved - $this->assertTrue(isset($schedulersJob->id)); - $this->assertEquals(36, strlen($schedulersJob->id)); + self::assertTrue(isset($schedulersJob->id)); + self::assertEquals(36, strlen($schedulersJob->id)); - $this->assertEquals(SchedulersJob::JOB_STATUS_DONE, $schedulersJob->status); - $this->assertEquals(SchedulersJob::JOB_SUCCESS, $schedulersJob->resolution); + self::assertEquals(SchedulersJob::JOB_STATUS_DONE, $schedulersJob->status); + self::assertEquals(SchedulersJob::JOB_SUCCESS, $schedulersJob->resolution); $schedulersJob->mark_deleted($schedulersJob->id); } - public function testonFailureRetry() + public function testonFailureRetry(): void { $schedulersJob = BeanFactory::newBean('SchedulersJobs'); // Execute the method and test that it works and doesn't throw an exception. try { $schedulersJob->onFailureRetry(); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } - $this->markTestIncomplete('method has no implementation: logic hooks not defined'); + self::markTestIncomplete('method has no implementation: logic hooks not defined'); } - public function testOnFinalFailure() + public function testOnFinalFailure(): void { $schedulersJob = BeanFactory::newBean('SchedulersJobs'); // Execute the method and test that it works and doesn't throw an exception. try { $schedulersJob->onFinalFailure(); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } - $this->markTestIncomplete('method has no implementation: logic hooks not defined'); + self::markTestIncomplete('method has no implementation: logic hooks not defined'); } - public function testresolveJob() + public function testresolveJob(): void { $schedulersJob = BeanFactory::newBean('SchedulersJobs'); //test for JOB_FAILURE $result = $schedulersJob->resolveJob(SchedulersJob::JOB_FAILURE, 'test'); - $this->assertEquals(true, $result); + self::assertEquals(true, $result); //test for record ID to verify that record is saved - $this->assertTrue(isset($schedulersJob->id)); - $this->assertEquals(36, strlen($schedulersJob->id)); + self::assertTrue(isset($schedulersJob->id)); + self::assertEquals(36, strlen($schedulersJob->id)); - $this->assertEquals(SchedulersJob::JOB_STATUS_DONE, $schedulersJob->status); - $this->assertEquals(SchedulersJob::JOB_FAILURE, $schedulersJob->resolution); + self::assertEquals(SchedulersJob::JOB_STATUS_DONE, $schedulersJob->status); + self::assertEquals(SchedulersJob::JOB_FAILURE, $schedulersJob->resolution); //tst for JOB_SUCCESS $result = $schedulersJob->resolveJob(SchedulersJob::JOB_SUCCESS, 'test'); - $this->assertEquals(true, $result); + self::assertEquals(true, $result); - $this->assertEquals(SchedulersJob::JOB_STATUS_DONE, $schedulersJob->status); - $this->assertEquals(SchedulersJob::JOB_SUCCESS, $schedulersJob->resolution); + self::assertEquals(SchedulersJob::JOB_STATUS_DONE, $schedulersJob->status); + self::assertEquals(SchedulersJob::JOB_SUCCESS, $schedulersJob->resolution); $schedulersJob->mark_deleted($schedulersJob->id); } - public function testpostponeJobAndMark_deleted() + public function testpostponeJobAndMark_deleted(): void { $schedulersJob = BeanFactory::newBean('SchedulersJobs'); $result = $schedulersJob->postponeJob('test message', 1); - $this->assertEquals(true, $result); + self::assertEquals(true, $result); //test for record ID to verify that record is saved - $this->assertTrue(isset($schedulersJob->id)); - $this->assertEquals(36, strlen($schedulersJob->id)); + self::assertTrue(isset($schedulersJob->id)); + self::assertEquals(36, strlen($schedulersJob->id)); //verify the related attributes - $this->assertEquals(SchedulersJob::JOB_STATUS_QUEUED, $schedulersJob->status); - $this->assertEquals(SchedulersJob::JOB_PARTIAL, $schedulersJob->resolution); + self::assertEquals(SchedulersJob::JOB_STATUS_QUEUED, $schedulersJob->status); + self::assertEquals(SchedulersJob::JOB_PARTIAL, $schedulersJob->resolution); //test mark deleted method and verify record doesn't exist after deletion $schedulersJob->mark_deleted($schedulersJob->id); $result = $schedulersJob->retrieve($schedulersJob->id); - $this->assertEquals(null, $result); + self::assertEquals(null, $result); } - public function testunexpectedExit() + public function testunexpectedExit(): void { $schedulersJob = BeanFactory::newBean('SchedulersJobs'); @@ -226,17 +223,17 @@ class SchedulersJobTest extends SuitePHPUnitFrameworkTestCase //execute the method $schedulersJob->unexpectedExit(); $schedulersJob->retrieve($schedulersJob->id); - $this->assertEquals(SchedulersJob::JOB_STATUS_DONE, $schedulersJob->status); - $this->assertEquals(SchedulersJob::JOB_FAILURE, $schedulersJob->resolution); + self::assertEquals(SchedulersJob::JOB_STATUS_DONE, $schedulersJob->status); + self::assertEquals(SchedulersJob::JOB_FAILURE, $schedulersJob->resolution); $schedulersJob->mark_deleted($schedulersJob->id); } - public function testrunJobId() + public function testrunJobId(): void { //test with invalid job id $result = SchedulersJob::runJobId('1', ''); - $this->assertEquals('Job 1 not found.', $result); + self::assertEquals('Job 1 not found.', $result); //test with valid job id $schedulersJob = BeanFactory::newBean('SchedulersJobs'); @@ -244,7 +241,7 @@ class SchedulersJobTest extends SuitePHPUnitFrameworkTestCase $schedulersJob->save(); $result = SchedulersJob::runJobId($schedulersJob->id, ''); - $this->assertEquals('Job '.$schedulersJob->id.' is not marked as running.', $result); + self::assertEquals('Job '.$schedulersJob->id.' is not marked as running.', $result); //test with valid job id and status but mismatch client $schedulersJob->client = 'client'; @@ -253,40 +250,40 @@ class SchedulersJobTest extends SuitePHPUnitFrameworkTestCase $result = SchedulersJob::runJobId($schedulersJob->id, 'test_client'); - $this->assertEquals('Job '.$schedulersJob->id.' belongs to another client, can not run as test_client.', $result); + self::assertEquals('Job '.$schedulersJob->id.' belongs to another client, can not run as test_client.', $result); $schedulersJob->mark_deleted($schedulersJob->id); } - public function testerrorHandler() + public function testerrorHandler(): void { $schedulersJob = BeanFactory::newBean('SchedulersJobs'); //execute the method with different Error Types $schedulersJob->errors = ''; $schedulersJob->errorHandler(E_USER_WARNING, 'test err', 'testfile', '1'); - $this->assertEquals("Warning [512]: test err in testfile on line 1\n", $schedulersJob->errors); + self::assertEquals("Warning [512]: test err in testfile on line 1\n", $schedulersJob->errors); $schedulersJob->errors = ''; $schedulersJob->errorHandler(E_ERROR, 'test err', 'testfile', '1'); - $this->assertEquals("Fatal Error [1]: test err in testfile on line 1\n", $schedulersJob->errors); + self::assertEquals("Fatal Error [1]: test err in testfile on line 1\n", $schedulersJob->errors); $schedulersJob->errors = ''; $schedulersJob->errorHandler(E_PARSE, 'test err', 'testfile', '1'); - $this->assertEquals("Parse Error [4]: test err in testfile on line 1\n", $schedulersJob->errors); + self::assertEquals("Parse Error [4]: test err in testfile on line 1\n", $schedulersJob->errors); $schedulersJob->errors = ''; $schedulersJob->errorHandler(E_RECOVERABLE_ERROR, 'test err', 'testfile', '1'); - $this->assertEquals("Recoverable Error [4096]: test err in testfile on line 1\n", $schedulersJob->errors); + self::assertEquals("Recoverable Error [4096]: test err in testfile on line 1\n", $schedulersJob->errors); } - public function testrunJob() + public function testrunJob(): void { //test without a valid user $schedulersJob = BeanFactory::newBean('SchedulersJobs'); $schedulersJob->target = 'function::processAOW_Workflow'; $result = $schedulersJob->runJob(); - $this->assertEquals(false, $result); + self::assertEquals(false, $result); $schedulersJob->mark_deleted($schedulersJob->id); //test with valid user @@ -295,7 +292,7 @@ class SchedulersJobTest extends SuitePHPUnitFrameworkTestCase $schedulersJob->target = 'function::processAOW_Workflow'; $result = $schedulersJob->runJob(); - $this->assertEquals(true, $result); + self::assertEquals(true, $result); $schedulersJob->mark_deleted($schedulersJob->id); //test with valid user diff --git a/tests/unit/phpunit/modules/SecurityGroups/SecurityGroupTest.php b/tests/unit/phpunit/modules/SecurityGroups/SecurityGroupTest.php index 90498bbd8..306e4ce6c 100644 --- a/tests/unit/phpunit/modules/SecurityGroups/SecurityGroupTest.php +++ b/tests/unit/phpunit/modules/SecurityGroups/SecurityGroupTest.php @@ -12,21 +12,21 @@ class SecurityGroupTest extends SuitePHPUnitFrameworkTestCase get_sugar_config_defaults(); $current_user = BeanFactory::newBean('Users'); } - public function testSecurityGroup() + public function testSecurityGroup(): void { // Execute the constructor and check for the Object type and attributes $securityGroup = BeanFactory::newBean('SecurityGroups'); - $this->assertInstanceOf('SecurityGroup', $securityGroup); - $this->assertInstanceOf('Basic', $securityGroup); - $this->assertInstanceOf('SugarBean', $securityGroup); + self::assertInstanceOf('SecurityGroup', $securityGroup); + self::assertInstanceOf('Basic', $securityGroup); + self::assertInstanceOf('SugarBean', $securityGroup); - $this->assertAttributeEquals('securitygroups', 'table_name', $securityGroup); - $this->assertAttributeEquals('SecurityGroups', 'module_dir', $securityGroup); - $this->assertAttributeEquals('SecurityGroup', 'object_name', $securityGroup); + self::assertEquals('securitygroups', $securityGroup->table_name); + self::assertEquals('SecurityGroups', $securityGroup->module_dir); + self::assertEquals('SecurityGroup', $securityGroup->object_name); } - public function testgetGroupWhere() + public function testgetGroupWhere(): void { $securityGroup = BeanFactory::newBean('SecurityGroups'); @@ -37,8 +37,8 @@ class SecurityGroupTest extends SuitePHPUnitFrameworkTestCase and secu.user_id = '1' where secg.deleted = 0 )"; - $actual = $securityGroup->getGroupWhere('securitygroups', 'SecurityGroups', 1); - $this->assertSame($expected, $actual); + $actual = $securityGroup::getGroupWhere('securitygroups', 'SecurityGroups', 1); + self::assertSame($expected, $actual); //test with //test with securitygroups module module $table_name = 'users'; @@ -56,11 +56,11 @@ class SecurityGroupTest extends SuitePHPUnitFrameworkTestCase AND secr.module = '$module' WHERE secr.record_id = ".$table_name.".id AND secg.deleted = 0) "; - $actual = $securityGroup->getGroupWhere($table_name, $module, $user_id); - $this->assertSame($expected, $actual); + $actual = $securityGroup::getGroupWhere($table_name, $module, $user_id); + self::assertSame($expected, $actual); } - public function testgetGroupUsersWhere() + public function testgetGroupUsersWhere(): void { $securityGroup = BeanFactory::newBean('SecurityGroups'); @@ -72,10 +72,10 @@ class SecurityGroupTest extends SuitePHPUnitFrameworkTestCase )"; $actual = $securityGroup::getGroupUsersWhere(1); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } - public function testgetGroupJoin() + public function testgetGroupJoin(): void { $securityGroup = BeanFactory::newBean('SecurityGroups'); @@ -85,8 +85,8 @@ class SecurityGroupTest extends SuitePHPUnitFrameworkTestCase and secu.user_id = '1' where secg.deleted = 0 ) securitygroup_join on securitygroup_join.id = securitygroups.id "; - $actual = $securityGroup->getGroupJoin('securitygroups', 'SecurityGroups', 1); - $this->assertSame($expected, $actual); + $actual = $securityGroup::getGroupJoin('securitygroups', 'SecurityGroups', 1); + self::assertSame($expected, $actual); //test with //test with securitygroups module $expected = " LEFT JOIN (select distinct secr.record_id as id from securitygroups secg @@ -96,11 +96,11 @@ class SecurityGroupTest extends SuitePHPUnitFrameworkTestCase and secr.module = 'Users' where secg.deleted = 0 ) securitygroup_join on securitygroup_join.id = users.id "; - $actual = $securityGroup->getGroupJoin('users', 'Users', 1); - $this->assertSame($expected, $actual); + $actual = $securityGroup::getGroupJoin('users', 'Users', 1); + self::assertSame($expected, $actual); } - public function testgetGroupUsersJoin() + public function testgetGroupUsersJoin(): void { $securityGroup = BeanFactory::newBean('SecurityGroups'); @@ -110,26 +110,26 @@ class SecurityGroupTest extends SuitePHPUnitFrameworkTestCase and secu.user_id = '1' where sec.deleted = 0 ) securitygroup_join on securitygroup_join.id = users.id "; - $actual = $securityGroup->getGroupUsersJoin(1); - $this->assertSame($expected, $actual); + $actual = $securityGroup::getGroupUsersJoin(1); + self::assertSame($expected, $actual); } - public function testgroupHasAccess() + public function testgroupHasAccess(): void { //test for listview $result = SecurityGroup::groupHasAccess('', '[SELECT_ID_LIST]'); - $this->assertEquals(true, $result); + self::assertEquals(true, $result); //test with invalid values $result = SecurityGroup::groupHasAccess('', ''); - $this->assertEquals(false, $result); + self::assertEquals(false, $result); //test with valid values $result = SecurityGroup::groupHasAccess('Users', '1'); - $this->assertEquals(false, $result); + self::assertEquals(false, $result); } - public function testinherit() + public function testinherit(): void { $account = BeanFactory::newBean('Accounts'); $account->id = 1; @@ -139,13 +139,13 @@ class SecurityGroupTest extends SuitePHPUnitFrameworkTestCase // Execute the method and test that it works and doesn't throw an exception. try { SecurityGroup::inherit($account, false); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } } - public function testassign_default_groups() + public function testassign_default_groups(): void { $account = BeanFactory::newBean('Accounts'); $account->id = 1; @@ -153,13 +153,13 @@ class SecurityGroupTest extends SuitePHPUnitFrameworkTestCase // Execute the method and test that it works and doesn't throw an exception. try { SecurityGroup::assign_default_groups($account, false); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } } - public function testinherit_creator() + public function testinherit_creator(): void { $account = BeanFactory::newBean('Accounts'); $account->id = 1; @@ -167,13 +167,13 @@ class SecurityGroupTest extends SuitePHPUnitFrameworkTestCase // Execute the method and test that it works and doesn't throw an exception. try { SecurityGroup::inherit_creator($account, false); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } } - public function testinherit_assigned() + public function testinherit_assigned(): void { $account = BeanFactory::newBean('Accounts'); $account->id = 1; @@ -182,13 +182,13 @@ class SecurityGroupTest extends SuitePHPUnitFrameworkTestCase // Execute the method and test that it works and doesn't throw an exception. try { SecurityGroup::inherit_assigned($account, false); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } } - public function testinherit_parent() + public function testinherit_parent(): void { $account = BeanFactory::newBean('Accounts'); $account->id = 1; @@ -196,13 +196,13 @@ class SecurityGroupTest extends SuitePHPUnitFrameworkTestCase // Execute the method and test that it works and doesn't throw an exception. try { SecurityGroup::inherit_parent($account, false); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } } - public function testinherit_parentQuery() + public function testinherit_parentQuery(): void { $account = BeanFactory::newBean('Accounts'); $account->id = 1; @@ -210,31 +210,27 @@ class SecurityGroupTest extends SuitePHPUnitFrameworkTestCase // Execute the method and test that it works and doesn't throw an exception. try { SecurityGroup::inherit_parentQuery($account, 'Accounts', 1, 1, $account->module_dir); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } } - public function testinheritOne() + public function testinheritOne(): void { - $securityGroup = BeanFactory::newBean('SecurityGroups'); - - $result = $securityGroup->inheritOne(1, 1, 'Accounts'); - $this->assertEquals(false, $result); + $result = BeanFactory::newBean('SecurityGroups')::inheritOne(1, 1, 'Accounts'); + self::assertEquals(false, $result); } - public function testgetMembershipCount() + public function testgetMembershipCount(): void { - $securityGroup = BeanFactory::newBean('SecurityGroups'); - - $result = $securityGroup->getMembershipCount('1'); - $this->assertEquals(0, $result); + $result = BeanFactory::newBean('SecurityGroups')::getMembershipCount('1'); + self::assertEquals(0, $result); } - public function testSaveAndRetrieveAndRemoveDefaultGroups() + public function testSaveAndRetrieveAndRemoveDefaultGroups(): void { - // unset and reconnect Db to resolve mysqli fetch exeception + // Unset and reconnect Db to resolve mysqli fetch exception $db = DBManagerFactory::getInstance(); $db->disconnect(); unset($db->database); @@ -247,29 +243,29 @@ class SecurityGroupTest extends SuitePHPUnitFrameworkTestCase $securityGroup->save(); //execute saveDefaultGroup method - $securityGroup->saveDefaultGroup($securityGroup->id, 'test_module'); + $securityGroup::saveDefaultGroup($securityGroup->id, 'test_module'); //execute retrieveDefaultGroups method - $result = $securityGroup->retrieveDefaultGroups(); + $result = $securityGroup::retrieveDefaultGroups(); //verify that default group is created - $this->assertTrue(is_array($result)); - $this->assertGreaterThan(0, count($result)); + self::assertIsArray($result); + self::assertGreaterThan(0, count($result)); //execute removeDefaultGroup method for each default group foreach ($result as $key => $value) { - $securityGroup->removeDefaultGroup($key); + $securityGroup::removeDefaultGroup($key); } //retrieve back and verify that default securith groups are deleted - $result = $securityGroup->retrieveDefaultGroups(); - $this->assertEquals(0, count($result)); + $result = $securityGroup::retrieveDefaultGroups(); + self::assertCount(0, $result); //delete the security group as well for cleanup $securityGroup->mark_deleted($securityGroup->id); } - public function testgetSecurityModules() + public function testgetSecurityModules(): void { $securityGroup = BeanFactory::newBean('SecurityGroups'); @@ -318,16 +314,16 @@ class SecurityGroupTest extends SuitePHPUnitFrameworkTestCase 'Surveys' => 'Surveys', ); - $actual = $securityGroup->getSecurityModules(); + $actual = $securityGroup::getSecurityModules(); $actualKeys = array_keys($actual); sort($expected); sort($actualKeys); - $this->assertSame($expected, $actualKeys); + self::assertSame($expected, $actualKeys); } - public function testgetLinkName() + public function testgetLinkName(): void { - //unset and reconnect Db to resolve mysqli fetch exeception + // Unset and reconnect Db to resolve mysqli fetch exceptions $db = DBManagerFactory::getInstance(); $db->disconnect(); unset($db->database); @@ -335,14 +331,14 @@ class SecurityGroupTest extends SuitePHPUnitFrameworkTestCase $securityGroup = BeanFactory::newBean('SecurityGroups'); - $result = $securityGroup->getLinkName('Accounts', 'Contacts'); - $this->assertEquals('contacts', $result); + $result = $securityGroup::getLinkName('Accounts', 'Contacts'); + self::assertEquals('contacts', $result); - $result = $securityGroup->getLinkName('SecurityGroups', 'ACLRoles'); - $this->assertEquals('aclroles', $result); + $result = $securityGroup::getLinkName('SecurityGroups', 'ACLRoles'); + self::assertEquals('aclroles', $result); } - public function testaddGroupToRecord() + public function testaddGroupToRecord(): void { // unset and reconnect Db to resolve mysqli fetch exeception $db = DBManagerFactory::getInstance(); @@ -355,13 +351,13 @@ class SecurityGroupTest extends SuitePHPUnitFrameworkTestCase // Execute the method and test that it works and doesn't throw an exception. try { $securityGroup->addGroupToRecord('Accounts', 1, 1); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } } - public function testremoveGroupFromRecord() + public function testremoveGroupFromRecord(): void { //unset and reconnect Db to resolve mysqli fetch exeception $db = DBManagerFactory::getInstance(); @@ -373,14 +369,14 @@ class SecurityGroupTest extends SuitePHPUnitFrameworkTestCase // Execute the method and test that it works and doesn't throw an exception. try { - $securityGroup->removeGroupFromRecord('Accounts', 1, 1); - $this->assertTrue(true); + $securityGroup::removeGroupFromRecord('Accounts', 1, 1); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } } - public function testgetUserSecurityGroups() + public function testgetUserSecurityGroups(): void { //unset and reconnect Db to resolve mysqli fetch exeception $db = DBManagerFactory::getInstance(); @@ -388,14 +384,12 @@ class SecurityGroupTest extends SuitePHPUnitFrameworkTestCase unset($db->database); $db->checkConnection(); - $securityGroup = BeanFactory::newBean('SecurityGroups'); + $result = BeanFactory::newBean('SecurityGroups')::getUserSecurityGroups('1'); - $result = $securityGroup->getUserSecurityGroups('1'); - - $this->assertTrue(is_array($result)); + self::assertIsArray($result); } - public function testgetAllSecurityGroups() + public function testgetAllSecurityGroups(): void { //unset and reconnect Db to resolve mysqli fetch exeception $db = DBManagerFactory::getInstance(); @@ -403,14 +397,12 @@ class SecurityGroupTest extends SuitePHPUnitFrameworkTestCase unset($db->database); $db->checkConnection(); - $securityGroup = BeanFactory::newBean('SecurityGroups'); + $result = BeanFactory::newBean('SecurityGroups')::getAllSecurityGroups(); - $result = $securityGroup->getAllSecurityGroups(); - - $this->assertTrue(is_array($result)); + self::assertIsArray($result); } - public function testgetMembers() + public function testgetMembers(): void { //unset and reconnect Db to resolve mysqli fetch exeception $db = DBManagerFactory::getInstance(); @@ -418,14 +410,12 @@ class SecurityGroupTest extends SuitePHPUnitFrameworkTestCase unset($db->database); $db->checkConnection(); - $securityGroup = BeanFactory::newBean('SecurityGroups'); + $result = BeanFactory::newBean('SecurityGroups')->getMembers(); - $result = $securityGroup->getMembers(); - - $this->assertTrue(is_array($result)); + self::assertIsArray($result); } - public function testgetPrimaryGroupID() + public function testgetPrimaryGroupID(): void { //unset and reconnect Db to resolve mysqli fetch exeception $db = DBManagerFactory::getInstance(); @@ -433,10 +423,8 @@ class SecurityGroupTest extends SuitePHPUnitFrameworkTestCase unset($db->database); $db->checkConnection(); - $securityGroup = BeanFactory::newBean('SecurityGroups'); + $result = BeanFactory::newBean('SecurityGroups')::getPrimaryGroupID(); - $result = $securityGroup->getPrimaryGroupID(); - - $this->assertEquals(null, $result); + self::assertEquals(null, $result); } } diff --git a/tests/unit/phpunit/modules/SugarFeed/SugarFeedTest.php b/tests/unit/phpunit/modules/SugarFeed/SugarFeedTest.php index 187b077ef..c18600769 100644 --- a/tests/unit/phpunit/modules/SugarFeed/SugarFeedTest.php +++ b/tests/unit/phpunit/modules/SugarFeed/SugarFeedTest.php @@ -13,24 +13,24 @@ class SugarFeedTest extends SuitePHPUnitFrameworkTestCase $current_user = BeanFactory::newBean('Users'); } - public function testSugarFeed() + public function testSugarFeed(): void { // Execute the constructor and check for the Object type and attributes $sugarFeed = BeanFactory::newBean('SugarFeed'); - $this->assertInstanceOf('SugarFeed', $sugarFeed); - $this->assertInstanceOf('Basic', $sugarFeed); - $this->assertInstanceOf('SugarBean', $sugarFeed); + self::assertInstanceOf('SugarFeed', $sugarFeed); + self::assertInstanceOf('Basic', $sugarFeed); + self::assertInstanceOf('SugarBean', $sugarFeed); - $this->assertAttributeEquals('sugarfeed', 'table_name', $sugarFeed); - $this->assertAttributeEquals('SugarFeed', 'module_dir', $sugarFeed); - $this->assertAttributeEquals('SugarFeed', 'object_name', $sugarFeed); + self::assertEquals('sugarfeed', $sugarFeed->table_name); + self::assertEquals('SugarFeed', $sugarFeed->module_dir); + self::assertEquals('SugarFeed', $sugarFeed->object_name); - $this->assertAttributeEquals(true, 'new_schema', $sugarFeed); - $this->assertAttributeEquals(false, 'importable', $sugarFeed); + self::assertEquals(true, $sugarFeed->new_schema); + self::assertEquals(false, $sugarFeed->importable); } - public function testactivateAndDisableModuleFeed() + public function testactivateAndDisableModuleFeed(): void { self::markTestIncomplete('environment dependency'); @@ -39,39 +39,39 @@ class SugarFeedTest extends SuitePHPUnitFrameworkTestCase //test activateModuleFeed method SugarFeed::activateModuleFeed('Accounts'); $admin->retrieveSettings('sugarfeed'); - $this->assertEquals(1, $admin->settings['sugarfeed_module_Accounts']); + self::assertEquals(1, $admin->settings['sugarfeed_module_Accounts']); //test disableModuleFeed method SugarFeed::disableModuleFeed('Accounts'); $admin->retrieveSettings('sugarfeed'); - $this->assertEquals(0, $admin->settings['sugarfeed_module_Accounts']); + self::assertEquals(0, $admin->settings['sugarfeed_module_Accounts']); } - public function testflushBackendCache() + public function testflushBackendCache(): void { // Execute the method and test that it works and doesn't throw an exception. try { SugarFeed::flushBackendCache(); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } } - public function testgetModuleFeedFiles() + public function testgetModuleFeedFiles(): void { //test with invalid module $expected = array(); $result = SugarFeed::getModuleFeedFiles('Accounts'); - $this->assertEquals($expected, $result); + self::assertEquals($expected, $result); //test with valid module $expected = array('CaseFeed.php' => 'modules/Cases/SugarFeeds/CaseFeed.php'); $result = SugarFeed::getModuleFeedFiles('Cases'); - $this->assertEquals($expected, $result); + self::assertEquals($expected, $result); } - public function testgetActiveFeedModules() + public function testgetActiveFeedModules(): void { $result = SugarFeed::getActiveFeedModules(); @@ -83,10 +83,10 @@ class SugarFeedTest extends SuitePHPUnitFrameworkTestCase 'Opportunities' => 'Opportunities', ); - $this->assertEquals($expected, $result); + self::assertEquals($expected, $result); } - public function testgetAllFeedModules() + public function testgetAllFeedModules(): void { $result = SugarFeed::getAllFeedModules(); $expected = array( @@ -97,10 +97,10 @@ class SugarFeedTest extends SuitePHPUnitFrameworkTestCase 'Opportunities' => 'Opportunities', ); - $this->assertEquals($expected, $result); + self::assertEquals($expected, $result); } - public function testpushFeed2() + public function testpushFeed2(): void { $lead = BeanFactory::newBean('Leads'); $lead->id = 1; @@ -113,14 +113,14 @@ class SugarFeedTest extends SuitePHPUnitFrameworkTestCase $result = $sugarFeed->retrieve_by_string_fields(array('related_id' => '1', 'related_module' => 'Leads')); //test for record ID to verify that record is saved - $this->assertTrue(isset($sugarFeed->id)); - $this->assertEquals(36, strlen($sugarFeed->id)); + self::assertTrue(isset($sugarFeed->id)); + self::assertEquals(36, strlen($sugarFeed->id)); //mark the record as deleted $sugarFeed->mark_deleted($sugarFeed->id); } - public function testpushFeed() + public function testpushFeed(): void { SugarFeed::pushFeed('some text', 'SugarFeed', 1, 1, 'Link', 'some url'); @@ -129,8 +129,8 @@ class SugarFeedTest extends SuitePHPUnitFrameworkTestCase $result = $sugarFeed->retrieve_by_string_fields(array('related_id' => '1', 'related_module' => 'SugarFeed')); //test for record ID to verify that record is saved - $this->assertTrue(isset($sugarFeed->id)); - $this->assertEquals(36, strlen($sugarFeed->id)); + self::assertTrue(isset($sugarFeed->id)); + self::assertEquals(36, strlen($sugarFeed->id)); //test fetchReplies method $this->fetchReplies(); @@ -139,15 +139,13 @@ class SugarFeedTest extends SuitePHPUnitFrameworkTestCase $sugarFeed->mark_deleted($sugarFeed->id); } - public function fetchReplies() + public function fetchReplies(): void { - $sugarFeed = BeanFactory::newBean('SugarFeed'); - - $actual = $sugarFeed->fetchReplies(array('ID' => '1')); - $this->assertGreaterThan(0, strlen($actual)); + $actual = BeanFactory::newBean('SugarFeed')->fetchReplies(array('ID' => '1')); + self::assertGreaterThan(0, strlen($actual)); } - public function testgetLinkTypes() + public function testgetLinkTypes(): void { $result = SugarFeed::getLinkTypes(); @@ -156,54 +154,52 @@ class SugarFeedTest extends SuitePHPUnitFrameworkTestCase 'Link' => 'Link', 'YouTube' => 'YouTube', ); - $this->assertEquals($expected, $result); + self::assertEquals($expected, $result); } - public function testgetLinkClass() + public function testgetLinkClass(): void { //test with invalid LinkType $result = SugarFeed::getLinkClass('test'); - $this->assertEquals(false, $result); + self::assertEquals(false, $result); //test with LinkType Image $result = SugarFeed::getLinkClass('Image'); - $this->assertInstanceOf('FeedLinkHandlerImage', $result); + self::assertInstanceOf('FeedLinkHandlerImage', $result); //test with LinkType Link $result = SugarFeed::getLinkClass('Link'); - $this->assertInstanceOf('FeedLinkHandlerLink', $result); + self::assertInstanceOf('FeedLinkHandlerLink', $result); //test with LinkType YouTube $result = SugarFeed::getLinkClass('YouTube'); - $this->assertInstanceOf('FeedLinkHandlerYoutube', $result); + self::assertInstanceOf('FeedLinkHandlerYoutube', $result); } - public function testget_list_view_data() + public function testget_list_view_data(): void { - $sugarFeed = BeanFactory::newBean('SugarFeed'); - - $result = $sugarFeed->get_list_view_data(); - $this->assertTrue(is_array($result)); + $result = BeanFactory::newBean('SugarFeed')->get_list_view_data(); + self::assertIsArray($result); } - public function testgetTimeLapse() + public function testgetTimeLapse(): void { $result = SugarFeed::getTimeLapse('2016-01-15 11:16:02'); - $this->assertTrue(isset($result)); - $this->assertGreaterThanOrEqual(0, strlen($result)); + self::assertTrue(isset($result)); + self::assertGreaterThanOrEqual(0, strlen($result)); } - public function testparseMessage() + public function testparseMessage(): void { // test with a string with no links $html = 'some text with no urls'; $result = SugarFeed::parseMessage($html); - $this->assertEquals($html, $result); + self::assertEquals($html, $result); // test with a string with links $html = 'some text http://www.url.com with no urls'; $expected = "some text http://www.url.com with no urls"; $result = SugarFeed::parseMessage($html); - $this->assertEquals($expected, $result); + self::assertEquals($expected, $result); } } diff --git a/tests/unit/phpunit/modules/Tasks/TaskTest.php b/tests/unit/phpunit/modules/Tasks/TaskTest.php index 6beb5aeb7..86e9567f3 100644 --- a/tests/unit/phpunit/modules/Tasks/TaskTest.php +++ b/tests/unit/phpunit/modules/Tasks/TaskTest.php @@ -13,23 +13,23 @@ class TaskTest extends SuitePHPUnitFrameworkTestCase $GLOBALS['mod_strings'] = return_module_language($GLOBALS['current_language'], 'Tasks'); } - public function testTask() + public function testTask(): void { // Execute the constructor and check for the Object type and attributes $task = BeanFactory::newBean('Tasks'); - $this->assertInstanceOf('Task', $task); - $this->assertInstanceOf('SugarBean', $task); + self::assertInstanceOf('Task', $task); + self::assertInstanceOf('SugarBean', $task); - $this->assertAttributeEquals('tasks', 'table_name', $task); - $this->assertAttributeEquals('Tasks', 'module_dir', $task); - $this->assertAttributeEquals('Task', 'object_name', $task); + self::assertEquals('tasks', $task->table_name); + self::assertEquals('Tasks', $task->module_dir); + self::assertEquals('Task', $task->object_name); - $this->assertAttributeEquals(true, 'new_schema', $task); - $this->assertAttributeEquals(true, 'importable', $task); + self::assertEquals(true, $task->new_schema); + self::assertEquals(true, $task->importable); } - public function testsave() + public function testsave(): void { $task = BeanFactory::newBean('Tasks'); @@ -41,43 +41,43 @@ class TaskTest extends SuitePHPUnitFrameworkTestCase $result = $task->save(); //test for record ID to verify that record is saved - $this->assertTrue(isset($task->id)); - $this->assertEquals(36, strlen($task->id)); + self::assertTrue(isset($task->id)); + self::assertEquals(36, strlen($task->id)); //mark the record as deleted and verify that this record cannot be retrieved anymore. $task->mark_deleted($task->id); $result = $task->retrieve($task->id); - $this->assertEquals(null, $result); + self::assertEquals(null, $result); } - public function testget_summary_text() + public function testget_summary_text(): void { $task = BeanFactory::newBean('Tasks'); //test without setting name - $this->assertEquals(null, $task->get_summary_text()); + self::assertEquals(null, $task->get_summary_text()); //test with name set $task->name = 'test'; - $this->assertEquals('test', $task->get_summary_text()); + self::assertEquals('test', $task->get_summary_text()); } - public function testcreate_export_query() + public function testcreate_export_query(): void { $task = BeanFactory::newBean('Tasks'); //test with empty string params $expected = 'SELECT tasks.*, users.user_name as assigned_user_name FROM tasks LEFT JOIN users ON tasks.assigned_user_id=users.id where tasks.deleted=0 ORDER BY tasks.name'; $actual = $task->create_export_query('', ''); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); //test with valid string params $expected = 'SELECT tasks.*, users.user_name as assigned_user_name FROM tasks LEFT JOIN users ON tasks.assigned_user_id=users.id where users.user_name = "" AND tasks.deleted=0 ORDER BY tasks.name'; $actual = $task->create_export_query('tasks.id', 'users.user_name = ""'); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } - public function testfill_in_additional_detail_fields() + public function testfill_in_additional_detail_fields(): void { $task = BeanFactory::newBean('Tasks'); $task->contact_id = 1; @@ -85,13 +85,13 @@ class TaskTest extends SuitePHPUnitFrameworkTestCase // Execute the method and test that it works and doesn't throw an exception. try { $task->fill_in_additional_detail_fields(); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } } - public function testfill_in_additional_parent_fields() + public function testfill_in_additional_parent_fields(): void { $task = BeanFactory::newBean('Tasks'); $task->parent_type = 'Accounts'; @@ -100,13 +100,13 @@ class TaskTest extends SuitePHPUnitFrameworkTestCase // Execute the method and test that it works and doesn't throw an exception. try { $task->fill_in_additional_parent_fields(); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } } - public function testget_list_view_data() + public function testget_list_view_data(): void { $task = BeanFactory::newBean('Tasks'); $current_theme = SugarThemeRegistry::current(); @@ -136,10 +136,10 @@ class TaskTest extends SuitePHPUnitFrameworkTestCase ); $actual = $task->get_list_view_data(); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } - public function testset_notification_body() + public function testset_notification_body(): void { $task = BeanFactory::newBean('Tasks'); @@ -155,36 +155,34 @@ class TaskTest extends SuitePHPUnitFrameworkTestCase $result = $task->set_notification_body(new Sugar_Smarty(), $task); - $this->assertEquals($task->name, $result->_tpl_vars['TASK_SUBJECT']); - $this->assertEquals($task->status, $result->_tpl_vars['TASK_STATUS']); - $this->assertEquals($task->priority, $result->_tpl_vars['TASK_PRIORITY']); - $this->assertEquals('02/11/2016 17:30 UTC(+00:00)', $result->_tpl_vars['TASK_DUEDATE']); - $this->assertEquals($task->description, $result->_tpl_vars['TASK_DESCRIPTION']); + self::assertEquals($task->name, $result->_tpl_vars['TASK_SUBJECT']); + self::assertEquals($task->status, $result->_tpl_vars['TASK_STATUS']); + self::assertEquals($task->priority, $result->_tpl_vars['TASK_PRIORITY']); + self::assertEquals('02/11/2016 17:30 UTC(+00:00)', $result->_tpl_vars['TASK_DUEDATE']); + self::assertEquals($task->description, $result->_tpl_vars['TASK_DESCRIPTION']); } - public function testbean_implements() + public function testbean_implements(): void { $task = BeanFactory::newBean('Tasks'); - $this->assertEquals(false, $task->bean_implements('')); //test with blank value - $this->assertEquals(false, $task->bean_implements('test')); //test with invalid value - $this->assertEquals(true, $task->bean_implements('ACL')); //test with valid value + self::assertEquals(false, $task->bean_implements('')); //test with blank value + self::assertEquals(false, $task->bean_implements('test')); //test with invalid value + self::assertEquals(true, $task->bean_implements('ACL')); //test with valid value } - public function testlistviewACLHelper() + public function testlistviewACLHelper(): void { $task = BeanFactory::newBean('Tasks'); $expected = array('MAIN' => 'a', 'PARENT' => 'a', 'CONTACT' => 'a'); $actual = $task->listviewACLHelper(); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } - public function testgetDefaultStatus() + public function testgetDefaultStatus(): void { - $task = BeanFactory::newBean('Tasks'); - - $result = $task->getDefaultStatus(); - $this->assertEquals('Not Started', $result); + $result = BeanFactory::newBean('Tasks')->getDefaultStatus(); + self::assertEquals('Not Started', $result); } } diff --git a/tests/unit/phpunit/modules/Trackers/TrackerTest.php b/tests/unit/phpunit/modules/Trackers/TrackerTest.php index 4a430193d..20c0be023 100644 --- a/tests/unit/phpunit/modules/Trackers/TrackerTest.php +++ b/tests/unit/phpunit/modules/Trackers/TrackerTest.php @@ -13,69 +13,67 @@ class TrackerTest extends SuitePHPUnitFrameworkTestCase $current_user = BeanFactory::newBean('Users'); } - public function testTracker() + public function testTracker(): void { // Execute the constructor and check for the Object type and attributes $tracker = BeanFactory::newBean('Trackers'); - $this->assertInstanceOf('Tracker', $tracker); - $this->assertInstanceOf('SugarBean', $tracker); + self::assertInstanceOf('Tracker', $tracker); + self::assertInstanceOf('SugarBean', $tracker); - $this->assertAttributeEquals('tracker', 'table_name', $tracker); - $this->assertAttributeEquals('Trackers', 'module_dir', $tracker); - $this->assertAttributeEquals('Tracker', 'object_name', $tracker); + self::assertEquals('tracker', $tracker->table_name); + self::assertEquals('Trackers', $tracker->module_dir); + self::assertEquals('Tracker', $tracker->object_name); - $this->assertAttributeEquals(true, 'disable_var_defs', $tracker); + self::assertEquals(true, $tracker->disable_var_defs); - $this->assertAttributeEquals('Tracker', 'acltype', $tracker); - $this->assertAttributeEquals('Trackers', 'acl_category', $tracker); - $this->assertAttributeEquals(true, 'disable_custom_fields', $tracker); + self::assertEquals('Tracker', $tracker->acltype); + self::assertEquals('Trackers', $tracker->acl_category); + self::assertEquals(true, $tracker->disable_custom_fields); } - public function testget_recently_viewed() + public function testget_recently_viewed(): void { - $tracker = BeanFactory::newBean('Trackers'); + $result = BeanFactory::newBean('Trackers')->get_recently_viewed(1); - $result = $tracker->get_recently_viewed(1); - - $this->assertInstanceOf('BreadCrumbStack', $_SESSION['breadCrumbs']); - $this->assertTrue(is_array($result)); + self::assertInstanceOf('BreadCrumbStack', $_SESSION['breadCrumbs']); + self::assertIsArray($result); } - public function testmakeInvisibleForAll() + public function testmakeInvisibleForAll(): void { $tracker = BeanFactory::newBean('Trackers'); // Execute the method and test that it works and doesn't throw an exception. try { $tracker->makeInvisibleForAll(1); - $this->assertTrue(true); + self::assertTrue(true); } catch (Exception $e) { - $this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString()); } } - public function testbean_implements() + public function testbean_implements(): void { $tracker = BeanFactory::newBean('Trackers'); - $this->assertEquals(false, $tracker->bean_implements('')); //test with blank value - $this->assertEquals(false, $tracker->bean_implements('test')); //test with invalid value - $this->assertEquals(false, $tracker->bean_implements('ACL')); //test with valid value + self::assertEquals(false, $tracker->bean_implements('')); //test with blank value + self::assertEquals(false, $tracker->bean_implements('test')); //test with invalid value + self::assertEquals(false, $tracker->bean_implements('ACL')); //test with valid value } - public function testlogPage() + public function testlogPage(): void { self::markTestIncomplete('Test parameters and local variables are not set'); //test without setting headerDisplayed Tracker::logPage(); - $this->assertEquals(null, $_SESSION['lpage']); + self::assertEquals(null, $_SESSION['lpage']); //test with headerDisplayed set $GLOBALS['app']->headerDisplayed = 1; Tracker::logPage(); - $this->assertEquals(time(), $_SESSION['lpage']); + self::assertEquals(time(), $_SESSION['lpage']); //$this->assertEquals(time(), null); } diff --git a/tests/unit/phpunit/modules/UserPreferences/UserPreferenceTest.php b/tests/unit/phpunit/modules/UserPreferences/UserPreferenceTest.php index 6fa47195f..78de941e0 100644 --- a/tests/unit/phpunit/modules/UserPreferences/UserPreferenceTest.php +++ b/tests/unit/phpunit/modules/UserPreferences/UserPreferenceTest.php @@ -13,20 +13,18 @@ class UserPreferenceTest extends SuitePHPUnitFrameworkTestCase $current_user = BeanFactory::newBean('Users'); } - public function testgetUserDateTimePreferences() + public function testgetUserDateTimePreferences(): void { $user = BeanFactory::newBean('Users'); $user->retrieve('1'); - $userPreference = new UserPreference($user); - - $result = $userPreference->getUserDateTimePreferences(); - $this->assertTrue(is_array($result)); + $result = (new UserPreference($user))->getUserDateTimePreferences(); + self::assertIsArray($result); } - public function testSetAndGetPreference() + public function testSetAndGetPreference(): void { - $this->markTestIncomplete('state is incorrect'); + self::markTestIncomplete('state is incorrect'); global $sugar_config; @@ -46,60 +44,60 @@ class UserPreferenceTest extends SuitePHPUnitFrameworkTestCase $result = $_SESSION[$user->user_name.'_PREFERENCES']['test_category']['test']; } - $this->assertEquals('test val', $result); + self::assertEquals('test val', $result); //test getPreference method $result = $userPreference->getPreference('test', 'test_category'); - $this->assertEquals('test val', $result); + self::assertEquals('test val', $result); $result = $userPreference->getPreference('chartEngine'); - $this->assertEquals($sugar_config['chartEngine'], $result); + self::assertEquals($sugar_config['chartEngine'], $result); } - public function testgetDefaultPreference() + public function testgetDefaultPreference(): void { global $sugar_config; $userPreference = BeanFactory::newBean('UserPreferences'); //test with non global category $result = $userPreference->getDefaultPreference('chartEngine', 'Home'); - $this->assertEquals(null, $result); + self::assertEquals(null, $result); //test with default global category $result = $userPreference->getDefaultPreference('chartEngine'); - $this->assertEquals($sugar_config['chartEngine'], $result); + self::assertEquals($sugar_config['chartEngine'], $result); $date_format = $sugar_config['datef'] != '' ? $sugar_config['datef'] : $sugar_config['default_date_format']; $result = $userPreference->getDefaultPreference('datef'); - $this->assertEquals($date_format, $result); + self::assertEquals($date_format, $result); $time_format = $sugar_config['timef'] != '' ? $sugar_config['timef'] : $sugar_config['default_time_format']; $result = $userPreference->getDefaultPreference('timef'); - $this->assertEquals($time_format, $result); + self::assertEquals($time_format, $result); $email_link_type = (isset($sugar_config['email_link_type']) ? $sugar_config['email_link_type'] : null) != '' ? (isset($sugar_config['email_link_type']) ? $sugar_config['email_link_type'] : null) : $sugar_config['email_default_client']; $result = $userPreference->getDefaultPreference('email_link_type'); - $this->assertEquals($email_link_type, $result); + self::assertEquals($email_link_type, $result); } - public function test__construct() + public function test__construct(): void { // execute the constructor and check for the Object type and attributes $userPreference = BeanFactory::newBean('UserPreferences'); - $this->assertInstanceOf('UserPreference', $userPreference); - $this->assertInstanceOf('SugarBean', $userPreference); + self::assertInstanceOf('UserPreference', $userPreference); + self::assertInstanceOf('SugarBean', $userPreference); - $this->assertAttributeEquals('user_preferences', 'table_name', $userPreference); - $this->assertAttributeEquals('UserPreferences', 'module_dir', $userPreference); - $this->assertAttributeEquals('UserPreference', 'object_name', $userPreference); + self::assertEquals('user_preferences', $userPreference->table_name); + self::assertEquals('UserPreferences', $userPreference->module_dir); + self::assertEquals('UserPreference', $userPreference->object_name); - $this->assertAttributeEquals(true, 'new_schema', $userPreference); - $this->assertAttributeEquals(true, 'disable_row_level_security', $userPreference); + self::assertEquals(true, $userPreference->new_schema); + self::assertEquals(true, $userPreference->disable_row_level_security); } - public function testSavePreferencesToDBAndResetPreferences() + public function testSavePreferencesToDBAndResetPreferences(): void { self::markTestIncomplete('environment dependency'); @@ -126,10 +124,10 @@ class UserPreferenceTest extends SuitePHPUnitFrameworkTestCase 'assigned_user_id' => $user->id, 'category' => 'test_category', )); - $this->assertEquals(null, $result); + self::assertEquals(null, $result); } - public function testupdateAllUserPrefs() + public function testupdateAllUserPrefs(): void { global $current_user; @@ -138,6 +136,6 @@ class UserPreferenceTest extends SuitePHPUnitFrameworkTestCase //UserPreference::updateAllUserPrefs("test","test val"); - $this->markTestIncomplete('Multiple errors in method: Unknown column user_preferences in field list'); + self::markTestIncomplete('Multiple errors in method: Unknown column user_preferences in field list'); } } diff --git a/tests/unit/phpunit/modules/Users/GoogleApiKeySaverEntryPointMock.php b/tests/unit/phpunit/modules/Users/GoogleApiKeySaverEntryPointMock.php index a3394cd6d..1d8b772c8 100644 --- a/tests/unit/phpunit/modules/Users/GoogleApiKeySaverEntryPointMock.php +++ b/tests/unit/phpunit/modules/Users/GoogleApiKeySaverEntryPointMock.php @@ -48,13 +48,13 @@ include_once __DIR__ . '/../../../../../modules/Users/GoogleApiKeySaverEntryPoin */ class GoogleApiKeySaverEntryPointMock extends GoogleApiKeySaverEntryPoint { - + /** * * @var bool */ protected $dieOk = false; - + /** * * @var string @@ -66,31 +66,31 @@ class GoogleApiKeySaverEntryPointMock extends GoogleApiKeySaverEntryPoint * @var string */ protected $redirectUrl; - + /** - * * @param string $exitString + * @noinspection ReturnTypeCanBeDeclaredInspection */ public function protectedDie($exitString) { $this->dieOk = true; $this->exitString = $exitString; } - + /** * * @return bool */ - public function getDieOk() + public function getDieOk(): bool { return $this->dieOk; } - + /** * * @return string */ - public function getExitString() + public function getExitString(): string { return $this->exitString; } @@ -99,14 +99,14 @@ class GoogleApiKeySaverEntryPointMock extends GoogleApiKeySaverEntryPoint * * @return string */ - public function getRedirectUrl() + public function getRedirectUrl(): string { return $this->redirectUrl; } /** - * - * @return string + * @param string $url + * @noinspection ReturnTypeCanBeDeclaredInspection */ public function redirect($url) { diff --git a/tests/unit/phpunit/modules/Users/GoogleApiKeySaverEntryPointTest.php b/tests/unit/phpunit/modules/Users/GoogleApiKeySaverEntryPointTest.php index b596e04cf..bc62ebead 100644 --- a/tests/unit/phpunit/modules/Users/GoogleApiKeySaverEntryPointTest.php +++ b/tests/unit/phpunit/modules/Users/GoogleApiKeySaverEntryPointTest.php @@ -51,7 +51,7 @@ use SuiteCRM\Test\SuitePHPUnitFrameworkTestCase; class GoogleApiKeySaverEntryPointTest extends SuitePHPUnitFrameworkTestCase { - public function testHandleRequestError() + public function testHandleRequestError(): void { $user = BeanFactory::getBean('Users'); $cfg['site_url'] = 'http://foo/bar.org'; @@ -61,8 +61,8 @@ class GoogleApiKeySaverEntryPointTest extends SuitePHPUnitFrameworkTestCase $epMock = new GoogleApiKeySaverEntryPointMock($user, $cfg, $client, $request); $dieOk = $epMock->getDieOk(); $exitString = $epMock->getExitString(); - $this->assertTrue($dieOk); - $this->assertEquals(' + self::assertTrue($dieOk); + self::assertEquals(' SuiteCRM Google Sync - ERROR @@ -75,7 +75,7 @@ class GoogleApiKeySaverEntryPointTest extends SuitePHPUnitFrameworkTestCase ', $exitString); } - public function testHandleRequestGetnew() + public function testHandleRequestGetnew(): void { $user = BeanFactory::getBean('Users'); $cfg['site_url'] = 'http://foo/bar.org'; @@ -85,10 +85,10 @@ class GoogleApiKeySaverEntryPointTest extends SuitePHPUnitFrameworkTestCase $epMock = new GoogleApiKeySaverEntryPointMock($user, $cfg, $client, $request); $expected = "https://accounts.google.com/o/oauth2/auth?response_type=code&access_type=offline&client_id=UNIT_TEST_client_id&redirect_uri=http%3A%2F%2Fwww.example.com%2Findex.php%3FentryPoint%3DsaveGoogleApiKey&state&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcalendar&approval_prompt=force"; $redirectString = $epMock->getRedirectUrl(); - $this->assertEquals($expected, $redirectString); + self::assertEquals($expected, $redirectString); } - public function testHandleRequestCode() + public function testHandleRequestCode(): void { $user = BeanFactory::getBean('Users'); $user->last_name = 'UNIT_TESTS'; @@ -101,13 +101,13 @@ class GoogleApiKeySaverEntryPointTest extends SuitePHPUnitFrameworkTestCase $request['code'] = '1234567890'; try { $epMock = new GoogleApiKeySaverEntryPointMock($user, $cfg, $client, $request); - $this->assertTrue(false, "This should have thrown an exception"); + self::assertTrue(false, "This should have thrown an exception"); } catch (Exception $e) { } - $this->assertEquals(10, $e->getCode()); + self::assertEquals(10, $e->getCode()); } - public function testHandleRequestSetInvalid() + public function testHandleRequestSetInvalid(): void { $user = BeanFactory::getBean('Users'); $user->last_name = 'UNIT_TESTS'; @@ -121,11 +121,11 @@ class GoogleApiKeySaverEntryPointTest extends SuitePHPUnitFrameworkTestCase $epMock = new GoogleApiKeySaverEntryPointMock($user, $cfg, $client, $request); $expected = "http://foo/bar.org/index.php?module=Users&action=EditView&record=" . $user->id; $redirectString = $epMock->getRedirectUrl(); - $this->assertEquals($expected, $redirectString); + self::assertEquals($expected, $redirectString); } - public function testHandleRequestUnknown() + public function testHandleRequestUnknown(): void { $user = BeanFactory::getBean('Users'); $user->last_name = 'UNIT_TESTS'; @@ -138,6 +138,6 @@ class GoogleApiKeySaverEntryPointTest extends SuitePHPUnitFrameworkTestCase $epMock = new GoogleApiKeySaverEntryPointMock($user, $cfg, $client, $request); $expected = "http://foo/bar.org/index.php?module=Users&action=EditView&record=" . $user->id; $redirectString = $epMock->getRedirectUrl(); - $this->assertEquals($expected, $redirectString); + self::assertEquals($expected, $redirectString); } } diff --git a/tests/unit/phpunit/modules/Users/SAML2AuthenticateTest.php b/tests/unit/phpunit/modules/Users/SAML2AuthenticateTest.php index c0ebd2314..c4d7b85ec 100644 --- a/tests/unit/phpunit/modules/Users/SAML2AuthenticateTest.php +++ b/tests/unit/phpunit/modules/Users/SAML2AuthenticateTest.php @@ -1,13 +1,56 @@    "; $actual = $user->getSignatureButtons(''); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); //test with defaultDisplay true $expected = "   "; $actual = $user->getSignatureButtons('', true); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } - public function testUser() + public function testUser(): void { // Execute the constructor and check for the Object type and attributes $user = BeanFactory::newBean('Users'); - $this->assertInstanceOf('User', $user); - $this->assertInstanceOf('Person', $user); - $this->assertInstanceOf('SugarBean', $user); + self::assertInstanceOf('User', $user); + self::assertInstanceOf('Person', $user); + self::assertInstanceOf('SugarBean', $user); - $this->assertAttributeEquals('Users', 'module_dir', $user); - $this->assertAttributeEquals('User', 'object_name', $user); - $this->assertAttributeEquals('users', 'table_name', $user); + self::assertEquals('Users', $user->module_dir); + self::assertEquals('User', $user->object_name); + self::assertEquals('users', $user->table_name); - $this->assertAttributeEquals(true, 'new_schema', $user); - $this->assertAttributeEquals(false, 'authenticated', $user); - $this->assertAttributeEquals(true, 'importable', $user); - $this->assertAttributeEquals(false, 'team_exists', $user); + self::assertEquals(true, $user->new_schema); + self::assertEquals(false, $user->authenticated); + self::assertEquals(true, $user->importable); + self::assertEquals(false, $user->team_exists); } - public function testgetSystemUser() + public function testgetSystemUser(): void { self::markTestIncomplete('environment dependency'); - $user = BeanFactory::newBean('Users'); + $result = BeanFactory::newBean('Users')->getSystemUser(); - $result = $user->getSystemUser(); - - $this->assertInstanceOf('User', $result); - $this->assertEquals(1, $result->id); + self::assertInstanceOf('User', $result); + self::assertEquals(1, $result->id); } - public function testgetDefaultSignature() + public function testgetDefaultSignature(): void { // test $db = DBManagerFactory::getInstance(); @@ -82,30 +80,30 @@ class UserTest extends SuitePHPUnitFrameworkTestCase $user->retrieve(1); $result = $user->getDefaultSignature(); - $this->assertTrue(is_array($result)); + self::assertIsArray($result); } - public function testgetSignature() + public function testgetSignature(): void { $user = BeanFactory::newBean('Users'); $user->retrieve(1); $result = $user->getSignature(1); - $this->assertEquals(false, $result); + self::assertEquals(false, $result); } - public function testgetSignaturesArray() + public function testgetSignaturesArray(): void { $user = BeanFactory::newBean('Users'); $user->retrieve(1); $result = $user->getSignaturesArray(); - $this->assertTrue(is_array($result)); + self::assertIsArray($result); } - public function testgetSignatures() + public function testgetSignatures(): void { $user = BeanFactory::newBean('Users'); @@ -113,24 +111,24 @@ class UserTest extends SuitePHPUnitFrameworkTestCase $expected = "