Commit graph

56 commits

Author SHA1 Message Date
Kunal Mehta
0eecfd015d RevisionTest: Fix @covers tags
Namespaced classes need to be absolutely named.

Change-Id: I48a4b356835e9edf3151a0c8d3bed08ea8cfb452
2017-12-21 23:29:38 -08:00
Kunal Mehta
ee3f8a60ef RevisionTest: Make @covers tags absolute (re-apply)
PHPUnit requires @covers tags to be absolute, they cannot depend
upon `use ...` statements.

Change-Id: I06efa94be3a814acbcb116162db162dcbf36432e
2017-12-21 20:43:54 -08:00
daniel
6af796f3e0 MCR: Deprecate and gut Revision class
This is a re-submission of I4f24e7fbb68.

As a first major step towards Multi-Content-Revisions (MCR),
this patch turns the Revision class into a legacy proxy for
the new RevisionRecord and RevisionStore classes.

Backwards compatibility is maintained for all but some
rare edge cases, like constructing a completely empty
Revision object.

For more information on MCR, see
<https://www.mediawiki.org/wiki/Requests_for_comment/Multi-Content_Revisions>.

NOTE: once this is merged, verify create/delete/restore cycle on beta,
      ideally with emulated replication lag.

Bug: T174025
Change-Id: Ia4c20a91e98df0b9b14b138eb4825c55e5200384
2017-12-21 18:08:54 +00:00
Daniel Kinzler
09bf4f5bb2 Revert "[MCR] Turn Revision into a proxy to new code."
This reverts commit 9dcc56b3c9.

With this patch applied, newly created revisions are sometimes not found
just after submitting an edit, until replicas have caught up.

Our best theory is that it somehow interfere with ChronologyProtector,
but we don't have a good idea how.

Also, as legoktm mentioned, the commit message is terrible and needs fixing.

Change-Id: Idf3404f3fa8f8d08a7fb2ab8268726e2c1edecfe
2017-12-19 12:38:48 +00:00
Kunal Mehta
1d17bbe563 RevisionTest: Make @covers tags absolute
PHPUnit requires @covers tags to be absolute, they cannot depend
upon `use ...` statements.

Change-Id: I92fadc51cc924477d884536b860272b5a230cd36
2017-12-18 22:01:02 -08:00
Kunal Mehta
7f02e0afb9 RevisionTest: Revision::constructFromRowArray is not a function
I'm guessing that RevisionStore::newMutableRevisionFromArray() is
what is supposed to be tested here, since Revision::__construct()
calls that if it gets an array.

Change-Id: Ia6c2e7eb667aa746a12ce74aad62e58d2468defd
2017-12-18 19:24:46 -08:00
daniel
9dcc56b3c9 [MCR] Turn Revision into a proxy to new code.
Change-Id: I4f24e7fbb683cb51f3fd8b250732bae9c7541ba2
2017-12-18 14:37:29 +00:00
Umherirrender
bc8734f882 RevisionTest: Use utf-8 as name in iconv
utf8 is an alias that doesn't work with all PHP installations.

Change-Id: Ief6e5d8b73c9b4a6614430b699f3399b8137689a
2017-12-15 05:18:09 +00:00
addshore
b8351fed48 More user related Revision construction test cases
I4f24e7fbb683cb51f3fd8b250732bae9c7541ba2 releaved
a failing test "PageArchiveTest::testUndeleteRevisions"
that constructs a revision from an array only passing
in 'user_text' and no 'user' field.

After investigation this is quite an odd case that
probably shouldnt happen in production code.

The test cases in this patch test the current behaviour.

Bug: T180210
Change-Id: I7040a16ac6cb29b49f8e7bed1caee72cdd4c6a61
2017-11-20 20:37:11 +00:00
addshore
181dc242ea Set wgCommentTableSchemaMigrationStage for some RevisionTests
Bug: T180922
Change-Id: Ib88b53e36a66042b3c177cae0663040b4fb14a4c
2017-11-20 09:33:28 +00:00
addshore
25e5d9b8c1 [MCR] tests for Revision::getQueryInfo
Bug: T180210
Change-Id: I5bdb5eed853e22bacd6b4c2546343e9d0f2d8c89
2017-11-18 18:22:24 +00:00
addshore
211143d7eb [MCR] tests for Revision::getArchiveQueryInfo
Bug: T180210
Change-Id: Icb016be8d69dfdfa83f44bbc4fb259b5beb30678
2017-11-18 18:08:45 +00:00
addshore
b2ff18b9ed [MCR] Readd various field & cond method tests for Revision
This is a partial revert of:
Idcfd15568489d9f03a7ba4460e96610d33bc4089
which removed these tests.

