From 4a73792fdc6bd9a230b999dd9607229b10ec571d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20S=CC=8Ctekl?= Date: Sun, 7 Feb 2016 12:07:30 +0100 Subject: [PATCH] Used autoload dev for testing environment --- composer.json | 3 +++ tests/CronnerTests/Cronner.phpt | 26 +++++++++++++++++-- .../CronnerTests/Tasks/ParametersParsing.phpt | 1 - tests/CronnerTests/Tasks/Task.phpt | 1 - 4 files changed, 27 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index aaebb51..6f292c6 100644 --- a/composer.json +++ b/composer.json @@ -36,5 +36,8 @@ }, "autoload": { "classmap": ["Cronner/"] + }, + "autoload-dev": { + "classmap": ["tests/CronnerTests/objects"] } } diff --git a/tests/CronnerTests/Cronner.phpt b/tests/CronnerTests/Cronner.phpt index 01c270c..6ed312d 100644 --- a/tests/CronnerTests/Cronner.phpt +++ b/tests/CronnerTests/Cronner.phpt @@ -11,6 +11,9 @@ use Nette\Utils\DateTime; use stdClass; use stekycz\Cronner\Cronner; use stekycz\Cronner\Tasks\Task; +use stekycz\Cronner\tests\objects\AnotherSimpleTestObject; +use stekycz\Cronner\tests\objects\NextSimpleTestObject; +use stekycz\Cronner\tests\objects\SameTaskNameObject; use stekycz\Cronner\tests\objects\TestExceptionObject; use stekycz\Cronner\tests\objects\TestObject; use Tester\Assert; @@ -18,8 +21,6 @@ use Tester\Assert; require_once(__DIR__ . "/bootstrap.php"); -require_once(__DIR__ . "/objects/TestObject.php"); -require_once(__DIR__ . "/objects/TestExceptionObject.php"); /** * @author Martin Štekl @@ -222,6 +223,27 @@ class CronnerTest extends \TestCase $this->cronner->run($now); } + + + public function testAddingTwoTestsWithTheSameNameInOneObject() + { + $self = $this; + Assert::exception(function () use ($self) { + $self->cronner->addTasks(new SameTaskNameObject()); + }, '\stekycz\Cronner\DuplicateTaskNameException'); + } + + + + public function testAddingTwoTestsWithTheSameNameInMoreObjects() + { + $self = $this; + Assert::exception(function () use ($self) { + $self->cronner->addTasks(new AnotherSimpleTestObject()); + $self->cronner->addTasks(new NextSimpleTestObject()); + }, '\stekycz\Cronner\DuplicateTaskNameException'); + } + } run(new CronnerTest()); diff --git a/tests/CronnerTests/Tasks/ParametersParsing.phpt b/tests/CronnerTests/Tasks/ParametersParsing.phpt index 30274eb..6c01bc9 100644 --- a/tests/CronnerTests/Tasks/ParametersParsing.phpt +++ b/tests/CronnerTests/Tasks/ParametersParsing.phpt @@ -13,7 +13,6 @@ use Tester\Assert; require_once(__DIR__ . "/../bootstrap.php"); -require_once(__DIR__ . "/../objects/TestObject.php"); /** * @author Martin Štekl diff --git a/tests/CronnerTests/Tasks/Task.phpt b/tests/CronnerTests/Tasks/Task.phpt index 56456f3..9ca81c8 100644 --- a/tests/CronnerTests/Tasks/Task.phpt +++ b/tests/CronnerTests/Tasks/Task.phpt @@ -15,7 +15,6 @@ use Tester\Assert; require_once(__DIR__ . "/../bootstrap.php"); -require_once(__DIR__ . "/../objects/TestObject.php"); /** * @author Martin Štekl