public function test適当な名前を生成する() { $this->assertRegExp('!^tmp\\-[a-z0-9]+$!i', Name::create()); $this->assertRegExp('!^first_[a-z0-9]+$!i', Name::create('first_')); $this->assertRegExp('!^tmp-[a-z0-9]+\\.end$!', Name::create(null, ".end")); $this->assertRegExp('!^[0-9]+[a-z0-9]+\\.end$!', Name::create("", '.end')); $this->assertRegExp('!^foo\\-[a-z0-9]+\\.bar$!', Name::create("foo-", ".bar")); }
protected function createUniquePathName($prefix = null, $suffix = null) { $stock = 100; $result = null; while ($stock > 0) { --$stock; $name = Name::create($prefix, $suffix); $path = sprintf('%s/%s', $this->directory, $name); if (!file_exists($path)) { $result = $path; break; } } return $result; }