Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fails testing nested pros #589

Open
emacaste opened this issue Mar 1, 2024 · 0 comments
Open

fails testing nested pros #589

emacaste opened this issue Mar 1, 2024 · 0 comments

Comments

@emacaste
Copy link

emacaste commented Mar 1, 2024

Hi folks, i have some problems with testing. It seems that pest can not handle nested props as documented.
Here my test.

Any ideas?

test('screenings without query sorting are sorted by last screening date desc', function () {
    $screeningDates = [
        'firstDates'  => [
            '2024-01-01 18:00:00',
            '2024-01-02 21:00:00',
            '2024-01-03 21:00:00',
        ],
        'secondDates' => [
            '2024-01-02 18:00:00',
            '2024-01-05 21:00:00',
            '2024-01-06 21:00:00',
        ],
        'thirdDates'  => [
            '2024-01-01 21:00:00',
            '2024-01-02 21:00:00',
            '2024-01-06 21:00:00',
        ]
    ];

    $screenings = [];
    foreach ($screeningDates as $var => $screeningDate) {
        $screenings[$var] = Screening::factory()->create([
            'title' => $var
        ])
            ->each(function (Screening $screening) use ($screeningDate) {
                foreach ($screeningDate as $date) {
                    $screening->dates()->save(ScreeningDate::factory()->make([
                        'date_time' => Carbon::parse($date)
                    ]));
                }
            });
    }

    $this->withoutMiddleware();
    $response = $this->get(route('admin.web.screening.index'));
    $response->assertInertia(fn(AssertableInertia $inertia) => $inertia
        ->component('Admin/Web/Screenings/Index')
        ->has('screenings', 3, fn(AssertableInertia $inertia) => $inertia
//            ->dd('title') // OK
//            ->has('title') // Unexpected properties were found in scope [screenings.0].
//                            Failed asserting that two arrays are identical.
        )
        ->where('screenings.0.title', 'firstDates') // OK
    );
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant