当前位置: 首页>>代码示例>>PHP>>正文


PHP Artist::populate方法代码示例

本文整理汇总了PHP中Artist::populate方法的典型用法代码示例。如果您正苦于以下问题:PHP Artist::populate方法的具体用法?PHP Artist::populate怎么用?PHP Artist::populate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Artist的用法示例。


在下文中一共展示了Artist::populate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testPopulate

 /**
  * @covers Artist::populate
  * @depends testUpdate
  */
 public function testPopulate(Artist $updatedArtistDummy)
 {
     $artistDummy = $this->dummyArtistProvider();
     //populate by name, expected no match
     $this->assertFalse($this->object->populate(['name' => 'nameValue']), 'Populate should not find any artist with name nameValue');
     //populate by name, expected match
     $this->assertTrue($this->object->populate(['name' => 'artistName']), 'Populate should find the created artist with name ' . $artistDummy->name);
     //populate by mbid, expected match
     $this->assertTrue($this->object->populate(['mbid' => $artistDummy->mbid]), 'Populate should find the created artist with mbid ' . $artistDummy->mbid);
     //populate by id, expected match
     $this->assertTrue($this->object->populate(['id' => 2]), 'Populate should find the created artist with id 2 (previously created)');
     //populate by all criteria, expected match
     $this->assertTrue($this->object->populate(['id' => 2, 'mbid' => $updatedArtistDummy->mbid, 'name' => $updatedArtistDummy->name]), 'Populate should find the created artist with id 2 (previously created)');
     //check populate return all attributes
     $this->assertEquals($updatedArtistDummy->name, $this->object->name, 'Artist name should have been set during populate');
     $this->assertEquals($updatedArtistDummy->country, $this->object->country, 'Artist country should have been set during populate');
     $this->assertEquals($updatedArtistDummy->summary, $this->object->summary, 'Artist summary should have been set during populate');
     $this->assertEquals($updatedArtistDummy->mbid, $this->object->mbid, 'Artist mbid should have been set during populate');
 }
开发者ID:nioc,项目名称:web-music-player,代码行数:23,代码来源:ArtistTest.php

示例2: Artist

 if (!$api->checkAuth()) {
     //User not authentified/authorized
     return;
 }
 if (!$api->checkScope('admin')) {
     $api->output(403, 'Admin scope is required for editing artist');
     //indicate the requester do not have the required scope for updating artist
     return;
 }
 if (!$api->checkParameterExists('id', $id)) {
     $api->output(400, 'Artist identifier must be provided');
     //artist was not provided, return an error
     return;
 }
 $artist = new Artist($id);
 if (!$artist->populate(['id' => $id])) {
     $api->output(404, 'Artist not found');
     //indicate the artist was not found
     return;
 }
 //adapt and validate object received
 $updatedArtist = $api->query['body'];
 if (!$artist->validateModel($updatedArtist, $errorMessage)) {
     $api->output(400, 'Artist is not valid: ' . $errorMessage);
     //provided user is not valid
     return;
 }
 if (!$artist->update($errorMessage)) {
     $api->output(500, 'Error during artist update' . $errorMessage);
     //something gone wrong :(
     return;
开发者ID:nioc,项目名称:web-music-player,代码行数:31,代码来源:artist.php


注:本文中的Artist::populate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。