public function testTrimSkipNonStrings() { $data = 1234; $form = $this->getMock('Symfony\\Component\\Form\\Tests\\FormInterface'); $event = new FormEvent($form, $data); $filter = new TrimListener(); $filter->preBind($event); $this->assertSame(1234, $event->getData()); }
/** * @dataProvider codePointProvider */ public function testTrimUtf8($chars) { if (!function_exists('mb_check_encoding')) { $this->markTestSkipped('The "mb_check_encoding" function is not available'); } $data = mb_convert_encoding(pack('H*', implode('', $chars)), 'UTF-8', 'UCS-2BE'); $data = $data . "ab\ncd" . $data; $form = $this->getMock('Symfony\\Component\\Form\\Test\\FormInterface'); $event = new FormEvent($form, $data); $filter = new TrimListener(); $filter->preBind($event); $this->assertSame("ab\ncd", $event->getData(), 'TrimListener should trim character(s): ' . implode(', ', $chars)); }