Bug: T180210
Change-Id: Ib0617ee0a7bd4391ed25415b44a8ed077a985eaa
2017-11-18 17:50:51 +00:00
addshore
962e7a4f2a Tests for Revision::getRevisionText with ExternalStore usage
Bug: T180210
Change-Id: I20e47a44a064ede4f5e674f57ec4d8e39b379ad6
2017-11-14 18:37:52 +00:00
addshore
64c973060c Initial tests for Revision::getRevisionText
Bug: T180210
Change-Id: Idd5c1af7ecc336ba3f32b15fd8d5cb5bd19f649b
2017-11-14 10:41:11 +00:00
addshore
c97caafa2e Tests for Revision::decompressRevisionText
Bug: T180210
Change-Id: I21f6bb02757bcf59ce483e7d61685d372f134048
2017-11-10 14:11:59 +00:00
addshore
aab3e3be88 Run RevisionIntegrationTest for both ContentHandlerUseDB settings
core used to have a test case that ran various Revision tests
with and without ContentHandlerUseDB set, however it did not
run due to the class / file having a bad name.

This patch reintroduces the running on Revision tests for both
ContentHandlerUseDB settings.

The global has to be set in setup / before the page used for
testing is created, else this page will be created with the
wrong values in the DB for use in the tests.

Change-Id: Ied1023e22eeac413fa86ea6946aa31619fd66319
2017-11-10 14:11:17 +00:00
addshore
9fe46fdd32 Split Revision tests into Unit & Integration classes
Change-Id: If10b102a1a0d680b5f067bf34c0fafcb59c09048
2017-10-13 14:46:36 +01:00
addshore
34581a51c0 Revision split __construct method
This makes the logic much easier to follow and each type of
construction easier to see.
This also emphisises the testing of construction being split
into row object vs array

Change-Id: Ie3aa6ec4c026f0249ccd438903fec27fcd266b67
2017-10-12 01:07:46 +00:00
addshore
288fb8cafa Revision: test and fix __construct exceptions
This adds tests for each exception that can be thrown
in the Revision constructor.
It also fixes where the exception for the content part of a row
not containing a content object is thrown.
Prior to this ->getModel() could be called on the content row
element before the check had actually occoured.

Change-Id: Ia2d2cfdca01871fc6dbb96707d781db33d7d0a40
2017-10-12 01:07:21 +00:00
addshore
5fabead899 RevisionTest: refactor test dataProviders
Change-Id: I238d0294de7112a78ef18ffba195c0c175d6d735
2017-10-11 23:54:35 +00:00
addshore
1bdc9e1d6b RevisionTest code style fixes & file split
Change-Id: I054a6810e29225e4341c518631a6dba9f40a1531
2017-10-11 16:20:15 +00:00
Brad Jorsch
2d9f29a846 Improve namespace handling in tests
MWNamespace has three internal caches, only one of which can be cleared
(and that somewhat oddly by passing a boolean to
MWNamespace::getCanonicalNamespaces()).

This change introduces a MWNamespace::clearCaches() method to clear all
three caches. It also adds some resetting in tests that seemed to be
missing it.

Change-Id: I1dcfcd8713888b3ff8fc75e95329ba72bd95d0c9
2017-09-29 05:21:47 +00:00
Reedy
0958f53373 Revision::getText() was removed
Bug: T154498
Change-Id: I29dcf768a9c176ca27b94359ac99cdc2b5ea930b
2017-01-19 01:57:38 +00:00
Florian
d2fa6856a8 Remove Revision::getRawText()
Bug: T122754
Depends-On: I742f02021959587edd83a4cfb25e0338d05a8e81
Depends-On: I10283802c26b99d7e345c5c06d59c4ea24002e52
Depends-On: I6da4fab1e0e8f698b824e977dd2336e4415ae1ba
Change-Id: Id1cfda59e381673be99d9561c9997c0baf26d425
2016-04-01 19:57:35 +01:00
Kunal Mehta
6e9b4f0e9c Convert all array() syntax to []
Per wikitech-l consensus:
 https://lists.wikimedia.org/pipermail/wikitech-l/2016-February/084821.html

Notes:
* Disabled CallTimePassByReference due to false positives (T127163)

