Description
Magento is slowly moving towards the latest dependencies in the PHP world. Part of this is to have (at least) supported version of PHPUnit ( https://phpunit.de/supported-versions.html )
Preconditions (*)
- Current Unit, Integration and API functional tests are not compatible with PHPUnit 8
Steps to reproduce (*)
- Install PHPUnit 8 on separate directory and run Unit Tests from Magento
Expected result (*)
- Tests should pass.
Actual result (*)
- Tests are failing due to multiple compatibility issues
Contribution
What needs to be done
Most of the cases, the scenario to make Unit Tests compatible with PHPUnit 8 is:
setUp
andtearDown
methods has to have: void
return type hint- Replace
PHPUnit_Framework_TestCase
withPHPUnit\Framework\TestCase
- Replace
\PHPUnit_Framework_MockObject_MockObject
with\PHPUnit\Framework\MockObject\MockObject
- Replace
@expectedException \Magento\Framework\Exception\ConfigurationMismatchException
annotation with$this->expectException(\Magento\Framework\Exception\ConfigurationMismatchException::class)
- Replace
@expectedExceptionMessage
with$this->expectExceptionMessage('The message');
If you find any other typical steps to be done - let me know in the comment, I'm going to update the issue.
PHPUnit 9+ compatibility
https://phpunit.de/announcements/phpunit-8.html
Review the use of deprecated methods: assertContains
, assertNotContains
etc.
... and annotations expectException
, expectExceptionMessage
etc.
Notice!
Make sure that you have linted your code after finish your work!
❗ ❗ ❗ If you see Tests that test nothing - rewrite or remove them. Let's avoid massive delusion of Tests coverage, based on the tests that test implementation instead of method / unit outcome!
Modules
Due to some compatibility issues and to make Code Review easier - please do your changes per module. You can find list of checkboxes underneath with list of modules that should be covered. When you start working on specific module, please check the chekbox and add the comment which module you start work. When you finish - edit your commend adding the link to PR.
Open Source
- app/code/Magento/AdminNotification
- app/code/Magento/AdminAnalytics
- app/code/Magento/AdvancedPricingImportExport
- app/code/Magento/AdvancedSearch
- app/code/Magento/Amqp
- app/code/Magento/Analytics
- app/code/Magento/AsynchronousOperations
- app/code/Magento/Authorization
- app/code/Magento/Authorizenet
- app/code/Magento/Backend
- app/code/Magento/Backup
- app/code/Magento/Braintree
- app/code/Magento/Bundle
- app/code/Magento/BundleImportExport
- app/code/Magento/CacheInvalidate
- app/code/Magento/Captcha
- app/code/Magento/CardinalCommerce
- app/code/Magento/Catalog
- app/code/Magento/CatalogImportExport
- app/code/Magento/CatalogInventory
- app/code/Magento/CatalogRule
- app/code/Magento/CatalogRuleConfigurable
- app/code/Magento/CatalogSearch
- app/code/Magento/CatalogUrlRewrite
- app/code/Magento/CatalogWidget
- app/code/Magento/Checkout
- app/code/Magento/CheckoutAgreements
- app/code/Magento/Cms
- app/code/Magento/CmsUrlRewrite
- app/code/Magento/Config
- app/code/Magento/ConfigurableImportExport
- app/code/Magento/ConfigurableProduct
- app/code/Magento/Contact
- app/code/Magento/Cookie
- app/code/Magento/Cron
- app/code/Magento/CurrencySymbol
- app/code/Magento/Customer
- app/code/Magento/CustomerImportExport
- app/code/Magento/Deploy
- app/code/Magento/Developer
- app/code/Magento/Directory
- app/code/Magento/Downloadable
- app/code/Magento/DownloadableImportExport
- app/code/Magento/Eav
- app/code/Magento/Elasticsearch
- app/code/Magento/Elasticsearch6
- app/code/Magento/Elasticsearch7
- app/code/Magento/Email
- app/code/Magento/EncryptionKey
- app/code/Magento/GiftMessage
- app/code/Magento/GoogleAdwords
- app/code/Magento/GoogleAnalytics
- app/code/Magento/GoogleOptimizer
- app/code/Magento/GroupedImportExport
- app/code/Magento/GroupedProduct
- app/code/Magento/ImportExport
- app/code/Magento/Indexer
- app/code/Magento/InstantPurchase
- app/code/Magento/Integration
- app/code/Magento/LayeredNavigation
- app/code/Magento/Marketplace
- app/code/Magento/MediaStorage
- app/code/Magento/MessageQueue
- app/code/Magento/Msrp
- app/code/Magento/Multishipping
- app/code/Magento/MysqlMq
- app/code/Magento/NewRelicReporting
- app/code/Magento/Newsletter
- app/code/Magento/OfflinePayments
- app/code/Magento/OfflineShipping
- app/code/Magento/PageCache
- app/code/Magento/Payment
- app/code/Magento/Paypal
- app/code/Magento/Persistent
- app/code/Magento/ProductAlert
- app/code/Magento/ProductVideo
- app/code/Magento/Quote
- app/code/Magento/ReleaseNotification
- app/code/Magento/Reports
- app/code/Magento/RequireJs
- app/code/Magento/Review
- app/code/Magento/Robots
- app/code/Magento/Rss
- app/code/Magento/Rule
- app/code/Magento/Sales
- app/code/Magento/SalesInventory
- app/code/Magento/SalesRule
- app/code/Magento/SalesSequence
- app/code/Magento/SampleData
- app/code/Magento/Search
- app/code/Magento/Security
- app/code/Magento/SendFriend
- app/code/Magento/Shipping
- app/code/Magento/Signifyd
- app/code/Magento/Sitemap
- app/code/Magento/Store
- app/code/Magento/Swagger
- app/code/Magento/SwaggerWebapi
- app/code/Magento/SwaggerWebapiAsync
- app/code/Magento/Swatches
- app/code/Magento/Tax
- app/code/Magento/TaxImportExport
- app/code/Magento/Theme
- app/code/Magento/Translation
- app/code/Magento/Ui
- app/code/Magento/UrlRewrite
- app/code/Magento/User
- app/code/Magento/Variable
- app/code/Magento/Vault
- app/code/Magento/Webapi
- app/code/Magento/WebapiAsync
- app/code/Magento/Weee
B2B
- .b2b/app/code/Magento/BundleNegotiableQuote
- .b2b/app/code/Magento/BundleSharedCatalog
- .b2b/app/code/Magento/Company
- .b2b/app/code/Magento/CompanyCredit
- .b2b/app/code/Magento/CompanyPayment
- .b2b/app/code/Magento/ConfigurableNegotiableQuote
- .b2b/app/code/Magento/ConfigurableSharedCatalog
- .b2b/app/code/Magento/GiftCardRequisitionList
- .b2b/app/code/Magento/GiftCardSharedCatalog
- .b2b/app/code/Magento/GroupedRequisitionList
- .b2b/app/code/Magento/GroupedSharedCatalog
- .b2b/app/code/Magento/NegotiableQuote
- .b2b/app/code/Magento/NegotiableQuoteSharedCatalog
- .b2b/app/code/Magento/OrderHistorySearch
- .b2b/app/code/Magento/QuickOrder
- .b2b/app/code/Magento/RequisitionList
- .b2b/app/code/Magento/SharedCatalog
EE
- .ee/app/code/Magento/AdminGws
- .ee/app/code/Magento/AdvancedCatalog
- .ee/app/code/Magento/AdvancedCheckout
- .ee/app/code/Magento/AdvancedRule
- .ee/app/code/Magento/AdvancedSalesRule
- .ee/app/code/Magento/Banner
- .ee/app/code/Magento/BannerCustomerSegment
- .ee/app/code/Magento/BundleImportExportStaging
- .ee/app/code/Magento/BundleStaging
- .ee/app/code/Magento/CatalogEvent
- .ee/app/code/Magento/CatalogImportExportStaging
- .ee/app/code/Magento/CatalogInventoryStaging
- .ee/app/code/Magento/CatalogPermissions
- .ee/app/code/Magento/CatalogRuleStaging
- .ee/app/code/Magento/CatalogStaging
- .ee/app/code/Magento/CheckoutStaging
- .ee/app/code/Magento/CmsStaging
- .ee/app/code/Magento/ConfigurableProductStaging
- .ee/app/code/Magento/CustomAttributeManagement
- .ee/app/code/Magento/CustomerBalance
- .ee/app/code/Magento/CustomerCustomAttributes
- .ee/app/code/Magento/CustomerFinance
- .ee/app/code/Magento/CustomerSegment
- .ee/app/code/Magento/Cybersource
- .ee/app/code/Magento/Enterprise
- .ee/app/code/Magento/Eway
- .ee/app/code/Magento/GiftCard
- .ee/app/code/Magento/GiftCardAccount
- .ee/app/code/Magento/GiftCardImportExport
- .ee/app/code/Magento/GiftRegistry
- .ee/app/code/Magento/GiftWrapping
- .ee/app/code/Magento/GoogleTagManager
- .ee/app/code/Magento/GroupedProductStaging
- .ee/app/code/Magento/Invitation
- .ee/app/code/Magento/Logging
- .ee/app/code/Magento/MultipleWishlist
- .ee/app/code/Magento/PaymentStaging
- .ee/app/code/Magento/PersistentHistory
- .ee/app/code/Magento/PricePermissions
- .ee/app/code/Magento/PromotionPermissions
- .ee/app/code/Magento/Reminder
- .ee/app/code/Magento/ResourceConnections
- .ee/app/code/Magento/ReviewStaging
- .ee/app/code/Magento/Reward
- .ee/app/code/Magento/Rma
- .ee/app/code/Magento/SalesArchive
- .ee/app/code/Magento/SalesRuleStaging
- .ee/app/code/Magento/ScalableCheckout
- .ee/app/code/Magento/ScalableInventory
- .ee/app/code/Magento/ScalableOms
- .ee/app/code/Magento/ScheduledImportExport
- .ee/app/code/Magento/Staging
- .ee/app/code/Magento/Support
- .ee/app/code/Magento/TargetRule
- .ee/app/code/Magento/VersionsCms
- .ee/app/code/Magento/VisualMerchandiser
- .ee/app/code/Magento/WebsiteRestriction
- .ee/app/code/Magento/Worldpay
- .ee/lib/internal/Magento/Framework/ForeignKey/Test/Unit
Inventory module
- ext/magento/inventory/Inventory/
- ext/magento/inventory/InventoryImportExport/
- ext/magento/inventory/InventoryMultiDimensionalIndexerApi/
- ext/magento/inventory/InventoryReservations/