Skip to content
Snippets Groups Projects
Commit c90e81d5 authored by SASSU Thomas's avatar SASSU Thomas
Browse files

Part II test

parent fa1344a8
Branches
No related tags found
No related merge requests found
......@@ -2,6 +2,7 @@
"require":{
"illuminate/database": "5.5.*",
"illuminate/pagination": ">=5.0",
"fzaninotto/faker": "^1.9",
"php": ">=7.0",
"slim/slim": "2.*"
},
......
......@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "cc18e66e95cadfdfa2cb91becd1b4524",
"content-hash": "33d3fc0ef69a930fd24a7dd964e150c1",
"packages": [
{
"name": "doctrine/inflector",
......@@ -73,6 +73,56 @@
],
"time": "2019-10-30T19:59:35+00:00"
},
{
"name": "fzaninotto/faker",
"version": "v1.9.1",
"source": {
"type": "git",
"url": "https://github.com/fzaninotto/Faker.git",
"reference": "fc10d778e4b84d5bd315dad194661e091d307c6f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/fzaninotto/Faker/zipball/fc10d778e4b84d5bd315dad194661e091d307c6f",
"reference": "fc10d778e4b84d5bd315dad194661e091d307c6f",
"shasum": ""
},
"require": {
"php": "^5.3.3 || ^7.0"
},
"require-dev": {
"ext-intl": "*",
"phpunit/phpunit": "^4.8.35 || ^5.7",
"squizlabs/php_codesniffer": "^2.9.2"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.9-dev"
}
},
"autoload": {
"psr-4": {
"Faker\\": "src/Faker/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "François Zaninotto"
}
],
"description": "Faker is a PHP library that generates fake data for you.",
"keywords": [
"data",
"faker",
"fixtures"
],
"time": "2019-12-12T13:22:17+00:00"
},
{
"name": "illuminate/container",
"version": "v5.5.44",
......
<?php
require_once dirname (__DIR__) . '/vendor/autoload.php';
session_start();
use \Slim\Slim as Slim;
use Illuminate\Database\Capsule\Manager as DB;
use \gp\controleurs\ControleurPrincipal as ControleurPrincipal;
use \gp\controleurs\ControleurScript as ControleurScript;
$db = new DB();
$db->addConnection(parse_ini_file('../conf/conf.ini'));
$db->setAsGlobal();
$db->bootEloquent();
echo ("<!DOCTYPE html>
<html>
<body>
<div>
<h1> Faker </h1>
</div>");
$c = new ControleurScript();
$c->generation();
echo "<div>";
echo $c->getLog();
echo "</div>";
echo ("</body>
</html>");
......@@ -349,4 +349,40 @@ class ControleurScript
$time = $time_end - $time_start;
return $time;
}
public function generation(){
// use the factory to create a Faker\Generator instance
$faker = Faker\Factory::create();
if(User::take(50)== null){
//all users
for($i=0; i<25000; $i++){
//fake data
$tmp = $faker->name.split(' ');
$user['fname'] = $tmp[0];
$user['name'] = $tmp[1];
$user['adress'] = $faker->adress;
$user['email'] = $faker->email;
$user['tel'] = $faker->e164PhoneNumber;
$user['date'] = $faker->date('Y-m-d','2005-01-01');
//insert
User::create($user['fname'], $user['name'], $user['email'], $user['adress'], $user['tel'], $user['date']);
}
}
if(Comment::take(50)== null){
//all comments
for($i=0; i<250000; $i++){
//random user
$user = User::all()->random(1)->first();
//random game
$game = Game::all()->random(1)->first();
//fake data
$title = $user->email;
$content = $faker->text(200);
$date = $faker->date('Y-m-d', '2015-02-01');
//insert comment
Comment::create($title, $content, $date);
}
}
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment