Skip to content

Instantly share code, notes, and snippets.

@DominikStyp
Created May 25, 2023 09:11
Show Gist options
  • Save DominikStyp/233768b37647b69e625c7f2b80d6cda2 to your computer and use it in GitHub Desktop.
Save DominikStyp/233768b37647b69e625c7f2b80d6cda2 to your computer and use it in GitHub Desktop.
Laravel: how to check if view blade syntax is correct and section tags are properly closed (PHPUnit)
<?php
class BladeViewCorrectSyntaxTest {
/**
* @see https://stackoverflow.com/questions/38400305/phpunit-help-needed-about-risky-tests
*/
public function view_test()
{
$viewName = 'some.view';
view($viewName)->render();
$this->assertEquals(
1,
ob_get_level(),
"$viewName didn't close the output buffering, please check if the view blade sections are closed properly like @section @endsection etc."
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment