2 months ago

Laravel Testing Asserting

Posted 2 months ago by Lestah

here's the code for the test I did

public function a_super_user_can_view_a_paginated_list_of_all_discussions()
        // Arrangements
        $this->actingAs($user = $this->superAdmin);
        $discussions = factory(Discussion::class, 5)->create();

        // Actions
        $response = $this->get(route('discussions.index'));

        // Assertions
                 ->assertSeeText(trans('All Discussions'))
                 ->assertSeeText(trans('Add Discussion'))
                 // ->assertSeeTextInOrder($discussions->pluck('commentable_type')->toArray())
                 // ->assertSeeTextInOrder($discussions->pluck('user_id')->toArray())
                 // ->assertSeeTextInOrder($discussions->pluck('parent_id')->toArray())
                 // ->assertSeeTextInOrder([trans('Edit'), trans('Move to Trash')]);

and on my index.blade.php i asserted that a body $resource->body is on there

  @container(['attr' => 'grid-list-xl'])
    @layout(['attr' => 'row wrap'])
      @flex(['attr' => 'xs12'])

        @foreach ($resources as $resource)
          <p>@a($resource->body, ['url' => route('discussions.show', $resource->id)])</p>
          <p>{{ $resource->body }}</p>  =========== here it is
          {{-- <p>{{ $resource->commentable_id }}</p>
          <p>{{ $resource->commentable_type }}</p>
          <p>{{ $resource->user_id }}</p>
          <p>{{ $resource->parent_id }}</p> --}}
              @a('Edit', [
                'icon' => 'mdi mdi-pencil-outline',
                'url' => route('discussions.edit', $resource->id),
              @a('Move to Trash', [
                'icon' => 'mdi mdi-delete-outline',
                'url' => route('discussions.destroy', $resource->id),

but the error says that it's not there any idea what could have been wrong

Please sign in or create an account to participate in this conversation.