I'm getting a JSON structure from an API and need to check, whether the successfull response has two specific attributes with specific values.

Key problems:

  1. I cannot compare the whole object, as there are some properties, which may vary with each request
  2. I cannot write two tests (for each attribute), because it can be considered as successful response only when both attributes matches the right values.

Example successful response:

{
    'success': true,
    'user_ip': '212.20.30.40',
    'id': '7629428643'
}

Dirty solution would be

<?php
public function testAddAccount() {
    $response = $this->api->addAccount( '7629428643' );

    $this->assertTrue(
        $response->success === TRUE &&
        $response->id === '7629428643'
    );
}

But I think there must be better and cleaner solution, is there?

Edit
Report