/** * @dataProvider provideGenerateString */ public function testGenerateString($length, $characters) { $generator = $this->createGenerator(); $string = $generator->generateString($length, $characters); $this->assertSame($length, strlen($string)); $allStringCharactersInCharacters = f\every(f\partial('in_array', f\_(), str_split($characters)), str_split($string)); $this->assertTrue($allStringCharactersInCharacters); }
function function_doc_info_from_code($code) { $buildDoc = function ($raw, $doc) { return array('raw' => $raw, 'usage' => $doc[0], 'desc' => $doc[1], 'example' => $doc[2]); }; $docTemplate = array('', '', ''); $getRawDoc = function ($contents) { if (preg_match('@^/\\*\\*\\n(.*)\\n \\*/\\nfunction.@ms', $contents, $matches)) { return preg_replace('/^ \\* ?/m', '', $matches[1]); } return false; }; $rawDoc = $getRawDoc($code); if ($rawDoc === false) { return $buildDoc('', $docTemplate); } $processDoc = f\compose(f\partial('array_replace', $docTemplate), f\partial('explode', "\n\n", f\_(), 3)); $doc = $processDoc($rawDoc); return $buildDoc($rawDoc, $doc); }
/** * @expectedException \InvalidArgumentException */ public function testPartialWithPlaceholdersShouldThrowAnExceptionIfAPlaceholderValueIsMissing() { $o = f\partial(array($this, 'over'), f\_(), f\_(), 2); $o(10); }
public function test_() { $_ = f\_(); $this->assertInstanceOf('felpado\\placeholder', $_); }
public function getNames() { return f\map(f\partial('felpado\\get', f\_(), 'name'), $this); }