Commit ee57cbd
committed
Tests: Improve coverage for
The case meant to test the optional `$length` parameter passed it as an argument to `assertSame()` instead of `url_shorten()`. So the latter ran with its default length of 35, the expected value happened to match the default output, and the assertion passed — while the `$length` parameter was never actually tested.
This commit:
* Converts the tests to a data provider with descriptive keys, so a failure points to the exact case.
* Separates the default-behavior cases from the custom-length cases.
* Adds real coverage for `$length`: the URL is kept when the length exceeds or equals the cleaned URL (pinning the strict `>` comparison) and shortened when it is smaller.
* Adds a comment clarifying that a shortened URL is cut to `( $length - 3 )` characters before `…` is appended.
No production code is changed — this is a test-only improvement.
Developed in WordPress#12558.
Follow-up to [35314].
Props Soean, mukesh27, SergeyBiryukov.
See #64894.
git-svn-id: https://develop.svn.wordpress.org/trunk@62768 602fd350-edb4-49c9-b593-d223f7449a82url_shorten() and test the $length parameter.1 parent 81b2b5b commit ee57cbd
1 file changed
Lines changed: 73 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
17 | 47 | | |
18 | | - | |
19 | | - | |
20 | | - | |
| 48 | + | |
21 | 49 | | |
22 | | - | |
23 | | - | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
24 | 84 | | |
25 | 85 | | |
0 commit comments