I upgraded the website from magento 2.3.6-p1 to magento 2.4.5-p1 , got the following error, when running PHP unite test for my custom module.

Error: Call to undefined method ABC\Product\Test\Unit\ViewModel\ProductGridVariations\FinderTest::assertInternalType()

Error: Call to undefined method ABC\Product\Test\Unit\Plugin\Search\AddSearchTermToCategoryPageTest::assertArraySubset() Please provide the solution

1 Answer 1


The errors you are encountering indicate that the test methods assertInternalType() and assertArraySubset() are undefined. These methods were deprecated in PHPUnit 9 and removed in PHPUnit 10.

To resolve this issue, you should update your test code to use the replacement methods:

assertIs*() methods should be used in place of assertInternalType(). For example, assertIsArray() can be used to check if a variable is an array. assertArrayHasKey() should be used in place of assertArraySubset(). For example, assertArrayHasKey('key', $array) can be used to check if an array has a specific key. Here's an example of how you could update your tests:

// Before
$this->assertInternalType('array', $myArray);
$this->assertArraySubset(['foo' => 'bar'], $myArray);

// After
$this->assertArrayHasKey('foo', $myArray);
$this->assertEquals('bar', $myArray['foo']);

Note that the assertArraySubset() method was replaced with assertArrayHasKey() and assertEquals() to achieve the same functionality.

Once you have updated your test methods, you should rerun your unit tests to ensure they pass without error.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.