tests\helpers\Factory::createList PHP Method

createList() public static method

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

Usage Example

示例#1
0
 public function test_Should_GetUsersByPage()
 {
     Factory::createList('App\\Models\\User', [['name' => 'User 1', 'email' => '*****@*****.**', 'password' => '12345678', 'api_token' => '12345678'], ['name' => 'User 2', 'email' => '*****@*****.**', 'password' => '23456789', 'api_token' => '23456789'], ['name' => 'User 3', 'email' => '*****@*****.**', 'password' => '34567890', 'api_token' => '34567890'], ['name' => 'User 4', 'email' => '*****@*****.**', 'password' => '4567890a', 'api_token' => '45678901'], ['name' => 'User 5', 'email' => '*****@*****.**', 'password' => '567890ab', 'api_token' => '56789012']]);
     $userRepository = new EloquentUser(new App\Models\User());
     $foundUsers = $userRepository->byPage();
     $this->assertCount(5, $foundUsers->items());
 }
All Usage Examples Of tests\helpers\Factory::createList