public function testVisitFormAction() { $writer = new HTMLWriter(); $label = 'l' . (string) rand(); $target = 't' . (string) rand(); $jsFormAction = FormActionBuilder::begin()->setType(FormAction::TYPE_JAVASCRIPT)->setLabel($label)->setTarget($target)->build(); // Get result and strip quotes, for easier analysis $result = $this->stripQuotes($writer->visitFormAction($jsFormAction)); $this->assertContains("onclick={$target}", $result); $this->assertContains(">{$label}</button>", $result); $submitAction = FormActionBuilder::begin()->setType(FormAction::TYPE_SUBMIT)->setLabel($label)->build(); // Get result and strip quotes, for easier analysis $result = $this->stripQuotes($writer->visitFormAction($submitAction)); $this->assertContains("<input", $result); $this->assertContains("value={$label}", $result); $ajaxSubmitAction = FormActionBuilder::begin()->setType(FormAction::TYPE_AJAX_SUBMIT)->setLabel($label)->build(); // Get result and strip quotes, for easier analysis $result = $this->stripQuotes($writer->visitFormAction($ajaxSubmitAction)); $this->assertContains("onclick=athens.ajax.submitForm(\$(this).closest(form)[0]);", $result); $this->assertContains(">{$label}</button>", $result); }