From 1643d462e4c3b7c873790a6eb9d4e2a9343aff78 Mon Sep 17 00:00:00 2001
From: Sascha Egerer <sascha@sascha-egerer.de>
Date: Thu, 14 Apr 2016 16:00:06 +0200
Subject: [PATCH] [TASK] Refactor scheduler task acceptance tests
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* Use Admin Actor
* Rename the class / test
* Split the test in smaller pieces
* Make the test more robust
* Add test for deleting a scheduler task

Change-Id: I0b1c0e326bc27590311451fd46cb40600af30719
Resolves: #75618
Releases: master
Reviewed-on: https://review.typo3.org/47667
Reviewed-by: Dirk Jüttner <dirk.juettner@gmail.com>
Tested-by: Dirk Jüttner <dirk.juettner@gmail.com>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
---
 .../Scheduler/CreateASchedulerTaskCest.php    | 69 --------------
 .../Backend/Scheduler/TasksCest.php           | 93 +++++++++++++++++++
 2 files changed, 93 insertions(+), 69 deletions(-)
 delete mode 100644 typo3/sysext/core/Tests/Acceptance/Backend/Scheduler/CreateASchedulerTaskCest.php
 create mode 100644 typo3/sysext/core/Tests/Acceptance/Backend/Scheduler/TasksCest.php

diff --git a/typo3/sysext/core/Tests/Acceptance/Backend/Scheduler/CreateASchedulerTaskCest.php b/typo3/sysext/core/Tests/Acceptance/Backend/Scheduler/CreateASchedulerTaskCest.php
deleted file mode 100644
index 9eb2f20d820c..000000000000
--- a/typo3/sysext/core/Tests/Acceptance/Backend/Scheduler/CreateASchedulerTaskCest.php
+++ /dev/null
@@ -1,69 +0,0 @@
-<?php
-namespace TYPO3\CMS\Core\Tests\Acceptance\Backend\Scheduler;
-
-/*
- * This file is part of the TYPO3 CMS project.
- *
- * It is free software; you can redistribute it and/or modify it under
- * the terms of the GNU General Public License, either version 2
- * of the License, or any later version.
- *
- * For the full copyright and license information, please read the
- * LICENSE.txt file that was distributed with this source code.
- *
- * The TYPO3 project - inspiring people to share!
- */
-
-use TYPO3\CMS\Core\Tests\Acceptance\Step\Backend\Kasper;
-
-/**
- * Acceptance test
- */
-class CreateASchedulerTaskCest
-{
-    /**
-     * @param Kasper $I
-     */
-    public function _before(Kasper $I)
-    {
-        $I->loginAsAdmin();
-    }
-
-    /**
-     * @param Kasper $I
-     */
-    public function _after(Kasper $I)
-    {
-        $I->logout();
-    }
-
-    /**
-     * @param Kasper $I
-     */
-    public function tryToTest(Kasper $I)
-    {
-        $I->wantTo("To create a scheduler task");
-        $I->see('Scheduler', '#system_txschedulerM1');
-        $I->click('Scheduler', '#system_txschedulerM1');
-
-        // switch to content iframe
-        $I->switchToIFrame('content');
-
-        // create a new task
-        $I->see('No tasks defined yet');
-        $I->click("//a[contains(@title, 'Add task')]");
-        $I->selectOption("form select[id=task_class]", 'System Status Update');
-        $I->selectOption("form select[id=task_type]", 'Single');
-        $I->fillField('#task_SystemStatusUpdateNotificationEmail', 'test@local.typo3.org');
-        $I->click("div.module button.dropdown-toggle");
-        $I->click("//a[contains(@data-value,'saveclose')]");
-        $I->waitForText('The task was added successfully.');
-
-        // run the task
-        $I->click("//a[contains(@title, 'Run task')]");
-        $I->waitForText('Executed: System Status Update');
-
-        // leave the iframe
-        $I->switchToIFrame();
-    }
-}
diff --git a/typo3/sysext/core/Tests/Acceptance/Backend/Scheduler/TasksCest.php b/typo3/sysext/core/Tests/Acceptance/Backend/Scheduler/TasksCest.php
new file mode 100644
index 000000000000..15990f8a73dd
--- /dev/null
+++ b/typo3/sysext/core/Tests/Acceptance/Backend/Scheduler/TasksCest.php
@@ -0,0 +1,93 @@
+<?php
+namespace TYPO3\CMS\Core\Tests\Acceptance\Backend\Scheduler;
+
+/*
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
+ */
+
+use TYPO3\CMS\Core\Tests\Acceptance\Step\Backend\Admin;
+
+/**
+ * Scheduler task tests
+ */
+class TasksCest
+{
+    /**
+     * @param Admin $I
+     */
+    public function _before(Admin $I)
+    {
+        $I->useExistingSession();
+
+        $I->see('Scheduler', '#system_txschedulerM1');
+        $I->click('Scheduler', '#system_txschedulerM1');
+
+        // switch to content iframe
+        $I->switchToIFrame('content');
+    }
+
+    /**
+     * @param Admin $I
+     * @return Admin
+     */
+    public function createASchedulerTask(Admin $I)
+    {
+        $I->see('No tasks defined yet');
+        $I->click('//a[contains(@title, "Add task")]', '.module-docheader');
+
+        $I->cantSeeElement('#task_SystemStatusUpdateNotificationEmail');
+        $I->selectOption('#task_class', 'System Status Update');
+        $I->seeElement('#task_SystemStatusUpdateNotificationEmail');
+
+        $I->selectOption('#task_type', 'Single');
+
+        $I->fillField('#task_SystemStatusUpdateNotificationEmail', 'test@local.typo3.org');
+
+        $I->click('button.dropdown-toggle', '.module-docheader');
+        $I->wantTo('Click "Save and close"');
+        $I->click("//a[contains(@data-value,'saveclose')]");
+
+        $I->waitForText('The task was added successfully.');
+
+        return $I;
+    }
+
+    /**
+     * @depends createASchedulerTask
+     * @param Admin $I
+     * @return Admin
+     */
+    public function canRunTask(Admin $I)
+    {
+        // run the task
+        $I->click('//a[contains(@title, "Run task")]');
+        $I->waitForText('Executed: System Status Update');
+
+        return $I;
+    }
+
+    /**
+     * @depends createASchedulerTask
+     * @param Admin $I
+     */
+    public function canDeleteTask(Admin $I)
+    {
+        // delete the task
+        $I->click('//a[contains(@title, "Delete")]');
+        $I->switchToIFrame();
+        $I->waitForElement('.t3-modal.modal');
+        $I->click('.t3-modal.modal .btn.btn-warning');
+        $I->switchToIFrame('content');
+        $I->see('The task was successfully deleted.');
+        $I->see('No tasks defined yet');
+    }
+}
-- 
GitLab