ApiOptionsTest: Do not use ->at()
authorBartosz Dziewoński <matma.rex@gmail.com>
Mon, 13 Nov 2017 18:42:33 +0000 (19:42 +0100)
committerBartosz Dziewoński <matma.rex@gmail.com>
Wed, 15 Nov 2017 11:04:09 +0000 (11:04 +0000)
commitf1ca6b8ca9c2dc65014bc8ae79f02158d2dc52c3
treef11a7d11b78885c703550aeda54db5aa45263fac
parent9219588de6834670ebf6b735f9230f5ef72d0bed
ApiOptionsTest: Do not use ->at()

Quoting PHPUnit docs:

  The $index parameter for the at() matcher refers to the index,
  starting at zero, in all method invocations for a given mock object.
  Exercise caution when using this matcher as it can lead to brittle
  tests which are too closely tied to specific implementation details.

Indeed these test cases would break horribly with unintuitive error
messages ("Mocked method does not exist") if anything in preferences
or API code called any additional methods on the mocked user. For
example, it relied on the caching in Preferences::getPreferences(),
which is being removed in I92390120a16448383a25e9ba2dd35a434a2f21bf.

I'm pretty sure all that matters here is that all the setOption()
calls with different arguments happen, so let's test just that.

Change-Id: I30a814151a006e5f147eebb918344049807b2b97
tests/phpunit/includes/api/ApiOptionsTest.php