public function testGenerateLetters_SimpleCall() { $list = array(0); Random::setCallbackRandomFunction(function ($minDigit, $maxDigit) use(&$list) { return array_shift($list); }); $random = new Random(); $this->assertSame('a', $random->generateLetter()); }
public function testGenerateAndGet_FiveCharacters() { $list = array(0, 1, 2, 3, 4); Random::setCallbackRandomFunction(function ($minDigit, $maxDigit) use(&$list) { return array_shift($list); }); $alnum = new Alnum(); $this->assertEquals('abcde', $alnum->generateAndGet(5)); }
public function testFindRandomLine_AllFlagsSet() { $list = array(0, 0); Random::setCallbackRandomFunction(function ($minDigit, $maxDigit) use(&$list) { return array_shift($list); }); $this->storage->createFile('some.file'); $this->storage->filePutContents('some.file', "first\n\n\nlast\n\n\n"); $file = new FileObject($this->storage->getPath('some.file')); $file->setFlags($file::DROP_NEW_LINE | $file::READ_AHEAD | $file::SKIP_EMPTY); $this->assertEquals('last', $file->findRandomLine()); }