Skip to content

Commit

Permalink
minor #2507 [TwigComponent][Docs] add explicit string cast on string …
Browse files Browse the repository at this point in the history
…assertions (Valmonzo)

This PR was merged into the 2.x branch.

Discussion
----------

[TwigComponent][Docs] add explicit string cast on string assertions

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | no
| Issues        |  <!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead -->
| License       | MIT

Following the examples from the documentation, I realized that if we use the `TestLiveComponent::render` method in `assertStringContainsString` and if we use strict types, then it throw an error because we try to assert a `RenderedComponent` object instead of a string.

I think that explicitly adding the cast can help.

Commits
-------

1a77c94 [TwigComponent][Docs] add explicit string cast on string assertions
  • Loading branch information
Kocal committed Jan 17, 2025
2 parents f1b645e + 1a77c94 commit dc6e6e4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/TwigComponent/doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1342,7 +1342,7 @@ You can test how your component is mounted and rendered using the
data: ['foo' => 'bar'],
);

$this->assertStringContainsString('bar', $rendered);
$this->assertStringContainsString('bar', (string) $rendered);

// use the crawler
$this->assertCount(5, $rendered->crawler()->filter('ul li'));
Expand All @@ -1360,7 +1360,7 @@ You can test how your component is mounted and rendered using the
],
);

$this->assertStringContainsString('bar', $rendered);
$this->assertStringContainsString('bar', (string) $rendered);
}
}

Expand Down

0 comments on commit dc6e6e4

Please sign in to comment.