From cf5059f42daa4d69a1a609a68762b7fad644d7f1 Mon Sep 17 00:00:00 2001
From: Daniel Rodriguez <danrod@gmail.com>
Date: Sun, 16 Mar 2025 17:46:45 -0500
Subject: [PATCH 1/4] Issue # 3513301: Added an initial Basic Test Class file.

---
 tests/src/Functional/TimepickerAdminTest.php | 74 ++++++++++++++++++++
 1 file changed, 74 insertions(+)
 create mode 100644 tests/src/Functional/TimepickerAdminTest.php

diff --git a/tests/src/Functional/TimepickerAdminTest.php b/tests/src/Functional/TimepickerAdminTest.php
new file mode 100644
index 0000000..ff7e29d
--- /dev/null
+++ b/tests/src/Functional/TimepickerAdminTest.php
@@ -0,0 +1,74 @@
+<?php
+
+namespace Drupal\Tests\timepicker\Functional;
+
+use Drupal\Tests\BrowserTestBase;
+
+/**
+ * Tests the Timepicker module.
+ *
+ * @group timepicker
+ */
+class TimepickerAdminTest extends BrowserTestBase {
+
+  /**
+   * {@inheritdoc}
+   */
+  protected static $modules = ['node', 'timepicker'];
+
+  /**
+   * {@inheritdoc}
+   */
+  protected $defaultTheme = 'stark';
+
+  /**
+   * Tests if user can load the front page among other things.
+   */
+  public function testLoadSite() {
+    // Load the front page.
+    $this->drupalGet('<front>');
+
+    // Confirm that the site didn't throw a server error or something else.
+    $this->assertSession()->statusCodeEquals(200);
+    $this->drupalGet("user");
+  }
+
+  /**
+   * Tests if an admin user can log in.
+   */
+  public function testAdminUser() {
+    // Log in an administrative user.
+    $this->drupalLogin($this->rootUser);
+
+    $this->drupalGet('admin/config');
+
+    $session = $this->assertSession();
+    $session->statusCodeEquals(200);
+  }
+
+  /**
+   * Tests if user can load the front page after the changes.
+   */
+  public function testLoadSiteAfterChanges() {
+    // Load the front page.
+    $this->drupalGet('<front>');
+
+    // Confirm that the site didn't throw a server error or something else.
+    $this->assertSession()->statusCodeEquals(200);
+    $this->drupalGet("user");
+  }
+
+  /**
+   * Tests if an admin access to pages again.
+   */
+  public function testAdminUserAfterChanges() {
+    // Log in an administrative user.
+    $this->drupalLogin($this->rootUser);
+
+    $this->drupalGet('admin/modules');
+
+    $session = $this->assertSession();
+    $session->statusCodeEquals(200);
+  }
+
+}
-- 
GitLab


From 09433710dc3a9c7989143c755a2ebb6c00681162 Mon Sep 17 00:00:00 2001
From: Daniel Rodriguez <danrod@gmail.com>
Date: Sun, 16 Mar 2025 19:34:14 -0500
Subject: [PATCH 2/4] Issue # 3513301: Added an additional test to create two
 article nodes with a text field and check if they are not equals.

---
 tests/src/Functional/TimepickerAdminTest.php | 82 ++++++++++++++++++--
 1 file changed, 75 insertions(+), 7 deletions(-)

diff --git a/tests/src/Functional/TimepickerAdminTest.php b/tests/src/Functional/TimepickerAdminTest.php
index ff7e29d..a21d306 100644
--- a/tests/src/Functional/TimepickerAdminTest.php
+++ b/tests/src/Functional/TimepickerAdminTest.php
@@ -3,6 +3,13 @@
 namespace Drupal\Tests\timepicker\Functional;
 
 use Drupal\Tests\BrowserTestBase;
+use Drupal\node\Entity\Node;
+use Drupal\node\Entity\NodeType;
+use Drupal\Core\Entity\Entity\EntityViewMode;
+use Drupal\datetime\Plugin\Field\FieldType\DateTimeItem;
+use Drupal\field\Entity\FieldConfig;
+use Drupal\field\Entity\FieldStorageConfig;
+use Drupal\Core\Field\FieldStorageDefinitionInterface;
 
 /**
  * Tests the Timepicker module.
@@ -14,7 +21,7 @@ class TimepickerAdminTest extends BrowserTestBase {
   /**
    * {@inheritdoc}
    */
