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

[8.x] Testing: Access component properties from the return value of $this->component() #38396

Merged
merged 5 commits into from
Aug 18, 2021

Conversation

yob-yob
Copy link
Contributor

@yob-yob yob-yob commented Aug 16, 2021

The benefits for this pull-request would be that it's possible to access component attributes when using
$this->component() in your test

Example:

$table = $this->component(Table::class, [ 'data' => ['foo','bar','baz','quz'] ]);

$string = $table->concatenated_data;

$this->assertEquals( 'foobarbazquz', $string );

It's not going to break any existing features because It's still possible to use the assertions from TestView::class since TestComponent::class it extends to that class...

I know that it's possible to use $this->app->make($componentClass, $data); to instantiate and access properties from a component but it does not have the assertions that $this->component() have....
if you want to access the component properties and use the assertions you need to do both...
also $this->app->make($componentClass, $data); is not documented.

I was looking to the test for the TestView::class but I didn't found any so I just added it into InteractsWithViewsTest

It's my first contribution, and I'm open to constructive criticism.

@driesvints
Copy link
Member

Hi, I merged #38398 into 8.x to get the test suite passing again. I've put your PR in draft. Please rebase your PR against 8.x to make the tests of this PR pass. After you've done that and tests pass, mark this PR as ready for review. Thanks.

@driesvints driesvints marked this pull request as draft August 16, 2021 10:27
@yob-yob
Copy link
Contributor Author

yob-yob commented Aug 17, 2021

So I need to support lower versions of php8.0 😅 My Bad... will update the code

@yob-yob
Copy link
Contributor Author

yob-yob commented Aug 17, 2021

@driesvints just a question... before I touch anything else... the errors are showing that tests are failing... but on test that this pull-request has not even touched... is this normal? and should I modify and fix those test files even thou It's not concerned with my pull-request in the first place?

I also checked...there's a commit from 2 days ago with a comment of "Apply Fixed from Style-CI"

or is there something wrong here that I'm not catching-up?

@yob-yob
Copy link
Contributor Author

yob-yob commented Aug 17, 2021

@driesvints sorry about that... I just needed to fetch from upstream... I forked a commit that has a failing test... and forgot to fetch from upstream before making the request...

I read about the Contribution Guide.. and it says that I shouldn't worry about StyleCI Errors since it would automatically fix styling

@driesvints driesvints marked this pull request as ready for review August 17, 2021 09:28
@GrahamCampbell
Copy link
Member

I read about the Contribution Guide.. and it says that I shouldn't worry about StyleCI Errors since it would automatically fix styling

Yes, it will. When the PR is merged, the fixes will be applied.

@taylorotwell taylorotwell merged commit 1a37f3d into laravel:8.x Aug 18, 2021
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

Successfully merging this pull request may close these issues.

4 participants