public function checkBackground($validator, $values)
 {
     if ('fit' == $values['method'] && !dmString::hexColor($values['background'])) {
         throw new sfValidatorErrorSchema($validator, array('background' => new sfValidatorError($validator, 'This is not a valid hexadecimal color')));
     }
     return $values;
 }
Exemplo n.º 2
0
 public function background($v)
 {
     if (!($hexColor = dmString::hexColor($v))) {
         throw new dmException(sprintf('%s is not a valid hexadecimal color', $v));
     }
     return $this->setOption('background', $hexColor);
 }
Exemplo n.º 3
0
require_once dirname(__FILE__) . '/helper/dmUnitTestHelper.php';
$helper = new dmUnitTestHelper();
$helper->boot();
$t = new lime_test(59);
$t->comment('iconv available : ' . function_exists('iconv'));
$t->is(dmString::slugify(" phrâse avèc dés accënts "), $expected = "phrase-avec-des-accents", $expected);
$t->is(dmString::slugify("fonctionnalité"), $expected = "fonctionnalite", $expected);
$t->is(dmString::urlize(" phrâse avèc dés accënts "), $expected = "phrase-avec-des-accents", $expected);
$t->is(dmString::urlize("fonctionnalité"), $expected = "fonctionnalite", $expected);
$t->is(dmString::slugify("an-url.htm"), $expected = "an-url-htm", $expected);
$t->is(dmString::slugify("an-url.html"), $expected = "an-url-html", $expected);
$t->is(dmString::urlize("an-url.htm"), $expected = "an-url.htm", $expected);
$t->is(dmString::urlize("an-url.html"), $expected = "an-url.html", $expected);
$hexTests = array(array('ffffff', 'FFFFFF'), array('#ffffff', 'FFFFFF'), array('#0Cd4fe', '0CD4FE'), array('aaa', null), array('fffff', null), array('fffxff', null));
foreach ($hexTests as $hexTest) {
    $t->is(dmString::hexColor($hexTest[0]), $hexTest[1], 'dmString::hexColor(' . $hexTest[0] . ') = ' . (null === $hexTest[1] ? 'NULL' : $hexTest[1]));
}
$t->is(dmString::lcfirst('TEST'), 'tEST', 'lcfirst test');
$t->is(dmString::lcfirst('another test'), 'another test', 'lcfirst test');
// ::retrieveOptFromString()
$t->diag('::retrieveOptFromString()');
// Empty string
$t->diag('  ::retrieveOptFromString() empty string');
$string = '';
$opt = array('aa' => 'bb');
$originalOpt = $opt;
$t->is_deeply(dmString::retrieveOptFromString($string, $opt), null, '::retrieveOptFromString() with an empty string returns null');
$t->is_deeply($opt, $originalOpt, '::retrieveOptFromString() with an empty string does not modify opt');
$t->is_deeply($string, '', '::retrieveOptFromString() with an empty string does not modify string');
// Non-empty string
$t->diag('  ::retrieveOptFromString() non-empty string');