Opened 3 years ago
Last modified 18 months ago
#59981 new enhancement
PHPUnit tests for is_main_network
| Reported by: | pbearne | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | Awaiting Review |
| Component: | Networks and Sites | Version: | |
| Severity: | normal | Keywords: | has-patch has-unit-tests |
| Cc: | Focuses: | tests |
Description
Change History (7)
#1
@
3 years ago
- Summary PHPUnit tests for is_site_meta_supported → PHPUnit tests for is_main_network
This ticket was mentioned in Slack in #core-test by pbearne. View the logs.
3 years ago
#5
@
22 months ago
- Component Build/Test Tools → Networks and Sites
- Type defect (bug) → enhancement
Since this is about adding tests and not a general build or test tooling change, I'm reassigning it to the relevant component.
This ticket was mentioned in PR #7571 on WordPress/wordpress-develop by @debarghyabanerjee.
22 months ago
#6
- Keywords has-patch has-unit-tests added; needs-patch removed
Trac Ticket: Core-59981
## Description:
- This pull request introduces the initial set of unit tests for the is_main_network() function. The tests are designed to verify the function's behavior in both multisite and single-site scenarios.
## Changes Made:
- Added Multisite Tests:
- Class:
Tests_Multisite_IsMainNetwork
- Purpose: Tests the behavior of is_main_network() for valid and invalid network IDs within a multisite environment.
- Test Cases:
- Valid network IDs that should return true:
- null
- 1 (main network)
- Invalid network IDs that should return false:
- 2
- 0
- Empty string
- Added Single-Site Tests:
- Class:
Tests_Functions_IsMainNetwork
- Purpose: Tests the behavior of is_main_network() in a single-site context.
- Test Cases:
- Valid network IDs that should return true:
- null
- 1
- 0
- Empty string
- Non-main network ID (2) which is also tested to ensure the function handles it correctly.
## Benefits:
- Coverage for Multisite and Single-Site
- Ensures that the is_main_network() function is thoroughly tested in different contexts.
- Early Detection of Issues
- The introduction of these tests will help catch any bugs or unexpected behavior early in the development process.
## Testing:
- The tests are designed to be run in the WordPress environment using PHPUnit.
- All tests have been verified to pass successfully.
## Commands
### Multisite
npm run test:php -- -c tests/phpunit/multisite.xml --group ms-site --filter Tests_MultiSite_is_main_network
### Single SIte
npm run test:php --filter Tests_Multisite_IsMainNetwork::test_should_return_true_for_valid_network_id
Note:
See TracTickets
for help on using tickets.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)