Change-Id: I2c8ce713ce6600a0bb7bf67537c87044c7a45c4b
2016-02-17 01:33:00 -08:00
Vivek Ghaisas
c54766586a Fix issues identified by SpaceBeforeSingleLineComment sniff
Change-Id: I048ccb1fa260e4b7152ca5f09b053defdd72d8f9
2015-09-26 23:06:52 +00:00
Siebrand Mazeland
d5df012a13 Pass phpcs-strict on some test files (3/x)
Change-Id: I44172b512cd9b6c43806dad697e449bf06897305
2014-04-24 18:51:39 +02:00
Thiemo Mättig
2aa67db39d Fix "@param null $param" documentations
... and very few other documentation details that are closely connected
to these mistakes.

Change-Id: I5b2691948e196124c77f0cc04d0ed5a7167cac25
2014-04-09 12:33:55 +02:00
umherirrender
5dbfd5bf80 Fixed spacing
- Removed trailing spaces in comments
- Removed multiple empty lines
- Removed space after object operator

Change-Id: I9fd3256ab490c7cd2034de3fd94e6be6e6d6d8f2
2013-11-21 18:52:25 +00:00
addshore
fb16eb2abe Add more @covers tags and test cleanup
Other cleanup includes
 - Adding method scopes
 - Fixing php comments
 - Adding todos

Change-Id: I0a231008e6a59110ffcab6af1bd8c4d3ee13f21d
2013-10-22 08:59:42 +00:00
Siebrand Mazeland
791d0b2a98 Update code formatting
Change-Id: I16a9b42651f1cfb1a70dffbb67b7b83dfeb90d03
2013-04-26 14:21:20 +00:00
umherirrender
ff3485ec99 Tests: Use more setMwGlobals
Change some tests to use setMwGlobals to have restoring of globals after
the test.
This also removes some save/restore code, which is not needed, due to
the automatically restoring on tearDown with setMwGlobals.

Change-Id: I8d2ac9f6cc14f0bd4ee8eb851c09f2e71babc6e0
2013-03-21 20:35:44 +01:00
Siebrand Mazeland
7a24666935 Update formatting
2 of n.

Change-Id: I5406673e99ed53e4e330ed47f022a17177544daa
2013-02-14 12:36:35 +01:00
jenkins-bot
75ef257c29 Merge "pass codesniffer on tests/" 2013-01-28 23:47:45 +00:00
Antoine Musso
94b196798c test: some Revision tests depends on PHP zlib ext
Use an helper to verify whether 'zlib' is available, else will happilly
skip the test.

Change-Id: I43f8b20a95286b5495799d54b415f6d15894a335
2013-01-28 11:19:01 +00:00
Antoine Musso
0fd05285d7 pass codesniffer on tests/
Fix almost all occurences of the following sniffs:

Generic.CodeAnalysis.UselessOverridingMethod.Found
Generic.Formatting.NoSpaceAfterCast.SpaceFound
Generic.Functions.FunctionCallArgumentSpacing.SpaceBeforeComma
Generic.Functions.OpeningFunctionBraceKernighanRitchie.BraceOnNewLine
Generic.PHP.LowerCaseConstant.Found
PSR2.Classes.PropertyDeclaration.ScopeMissing
PSR2.Files.EndFileNewline.TooMany
PSR2.Methods.MethodDeclaration.StaticBeforeVisibility

Change-Id: I96aacef5bafe5a2bca659744fba1380999cfc37d
2013-01-28 12:14:26 +01:00
Alexandre Emsenhuber
07818096df (bug 35204) set wgLanguageCode in unit tests
Setting $wgContLang without changing $wgLanguageCode accordingly is a
very bad idea.

This caused about 20 exceptions when using LanguageCode set to 'fr'
on my installation:

"MWException: Error in MediaWikiLangTestCase::setUp(): $wgLanguageCode
('fr') is different from $wgContLang->getCode() (en)"

Follow-up of I2987db68 (2b0edc8).

Change-Id: I56d3f1bfc78d6a2e40460533524e82f360490206
2012-11-17 09:53:34 +01:00
daniel
329d5b3516 Merge branch 'Wikidata' into master.
This introduces the ContentHandler facility into MediaWiki,
see docs/contenthandler.txt.

For convenient review, a squashed version is available at
https://gerrit.wikimedia.org/r/27191

The ContentHandler facility is a major building block of the Wikidata project.
It has been discussed repeatedly on wikitech-l.

