tests\helpers\Factory::buildList PHP Method

buildList() public static method

public static buildList ( $class, $dataList = [] )
    public static function buildList($class, $dataList = [])
    {
        foreach ($dataList as $data) {
            $instanceList[] = static::build($class, $data);
        }
        return $instanceList;
    }

Usage Example

コード例 #1
0
 public function test_Should_DisplayIndexPage_When_IndexPageIsRequested()
 {
     $servers = Factory::buildList('App\\Models\\Server', [['id' => 1, 'name' => 'Server 1', 'description' => '', 'body' => '', 'created_at' => new Carbon\Carbon(), 'updated_at' => new Carbon\Carbon()], ['id' => 2, 'name' => 'Server 2', 'description' => '', 'body' => '', 'created_at' => new Carbon\Carbon(), 'updated_at' => new Carbon\Carbon()], ['id' => 3, 'name' => 'Server 3', 'description' => '', 'body' => '', 'created_at' => new Carbon\Carbon(), 'updated_at' => new Carbon\Carbon()]]);
     $perPage = 10;
     $this->mockServerRepository->shouldReceive('byPage')->once()->andReturn(new Illuminate\Pagination\Paginator($servers, $perPage));
     $this->get('servers');
     $this->assertResponseOk();
     $this->assertViewHas('servers');
 }
All Usage Examples Of tests\helpers\Factory::buildList