InteractsWithViewsTest.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. namespace Illuminate\Tests\Foundation\Bootstrap\Testing\Concerns;
  3. use Illuminate\Foundation\Testing\Concerns\InteractsWithViews;
  4. use Illuminate\View\Component;
  5. use Orchestra\Testbench\TestCase;
  6. class InteractsWithViewsTest extends TestCase
  7. {
  8. use InteractsWithViews;
  9. public function testBladeCorrectlyRendersString()
  10. {
  11. $string = (string) $this->blade('@if(true)test @endif');
  12. $this->assertEquals('test ', $string);
  13. }
  14. public function testComponentCanAccessPublicProperties()
  15. {
  16. $exampleComponent = new class extends Component
  17. {
  18. public $foo = 'bar';
  19. public function speak()
  20. {
  21. return 'hello';
  22. }
  23. public function render()
  24. {
  25. return 'rendered content';
  26. }
  27. };
  28. $component = $this->component(get_class($exampleComponent));
  29. $this->assertEquals('bar', $component->foo);
  30. $this->assertEquals('hello', $component->speak());
  31. $component->assertSee('content');
  32. }
  33. }