本文整理汇总了PHP中Brand::setFieldNameForAlias方法的典型用法代码示例。如果您正苦于以下问题:PHP Brand::setFieldNameForAlias方法的具体用法?PHP Brand::setFieldNameForAlias怎么用?PHP Brand::setFieldNameForAlias使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Brand
的用法示例。
在下文中一共展示了Brand::setFieldNameForAlias方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testBasic
public function testBasic()
{
$brand = new \Brand(array('title' => 'Apple'));
$brand->save();
$brand = \Brand::loadOne(1);
$brand->attachFileFromPath('logo', __DIR__ . '/../README.md');
$this->assertEquals('01/1/logo/README.md', $brand->logo[0]['link'], 'original file name');
$brand->attachFileFromPath('logo', __DIR__ . '/../README.md');
$this->assertEquals('01/1/logo/README_1.md', $brand->logo[1]['link'], 'duplicate of original file name');
$brand = \Brand::loadOne(1);
$this->assertEquals(2, count($brand->logo), 'loaded two files on demand');
$brand->delete();
$this->assertEmpty(FSService::getInstance()->in(__DIR__ . '/upload/01/')->find(), 'No files left after deleting');
$brand = new \Brand(array('title' => 'Apple'));
$_FILES['logo'] = array('tmp_name' => __DIR__ . '/../README.md', 'name' => 'readme.md');
$_FILES['info_file'] = array('tmp_name' => __DIR__ . '/../README.md', 'name' => 'readme.md');
$brand->setFieldNameForAlias('info', 'info_file');
$brand->save();
$this->assertEquals(2, count(FSService::getInstance()->in(__DIR__ . '/upload/02/2')->find()), 'Two files saved to object');
$brand->delete();
$brand = new \Brand(array('title' => 'Apple'));
$_FILES['logo'] = array('tmp_name' => __DIR__ . '/../README.md', 'name' => 'readme.md');
$_FILES['info'] = array('tmp_name' => __DIR__ . '/../README.md', 'name' => 'readme.md');
$brand->skipFileAliasForSave('logo');
$brand->save();
$this->assertEquals(1, count(FSService::getInstance()->in(__DIR__ . '/upload/03/3')->find()), 'Skipped logo');
$brand->delete();
}