shouldReceive('card->last_digits')->andReturn('1234'); $paymentSource->shouldReceive('card->brand')->andReturn('VISA'); $token = Mockery::mock(PaymentToken::class); $source = (object)[ 'card' => (object)[ 'last_digits' => '1234', 'brand' => 'VISA', ], ]; $token->shouldReceive('source')->andReturn($source); $tokens = [$token]; $factory = Mockery::mock(PaymentTokenFactory::class); $endpoint = Mockery::mock(PaymentTokenEndpoint::class); $testee = new PaymentTokenRepository($factory, $endpoint); self::assertTrue($testee->tokens_contains_payment_source($tokens, $paymentSource)); } }