test.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <?php
  2. /*
  3. * Copyright (C) 2022 Echedey López Romero <elr@disroot.org>
  4. *
  5. * This program is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. // Show errors in screen
  19. ini_set('display_errors', '1');
  20. ini_set('display_startup_errors', '1');
  21. error_reporting(E_ALL);
  22. // Repair output with Tidy
  23. ini_set('tidy.clean_output', '1');
  24. // Empty web browser cache
  25. header('Cache-Control: no-cache');
  26. header('Pragma: no-cache');
  27. // Load dependencies paths
  28. require './vendor/autoload.php';
  29. // Load classes
  30. require './connections/FirebaseCon.php';
  31. require './models/User.php';
  32. require './models/Comment.php';
  33. require './models/Post.php';
  34. require './controllers/ManageUsers.php';
  35. require './controllers/ManageComments.php';
  36. require './controllers/ManagePosts.php';
  37. require './controllers/ManageBlog.php';
  38. // Load variables
  39. require './variables.php';
  40. $User1 = new User('001', 'Echedey', 'elr@disroot.org',
  41. (new DateTime())->format('d/m/Y H:i'), 0);
  42. $User2 = new User('002', 'Tomy', 'tomy@tomy.tomy',
  43. (new DateTime())->format('d/m/Y H:i'), 1);
  44. $User3 = new User('003', 'Dani', 'dani@dani.dani',
  45. (new DateTime())->format('d/m/Y H:i'), 1);
  46. $User4 = new User('004', 'Gabriel', 'gabriel@gabriel.gabriel',
  47. (new DateTime())->format('d/m/Y H:i'), 2);
  48. $Comment1 = new Comment('0001', '001', 'Good post',
  49. (new DateTime())->format('d/m/Y H:i'),
  50. 'I like this post');
  51. $Comment2 = new Comment('0002', '004', 'Garbage',
  52. (new DateTime())->format('d/m/Y H:i'),
  53. 'This post is too summarized');
  54. $Comment3 = new Comment('0003', '002', 'A typo',
  55. (new DateTime())->format('d/m/Y H:i'),
  56. 'You said "more complete then" when should be "more complete than" '
  57. . 'in the second sentence.');
  58. $Post1 = new Post('001', '002',
  59. 'Structure and Interpretation of Computer Programs',
  60. (new DateTime())->format('d/m/Y H:i'),
  61. './images/SICP.jpg',
  62. 'The SICP book is a complete book for practicing maths while learning '
  63. . 'how to program in the best way. It is old but more complete then '
  64. . 'current programming books.', ['0001', '0003']);
  65. $Post2 = new Post('002', '003', 'Doctor Who with new Doctor',
  66. (new DateTime())->format('d/m/Y H:i'),
  67. './images/doctor_who.png', 'With the fall of 11st season of the modern '
  68. . 'series of Doctor Who, a new Doctor appears being a full woman.',
  69. ['0002']);
  70. $Page = '<p>THE TEST MODE BEGINS</p>' . PHP_EOL . PHP_EOL;
  71. $Page .= '<p>USERS</p>' . PHP_EOL;
  72. $Page .= '<p>Adding first user...<p>' . PHP_EOL;
  73. $Page .= '<p>' . $ManageUsers->AddUser($User1) . '</p>' . PHP_EOL;
  74. $Page .= '<p>Adding second user...</p>' . PHP_EOL;
  75. $Page .= '<p>' . $ManageUsers->AddUser($User2) . '</p>' . PHP_EOL;
  76. $Page .= '<p>Adding third user...</p>' . PHP_EOL;
  77. $Page .= '<p>' . $ManageUsers->AddUser($User3) . '</p>' . PHP_EOL;
  78. $Page .= '<p>Adding forth user...</p>' . PHP_EOL;
  79. $Page .= '<p>' . $ManageUsers->AddUser($User4) . '</p>' . PHP_EOL . PHP_EOL;
  80. $Page .= '<p>Comments</p>' . PHP_EOL;
  81. $Page .= '<p>Adding first comment</p>' . PHP_EOL;
  82. $Page .= '<p>' . $ManageComments->AddComment($Comment1) . '</p>' . PHP_EOL;
  83. $Page .= '<p>Adding second comment</p>' . PHP_EOL;
  84. $Page .= '<p>' . $ManageComments->AddComment($Comment2) . '</p>' . PHP_EOL;
  85. $Page .= '<p>Adding third comment</p>' . PHP_EOL;
  86. $Page .= '<p>' . $ManageComments->AddComment($Comment3) . '</p>' . PHP_EOL . PHP_EOL;
  87. $Page .= '<p>Posts</p>' . PHP_EOL;
  88. $Page .= '<p>Adding first post</p>' . PHP_EOL;
  89. $Page .= '<p>' . $ManagePosts->AddPost($Post1) . '</p>' . PHP_EOL;
  90. $Page .= '<p>Adding second post</p>' . PHP_EOL;
  91. $Page .= '<p>' . $ManagePosts->AddPost($Post2) . '</p>' . PHP_EOL . PHP_EOL;
  92. $Page .= '<p>THE TEST MODE ENDS</p>' . PHP_EOL . PHP_EOL;
  93. $Page .= $ManageBlog->ShowPosts();
  94. require './view.php';