summaryrefslogtreecommitdiff
path: root/tests/service/lorem-md.php
diff options
context:
space:
mode:
authorGeorge Halkiadakis <gchalkiadakis@sklavenitis.co.gr>2023-04-27 03:47:30 +0300
committerGeorge Halkiadakis <gchalkiadakis@sklavenitis.co.gr>2023-04-27 03:47:30 +0300
commit059e0d95d0c28bc5060e87e146eaf7411f51bf90 (patch)
tree7c21ac432f16dde2329a0d5954d70711eceb48e6 /tests/service/lorem-md.php
parent26cd8ee99659ef1926c96a049c93645ffc9b169d (diff)
downloadgyraf1gov-059e0d95d0c28bc5060e87e146eaf7411f51bf90.tar.gz
gyraf1gov-059e0d95d0c28bc5060e87e146eaf7411f51bf90.tar.bz2
gyraf1gov-059e0d95d0c28bc5060e87e146eaf7411f51bf90.zip
skeleton commit; based on an anom project
Diffstat (limited to 'tests/service/lorem-md.php')
-rwxr-xr-xtests/service/lorem-md.php71
1 files changed, 71 insertions, 0 deletions
diff --git a/tests/service/lorem-md.php b/tests/service/lorem-md.php
new file mode 100755
index 0000000..c7b8d0f
--- /dev/null
+++ b/tests/service/lorem-md.php
@@ -0,0 +1,71 @@
+<?php
+
+use Registry;
+
+define("LIMIT", 50); // number of random records to make
+
+function lorem_md() {
+ // create curl resource
+ $ch = curl_init();
+
+ // set url
+ curl_setopt($ch, CURLOPT_URL, "https://jaspervdj.be/lorem-markdownum/markdown.txt");
+
+ //return the transfer as a string
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+
+ // $output contains the output string
+ $output = curl_exec($ch);
+
+
+ $title = substr($output, 2, strpos( $output, "\n" )-1);
+ $body = trim(substr($output, strpos( $output, "\n" )+1));
+ $intro = str_replace("\n", " ", (substr($body, 3, strpos( $body, "\n" )-2) . $title));
+
+
+
+ // close curl resource to free up system resources
+ curl_close($ch);
+
+ return [
+ 'title' => $title,
+ 'intro' => $intro,
+ 'body' => $body
+ ];
+
+}
+
+$rand_content = lorem_md();
+
+
+for ($i=0; $i < LIMIT ; $i++) {
+
+ $rand_content = lorem_md();
+
+ $id = Registry::use('database')->query(
+ "INSERT INTO lesson (title, course_id, intro, `body`, `status`)
+ VALUES (:title, :courseid, :intro, :body, :status)",
+ [
+ ':title' => $rand_content['title'],
+ ':courseid' => rand(3,11),
+ ':intro' => $rand_content['intro'],
+ ':body' => $rand_content['body'],
+ 'status' => rand(0,1)
+ ]
+ )->lastInsertID();
+
+ Registry::use('database')->runQuery(
+ "INSERT INTO lesson_privilege (lesson_id, privilege_id)
+ VALUES (:lesson_id, :privilege_id)",
+ [
+ ':lesson_id' => $id,
+ ':privilege_id' => rand(1,2)
+ ]
+ );
+
+}
+
+
+?>
+
+done! \ No newline at end of file