Passed
Push — 8.x-2.x ( f62cf7...d9f9fd )
by Frédéric G.
07:55
created

FormStateValueResolverTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 28
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testOptionnalExtraArgumentResolver() 0 7 1
A testFormStateArgumentResolver() 0 7 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Drupal\Tests\mongodb_watchdog\Unit;
6
7
use Drupal\Core\Form\FormState;
0 ignored issues
show
Bug introduced by
The type Drupal\Core\Form\FormState was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
use Drupal\Core\Form\FormStateInterface;
0 ignored issues
show
Bug introduced by
The type Drupal\Core\Form\FormStateInterface was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
9
use Drupal\mongodb_watchdog\Controller\ArgumentResolver\FormStateValueResolver;
10
use Drupal\Tests\UnitTestCase;
0 ignored issues
show
Bug introduced by
The type Drupal\Tests\UnitTestCase was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
11
use Symfony\Component\HttpFoundation\Request;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\HttpFoundation\Request was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
12
use Symfony\Component\HttpKernel\ControllerMetadata\ArgumentMetadata;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\HttpKe...tadata\ArgumentMetadata was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
13
14
/**
15
 * Test the FormStateValueResolver mechanisms.
16
 *
17
 * @coversDefaultClass \Drupal\mongodb_watchdog\Controller\ArgumentResolver\FormStateValueResolver
18
 *
19
 * @group mongodb
20
 */
21
class FormStateValueResolverTest extends UnitTestCase {
22
23
  /**
24
   * Test formState argument resolution.
25
   *
26
   * @covers ::supports
27
   */
28
  public function testFormStateArgumentResolver() {
29
    $resolver = new FormStateValueResolver();
30
    $request = new Request();
31
    $request->attributes->add([FormStateValueResolver::NAME_LEGACY => new FormState()]);
32
    $argument = new ArgumentMetadata('formState', FormStateInterface::class, FALSE, FALSE, NULL, FALSE);
33
34
    $this->assertEquals(TRUE, $resolver->supports($request, $argument));
35
  }
36
37
  /**
38
   * Test extra optionnal argument resolution.
39
   *
40
   * @covers ::supports
41
   */
42
  public function testOptionnalExtraArgumentResolver() {
43
    $resolver = new FormStateValueResolver();
44
    $request = new Request();
45
    $request->attributes->add([FormStateValueResolver::NAME_LEGACY => new FormState()]);
46
    $argument = new ArgumentMetadata('extra', NULL, FALSE, TRUE, '', TRUE);
47
48
    $this->assertEquals(FALSE, $resolver->supports($request, $argument));
49
  }
50
51
}
52