-  protected static $modules = ['node', 'timepicker'];
+  protected static $modules = ['node', 'datetime', 'text', 'timepicker'];
 
   /**
    * {@inheritdoc}
@@ -47,15 +54,76 @@ class TimepickerAdminTest extends BrowserTestBase {
   }
 
   /**
-   * Tests if user can load the front page after the changes.
+   * Testing to create a node with a datetime textfield
    */
   public function testLoadSiteAfterChanges() {
-    // Load the front page.
-    $this->drupalGet('<front>');
+    // Create the article content type with a datetime and a text textfield
+    $node_type = NodeType::create([
+      'type' => 'article',
+    ]);
+    $node_type->save();
+
+    // Add a text field.
+    $field_storage = FieldStorageConfig::create([
+      'field_name' => 'test_field',
+      'entity_type' => 'node',
+      'type' => 'text',
+    ]);
+    $field_storage->save();
+
+    $field = FieldConfig::create([
+      'field_name' => 'test_field',
+      'entity_type' => 'node',
+      'bundle' => 'article',
+      'label' => 'Test field',
+    ]);
+    $field->save();
+
+    // Add a datetime field.
+    $field_datetime_storage = FieldStorageConfig::create([
+      'field_name' => 'field_datetime',
+      'type' => 'datetime',
+      'entity_type' => 'node',
+      'settings' => ['datetime_type' => DateTimeItem::DATETIME_TYPE_DATETIME],
+      'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED,
+    ]);
+
+    $field_datetime_storage->save();
+
+    $field_datetime = FieldConfig::create([
+      'field_storage' => $field_datetime_storage,
+      'bundle' => 'article',
+    ]);
+
+    $field_datetime->save();
+
+    // Creates two different articles and tests them
+    $node1 = Node::create([
+      'title' => 'Test node title',
+      'type' => 'article',
+      'test_field' => [
+        'value' => 'foo',
+      ],
+      'field_datetime' => [
+        'value' => "2014-08-22T00:00:00",
+      ],
+    ]);
+    $node1->save();
+
+    $node2 = Node::create([
+      'title' => 'Test node title 2',
+      'type' => 'article',
+      'test_field' => [
+        'value' => 'food',
+      ],
+      'field_datetime' => [
+        'value' => "2023-02-14T00:00:00",
+      ],
+    ]);
+    $node2->save();
+
+    $this->assertNotEquals($node1, $node2, "There was an error creating the content type or the nodes");
 
-    // Confirm that the site didn't throw a server error or something else.
-    $this->assertSession()->statusCodeEquals(200);
-    $this->drupalGet("user");
   }
 
   /**
-- 
GitLab


From 08405df93ef3d108fb9c48a4d6394ac922a4760a Mon Sep 17 00:00:00 2001
From: Daniel Rodriguez <danrod@gmail.com>
Date: Sun, 16 Mar 2025 19:44:01 -0500
Subject: [PATCH 3/4] Issue # 3513301: Added PHPCS fixes

---
 tests/src/Functional/TimepickerAdminTest.php | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/tests/src/Functional/TimepickerAdminTest.php b/tests/src/Functional/TimepickerAdminTest.php
index a21d306..8987368 100644
--- a/tests/src/Functional/TimepickerAdminTest.php
+++ b/tests/src/Functional/TimepickerAdminTest.php
@@ -5,7 +5,6 @@ namespace Drupal\Tests\timepicker\Functional;
 use Drupal\Tests\BrowserTestBase;
 use Drupal\node\Entity\Node;
 use Drupal\node\Entity\NodeType;
-use Drupal\Core\Entity\Entity\EntityViewMode;
 use Drupal\datetime\Plugin\Field\FieldType\DateTimeItem;
 use Drupal\field\Entity\FieldConfig;
 use Drupal\field\Entity\FieldStorageConfig;
@@ -54,10 +53,10 @@ class TimepickerAdminTest extends BrowserTestBase {
   }
 
   /**
-   * Testing to create a node with a datetime textfield
+   * Testing to create a node with a datetime textfield.
    */
   public function testLoadSiteAfterChanges() {
-    // Create the article content type with a datetime and a text textfield
+    // Create the article content type with a datetime and a text textfield.
     $node_type = NodeType::create([
       'type' => 'article',
     ]);
@@ -97,7 +96,7 @@ class TimepickerAdminTest extends BrowserTestBase {
 
     $field_datetime->save();
 
-    // Creates two different articles and tests them
+    // Creates two different articles and tests them.
     $node1 = Node::create([
       'title' => 'Test node title',
       'type' => 'article',
-- 
GitLab


From 51c9243dbeb09ef12e7d0f24c35a4b8a4ac2958c Mon Sep 17 00:00:00 2001
From: Daniel Rodriguez <danrod@gmail.com>
Date: Sun, 16 Mar 2025 20:39:56 -0500
Subject: [PATCH 4/4] Issue # 3513301: Added PHPCS fixes - README-md

---
 README.md | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/README.md b/README.md
index 1b68ee4..9e4e60e 100644
--- a/README.md
+++ b/README.md
@@ -39,7 +39,8 @@ The Date Timepicker module requires the following JavaScript libraries:
 - [jQuery Timepicker Addon](https://github.com/trentrichardson/jQuery
 -Timepicker-Addon)
 
-Follow the installation instructions below for installing the module and the libraries.
+Follow the installation instructions below for installing the module and 
+the libraries.
 
 Installation
 ------------
@@ -50,7 +51,8 @@ Installation
 
 2. Install merge plugin using `composer require wikimedia/composer-merge-plugin`
 
-3. Edit your site's composer.json file and add the following under the "extra" section:
+3. Edit your site's composer.json file and add the following under 
+   the "extra" section:
   ```
   "merge-plugin": {
     "include": [
-- 
GitLab