You are here

public function AdjustmentTest::invalidDefinitionProvider in Commerce Core 8.2

Invalid constructor definitions.

Return value

array The definitions.

File

modules/order/tests/src/Kernel/AdjustmentTest.php, line 40

Class

AdjustmentTest
@coversDefaultClass \Drupal\commerce_order\Adjustment @group commerce

Namespace

Drupal\Tests\commerce_order\Kernel

Code

public function invalidDefinitionProvider() {
  return [
    [
      [],
      'Missing required property type',
    ],
    [
      [
        'type' => 'custom',
      ],
      'Missing required property label',
    ],
    [
      [
        'type' => 'custom',
        'label' => 'Test',
      ],
      'Missing required property amount',
    ],
    [
      [
        'type' => 'custom',
        'label' => 'Test',
        'amount' => '10 USD',
      ],
      sprintf('Property "amount" should be an instance of %s.', Price::class),
    ],
    [
      [
        'type' => 'foo',
        'label' => 'Foo',
        'amount' => new Price('1.00', 'USD'),
      ],
      'foo is an invalid adjustment type.',
    ],
    [
      [
        'type' => 'custom',
        'label' => 'Foo',
        'amount' => new Price('1.00', 'USD'),
        'percentage' => 0.1,
      ],
      'The provided percentage "0.1" must be a string, not a float.',
    ],
    [
      [
        'type' => 'custom',
        'label' => 'Foo',
        'amount' => new Price('1.00', 'USD'),
        'percentage' => 'INVALID',
      ],
      'The provided percentage "INVALID" is not a numeric value.',
    ],
  ];
}