Filter collection based on tags with AND

I have a collection which I filter by tags. This works really great with the when()method.

$categories = ['Test1', 'Test2'];
$articles = collection('articles')
->when(!empty($categories), function ($child) use ($categories) {
     return $this->filter(function ($child) use ($categories) {
         return array_intersect($child->categories()->split(','), $categories);

This returns all pages with the category Test1 OR Test2. How can I get only items with both categories included?

Iā€™m just feeling really stupid :see_no_evil:.

return count(array_intersect($child->categories()->split(','), $categories)) === count($categories);

Thanks alot. That works as expected.