materom's avatar

@dataProvider fails running Test

I have this CreditLimit test that does test an API response. This works as excpected.

/** @test */
public function get_credit_limit_data()
{

    $this->withoutExceptionHandling();
    $this->withoutMiddleware();

    $response = $this->get('api/customer/credit_limit/9yZV&WrLBiBxN@ZACBQVxcLCMc74fQ/10003');
    $response->assertStatus(200);
    $response->assertJsonStructure([
            'total_credit_limit',
            'used_credit',
            'remaining_credit',
            'used_percent',
            'remaining_percent',
        ]);
}

But when I want to use a @dataProvider, the response is empty, but the variable is correct.

namespace Tests\Feature\Api;
use Tests\TestCase;

class CreditLimitTest extends TestCase
{
    /** @test
     * @dataProvider checks
     */
    public function get_credit_limit_data(int $kunnr)
    {

        $this->withoutExceptionHandling();
        $this->withoutMiddleware();

        $response = $this->get('api/customer/credit_limit/9yZV&WrLBiBxN@ZACBQVxcLCMc74fQ/'.$kunnr);
        $response->assertStatus(200);
        $response->assertJsonStructure([
                'total_credit_limit',
                'used_credit',
                'remaining_credit',
                'used_percent',
                'remaining_percent',
            ]);
    }

    public function checks()
    {
        return [
            [10000],
            [10003],
            [10834],
        ];
    }
}

What do you think that generates this issue?

0 likes
2 replies
shez1983's avatar

and the test works if you repalce $kunnr with 10000 inside the get?

Please or to participate in this conversation.