| Total Complexity | 5 |
| Total Lines | 51 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 12 | class FormTest extends \WP_UnitTestCase |
||
|
|
|||
| 13 | { |
||
| 14 | protected $fields; |
||
| 15 | |||
| 16 | public function test_condition_contains() |
||
| 17 | { |
||
| 18 | $this->assertEquals( |
||
| 19 | '<div class="glsr-form-wrap">'. |
||
| 20 | '<form class="glsr-form test-form" method="post" enctype="multipart/form-data">'. |
||
| 21 | '<div class="glsr-form-message"></div>'. |
||
| 22 | '<div data-field="submit-button">'. |
||
| 23 | '<div class="wp-block-buttons is-layout-flex">'. |
||
| 24 | '<div class="wp-block-button">'. |
||
| 25 | '<button type="submit" class="glsr-button wp-block-button__link wp-element-button" aria-busy="false" data-loading="Please wait">'. |
||
| 26 | 'Test'. |
||
| 27 | '</button>'. |
||
| 28 | '</div>'. |
||
| 29 | '</div>'. |
||
| 30 | '</div>'. |
||
| 31 | '</form>'. |
||
| 32 | '</div>', |
||
| 33 | $this->build([ |
||
| 34 | 'button_text' => 'Test', |
||
| 35 | 'button_text_loading' => 'Please wait', |
||
| 36 | 'class' => 'test-form', |
||
| 37 | ]) |
||
| 38 | ); |
||
| 39 | } |
||
| 40 | |||
| 41 | protected function build(array $args = []): string |
||
| 42 | { |
||
| 43 | $this->removeFields(); |
||
| 44 | $form = new Form($args); |
||
| 45 | $html = $form->build(); |
||
| 46 | $this->restoreFields(); |
||
| 47 | $parts = preg_split('/\R/', $html); |
||
| 48 | $parts = array_map('trim', $parts); |
||
| 49 | $html = implode('', $parts); |
||
| 50 | return $html; |
||
| 51 | } |
||
| 52 | |||
| 53 | protected function removeFields(): void |
||
| 54 | { |
||
| 55 | $this->fields = fn () => ''; |
||
| 56 | add_filter('site-reviews/form/build/fields', $this->fields, 10); |
||
| 57 | } |
||
| 58 | |||
| 59 | protected function restoreFields(): void |
||
| 63 | } |
||
| 64 | } |
||
| 65 | } |
||
| 66 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths