This module could benefit of more tests

Created on 13 February 2025, 2 months ago

Problem/Motivation

This module could use some tests, right now there's just a Test that check if the home page is loading and the it admin form setttings is saving correctly, and that's it

1.93 KiB
<?php
namespace Drupal\Tests\google_calendar_service\Functional;
use Drupal\Tests\BrowserTestBase;
/**
 * Tests Google Calendar Service configuration.
 *
 * @group google_calendar_service
 */
class GoogleCalendarServiceTest extends BrowserTestBase {
  /**
   * Modules to enable.
   *
   * @var array<string>
   */
  protected static $modules = ['google_calendar_service'];
  /**
   * Theme to enable. This field is mandatory.
   *
   * @var string
   */
  protected $defaultTheme = 'stark';
  /**
   * A test user with permission to access google calendar service config page.
   *
   * @var \Drupal\user\UserInterface
   */
  protected $adminUser;
  /**
   * {@inheritdoc}
   */
  protected function setUp(): void {
    // Make sure to complete the normal setup steps first.
    parent::setUp();
    // Create and log in an administrative user.
    $this->adminUser = $this->drupalCreateUser([
      'administer calendars and events',
    ]);
    $this->drupalLogin($this->adminUser);
  }
  /**
   * The simplest assert possible.
   */
  public function testOne() {
    // Load the front page.
    $this->drupalGet('<front>');
    // Confirm that the site didn't throw a server error or something else.
    $this->assertSession()->statusCodeEquals(200);
  }
  /**
   * Test the admin page.
   */
  public function testAdminPage() {
    // Load the destination page.
    $this->drupalGet('admin/config/google-calendar-service/settings');
    $session = $this->assertSession();
    $session->statusCodeEquals(200);
    $session->pageTextContains('Secret Client File Step');
    $session->pageTextContains('Google User Email');
    $session->pageTextContains('Secret Client File');
    $session->fieldExists('google_user_email');
    $session->buttonExists('Save configuration');
    // Create a new source of type File Directory.
    $edit = [
      'google_user_email' => 'googletest@gmail.com',
    ];
    $this->submitForm($edit, 'Save configuration');
  }
}

I believe this module needs more functional tests (Calendar/Event creation/edition/deletion) and some Javascript function tal (Event Imports), but I haven't found some time for this, any takers?

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Feature request
Status

Active

Version

3.0

Component

Code

Created by

🇨🇦Canada danrod Ottawa

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024