Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ポイントの最大長チェックの追加 #5739

Merged
merged 3 commits into from
Sep 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/Eccube/Form/Type/Admin/CustomerType.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,10 @@ public function buildForm(FormBuilderInterface $builder, array $options)
[
'required' => false,
'constraints' => [
new Assert\Regex([
'pattern' => "/^\d+$/u",
'message' => 'form_error.numeric_only',
]),
new Assert\NotBlank(),
new Assert\Range([
'min' => "-".$this->eccubeConfig['eccube_price_max'],
'max' => $this->eccubeConfig['eccube_price_max']])
],
]
)
Expand Down
4 changes: 4 additions & 0 deletions src/Eccube/Form/Type/Admin/OrderType.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,10 @@ public function buildForm(FormBuilderInterface $builder, array $options)
'pattern' => "/^\d+$/u",
'message' => 'form_error.numeric_only',
]),
new Assert\Range([
'min' => 0,
'max' => $this->eccubeConfig['eccube_price_max']
]),
],
])
->add('note', TextareaType::class, [
Expand Down
42 changes: 42 additions & 0 deletions tests/Eccube/Tests/Form/Type/Admin/CustomerTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class CustomerTypeTest extends \Eccube\Tests\Form\Type\AbstractTypeTestCase
],
'status' => 1,
'note' => 'note',
'point' => '0',
];

protected function setUp(): void
Expand Down Expand Up @@ -284,4 +285,45 @@ public function testInvalidNoteBlank()
$this->form->submit($this->formData);
$this->assertTrue($this->form->isValid());
}


public function testInvalidPointPlus()
{
$this->formData['point'] = '123';

$this->form->submit($this->formData);
$this->assertTrue($this->form->isValid());
}

public function testInvalidPointMinus()
{
$this->formData['point'] = '-123';

$this->form->submit($this->formData);
$this->assertTrue($this->form->isValid());
}

public function testInvalidPointBlank()
{
$this->formData['point'] = '';

$this->form->submit($this->formData);
$this->assertFalse($this->form->isValid());
}

public function testInvalidPointMin()
{
$this->formData['point'] = '-1234567890123';

$this->form->submit($this->formData);
$this->assertFalse($this->form->isValid());
}

public function testInvalidPointMax()
{
$this->formData['point'] = '1234567890123';

$this->form->submit($this->formData);
$this->assertFalse($this->form->isValid());
}
}
17 changes: 17 additions & 0 deletions tests/Eccube/Tests/Form/Type/Admin/OrderTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class OrderTypeTest extends \Eccube\Tests\Form\Type\AbstractTypeTestCase
'phone_number' => '012-345-6789',
'email' => 'default@example.com',
'discount' => '1',
'use_point' => '',
'delivery_fee_total' => '1',
'charge' => '1',
'Payment' => '1', // dtb_payment?
Expand Down Expand Up @@ -176,4 +177,20 @@ public function testInvalidPostalCodeToLong()
$this->form->submit($this->formData);
$this->assertFalse($this->form['postal_code']->isValid());
}


public function testInValidUsePointHasMinus()
{
$this->formData['use_point'] = '-12345';

$this->form->submit($this->formData);
$this->assertFalse($this->form['use_point']->isValid());
}

public function testInvalidUsePointToLong()
{
$this->formData['use_point'] = '1234567890123';
$this->form->submit($this->formData);
$this->assertFalse($this->form['use_point']->isValid());
}
}