diff --git a/tests/auth/provider_apache_test.php b/tests/auth/provider_apache_test.php
index 5b4c8ff9db..f09115c9d3 100644
--- a/tests/auth/provider_apache_test.php
+++ b/tests/auth/provider_apache_test.php
@@ -72,14 +72,10 @@ class phpbb_auth_provider_apache_test extends phpbb_database_test_case
 			->with('PHP_AUTH_USER',
 				\phpbb\request\request_interface::SERVER)
 			->will($this->returnValue(true));
-		$this->request->expects($this->at(1))
+		$this->request->expects($this->exactly(2))
 			->method('server')
-			->with('PHP_AUTH_USER')
-			->will($this->returnValue('foobar'));
-		$this->request->expects($this->at(2))
-			->method('server')
-			->with('PHP_AUTH_PW')
-			->will($this->returnValue('example'));
+			->withConsecutive(['PHP_AUTH_USER'], ['PHP_AUTH_PW'])
+			->will($this->onConsecutiveCalls($this->returnValue('foobar'), $this->returnValue('example')));
 
 		$expected = array(
 			'status'		=> LOGIN_SUCCESS,
@@ -104,14 +100,10 @@ class phpbb_auth_provider_apache_test extends phpbb_database_test_case
 			->with('PHP_AUTH_USER',
 				\phpbb\request\request_interface::SERVER)
 			->will($this->returnValue(true));
-		$this->request->expects($this->at(1))
+		$this->request->expects($this->exactly(2))
 			->method('server')
-			->with('PHP_AUTH_USER')
-			->will($this->returnValue('foobar'));
-		$this->request->expects($this->at(2))
-			->method('server')
-			->with('PHP_AUTH_PW')
-			->will($this->returnValue('example'));
+			->withConsecutive(['PHP_AUTH_USER'], ['PHP_AUTH_PW'])
+			->will($this->onConsecutiveCalls($this->returnValue('foobar'), $this->returnValue('example')));
 
 		$expected = array(
 			'user_id' => 1,
diff --git a/tests/dbal/db_tools_test.php b/tests/dbal/db_tools_test.php
index 0f7a37a8da..4d896f3014 100644
--- a/tests/dbal/db_tools_test.php
+++ b/tests/dbal/db_tools_test.php
@@ -356,11 +356,8 @@ class phpbb_dbal_db_tools_test extends phpbb_database_test_case
 			->will($this->returnValue(true));
 
 		// drop tables
-		$db_tools->expects($this->exactly(2))->method('sql_table_drop');
-		$db_tools->expects($this->at(1))->method('sql_table_drop')
-			->with($this->equalTo('dropped_table_1'));
-		$db_tools->expects($this->at(3))->method('sql_table_drop')
-			->with($this->equalTo('dropped_table_2'));
+		$db_tools->expects($this->exactly(2))->method('sql_table_drop')
+			->withConsecutive([$this->equalTo('dropped_table_1')], [$this->equalTo('dropped_table_2')]);
 
 		$db_tools->perform_schema_changes(array(
 			'drop_tables' => array(
@@ -384,11 +381,11 @@ class phpbb_dbal_db_tools_test extends phpbb_database_test_case
 			->will($this->returnValue(true));
 
 		// drop columns
-		$db_tools->expects($this->exactly(2))->method('sql_column_remove');
-		$db_tools->expects($this->at(1))->method('sql_column_remove')
-			->with($this->equalTo('existing_table'), $this->equalTo('dropped_column_1'));
-		$db_tools->expects($this->at(3))->method('sql_column_remove')
-			->with($this->equalTo('existing_table'), $this->equalTo('dropped_column_2'));
+		$db_tools->expects($this->exactly(2))->method('sql_column_remove')
+			->withConsecutive(
+				[$this->equalTo('existing_table'), $this->equalTo('dropped_column_1')],
+				[$this->equalTo('existing_table'), $this->equalTo('dropped_column_2')]
+			);
 
 		$db_tools->perform_schema_changes(array(
 			'drop_columns' => array(
diff --git a/tests/help/manager_test.php b/tests/help/manager_test.php
index e841a23a53..02695806b6 100644
--- a/tests/help/manager_test.php
+++ b/tests/help/manager_test.php
@@ -64,44 +64,33 @@ class phpbb_help_manager_test extends phpbb_test_case
 	 */
 	public function test_add_block($block_name, $switch, $questions, $switch_expected)
 	{
-		$this->language->expects($this->at(0))
-			->method('lang')
-			->with($block_name)
-			->willReturn(strtoupper($block_name));
-		$lang_call_count = 1;
+		$question_ary = $question_ary_upper = $template_call_args = [];
 		foreach ($questions as $question => $answer)
 		{
-			$this->language->expects($this->at($lang_call_count))
-				->method('lang')
-				->with($question)
-				->willReturn(strtoupper($question));
-			$lang_call_count++;
-
-			$this->language->expects($this->at($lang_call_count))
-				->method('lang')
-				->with($answer)
-				->willReturn(strtoupper($answer));
-			$lang_call_count++;
-		}
-
-		$this->template->expects($this->at(0))
-			->method('assign_block_vars')
-			->with('faq_block', array(
-				'BLOCK_TITLE' => strtoupper($block_name),
-				'SWITCH_COLUMN' => $switch_expected,
-			));
-		$template_call_count = 1;
-		foreach ($questions as $question => $answer)
-		{
-			$this->template->expects($this->at($template_call_count))
-				->method('assign_block_vars')
-				->with('faq_block.faq_row', array(
+			$question_ary = array_merge($question_ary, [[$question], [$answer]]);
+			$question_ary_upper = array_merge($question_ary_upper, [strtoupper($question), strtoupper($answer)]);
+			$template_call_args = array_merge($template_call_args, [['faq_block.faq_row', [
 					'FAQ_QUESTION' => strtoupper($question),
 					'FAQ_ANSWER' => strtoupper($answer),
-				));
-			$template_call_count++;
+				]
+			]]);
 		}
 
+		$this->language->expects($this->exactly(count($questions)*2 + 1))
+			->method('lang')
+			->withConsecutive([$block_name], ...$question_ary)
+			->will($this->onConsecutiveCalls(strtoupper($block_name), ...$question_ary_upper));
+
+		$this->template->expects($this->exactly(count($questions) + 1))
+			->method('assign_block_vars')
+			->withConsecutive(
+				['faq_block', [
+					'BLOCK_TITLE' => strtoupper($block_name),
+					'SWITCH_COLUMN' => $switch_expected,
+				]],
+				...$template_call_args
+			);
+
 		$this->manager->add_block($block_name, $switch, $questions);
 
 		$this->assertEquals($switch_expected, $this->manager->switched_column());
@@ -110,8 +99,8 @@ class phpbb_help_manager_test extends phpbb_test_case
 	public function add_question_data()
 	{
 		return array(
-			array('abc', false, false),
-			array('def', true, true),
+			array('question1', 'answer1'),
+			array('question2', 'answer2'),
 		);
 	}
 
@@ -123,14 +112,13 @@ class phpbb_help_manager_test extends phpbb_test_case
 	 */
 	public function test_add_question($question, $answer)
 	{
-		$this->language->expects($this->at(0))
+		$this->language->expects($this->exactly(2))
 			->method('lang')
-			->with($question)
-			->willReturn(strtoupper($question));
-		$this->language->expects($this->at(1))
-			->method('lang')
-			->with($answer)
-			->willReturn(strtoupper($answer));
+			->withConsecutive(
+				[$question],
+				[$answer]
+			)
+			->will($this->onConsecutiveCalls(strtoupper($question), strtoupper($answer)));
 
 		$this->template->expects($this->once())
 			->method('assign_block_vars')
@@ -144,41 +132,33 @@ class phpbb_help_manager_test extends phpbb_test_case
 
 	public function test_add_block_double_switch()
 	{
-		$block_name = 'abc';
-		$switch_expected = true;
+		$block_name = ['abc', 'def'];
+		$switch_expected = [true, false];
 
-		$this->language->expects($this->at(0))
+		$this->language->expects($this->exactly(2))
 			->method('lang')
-			->with($block_name)
-			->willReturn(strtoupper($block_name));
+			->withConsecutive([$block_name[0]], [$block_name[1]])
+			->will($this->onConsecutiveCalls(strtoupper($block_name[0]), strtoupper($block_name[1])));
 
-		$this->template->expects($this->at(0))
+		$this->template->expects($this->exactly(2))
 			->method('assign_block_vars')
-			->with('faq_block', array(
-				'BLOCK_TITLE' => strtoupper($block_name),
-				'SWITCH_COLUMN' => $switch_expected,
-			));
+			->withConsecutive(
+				['faq_block', [
+					'BLOCK_TITLE' => strtoupper($block_name[0]),
+					'SWITCH_COLUMN' => $switch_expected[0],
+				]],
+				['faq_block', [
+					'BLOCK_TITLE' => strtoupper($block_name[1]),
+					'SWITCH_COLUMN' => $switch_expected[1],
+				]]
+		
+			);
 
-		$this->manager->add_block($block_name, true);
+		$this->manager->add_block($block_name[0], true);
 		$this->assertTrue($this->manager->switched_column());
 
 		// Add a second block with switch
-		$block_name = 'def';
-		$switch_expected = false;
-
-		$this->language->expects($this->at(0))
-			->method('lang')
-			->with($block_name)
-			->willReturn(strtoupper($block_name));
-
-		$this->template->expects($this->at(0))
-			->method('assign_block_vars')
-			->with('faq_block', array(
-				'BLOCK_TITLE' => strtoupper($block_name),
-				'SWITCH_COLUMN' => $switch_expected,
-			));
-
-		$this->manager->add_block($block_name, true);
+		$this->manager->add_block($block_name[1], true);
 		$this->assertTrue($this->manager->switched_column());
 	}
 }
diff --git a/tests/text_formatter/s9e/factory_test.php b/tests/text_formatter/s9e/factory_test.php
index f57bbdd6dc..d9ba86b05d 100644
--- a/tests/text_formatter/s9e/factory_test.php
+++ b/tests/text_formatter/s9e/factory_test.php
@@ -288,22 +288,13 @@ class phpbb_textformatter_s9e_factory_test extends phpbb_database_test_case
 	{
 		$this->dispatcher = $this->createMock('phpbb\\event\\dispatcher_interface');
 		$this->dispatcher
-			->expects($this->at(0))
+			->expects($this->exactly(2))
 			->method('trigger_event')
-			->with(
-				'core.text_formatter_s9e_configure_before',
-				$this->callback(array($this, 'configure_event_callback'))
+			->withConsecutive(
+				['core.text_formatter_s9e_configure_before', $this->callback(array($this, 'configure_event_callback'))],
+				['core.text_formatter_s9e_configure_after', $this->callback(array($this, 'configure_event_callback'))]
 			)
 			->will($this->returnArgument(1));
-		$this->dispatcher
-			->expects($this->at(1))
-			->method('trigger_event')
-			->with(
-				'core.text_formatter_s9e_configure_after',
-				$this->callback(array($this, 'configure_event_callback'))
-			)
-			->will($this->returnArgument(1));
-
 		$this->get_factory()->get_configurator();
 	}
 
diff --git a/tests/text_formatter/s9e/parser_test.php b/tests/text_formatter/s9e/parser_test.php
index e10ebd29ee..ef9a1184ee 100644
--- a/tests/text_formatter/s9e/parser_test.php
+++ b/tests/text_formatter/s9e/parser_test.php
@@ -101,15 +101,19 @@ class phpbb_textformatter_s9e_parser_test extends phpbb_test_case
 	public function test_options($adapter_method, $adapter_arg, $concrete_method, $concrete_arg)
 	{
 		$mock = $this->getMockBuilder('s9e\\TextFormatter\\Parser')
-		             ->setMethods(array($concrete_method))
+		             ->setMethods([$concrete_method])
 		             ->disableOriginalConstructor()
 		             ->getMock();
-		foreach ((array) $concrete_arg as $i => $concrete_arg)
-		{
-			$mock->expects($this->at($i))
-			     ->method($concrete_method)
-			     ->with($concrete_arg);
-		}
+
+		$concrete_args = (array) $concrete_arg;
+		array_walk($concrete_args, function(&$value)
+			{
+				$value = (array) $value;
+			}
+		);
+		$mock->expects($this->exactly(count($concrete_args)))
+			->method($concrete_method)
+			->withConsecutive(...$concrete_args);
 
 		$cache = new phpbb_mock_cache;
 		$cache->put('_foo_parser', $mock);
@@ -141,11 +145,11 @@ class phpbb_textformatter_s9e_parser_test extends phpbb_test_case
 			),
 			array(
 				'disable_magic_url', null,
-				'disablePlugin',     array('Autoemail', 'Autolink')
+				'disablePlugin',     ['Autoemail', 'Autolink']
 			),
 			array(
 				'disable_smilies', null,
-				'disablePlugin',   'Emoticons'
+				'disablePlugin',   ['Emoticons', 'Emoji']
 			),
 			array(
 				'enable_bbcode', 'url',
@@ -157,11 +161,11 @@ class phpbb_textformatter_s9e_parser_test extends phpbb_test_case
 			),
 			array(
 				'enable_magic_url', null,
-				'enablePlugin',     array('Autoemail', 'Autolink')
+				'enablePlugin',     ['Autoemail', 'Autolink']
 			),
 			array(
 				'enable_smilies', null,
-				'enablePlugin',   'Emoticons'
+				'enablePlugin',   ['Emoticons', 'Emoji']
 			)
 		);
 	}
@@ -207,22 +211,6 @@ class phpbb_textformatter_s9e_parser_test extends phpbb_test_case
 			->expects($this->any())
 			->method('trigger_event')
 			->will($this->returnArgument(1));
-		$dispatcher
-			->expects($this->at(1))
-			->method('trigger_event')
-			->with(
-				'core.text_formatter_s9e_parse_before',
-				$this->callback(array($this, 'parse_before_event_callback'))
-			)
-			->will($this->returnArgument(1));
-		$dispatcher
-			->expects($this->at(2))
-			->method('trigger_event')
-			->with(
-				'core.text_formatter_s9e_parse_after',
-				$this->callback(array($this, 'parse_after_event_callback'))
-			)
-			->will($this->returnArgument(1));
 
 		$parser = new \phpbb\textformatter\s9e\parser(
 			$container->get('cache.driver'),
@@ -230,6 +218,16 @@ class phpbb_textformatter_s9e_parser_test extends phpbb_test_case
 			$container->get('text_formatter.s9e.factory'),
 			$dispatcher
 		);
+
+		$dispatcher
+			->expects($this->exactly(2))
+			->method('trigger_event')
+			->withConsecutive(
+				['core.text_formatter_s9e_parse_before', $this->callback(array($this, 'parse_before_event_callback'))],
+				['core.text_formatter_s9e_parse_after', $this->callback(array($this, 'parse_after_event_callback'))]
+			)
+			->will($this->returnArgument(1));
+
 		$parser->parse('...');
 	}
 
diff --git a/tests/text_formatter/s9e/renderer_test.php b/tests/text_formatter/s9e/renderer_test.php
index f34c656359..69075ebaca 100644
--- a/tests/text_formatter/s9e/renderer_test.php
+++ b/tests/text_formatter/s9e/renderer_test.php
@@ -438,22 +438,6 @@ class phpbb_textformatter_s9e_renderer_test extends phpbb_test_case
 			->expects($this->any())
 			->method('trigger_event')
 			->will($this->returnArgument(1));
-		$dispatcher
-			->expects($this->at(1))
-			->method('trigger_event')
-			->with(
-				'core.text_formatter_s9e_render_before',
-				$this->callback(array($this, 'render_before_event_callback'))
-			)
-			->will($this->returnArgument(1));
-		$dispatcher
-			->expects($this->at(2))
-			->method('trigger_event')
-			->with(
-				'core.text_formatter_s9e_render_after',
-				$this->callback(array($this, 'render_after_event_callback'))
-			)
-			->will($this->returnArgument(1));
 
 		$renderer = new \phpbb\textformatter\s9e\renderer(
 			$container->get('cache.driver'),
@@ -462,6 +446,16 @@ class phpbb_textformatter_s9e_renderer_test extends phpbb_test_case
 			$container->get('text_formatter.s9e.factory'),
 			$dispatcher
 		);
+
+		$dispatcher
+			->expects($this->exactly(2))
+			->method('trigger_event')
+			->withConsecutive(
+				['core.text_formatter_s9e_render_before', $this->callback(array($this, 'render_before_event_callback'))],
+				['core.text_formatter_s9e_render_after', $this->callback(array($this, 'render_after_event_callback'))]
+			)
+			->will($this->returnArgument(1));
+
 		$renderer->render('<t>...</t>');
 	}