Merge pull request #1432 from jygaulier/PHRAS-504_CRLF-in-proposals

PHRAS-504
This commit is contained in:
Benoît Burnichon
2015-07-16 11:11:10 +02:00
12 changed files with 133 additions and 105 deletions

View File

@@ -4,7 +4,6 @@ namespace Alchemy\Tests\Phrasea\Form\Login;
use Alchemy\Phrasea\Form\Login\PhraseaRegisterForm;;
use Alchemy\Tests\Phrasea\Form\FormTestCase;
use Alchemy\Phrasea\Utilities\String\Camelizer;
/**
* @group functional
@@ -27,7 +26,7 @@ class PhraseaRegisterFormTest extends FormTestCase
]
];
return new PhraseaRegisterForm(self::$DI['app'], $available, $params, new Camelizer());
return new PhraseaRegisterForm(self::$DI['app'], $available, $params);
}
public function testFormDoesRegisterValidFields()
@@ -63,7 +62,7 @@ class PhraseaRegisterFormTest extends FormTestCase
$expected[] = 'collections';
}
$form = new PhraseaRegisterForm(self::$DI['app'], $available, $params, new Camelizer());
$form = new PhraseaRegisterForm(self::$DI['app'], $available, $params);
foreach (array_keys(self::$DI['app']->form($form)->createView()->vars['form']->children) as $name) {
$this->assertContains($name, $expected);
@@ -99,7 +98,7 @@ class PhraseaRegisterFormTest extends FormTestCase
$expected[] = 'collections';
}
$form = new PhraseaRegisterForm(self::$DI['app'], $available, $params, new Camelizer());
$form = new PhraseaRegisterForm(self::$DI['app'], $available, $params);
foreach (array_keys(self::$DI['app']->form($form)->createView()->vars['form']->children) as $name) {
$this->assertContains($name, $expected);

View File

@@ -1,34 +0,0 @@
<?php
namespace Alchemy\Tests\Phrasea\Utilities\String;
use Alchemy\Phrasea\Utilities\String\Camelizer;
/**
* @group functional
* @group legacy
*/
class CamelizerTest extends \PhraseanetTestCase
{
/**
* @dataProvider provideStrings
* @covers Alchemy\Phrasea\Utilities\String\Camelizer::camelize
*/
public function testCamelize($string, $separator, $expected, $pascalize)
{
$camelizer = new Camelizer();
$result = $camelizer->camelize($string, $separator, $pascalize);
$this->assertEquals($expected, $result);
}
public function provideStrings()
{
return [
['string-test', '-', 'stringTest', false],
['string test', ' ', 'stringTest', false],
['string_test', '_', 'stringTest', false],
['string#test', '#', 'StringTest', true],
];
}
}

View File

@@ -0,0 +1,55 @@
<?php
namespace Alchemy\Tests\Phrasea\Utilities\String;
use Alchemy\Phrasea\Utilities\StringHelper;
/**
* @group unit
*/
class StringHelperTest extends \PhraseanetTestCase
{
/**
* @dataProvider provideStringsForCamelize
* @covers Alchemy\Phrasea\Utilities\StringHelper::camelize
*/
public function testCamelize($string, $separator, $expected, $pascalize)
{
$result = StringHelper::camelize($string, $separator, $pascalize);
$this->assertEquals($expected, $result);
}
public function provideStringsForCamelize()
{
return [
['string-test', '-', 'stringTest', false],
['string test', ' ', 'stringTest', false],
['string_test', '_', 'stringTest', false],
['string#test', '#', 'StringTest', true],
];
}
/**
* @dataProvider provideStringsForCrLfNormalize
* @covers Alchemy\Phrasea\Utilities\StringHelper::crlfNormalize
*/
public function testCrLfNormalize($string, $expected)
{
$result = StringHelper::crlfNormalize($string);
$this->assertEquals($expected, $result);
}
public function provideStringsForCrLfNormalize()
{
return [
["ABC\rDEF", "ABC\nDEF"],
["ABC\nDEF", "ABC\nDEF"],
["ABC\r\nDEF", "ABC\nDEF"],
["ABC\n\rDEF", "ABC\n\nDEF"],
];
}
}