Commit 13ef5f66 authored by bojanz's avatar bojanz

Clean up PromotionForm, fix the redirect url.

parent 4108a137
......@@ -32,8 +32,6 @@ class PromotionForm extends ContentEntityForm {
* {@inheritdoc}
*/
public function form(array $form, FormStateInterface $form_state) {
/* @var \Drupal\commerce_promotion\Entity\Promotion $promotion */
$promotion = $this->entity;
$form = parent::form($form, $form_state);
$form['#tree'] = TRUE;
......@@ -46,11 +44,9 @@ class PromotionForm extends ContentEntityForm {
* {@inheritdoc}
*/
public function save(array $form, FormStateInterface $form_state) {
/* @var \Drupal\commerce_promotion\Entity\Promotion $promotion */
$promotion = $this->getEntity();
$promotion->save();
drupal_set_message($this->t('The promotion %label has been successfully saved.', ['%label' => $promotion->label()]));
$form_state->setRedirect('entity.commerce_promotion.collection', ['commerce_promotion' => $promotion->id()]);
$this->entity->save();
drupal_set_message($this->t('Saved the %label promotion.', ['%label' => $this->entity->label()]));
$form_state->setRedirect('entity.commerce_promotion.collection');
}
}
......@@ -63,7 +63,7 @@ class PromotionTest extends CommerceBrowserTestBase {
$edit['conditions[0][target_plugin_configuration][amount][number]'] = '50.00';
$this->submitForm($edit, t('Save'));
$this->assertSession()->pageTextContains("The promotion $name has been successfully saved.");
$this->assertSession()->pageTextContains("Saved the $name promotion.");
$promotion_count = $this->getSession()->getPage()->find('xpath', '//table/tbody/tr/td[text()="' . $name . '"]');
$this->assertEquals(count($promotion_count), 1, 'promotions exists in the table.');
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment