https://bugzilla.wikimedia.org/show_bug.cgi?id=41491

Brad Jorsch <[email protected]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |[email protected]

--- Comment #10 from Brad Jorsch <[email protected]> ---
(In reply to comment #8)
> > core/tests/phpunit/includes/libs/GenericArrayObjectTest.php:          try {
> > $list->offsetUnset( 'sdfsedtgsrdysftu' ); } catch ( \Exception $exception 
> > ){}
> 
> Perfectly legit code to test if an exception that should be thrown is
> actually
> thrown. We have such code at multiple places in Wikibase and no one has a
> problem with it there either.

The problem with that test is that it checks for *any* exception to be thrown.
It doesn't check whether the exception is the right exception.

What you end up catching in this particular case is the exception for the
warning "Undefined index:  sdfsedtgsrdysftu". Which stops the unit test there,
so you never find out that PHP's documentation for ArrayObject::offsetGet is
incorrect (at least in php 5.2.6 and 5.4.4), because the method actually
returns null rather than false:

  $ php -r '$a=new ArrayObject; var_dump( @$a->offsetGet("foobar") );'
  NULL

so the implementation of offsetUnset in includes/site/SiteArray.php doesn't
work right. Never mind that it should probably be using offsetExists instead of
offsetGet anyway.

Although the biggest question here is why does Niklas's installation of phpunit
not respect the convertErrorsToExceptions="true" setting (and related settings)
in MediaWiki's suite.xml?

-- 
You are receiving this mail because:
You are the assignee for the bug.
You are watching all bug changes.
_______________________________________________
Wikibugs-l mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikibugs-l

Reply via email to