Commit graph

9 commits

Author SHA1 Message Date
James D. Forrester
35b2542895 Namespace includes/cache
Bug: T353458
Change-Id: Ic3f3168ef17113f5fb3ec11e0a47f52d65eefba9
2024-02-20 10:28:03 -05:00
Timo Tijhof
0ca2b996b7 CommentFormatter: Clean up CommentParserFactoryTest
* Widen `@covers` annotation to at least the subject class.
  Ref https://gerrit.wikimedia.org/r/c/mediawiki/extensions/Cite/+/982945
  Ref https://gerrit.wikimedia.org/r/q/owner:Krinkle+is:merged+message:%2522Widen%2522

* Remove useless test for private properties existing, which
  is implementation detail of no interest to whether the class is
  working correctly or not.

* Given no assertions exist, combine testCreate()

This commit removes use of deprecated assertObjectHasAttribute, hence
tagging as T342110.

Bug: T342110
Needed-By: Id708a7716505ffce26c8eb438a98d74195682e91
Change-Id: Id7a7593b41afef89fd02af070bdf760baddd2c30
2024-02-13 19:13:37 +00:00
Doğu Abaris
f5db3195eb test: Add PHPUnit tests for StringCommentIterator
Covered:
- `testConstruct`: Constructor initializes properties.
- `testCurrent`: `current` method returns CommentItem object.

Change-Id: I420b87deb29a7b4a2f4611f1dbef3d3621052382
2024-02-08 20:39:41 +00:00
Doğu Abaris
f03e49c177 Add PHPUnit tests for CommentParserFactory
Adds tests for \MediaWiki\CommentFormatter\CommentParserFactory
The test suite includes the following validations:
- Tests constructor for property initialization.
- Tests create method for proper initialization.

Change-Id: I8c66ebaeeccb320c439ef4c879440d7b3e1233dd
2024-02-08 20:39:22 +00:00
Doğu Abaris
4fa6a05d71 Add PHPUnit tests for CommentItem
Adds tests for \MediaWiki\CommentFormatter\CommentItem
The test suite includes the following validations:
- Constructor initialization with expected parameters and behaviors.
- Checks correct assignment of LinkTarget objects.
- Assesses boolean flag manipulation for the same-page context.
- Examines wikiId setter with diverse input types.

Change-Id: Ibc12cced8da70cdf75bb1764ad16ce5dd872820b
2024-02-08 13:07:08 -05:00
James D. Forrester
94ece673b2 Namespace TitleValue under \MediaWiki\Title
One of the big ones, so doing this alone.

Bug: T166010
Change-Id: I4c901d5c32696d8334ec30cede7d9b6f3d8d645e
2023-09-18 18:24:39 +01:00
Tim Starling
5e30a927bc tests: Make some PHPUnit data providers static
Just methods where adding "static" to the declaration was enough, I
didn't do anything with providers that used $this.

Initially by search and replace. There were many mistakes which I
found mostly by running the PHPStorm inspection which searches for
$this usage in a static method. Later I used the PHPStorm "make static"
action which avoids the more obvious mistakes.

Bug: T332865
Change-Id: I47ed6692945607dfa5c139d42edbd934fa4f3a36
2023-03-24 02:53:57 +00:00
Func
7f74a2e50c Clean up tests that misused the parameters of assertSame/Equals
Expected value is the first parameter to assertSame() or assertEquals().
And turn to use assertCount() for some assertions aginst count of array.

Based on code search `assert(?:Same|Equals)\(.+,.+expected` and I look
through files roughly, so some assertions that don't contains 'expected'
are also fixed. In the meantime, some assertions that I am not clear
about are not touched.

Change-Id: I75798b60d29fd19b33f4fdf34ed3c788db420d01
2022-02-08 07:21:10 +00:00
Tim Starling
f7f84dddb3 Introduce CommentFormatter
CommentParser:

* Move comment formatting backend from Linker to a CommentParser service.
  Allow link existence and file existence to be batched.
* Rename $local to $samePage since I think that is clearer.
* Rename $title to $selfLinkTarget since it was unclear what the title
  was used for.
* Rename the "autocomment" concept to "section link" in public
  interfaces, although the old term remains in CSS classes.
* Keep unsafe HTML pass-through in separate "unsafe" methods, for easier
  static analysis and code review.

CommentFormatter:

* Add CommentFormatter and RowCommentFormatter services as a usable
  frontend for comment batches, and to replace the Linker static methods.
* Provide fluent and parametric interfaces.

Linker:

* Remove Linker::makeCommentLink() without deprecation -- nothing calls
  it and it is obviously an internal helper.
* Soft-deprecate Linker methods formatComment(), formatLinksInComment(),
  commentBlock() and revComment().

Caller migration:

* CommentFormatter single: Linker, RollbackAction, ApiComparePages,
  ApiParse
* CommentFormatter parametric batch: ImageHistoryPseudoPager
* CommentFormatter fluent batch: ApiQueryFilearchive
* RowCommentFormatter sequential: History feed, BlocklistPager,
  ProtectedPagesPager, ApiQueryProtectedTitles
* RowCommentFormatter with index: ChangesFeed, ChangesList,
  ApiQueryDeletedrevs, ApiQueryLogEvents, ApiQueryRecentChanges
* RevisionCommentBatch: HistoryPager, ContribsPager

Bug: T285917
Change-Id: Ia3fd50a4a13138ba5003d884962da24746d562d0
2021-09-28 11:13:03 -07:00