Skip to content

Commit

Permalink
deprecate some old test helper stuff. Replaced by Mockery
Browse files Browse the repository at this point in the history
  • Loading branch information
Glutamat42 committed Nov 28, 2023
1 parent 1b683b1 commit ce3f764
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
8 changes: 7 additions & 1 deletion tests/external/deprecated_mocks.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

/** This file contains mocks from old mocking approaches of static stuff.
* Don't use them anymore in new tests. Use Mockito instead.
* Don't use them anymore in new tests. Use Mockery instead.
*/

namespace local_adler\external;
Expand All @@ -11,13 +11,19 @@

require_once(__DIR__ . '/generic_mocks.php');

/**
* @deprecated use Mockery instead
*/
class score_get_element_scores_mock extends score_get_element_scores {
use external_api_validate_context_trait;

protected static string $adler_score_helpers = adler_score_helpers_mock::class;
protected static string $context_module = context_module_mock::class;
}

/**
* @deprecated use Mockery instead
*/
class mock_score_primitive_learning_element extends score_primitive_learning_element {
private static $index = 0;
private static $data = array();
Expand Down
8 changes: 7 additions & 1 deletion tests/external/generic_mocks.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

/** This file contains mocks from old mocking approaches of static stuff.
* Don't use them anymore in new tests. Use Mockito instead.
* Don't use them anymore in new tests. Use Mockery instead.
*/

namespace local_adler\external;
Expand All @@ -11,6 +11,9 @@

use local_adler\lib\static_mock_utilities_trait;

/**
* @deprecated use Mockery instead
*/
trait external_api_validate_context_trait {
use static_mock_utilities_trait;

Expand All @@ -19,6 +22,9 @@ public static function validate_context($context) {
}
}

/**
* @deprecated use Mockery instead
*/
class context_module_mock {
use static_mock_utilities_trait;

Expand Down
2 changes: 1 addition & 1 deletion tests/lib/adler_testcase.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ abstract class local_adler_testcase extends advanced_testcase {

abstract class local_adler_externallib_testcase extends externallib_advanced_testcase {
use general_testcase_adjustments {
setUp as protected setUpTrait;
general_testcase_adjustments::setUp as protected setUpTrait;
}

public function setUp(): void {
Expand Down
2 changes: 2 additions & 0 deletions tests/lib/static_mock_framework.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

/**
* calls, returns and exceptions are arrays, the used index corresponds to the call index. 1st func call uses index 0, 2nd func call uses index 1, ...
*
* @deprecated use Mockery instead
*/
trait static_mock_utilities_trait {
private static array $calls = array();
Expand Down

0 comments on commit ce3f764

Please sign in to comment.