Commit graph

18 commits

Author SHA1 Message Date
Platonides
d197824c54 Replace a bunch of extension_loaded() checks with checkPHPExtension()
Change-Id: I7bd9bc3a753975f45e63532d4f07aeff853b9970
2014-01-23 23:09:53 +00:00
addshore
c40786cba2 Cleanup tests/includes/media
- Adds @covers tags
- fixes comments
- fixes scope
- adds @todos
- split files per class

Change-Id: Id5aaa20769725a96f22fb838d376697c250874a5
2013-10-24 08:12:42 +00:00
Chad Horohoe
d0c8ba037c Remove wfDl() and cleanup everything it touched
wfDl() is a wrapper around dl(), which is an evil function and
basically only works from the command line of Zend. Luckily
no extension has ever used this thing, so let's just remove it
outright.

For comparison, here's a list of places it does not work:
- hhvm
- php as apache module
- php compiled with zts support
- safe_mode
- Basically any shared host that cares about security

Most callers are using it to check for extension support and are
actually failing gracefully when wfDl() returns false. In these
places we're just going to use extension_loaded().

While we're at it, clean up some of the test skip logic in the
media tests so we can bail as early as possible if we know we
can't complete the test.

This also immediately removes $wgLoadFileinfoExtension. It's been
enabled by default since 5.3 and falls back gracefully when the
support isn't available.

Change-Id: Ieb430dfc74483731dde51d6e20fa700d641ba1f4
2013-10-09 10:51:35 -07: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
de04f37ef1 Update formatting
5 of n.

Change-Id: I811ca957b6588085d67606ebc0cd4033a1e53839
2013-02-15 12:35:50 +00: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
umherirrender
99159fd750 wfTimestamp should not die on bogus input [Regression]
Followup I68eb9f27

No caller of wfTimestamp can handle the exception, false is always used,
as the method comment says.

See bug 40037 for File related timestamps.
The api result is also not b/c:
<api servedby="mw70">
  <error code="internal_api_error_TimestampException" info="Exception
Caught: MWTimestamp::setTimestamp : Invalid timestamp - te"
xml:space="preserve" />
</api>

Change-Id: I1e8c785941d35678f3d12824bdde0ce245572592
2012-09-14 18:28:22 +02:00
Tyler Anthony Romeo
e738203a8e Added PHP complement for mw.Time.
Figured since a JS Timestamp class was being implemented
it might be appropriate to create a complementary PHP
Timestamp class. Much of code is taken from wfTimestamp().

Note: Another change (I53dcf547) is attempting a related
issue. Not sure how much of scope overlap there is.

Change-Id: I68eb9f27eebe80df757187f634392e1bcba5551f
Signed-off-by: Tyler Romeo <tylerromeo@gmail.com>
2012-08-30 20:44:09 -04:00
jeroendedauw
38c7f444e1 Use __DIR__ instead of dirname( __FILE__ )
We can now do this since we finally switched to PHP 5.3 for MW 1.20 and get rid of the silly dirname(__FILE__) stuff :)

Change-Id: Id9b2c9cd2e678197aa81c78adced5d1d31ff57b1
2012-08-27 21:45:00 +02:00
Brian Wolff
f9173cb902 Make sure that if we fail to read the App13 (iptc) block of a JPG file, that that doesn't block other metadata from being read. Also makes sure if more then one app13 block is in the file, they are all read, not just the last one that appears in the file (This required some changes to tests since before the intermediate value was just one value, now its an array of all such blocks) 2012-01-05 23:25:39 +00:00
Brian Wolff
ffed20a5da Follow-up r92635 Make sure the Exif related tests handle not having the Exif extension available properly
This should fix issues reported in http://lists.wikimedia.org/pipermail/wikitech-l/2011-September/055212.html Lots of these tests loaded the exif extension dynamically, but then didn't reset $wgShowEXIF var properly.

Also change some of the markTestIncomplete to markTestSkipped as that seemed more correct.
2011-09-18 01:53:09 +00:00
Brian Wolff
4aaf9fe071 (follow-up r86169) Moar unit-tests!! (sorry for uttetly huge commit)
This should be my last commit of unit tests for the media metadata stuff (hopefully).
2011-08-21 18:05:34 +00:00
Brian Wolff
c0e419ce5e follow-up r86169: unit tests for extraction of JPEG comment (COM) segments. 2011-08-18 05:45:04 +00:00
Brian Wolff
a6623f7fac Move the image files used in the media tests from includes/media to data/media as the includes/media
was starting to get crowded with supporting image files.

This changes the following things
*Moves the media files to a different directory
*Changes the references to the files to reference there new locations

2 semi-unrelated changes
*Modify the README file that was basically giving credit for the images where due to explain what the images are for.
*set svn:mime-type to image/svg+xml for the svg files.
2011-08-17 23:28:31 +00:00
Platonides
ae3910dd5d Follow up r92635 2011-07-20 15:35:48 +00:00
Platonides
eded6a8db8 Make BitmapMetadataHandlerTest incomplete if $wgShowEXIF is not set.
It was throwing 'MWException: Internal error: exif_read_data not present. $wgShowEXIF may be incorrectly set or not checked by an extension.'
Fixed typo in LocalSettings.
2011-06-29 13:45:57 +00:00
Brian Wolff
cf32ccd072 Per CR on r86169, start adding unit tests for metadata extraction.
This is just some initial tests that really only cover png's. I plan
to add more soon.

Also well I'm here, fix the svn prop on broken_exif_date.jpg from r90421.
2011-06-23 23:25:49 +00:00