Change-Id: I3804e2d5f6f59e6a39db80744bdf61bfe8c14f98
2012-10-09 11:34:24 +02:00
Timo Tijhof
181c7cdc8e Clean and repair many phpunit tests (+ fix implied configuration)
This commit depends on the introduction of
MediaWikiTestCase::setMwGlobals in change Iccf6ea81f4.

Various tests already set their globals, but forgot to restore
them afterwards, or forgot to call the parent setUp, tearDown...

Either way they won't have to anymore with setMwGlobals.

Consistent use of function characteristics:
* protected function setUp
* protected function tearDown
* public static function (provide..)

(Matching the function signature with PHPUnit/Framework/TestCase.php)

Replaces:
 * public function (setUp|tearDown)\(
 * protected function $1(

 * \tfunction (setUp|tearDown)\(
 * \tprotected function $1(

 * \tfunction (data|provide)\(
 * \tpublic static function $1\(

Also renamed a few "data#", "provider#" and "provides#" functions
to "provide#" for consistency. This also removes confusion where
the /media tests had a few private methods called dataFile(),
which were sometimes expected to be data providers.

Fixes:

TimestampTest often failed due to a previous test setting a
different language (it tests "1 hour ago" so need to make sure
it is set to English).

MWNamespaceTest became a lot cleaner now that it executes with
a known context. Though the now-redundant code that was removed
didn't work anyway because wgContentNamespaces isn't keyed by
namespace id, it had them was values...

FileBackendTest:
* Fixed: "PHP Fatal: Using $this when not in object context"

HttpTest
* Added comment about:
  "PHP Fatal: Call to protected MWHttpRequest::__construct()"
  (too much unrelated code to fix in this commit)

ExternalStoreTest
* Add an assertTrue as well, without it the test is useless
  because regardless of whether wgExternalStores is true or false
  it only uses it if it is an array.

Change-Id: I9d2b148e57bada64afeb7d5a99bec0e58f8e1561
2012-10-09 03:01:51 +02:00
daniel
63f42295c3 Don't assume main namespace contains wikitext
Change-Id: Ie5bb593f850ab97b2e63f064e3fc52bc17edfdd1
2012-09-20 16:18:30 +02:00
daniel
0797473710 suppress deprecation warnings about getText in tests
Change-Id: I158cbf6e6d5bbca56df950a00a7ba5cd9efc32f9
2012-08-30 11:05:52 +02:00
daniel
96f7db3f7b Avoid deprecation warnings in test cases.
a) when testing deprecated functions, use $this->hideDeprecated() to
suppress warnings.

b) use doEditContent() instead of doEdit()

Change-Id: Ifa9e0ef373ed72ef7d4a3c2dd558483af4a3fd55
2012-08-28 16:00:39 +02:00
daniel
266b66c899 Revision::getContent must return clone if mutable
Revision::getContent must return a cloned instance of the Content object
if the Content object is mutable to avoid confusion.

Content::copy is used to achieve this, which is specified to return $this
for immutable Content.

Change-Id: Iace17b6ae8aa85a3500624441b69bc067c1ade00
2012-08-21 12:48:29 +02:00
Antoine Musso
763da2e3e3 RevisionTest might need database access
By adding '@group Database', we make sure those tests are not going to
be run before a database is actually setup.

Change-Id: I6ef256e4c247ceb0a344a963dd3cb67b018e586f
2012-07-06 17:35:21 +02:00
daniel
906a1ba51f [bug 37746] string ids for content model and format.
The content model is stored as a varbinary(32), the format
as varbinary(64).

If the standard model resp. format is used, null is written
to the database instead of the actual id, saving space.

Change-Id: I32659b49a9ad3cb8ecae9019562cff7de42b65f9
2012-06-26 15:56:06 +02:00
daniel
cbc2014b2d Use integers for content_model and content_format.
Representing content_model and content_format as integers in the
database was suggested by Asher mainly to save space.

This change entails some refactoring and renaming, but no big
change in logic.
2012-05-14 10:22:52 +02:00
daniel
060b6c74c6 implement feature switch for ContentHandler database integration, to allow for easy deployment 2012-05-02 15:41:47 +02:00
daniel
74a65269fe fix test: use text/x-wiki, not application/x-wiki 2012-04-26 12:17:47 +02:00
daniel
ce4a6e26ea reset namespace caches when testing extra namespace handling 2012-04-26 12:11:01 +02:00