diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/functionals/UserApiTest.php | 6 | ||||
-rw-r--r-- | tests/php.ini | 5 | ||||
-rw-r--r-- | tests/units/Action/CommentCreationTest.php (renamed from tests/units/ActionCommentCreationTest.php) | 4 | ||||
-rw-r--r-- | tests/units/Action/TaskAssignColorCategoryTest.php (renamed from tests/units/ActionTaskAssignColorCategoryTest.php) | 4 | ||||
-rw-r--r-- | tests/units/Action/TaskAssignColorColumnTest.php (renamed from tests/units/ActionTaskAssignColorColumnTest.php) | 4 | ||||
-rw-r--r-- | tests/units/Action/TaskAssignColorLinkTest.php (renamed from tests/units/ActionTaskAssignColorLinkTest.php) | 4 | ||||
-rw-r--r-- | tests/units/Action/TaskAssignColorUserTest.php (renamed from tests/units/ActionTaskAssignColorUserTest.php) | 4 | ||||
-rw-r--r-- | tests/units/Action/TaskAssignCurrentUserTest.php (renamed from tests/units/ActionTaskAssignCurrentUserTest.php) | 4 | ||||
-rw-r--r-- | tests/units/Action/TaskAssignSpecificUserTest.php (renamed from tests/units/ActionTaskAssignSpecificUserTest.php) | 4 | ||||
-rw-r--r-- | tests/units/Action/TaskCloseTest.php (renamed from tests/units/ActionTaskCloseTest.php) | 4 | ||||
-rw-r--r-- | tests/units/Action/TaskDuplicateAnotherProjectTest.php (renamed from tests/units/ActionTaskDuplicateAnotherProjectTest.php) | 4 | ||||
-rw-r--r-- | tests/units/Action/TaskEmailTest.php (renamed from tests/units/ActionTaskEmailTest.php) | 4 | ||||
-rw-r--r-- | tests/units/Action/TaskMoveAnotherProjectTest.php (renamed from tests/units/ActionTaskMoveAnotherProjectTest.php) | 4 | ||||
-rw-r--r-- | tests/units/Action/TaskMoveColumnCategoryChangeTest.php (renamed from tests/units/ActionTaskMoveColumnCategoryChangeTest.php) | 4 | ||||
-rw-r--r-- | tests/units/Action/TaskUpdateStartDateTest.php (renamed from tests/units/ActionTaskUpdateStartDateTest.php) | 4 | ||||
-rw-r--r-- | tests/units/Auth/LdapTest.php | 678 | ||||
-rw-r--r-- | tests/units/Auth/ReverseProxyTest.php | 37 | ||||
-rw-r--r-- | tests/units/Core/LexerTest.php (renamed from tests/units/LexerTest.php) | 2 | ||||
-rw-r--r-- | tests/units/Core/OAuth2Test.php (renamed from tests/units/OAuth2Test.php) | 2 | ||||
-rw-r--r-- | tests/units/Core/PluginLoaderTest.php | 23 | ||||
-rw-r--r-- | tests/units/Core/RouterTest.php (renamed from tests/units/RouterTest.php) | 2 | ||||
-rw-r--r-- | tests/units/Core/TemplateTest.php | 28 | ||||
-rw-r--r-- | tests/units/Core/ToolTest.php (renamed from tests/units/ToolTest.php) | 2 | ||||
-rw-r--r-- | tests/units/Helper/AppHelperTest.php (renamed from tests/units/AppHelperTest.php) | 2 | ||||
-rw-r--r-- | tests/units/Helper/AssetHelperTest.php (renamed from tests/units/AssetHelperTest.php) | 2 | ||||
-rw-r--r-- | tests/units/Helper/DatetimeHelperTest.php (renamed from tests/units/DatetimeHelperTest.php) | 2 | ||||
-rw-r--r-- | tests/units/Helper/FileHelperText.php (renamed from tests/units/FileHelperText.php) | 2 | ||||
-rw-r--r-- | tests/units/Helper/TextHelperTest.php (renamed from tests/units/TextHelperTest.php) | 2 | ||||
-rw-r--r-- | tests/units/Helper/UrlHelperTest.php (renamed from tests/units/UrlHelperTest.php) | 2 | ||||
-rw-r--r-- | tests/units/Helper/UserHelperTest.php (renamed from tests/units/UserHelperTest.php) | 2 | ||||
-rw-r--r-- | tests/units/HourlyRate.php | 43 | ||||
-rw-r--r-- | tests/units/Integration/BitbucketWebhookTest.php (renamed from tests/units/BitbucketWebhookTest.php) | 30 | ||||
-rw-r--r-- | tests/units/Integration/GithubWebhookTest.php (renamed from tests/units/GithubWebhookTest.php) | 40 | ||||
-rw-r--r-- | tests/units/Integration/GitlabWebhookTest.php (renamed from tests/units/GitlabWebhookTest.php) | 20 | ||||
-rw-r--r-- | tests/units/Integration/MailgunTest.php (renamed from tests/units/MailgunTest.php) | 2 | ||||
-rw-r--r-- | tests/units/Integration/PostmarkTest.php (renamed from tests/units/PostmarkTest.php) | 2 | ||||
-rw-r--r-- | tests/units/Integration/SendgridTest.php (renamed from tests/units/SendgridTest.php) | 2 | ||||
-rw-r--r-- | tests/units/Locale/LocaleTest.php (renamed from tests/units/LocaleTest.php) | 2 | ||||
-rw-r--r-- | tests/units/Model/AclTest.php (renamed from tests/units/AclTest.php) | 14 | ||||
-rw-r--r-- | tests/units/Model/ActionTest.php (renamed from tests/units/ActionTest.php) | 2 | ||||
-rw-r--r-- | tests/units/Model/AuthenticationTest.php (renamed from tests/units/AuthenticationTest.php) | 2 | ||||
-rw-r--r-- | tests/units/Model/BoardTest.php (renamed from tests/units/BoardTest.php) | 4 | ||||
-rw-r--r-- | tests/units/Model/CategoryTest.php (renamed from tests/units/CategoryTest.php) | 2 | ||||
-rw-r--r-- | tests/units/Model/CommentTest.php (renamed from tests/units/CommentTest.php) | 2 | ||||
-rw-r--r-- | tests/units/Model/ConfigTest.php (renamed from tests/units/ConfigTest.php) | 2 | ||||
-rw-r--r-- | tests/units/Model/DateParserTest.php (renamed from tests/units/DateParserTest.php) | 2 | ||||
-rw-r--r-- | tests/units/Model/FileTest.php (renamed from tests/units/FileTest.php) | 79 | ||||
-rw-r--r-- | tests/units/Model/LinkTest.php (renamed from tests/units/LinkTest.php) | 2 | ||||
-rw-r--r-- | tests/units/Model/NotificationTest.php (renamed from tests/units/NotificationTest.php) | 2 | ||||
-rw-r--r-- | tests/units/Model/ProjectActivityTest.php (renamed from tests/units/ProjectActivityTest.php) | 2 | ||||
-rw-r--r-- | tests/units/Model/ProjectDailyColumnStatsTest.php (renamed from tests/units/ProjectDailyColumnStatsTest.php) | 2 | ||||
-rw-r--r-- | tests/units/Model/ProjectDuplicationTest.php (renamed from tests/units/ProjectDuplicationTest.php) | 26 | ||||
-rw-r--r-- | tests/units/Model/ProjectPermissionTest.php (renamed from tests/units/ProjectPermissionTest.php) | 2 | ||||
-rw-r--r-- | tests/units/Model/ProjectTest.php (renamed from tests/units/ProjectTest.php) | 4 | ||||
-rw-r--r-- | tests/units/Model/SubtaskTest.php (renamed from tests/units/SubtaskTest.php) | 132 | ||||
-rw-r--r-- | tests/units/Model/SubtaskTimeTrackingTest.php (renamed from tests/units/SubtaskTimeTrackingTest.php) | 28 | ||||
-rw-r--r-- | tests/units/Model/SwimlaneTest.php (renamed from tests/units/SwimlaneTest.php) | 46 | ||||
-rw-r--r-- | tests/units/Model/TaskCreationTest.php (renamed from tests/units/TaskCreationTest.php) | 2 | ||||
-rw-r--r-- | tests/units/Model/TaskDuplicationTest.php (renamed from tests/units/TaskDuplicationTest.php) | 24 | ||||
-rw-r--r-- | tests/units/Model/TaskExportTest.php (renamed from tests/units/TaskExportTest.php) | 6 | ||||
-rw-r--r-- | tests/units/Model/TaskFilterTest.php (renamed from tests/units/TaskFilterTest.php) | 6 | ||||
-rw-r--r-- | tests/units/Model/TaskFinderTest.php (renamed from tests/units/TaskFinderTest.php) | 2 | ||||
-rw-r--r-- | tests/units/Model/TaskLinkTest.php (renamed from tests/units/TaskLinkTest.php) | 2 | ||||
-rw-r--r-- | tests/units/Model/TaskModificationTest.php (renamed from tests/units/TaskModificationTest.php) | 2 | ||||
-rw-r--r-- | tests/units/Model/TaskMovedDateSubscriberTest.php (renamed from tests/units/TaskMovedDateSubscriberTest.php) | 6 | ||||
-rw-r--r-- | tests/units/Model/TaskPermissionTest.php (renamed from tests/units/TaskPermissionTest.php) | 2 | ||||
-rw-r--r-- | tests/units/Model/TaskPositionTest.php (renamed from tests/units/TaskPositionTest.php) | 6 | ||||
-rw-r--r-- | tests/units/Model/TaskStatusTest.php (renamed from tests/units/TaskStatusTest.php) | 2 | ||||
-rw-r--r-- | tests/units/Model/TaskTest.php (renamed from tests/units/TaskTest.php) | 2 | ||||
-rw-r--r-- | tests/units/Model/TimetableTest.php (renamed from tests/units/TimetableTest.php) | 2 | ||||
-rw-r--r-- | tests/units/Model/UserSessionTest.php (renamed from tests/units/UserSessionTest.php) | 2 | ||||
-rw-r--r-- | tests/units/Model/UserTest.php (renamed from tests/units/UserTest.php) | 2 | ||||
-rw-r--r-- | tests/units/Model/WebhookTest.php (renamed from tests/units/WebhookTest.php) | 2 |
73 files changed, 1180 insertions, 237 deletions
diff --git a/tests/functionals/UserApiTest.php b/tests/functionals/UserApiTest.php index e1ce1878..e2c693dd 100644 --- a/tests/functionals/UserApiTest.php +++ b/tests/functionals/UserApiTest.php @@ -37,15 +37,15 @@ class UserApi extends PHPUnit_Framework_TestCase { $this->app = new JsonRPC\Client(API_URL); $this->app->authentication('jsonrpc', API_KEY); - $this->app->debug = true; + // $this->app->debug = true; $this->admin = new JsonRPC\Client(API_URL); $this->admin->authentication('admin', 'admin'); - $this->admin->debug = true; + // $this->admin->debug = true; $this->user = new JsonRPC\Client(API_URL); $this->user->authentication('user', 'password'); - $this->user->debug = true; + // $this->user->debug = true; } public function testCreateProject() diff --git a/tests/php.ini b/tests/php.ini index 7079a4e6..9f683297 100644 --- a/tests/php.ini +++ b/tests/php.ini @@ -1,2 +1,5 @@ short_open_tag = On -date.timezone = UTC
\ No newline at end of file +date.timezone = UTC +opcache.enable = Off +opcache.enable_cli = Off +extension=ldap.so
\ No newline at end of file diff --git a/tests/units/ActionCommentCreationTest.php b/tests/units/Action/CommentCreationTest.php index cf9e1e0a..6b5fe1ea 100644 --- a/tests/units/ActionCommentCreationTest.php +++ b/tests/units/Action/CommentCreationTest.php @@ -1,6 +1,6 @@ <?php -require_once __DIR__.'/Base.php'; +require_once __DIR__.'/../Base.php'; use Event\GenericEvent; use Model\Task; @@ -9,7 +9,7 @@ use Model\Comment; use Model\Project; use Integration\GithubWebhook; -class ActionCommentCreationTest extends Base +class CommentCreationTest extends Base { public function testWithoutRequiredParams() { diff --git a/tests/units/ActionTaskAssignColorCategoryTest.php b/tests/units/Action/TaskAssignColorCategoryTest.php index 3669ce46..44d23943 100644 --- a/tests/units/ActionTaskAssignColorCategoryTest.php +++ b/tests/units/Action/TaskAssignColorCategoryTest.php @@ -1,6 +1,6 @@ <?php -require_once __DIR__.'/Base.php'; +require_once __DIR__.'/../Base.php'; use Model\Task; use Model\TaskCreation; @@ -9,7 +9,7 @@ use Model\Project; use Model\Category; use Event\GenericEvent; -class ActionTaskAssignColorCategory extends Base +class TaskAssignColorCategory extends Base { public function testBadProject() { diff --git a/tests/units/ActionTaskAssignColorColumnTest.php b/tests/units/Action/TaskAssignColorColumnTest.php index 363bb05c..55767327 100644 --- a/tests/units/ActionTaskAssignColorColumnTest.php +++ b/tests/units/Action/TaskAssignColorColumnTest.php @@ -1,6 +1,6 @@ <?php -require_once __DIR__.'/Base.php'; +require_once __DIR__.'/../Base.php'; use Event\GenericEvent; use Model\Task; @@ -8,7 +8,7 @@ use Model\TaskCreation; use Model\TaskFinder; use Model\Project; -class ActionTaskAssignColorColumnTest extends Base +class TaskAssignColorColumnTest extends Base { public function testColorChange() { diff --git a/tests/units/ActionTaskAssignColorLinkTest.php b/tests/units/Action/TaskAssignColorLinkTest.php index b0cd269e..c78af5bb 100644 --- a/tests/units/ActionTaskAssignColorLinkTest.php +++ b/tests/units/Action/TaskAssignColorLinkTest.php @@ -1,6 +1,6 @@ <?php -require_once __DIR__.'/Base.php'; +require_once __DIR__.'/../Base.php'; use Event\TaskLinkEvent; use Model\Task; @@ -9,7 +9,7 @@ use Model\TaskFinder; use Model\TaskLink; use Model\Project; -class ActionTaskAssignColorLinkTest extends Base +class TaskAssignColorLinkTest extends Base { public function testExecute() { diff --git a/tests/units/ActionTaskAssignColorUserTest.php b/tests/units/Action/TaskAssignColorUserTest.php index c1bf3a34..896b48fc 100644 --- a/tests/units/ActionTaskAssignColorUserTest.php +++ b/tests/units/Action/TaskAssignColorUserTest.php @@ -1,6 +1,6 @@ <?php -require_once __DIR__.'/Base.php'; +require_once __DIR__.'/../Base.php'; use Model\Task; use Model\TaskCreation; @@ -8,7 +8,7 @@ use Model\TaskFinder; use Model\Project; use Event\GenericEvent; -class ActionTaskAssignColorUser extends Base +class TaskAssignColorUser extends Base { public function testBadProject() { diff --git a/tests/units/ActionTaskAssignCurrentUserTest.php b/tests/units/Action/TaskAssignCurrentUserTest.php index f32fc77c..9ea816d4 100644 --- a/tests/units/ActionTaskAssignCurrentUserTest.php +++ b/tests/units/Action/TaskAssignCurrentUserTest.php @@ -1,6 +1,6 @@ <?php -require_once __DIR__.'/Base.php'; +require_once __DIR__.'/../Base.php'; use Event\GenericEvent; use Model\Task; @@ -9,7 +9,7 @@ use Model\TaskFinder; use Model\Project; use Model\UserSession; -class ActionTaskAssignCurrentUser extends Base +class TaskAssignCurrentUser extends Base { public function testBadProject() { diff --git a/tests/units/ActionTaskAssignSpecificUserTest.php b/tests/units/Action/TaskAssignSpecificUserTest.php index ac054ba6..ae8de177 100644 --- a/tests/units/ActionTaskAssignSpecificUserTest.php +++ b/tests/units/Action/TaskAssignSpecificUserTest.php @@ -1,6 +1,6 @@ <?php -require_once __DIR__.'/Base.php'; +require_once __DIR__.'/../Base.php'; use Event\GenericEvent; use Model\Task; @@ -8,7 +8,7 @@ use Model\TaskCreation; use Model\TaskFinder; use Model\Project; -class ActionTaskAssignSpecificUser extends Base +class TaskAssignSpecificUser extends Base { public function testBadProject() { diff --git a/tests/units/ActionTaskCloseTest.php b/tests/units/Action/TaskCloseTest.php index 7f2c42de..8cee6f13 100644 --- a/tests/units/ActionTaskCloseTest.php +++ b/tests/units/Action/TaskCloseTest.php @@ -1,6 +1,6 @@ <?php -require_once __DIR__.'/Base.php'; +require_once __DIR__.'/../Base.php'; use Event\GenericEvent; use Model\Task; @@ -9,7 +9,7 @@ use Model\TaskFinder; use Model\Project; use Integration\GithubWebhook; -class ActionTaskCloseTest extends Base +class TaskCloseTest extends Base { public function testExecutable() { diff --git a/tests/units/ActionTaskDuplicateAnotherProjectTest.php b/tests/units/Action/TaskDuplicateAnotherProjectTest.php index 10c7c36a..37eb4052 100644 --- a/tests/units/ActionTaskDuplicateAnotherProjectTest.php +++ b/tests/units/Action/TaskDuplicateAnotherProjectTest.php @@ -1,6 +1,6 @@ <?php -require_once __DIR__.'/Base.php'; +require_once __DIR__.'/../Base.php'; use Event\GenericEvent; use Model\Task; @@ -8,7 +8,7 @@ use Model\TaskCreation; use Model\TaskFinder; use Model\Project; -class ActionTaskDuplicateAnotherProject extends Base +class TaskDuplicateAnotherProject extends Base { public function testBadProject() { diff --git a/tests/units/ActionTaskEmailTest.php b/tests/units/Action/TaskEmailTest.php index adc74512..d74e1af2 100644 --- a/tests/units/ActionTaskEmailTest.php +++ b/tests/units/Action/TaskEmailTest.php @@ -1,6 +1,6 @@ <?php -require_once __DIR__.'/Base.php'; +require_once __DIR__.'/../Base.php'; use Event\GenericEvent; use Model\Task; @@ -9,7 +9,7 @@ use Model\TaskFinder; use Model\Project; use Model\User; -class ActionTaskEmailTest extends Base +class TaskEmailTest extends Base { public function testNoEmail() { diff --git a/tests/units/ActionTaskMoveAnotherProjectTest.php b/tests/units/Action/TaskMoveAnotherProjectTest.php index 3f0c3de6..78bc6570 100644 --- a/tests/units/ActionTaskMoveAnotherProjectTest.php +++ b/tests/units/Action/TaskMoveAnotherProjectTest.php @@ -1,6 +1,6 @@ <?php -require_once __DIR__.'/Base.php'; +require_once __DIR__.'/../Base.php'; use Event\GenericEvent; use Model\Task; @@ -8,7 +8,7 @@ use Model\TaskCreation; use Model\TaskFinder; use Model\Project; -class ActionTaskMoveAnotherProject extends Base +class TaskMoveAnotherProject extends Base { public function testBadProject() { diff --git a/tests/units/ActionTaskMoveColumnCategoryChangeTest.php b/tests/units/Action/TaskMoveColumnCategoryChangeTest.php index 0ddee786..4b7dec68 100644 --- a/tests/units/ActionTaskMoveColumnCategoryChangeTest.php +++ b/tests/units/Action/TaskMoveColumnCategoryChangeTest.php @@ -1,6 +1,6 @@ <?php -require_once __DIR__.'/Base.php'; +require_once __DIR__.'/../Base.php'; use Event\GenericEvent; use Model\Task; @@ -10,7 +10,7 @@ use Model\Project; use Model\Category; use Integration\GithubWebhook; -class ActionTaskMoveColumnCategoryChangeTest extends Base +class TaskMoveColumnCategoryChangeTest extends Base { public function testExecute() { diff --git a/tests/units/ActionTaskUpdateStartDateTest.php b/tests/units/Action/TaskUpdateStartDateTest.php index a7df820f..14f3b5b7 100644 --- a/tests/units/ActionTaskUpdateStartDateTest.php +++ b/tests/units/Action/TaskUpdateStartDateTest.php @@ -1,6 +1,6 @@ <?php -require_once __DIR__.'/Base.php'; +require_once __DIR__.'/../Base.php'; use Event\GenericEvent; use Model\Task; @@ -8,7 +8,7 @@ use Model\TaskCreation; use Model\TaskFinder; use Model\Project; -class ActionTaskUpdateStartDateTest extends Base +class TaskUpdateStartDateTest extends Base { public function testExecute() { diff --git a/tests/units/Auth/LdapTest.php b/tests/units/Auth/LdapTest.php new file mode 100644 index 00000000..a52b8cf8 --- /dev/null +++ b/tests/units/Auth/LdapTest.php @@ -0,0 +1,678 @@ +<?php + +namespace Auth; + +require_once __DIR__.'/../Base.php'; + +function ldap_connect($hostname, $port) +{ + return LdapTest::$functions->ldap_connect($hostname, $port); +} + +function ldap_set_option() +{ +} + +function ldap_bind($link_identifier, $bind_rdn, $bind_password) +{ + return LdapTest::$functions->ldap_bind($link_identifier, $bind_rdn, $bind_password); +} + +function ldap_search($link_identifier, $base_dn, $filter, array $attributes) +{ + return LdapTest::$functions->ldap_search($link_identifier, $base_dn, $filter, $attributes); +} + +function ldap_get_entries($link_identifier, $result_identifier) +{ + return LdapTest::$functions->ldap_get_entries($link_identifier, $result_identifier); +} + +class LdapTest extends \Base +{ + public static $functions; + private $ldap; + + public function setUp() + { + parent::setup(); + + self::$functions = $this + ->getMockBuilder('stdClass') + ->setMethods(array( + 'ldap_connect', + 'ldap_set_option', + 'ldap_bind', + 'ldap_search', + 'ldap_get_entries', + )) + ->getMock(); + } + + public function tearDown() + { + parent::tearDown(); + self::$functions = null; + } + + public function testGetAttributes() + { + $ldap = new Ldap($this->container); + $this->assertCount(3, $ldap->getProfileAttributes()); + $this->assertContains(LDAP_ACCOUNT_FULLNAME, $ldap->getProfileAttributes()); + $this->assertContains(LDAP_ACCOUNT_EMAIL, $ldap->getProfileAttributes()); + $this->assertContains(LDAP_ACCOUNT_MEMBEROF, $ldap->getProfileAttributes()); + } + + public function testConnectSuccess() + { + $ldap = $this + ->getMockBuilder('\Auth\Ldap') + ->setConstructorArgs(array($this->container)) + ->setMethods(array('getLdapServer')) + ->getMock(); + + $ldap + ->expects($this->once()) + ->method('getLdapServer') + ->will($this->returnValue('my_ldap_server')); + + self::$functions + ->expects($this->once()) + ->method('ldap_connect') + ->with( + $this->equalTo('my_ldap_server'), + $this->equalTo($ldap->getLdapPort()) + ) + ->will($this->returnValue('my_ldap_resource')); + + $this->assertNotFalse($ldap->connect()); + } + + public function testConnectFailure() + { + $ldap = $this + ->getMockBuilder('\Auth\Ldap') + ->setConstructorArgs(array($this->container)) + ->setMethods(array('getLdapServer')) + ->getMock(); + + $ldap + ->expects($this->once()) + ->method('getLdapServer') + ->will($this->returnValue('my_ldap_server')); + + self::$functions + ->expects($this->once()) + ->method('ldap_connect') + ->with( + $this->equalTo('my_ldap_server'), + $this->equalTo($ldap->getLdapPort()) + ) + ->will($this->returnValue(false)); + + $this->assertFalse($ldap->connect()); + } + + public function testBindAnonymous() + { + $ldap = new Ldap($this->container); + + self::$functions + ->expects($this->once()) + ->method('ldap_bind') + ->with( + $this->equalTo('my_ldap_connection'), + $this->equalTo(null), + $this->equalTo(null) + ) + ->will($this->returnValue(true)); + + $this->assertTrue($ldap->bind('my_ldap_connection', 'my_user', 'my_password', 'anonymous')); + } + + public function testBindUser() + { + $ldap = $this + ->getMockBuilder('\Auth\Ldap') + ->setConstructorArgs(array($this->container)) + ->setMethods(array('getLdapUserPattern')) + ->getMock(); + + $ldap + ->expects($this->once()) + ->method('getLdapUserPattern') + ->will($this->returnValue('uid=my_user')); + + self::$functions + ->expects($this->once()) + ->method('ldap_bind') + ->with( + $this->equalTo('my_ldap_connection'), + $this->equalTo('uid=my_user'), + $this->equalTo('my_password') + ) + ->will($this->returnValue(true)); + + $this->assertTrue($ldap->bind('my_ldap_connection', 'my_user', 'my_password', 'user')); + } + + public function testBindProxy() + { + $ldap = $this + ->getMockBuilder('\Auth\Ldap') + ->setConstructorArgs(array($this->container)) + ->setMethods(array('getLdapUsername', 'getLdapPassword')) + ->getMock(); + + $ldap + ->expects($this->once()) + ->method('getLdapUsername') + ->will($this->returnValue('someone')); + + $ldap + ->expects($this->once()) + ->method('getLdapPassword') + ->will($this->returnValue('something')); + + self::$functions + ->expects($this->once()) + ->method('ldap_bind') + ->with( + $this->equalTo('my_ldap_connection'), + $this->equalTo('someone'), + $this->equalTo('something') + ) + ->will($this->returnValue(true)); + + $this->assertTrue($ldap->bind('my_ldap_connection', 'my_user', 'my_password', 'proxy')); + } + + public function testSearchSuccess() + { + $entries = array( + 'count' => 1, + 0 => array( + 'count' => 2, + 'dn' => 'uid=my_user,ou=People,dc=kanboard,dc=local', + 'displayname' => array( + 'count' => 1, + 0 => 'My user', + ), + 'mail' => array( + 'count' => 2, + 0 => 'user1@localhost', + 1 => 'user2@localhost', + ), + 0 => 'displayname', + 1 => 'mail', + ) + ); + + $expected = array( + 'username' => 'my_user', + 'name' => 'My user', + 'email' => 'user1@localhost', + 'is_admin' => 0, + 'is_project_admin' => 0, + 'is_ldap_user' => 1, + ); + + $ldap = $this + ->getMockBuilder('\Auth\Ldap') + ->setConstructorArgs(array($this->container)) + ->setMethods(array('getLdapUserPattern', 'getLdapBaseDn')) + ->getMock(); + + $ldap + ->expects($this->once()) + ->method('getLdapUserPattern') + ->will($this->returnValue('uid=my_user')); + + $ldap + ->expects($this->once()) + ->method('getLdapBaseDn') + ->will($this->returnValue('ou=People,dc=kanboard,dc=local')); + + self::$functions + ->expects($this->at(0)) + ->method('ldap_search') + ->with( + $this->equalTo('my_ldap_connection'), + $this->equalTo('ou=People,dc=kanboard,dc=local'), + $this->equalTo('uid=my_user'), + $this->equalTo($ldap->getProfileAttributes()) + ) + ->will($this->returnValue('my_result_identifier')); + + self::$functions + ->expects($this->at(1)) + ->method('ldap_get_entries') + ->with( + $this->equalTo('my_ldap_connection'), + $this->equalTo('my_result_identifier') + ) + ->will($this->returnValue($entries)); + + self::$functions + ->expects($this->at(2)) + ->method('ldap_bind') + ->with( + $this->equalTo('my_ldap_connection'), + $this->equalTo('uid=my_user,ou=People,dc=kanboard,dc=local'), + $this->equalTo('my_password') + ) + ->will($this->returnValue(true)); + + $this->assertEquals($expected, $ldap->getProfile('my_ldap_connection', 'my_user', 'my_password')); + } + + public function testSearchWithBadPassword() + { + $entries = array( + 'count' => 1, + 0 => array( + 'count' => 2, + 'dn' => 'uid=my_user,ou=People,dc=kanboard,dc=local', + 'displayname' => array( + 'count' => 1, + 0 => 'My user', + ), + 'mail' => array( + 'count' => 2, + 0 => 'user1@localhost', + 1 => 'user2@localhost', + ), + 0 => 'displayname', + 1 => 'mail', + ) + ); + + $ldap = $this + ->getMockBuilder('\Auth\Ldap') + ->setConstructorArgs(array($this->container)) + ->setMethods(array('getLdapUserPattern', 'getLdapBaseDn')) + ->getMock(); + + $ldap + ->expects($this->once()) + ->method('getLdapUserPattern') + ->will($this->returnValue('uid=my_user')); + + $ldap + ->expects($this->once()) + ->method('getLdapBaseDn') + ->will($this->returnValue('ou=People,dc=kanboard,dc=local')); + + self::$functions + ->expects($this->at(0)) + ->method('ldap_search') + ->with( + $this->equalTo('my_ldap_connection'), + $this->equalTo('ou=People,dc=kanboard,dc=local'), + $this->equalTo('uid=my_user'), + $this->equalTo($ldap->getProfileAttributes()) + ) + ->will($this->returnValue('my_result_identifier')); + + self::$functions + ->expects($this->at(1)) + ->method('ldap_get_entries') + ->with( + $this->equalTo('my_ldap_connection'), + $this->equalTo('my_result_identifier') + ) + ->will($this->returnValue($entries)); + + self::$functions + ->expects($this->at(2)) + ->method('ldap_bind') + ->with( + $this->equalTo('my_ldap_connection'), + $this->equalTo('uid=my_user,ou=People,dc=kanboard,dc=local'), + $this->equalTo('my_password') + ) + ->will($this->returnValue(false)); + + $this->assertFalse($ldap->getProfile('my_ldap_connection', 'my_user', 'my_password')); + } + + public function testSearchWithUserNotFound() + { + $ldap = $this + ->getMockBuilder('\Auth\Ldap') + ->setConstructorArgs(array($this->container)) + ->setMethods(array('getLdapUserPattern', 'getLdapBaseDn')) + ->getMock(); + + $ldap + ->expects($this->once()) + ->method('getLdapUserPattern') + ->will($this->returnValue('uid=my_user')); + + $ldap + ->expects($this->once()) + ->method('getLdapBaseDn') + ->will($this->returnValue('ou=People,dc=kanboard,dc=local')); + + self::$functions + ->expects($this->at(0)) + ->method('ldap_search') + ->with( + $this->equalTo('my_ldap_connection'), + $this->equalTo('ou=People,dc=kanboard,dc=local'), + $this->equalTo('uid=my_user'), + $this->equalTo($ldap->getProfileAttributes()) + ) + ->will($this->returnValue('my_result_identifier')); + + self::$functions + ->expects($this->at(1)) + ->method('ldap_get_entries') + ->with( + $this->equalTo('my_ldap_connection'), + $this->equalTo('my_result_identifier') + ) + ->will($this->returnValue(array())); + + $this->assertFalse($ldap->getProfile('my_ldap_connection', 'my_user', 'my_password')); + } + + public function testSuccessfulAuthentication() + { + $this->container['userSession'] = $this + ->getMockBuilder('\Model\UserSession') + ->setConstructorArgs(array($this->container)) + ->setMethods(array('refresh')) + ->getMock(); + + $this->container['user'] = $this + ->getMockBuilder('\Model\User') + ->setConstructorArgs(array($this->container)) + ->setMethods(array('getByUsername')) + ->getMock(); + + $ldap = $this + ->getMockBuilder('\Auth\Ldap') + ->setConstructorArgs(array($this->container)) + ->setMethods(array('findUser')) + ->getMock(); + + $ldap + ->expects($this->once()) + ->method('findUser') + ->with( + $this->equalTo('user'), + $this->equalTo('password') + ) + ->will($this->returnValue(array('username' => 'user', 'name' => 'My user', 'email' => 'user@here'))); + + $this->container['user'] + ->expects($this->once()) + ->method('getByUsername') + ->with( + $this->equalTo('user') + ) + ->will($this->returnValue(array('id' => 2, 'username' => 'user', 'is_ldap_user' => 1))); + + $this->container['userSession'] + ->expects($this->once()) + ->method('refresh'); + + $this->assertTrue($ldap->authenticate('user', 'password')); + } + + public function testAuthenticationWithExistingLocalUser() + { + $this->container['userSession'] = $this + ->getMockBuilder('\Model\UserSession') + ->setConstructorArgs(array($this->container)) + ->setMethods(array('refresh')) + ->getMock(); + + $this->container['user'] = $this + ->getMockBuilder('\Model\User') + ->setConstructorArgs(array($this->container)) + ->setMethods(array('getByUsername')) + ->getMock(); + + $ldap = $this + ->getMockBuilder('\Auth\Ldap') + ->setConstructorArgs(array($this->container)) + ->setMethods(array('findUser')) + ->getMock(); + + $ldap + ->expects($this->once()) + ->method('findUser') + ->with( + $this->equalTo('user'), + $this->equalTo('password') + ) + ->will($this->returnValue(array('username' => 'user', 'name' => 'My user', 'email' => 'user@here'))); + + $this->container['user'] + ->expects($this->once()) + ->method('getByUsername') + ->with( + $this->equalTo('user') + ) + ->will($this->returnValue(array('id' => 2, 'username' => 'user', 'is_ldap_user' => 0))); + + $this->container['userSession'] + ->expects($this->never()) + ->method('refresh'); + + $this->assertFalse($ldap->authenticate('user', 'password')); + } + + public function testAuthenticationWithAutomaticAccountCreation() + { + $ldap_profile = array('username' => 'user', 'name' => 'My user', 'email' => 'user@here'); + + $this->container['userSession'] = $this + ->getMockBuilder('\Model\UserSession') + ->setConstructorArgs(array($this->container)) + ->setMethods(array('refresh')) + ->getMock(); + + $this->container['user'] = $this + ->getMockBuilder('\Model\User') + ->setConstructorArgs(array($this->container)) + ->setMethods(array('getByUsername', 'create')) + ->getMock(); + + $ldap = $this + ->getMockBuilder('\Auth\Ldap') + ->setConstructorArgs(array($this->container)) + ->setMethods(array('findUser')) + ->getMock(); + + $ldap + ->expects($this->at(0)) + ->method('findUser') + ->with( + $this->equalTo('user'), + $this->equalTo('password') + ) + ->will($this->returnValue($ldap_profile)); + + $this->container['user'] + ->expects($this->at(0)) + ->method('getByUsername') + ->with( + $this->equalTo('user') + ) + ->will($this->returnValue(null)); + + $this->container['user'] + ->expects($this->at(1)) + ->method('create') + ->with( + $this->equalTo($ldap_profile) + ) + ->will($this->returnValue(true)); + + $this->container['user'] + ->expects($this->at(2)) + ->method('getByUsername') + ->with( + $this->equalTo('user') + ) + ->will($this->returnValue(array('id' => 2, 'username' => 'user', 'is_ldap_user' => 1))); + + $this->container['userSession'] + ->expects($this->once()) + ->method('refresh'); + + $this->assertTrue($ldap->authenticate('user', 'password')); + } + + public function testAuthenticationWithAutomaticAccountCreationFailed() + { + $ldap_profile = array('username' => 'user', 'name' => 'My user', 'email' => 'user@here'); + + $this->container['userSession'] = $this + ->getMockBuilder('\Model\UserSession') + ->setConstructorArgs(array($this->container)) + ->setMethods(array('refresh')) + ->getMock(); + + $this->container['user'] = $this + ->getMockBuilder('\Model\User') + ->setConstructorArgs(array($this->container)) + ->setMethods(array('getByUsername', 'create')) + ->getMock(); + + $ldap = $this + ->getMockBuilder('\Auth\Ldap') + ->setConstructorArgs(array($this->container)) + ->setMethods(array('findUser')) + ->getMock(); + + $ldap + ->expects($this->at(0)) + ->method('findUser') + ->with( + $this->equalTo('user'), + $this->equalTo('password') + ) + ->will($this->returnValue($ldap_profile)); + + $this->container['user'] + ->expects($this->at(0)) + ->method('getByUsername') + ->with( + $this->equalTo('user') + ) + ->will($this->returnValue(null)); + + $this->container['user'] + ->expects($this->at(1)) + ->method('create') + ->with( + $this->equalTo($ldap_profile) + ) + ->will($this->returnValue(false)); + + $this->container['userSession'] + ->expects($this->never()) + ->method('refresh'); + + $this->assertFalse($ldap->authenticate('user', 'password')); + } + + public function testLookup() + { + $entries = array( + 'count' => 1, + 0 => array( + 'count' => 2, + 'dn' => 'uid=my_user,ou=People,dc=kanboard,dc=local', + 'displayname' => array( + 'count' => 1, + 0 => 'My LDAP user', + ), + 'mail' => array( + 'count' => 2, + 0 => 'user1@localhost', + 1 => 'user2@localhost', + ), + 'samaccountname' => array( + 'count' => 1, + 0 => 'my_ldap_user', + ), + 0 => 'displayname', + 1 => 'mail', + 2 => 'samaccountname', + ) + ); + + $expected = array( + 'username' => 'my_ldap_user', + 'name' => 'My LDAP user', + 'email' => 'user1@localhost', + 'is_admin' => 0, + 'is_project_admin' => 0, + 'is_ldap_user' => 1, + ); + + $ldap = $this + ->getMockBuilder('\Auth\Ldap') + ->setConstructorArgs(array($this->container)) + ->setMethods(array('connect', 'getLdapUserPattern', 'getLdapBaseDn', 'getLdapAccountId')) + ->getMock(); + + $ldap + ->expects($this->once()) + ->method('connect') + ->will($this->returnValue('my_ldap_connection')); + + $ldap + ->expects($this->once()) + ->method('getLdapUserPattern') + ->will($this->returnValue('sAMAccountName=my_user')); + + $ldap + ->expects($this->any()) + ->method('getLdapAccountId') + ->will($this->returnValue('samaccountname')); + + $ldap + ->expects($this->once()) + ->method('getLdapBaseDn') + ->will($this->returnValue('ou=People,dc=kanboard,dc=local')); + + self::$functions + ->expects($this->at(0)) + ->method('ldap_bind') + ->with( + $this->equalTo('my_ldap_connection'), + $this->equalTo(null), + $this->equalTo(null) + ) + ->will($this->returnValue(true)); + + self::$functions + ->expects($this->at(1)) + ->method('ldap_search') + ->with( + $this->equalTo('my_ldap_connection'), + $this->equalTo('ou=People,dc=kanboard,dc=local'), + $this->equalTo('(&(sAMAccountName=my_user)(mail=user@localhost))'), + $this->equalTo($ldap->getProfileAttributes()) + ) + ->will($this->returnValue('my_result_identifier')); + + self::$functions + ->expects($this->at(2)) + ->method('ldap_get_entries') + ->with( + $this->equalTo('my_ldap_connection'), + $this->equalTo('my_result_identifier') + ) + ->will($this->returnValue($entries)); + + $this->assertEquals($expected, $ldap->lookup('my_user', 'user@localhost')); + } +} diff --git a/tests/units/Auth/ReverseProxyTest.php b/tests/units/Auth/ReverseProxyTest.php new file mode 100644 index 00000000..bbab7c0d --- /dev/null +++ b/tests/units/Auth/ReverseProxyTest.php @@ -0,0 +1,37 @@ +<?php + +require_once __DIR__.'/../Base.php'; + +use Auth\ReverseProxy; +use Model\User; + +class ReverseProxyTest extends Base +{ + public function setUp() + { + parent::setup(); + $_SERVER = array(); + } + + public function testFailedAuthentication() + { + $auth = new ReverseProxy($this->container); + $this->assertFalse($auth->authenticate()); + } + + public function testSuccessfulAuthentication() + { + $_SERVER[REVERSE_PROXY_USER_HEADER] = 'my_user'; + + $a = new ReverseProxy($this->container); + $u = new User($this->container); + + $this->assertTrue($a->authenticate()); + + $user = $u->getByUsername('my_user'); + $this->assertNotEmpty($user); + $this->assertEquals(0, $user['is_admin']); + $this->assertEquals(1, $user['is_ldap_user']); + $this->assertEquals(1, $user['disable_login_form']); + } +} diff --git a/tests/units/LexerTest.php b/tests/units/Core/LexerTest.php index 3b15810e..044655fc 100644 --- a/tests/units/LexerTest.php +++ b/tests/units/Core/LexerTest.php @@ -1,6 +1,6 @@ <?php -require_once __DIR__.'/Base.php'; +require_once __DIR__.'/../Base.php'; use Core\Lexer; diff --git a/tests/units/OAuth2Test.php b/tests/units/Core/OAuth2Test.php index 0275f426..a0e4b43f 100644 --- a/tests/units/OAuth2Test.php +++ b/tests/units/Core/OAuth2Test.php @@ -1,6 +1,6 @@ <?php -require_once __DIR__.'/Base.php'; +require_once __DIR__.'/../Base.php'; use Core\OAuth2; diff --git a/tests/units/Core/PluginLoaderTest.php b/tests/units/Core/PluginLoaderTest.php new file mode 100644 index 00000000..62327f01 --- /dev/null +++ b/tests/units/Core/PluginLoaderTest.php @@ -0,0 +1,23 @@ +<?php + +require_once __DIR__.'/../Base.php'; + +use Core\PluginLoader; + +class PluginLoaderTest extends Base +{ + public function testGetSchemaVersion() + { + $p = new PluginLoader($this->container); + $this->assertEquals(0, $p->getSchemaVersion('not_found')); + + $this->assertTrue($p->setSchemaVersion('plugin1', 1)); + $this->assertEquals(1, $p->getSchemaVersion('plugin1')); + + $this->assertTrue($p->setSchemaVersion('plugin2', 33)); + $this->assertEquals(33, $p->getSchemaVersion('plugin2')); + + $this->assertTrue($p->setSchemaVersion('plugin1', 2)); + $this->assertEquals(2, $p->getSchemaVersion('plugin1')); + } +} diff --git a/tests/units/RouterTest.php b/tests/units/Core/RouterTest.php index e4582121..99c49ba8 100644 --- a/tests/units/RouterTest.php +++ b/tests/units/Core/RouterTest.php @@ -1,6 +1,6 @@ <?php -require_once __DIR__.'/Base.php'; +require_once __DIR__.'/../Base.php'; use Core\Router; diff --git a/tests/units/Core/TemplateTest.php b/tests/units/Core/TemplateTest.php new file mode 100644 index 00000000..9833397b --- /dev/null +++ b/tests/units/Core/TemplateTest.php @@ -0,0 +1,28 @@ +<?php + +require_once __DIR__.'/../Base.php'; + +use Core\Template; + +class TemplateTest extends Base +{ + public function testGetTemplateFile() + { + $t = new Template($this->container); + $this->assertStringEndsWith('app/Core/../Template/a/b.php', $t->getTemplateFile('a/b')); + } + + public function testGetPluginTemplateFile() + { + $t = new Template($this->container); + $this->assertStringEndsWith('app/Core/../../plugins/Myplugin/Template/a/b.php', $t->getTemplateFile('myplugin:a/b')); + } + + public function testGetOverridedTemplateFile() + { + $t = new Template($this->container); + $t->setTemplateOverride('a/b', 'myplugin:c'); + $this->assertStringEndsWith('app/Core/../../plugins/Myplugin/Template/c.php', $t->getTemplateFile('a/b')); + $this->assertStringEndsWith('app/Core/../Template/d.php', $t->getTemplateFile('d')); + } +} diff --git a/tests/units/ToolTest.php b/tests/units/Core/ToolTest.php index 4a62fe3b..e714f506 100644 --- a/tests/units/ToolTest.php +++ b/tests/units/Core/ToolTest.php @@ -1,6 +1,6 @@ <?php -require_once __DIR__.'/Base.php'; +require_once __DIR__.'/../Base.php'; use Core\Tool; diff --git a/tests/units/AppHelperTest.php b/tests/units/Helper/AppHelperTest.php index ad4bc151..54ccd697 100644 --- a/tests/units/AppHelperTest.php +++ b/tests/units/Helper/AppHelperTest.php @@ -1,6 +1,6 @@ <?php -require_once __DIR__.'/Base.php'; +require_once __DIR__.'/../Base.php'; use Core\Session; use Helper\App; diff --git a/tests/units/AssetHelperTest.php b/tests/units/Helper/AssetHelperTest.php index 1143ce1f..ece81d04 100644 --- a/tests/units/AssetHelperTest.php +++ b/tests/units/Helper/AssetHelperTest.php @@ -1,6 +1,6 @@ <?php -require_once __DIR__.'/Base.php'; +require_once __DIR__.'/../Base.php'; use Helper\Asset; use Model\Config; diff --git a/tests/units/DatetimeHelperTest.php b/tests/units/Helper/DatetimeHelperTest.php index 21d452dd..d4fc3c3d 100644 --- a/tests/units/DatetimeHelperTest.php +++ b/tests/units/Helper/DatetimeHelperTest.php @@ -1,6 +1,6 @@ <?php -require_once __DIR__.'/Base.php'; +require_once __DIR__.'/../Base.php'; use Helper\Dt; diff --git a/tests/units/FileHelperText.php b/tests/units/Helper/FileHelperText.php index ce04fdbd..cd5ebffd 100644 --- a/tests/units/FileHelperText.php +++ b/tests/units/Helper/FileHelperText.php @@ -1,6 +1,6 @@ <?php -require_once __DIR__.'/Base.php'; +require_once __DIR__.'/../Base.php'; use Helper\File; diff --git a/tests/units/TextHelperTest.php b/tests/units/Helper/TextHelperTest.php index 95c83e57..5495cd1c 100644 --- a/tests/units/TextHelperTest.php +++ b/tests/units/Helper/TextHelperTest.php @@ -1,6 +1,6 @@ <?php -require_once __DIR__.'/Base.php'; +require_once __DIR__.'/../Base.php'; use Helper\Text; diff --git a/tests/units/UrlHelperTest.php b/tests/units/Helper/UrlHelperTest.php index ebfe9c99..5c2477b5 100644 --- a/tests/units/UrlHelperTest.php +++ b/tests/units/Helper/UrlHelperTest.php @@ -1,6 +1,6 @@ <?php -require_once __DIR__.'/Base.php'; +require_once __DIR__.'/../Base.php'; use Helper\Url; use Model\Config; diff --git a/tests/units/UserHelperTest.php b/tests/units/Helper/UserHelperTest.php index 9129edd9..947f606a 100644 --- a/tests/units/UserHelperTest.php +++ b/tests/units/Helper/UserHelperTest.php @@ -1,6 +1,6 @@ <?php -require_once __DIR__.'/Base.php'; +require_once __DIR__.'/../Base.php'; use Helper\User; diff --git a/tests/units/HourlyRate.php b/tests/units/HourlyRate.php deleted file mode 100644 index 5daf0446..00000000 --- a/tests/units/HourlyRate.php +++ /dev/null @@ -1,43 +0,0 @@ -<?php - -require_once __DIR__.'/Base.php'; - -use Model\User; -use Model\HourlyRate; - -class HourlyRateTest extends Base -{ - public function testCreation() - { - $hr = new HourlyRate($this->container); - $this->assertEquals(1, $hr->create(1, 32.4, 'EUR', '2015-01-01')); - $this->assertEquals(2, $hr->create(1, 42, 'CAD', '2015-02-01')); - - $rates = $hr->getAllByUser(0); - $this->assertEmpty($rates); - - $rates = $hr->getAllByUser(1); - $this->assertNotEmpty($rates); - $this->assertCount(2, $rates); - - $this->assertEquals(42, $rates[0]['rate']); - $this->assertEquals('CAD', $rates[0]['currency']); - $this->assertEquals('2015-02-01', date('Y-m-d', $rates[0]['date_effective'])); - - $this->assertEquals(32.4, $rates[1]['rate']); - $this->assertEquals('EUR', $rates[1]['currency']); - $this->assertEquals('2015-01-01', date('Y-m-d', $rates[1]['date_effective'])); - - $this->assertEquals(0, $hr->getCurrentRate(0)); - $this->assertEquals(42, $hr->getCurrentRate(1)); - - $this->assertTrue($hr->remove(2)); - $this->assertEquals(32.4, $hr->getCurrentRate(1)); - - $this->assertTrue($hr->remove(1)); - $this->assertEquals(0, $hr->getCurrentRate(1)); - - $rates = $hr->getAllByUser(1); - $this->assertEmpty($rates); - } -} diff --git a/tests/units/BitbucketWebhookTest.php b/tests/units/Integration/BitbucketWebhookTest.php index afc8be1d..1902f738 100644 --- a/tests/units/BitbucketWebhookTest.php +++ b/tests/units/Integration/BitbucketWebhookTest.php @@ -1,6 +1,6 @@ <?php -require_once __DIR__.'/Base.php'; +require_once __DIR__.'/../Base.php'; use Integration\BitbucketWebhook; use Model\TaskCreation; @@ -18,7 +18,7 @@ class BitbucketWebhookTest extends Base $tc = new TaskCreation($this->container); $p = new Project($this->container); $bw = new BitbucketWebhook($this->container); - $payload = json_decode(file_get_contents(__DIR__.'/fixtures/bitbucket_push.json'), true); + $payload = json_decode(file_get_contents(__DIR__.'/../fixtures/bitbucket_push.json'), true); $this->assertEquals(1, $p->create(array('name' => 'test'))); $bw->setProjectId(1); @@ -50,7 +50,7 @@ class BitbucketWebhookTest extends Base $this->assertNotFalse($bw->parsePayload( 'issue:created', - json_decode(file_get_contents(__DIR__.'/fixtures/bitbucket_issue_opened.json'), true) + json_decode(file_get_contents(__DIR__.'/../fixtures/bitbucket_issue_opened.json'), true) )); } @@ -69,7 +69,7 @@ class BitbucketWebhookTest extends Base $this->assertNotFalse($g->parsePayload( 'issue:comment_created', - json_decode(file_get_contents(__DIR__.'/fixtures/bitbucket_comment_created.json'), true) + json_decode(file_get_contents(__DIR__.'/../fixtures/bitbucket_comment_created.json'), true) )); } @@ -91,7 +91,7 @@ class BitbucketWebhookTest extends Base $this->assertNotFalse($g->parsePayload( 'issue:comment_created', - json_decode(file_get_contents(__DIR__.'/fixtures/bitbucket_comment_created.json'), true) + json_decode(file_get_contents(__DIR__.'/../fixtures/bitbucket_comment_created.json'), true) )); } @@ -116,7 +116,7 @@ class BitbucketWebhookTest extends Base $this->assertNotFalse($g->parsePayload( 'issue:comment_created', - json_decode(file_get_contents(__DIR__.'/fixtures/bitbucket_comment_created.json'), true) + json_decode(file_get_contents(__DIR__.'/../fixtures/bitbucket_comment_created.json'), true) )); } @@ -135,7 +135,7 @@ class BitbucketWebhookTest extends Base $this->assertNotFalse($g->parsePayload( 'issue:updated', - json_decode(file_get_contents(__DIR__.'/fixtures/bitbucket_issue_closed.json'), true) + json_decode(file_get_contents(__DIR__.'/../fixtures/bitbucket_issue_closed.json'), true) )); } @@ -154,7 +154,7 @@ class BitbucketWebhookTest extends Base $this->assertFalse($g->parsePayload( 'issue:updated', - json_decode(file_get_contents(__DIR__.'/fixtures/bitbucket_issue_closed.json'), true) + json_decode(file_get_contents(__DIR__.'/../fixtures/bitbucket_issue_closed.json'), true) )); $this->assertEmpty($this->container['dispatcher']->getCalledListeners()); @@ -175,7 +175,7 @@ class BitbucketWebhookTest extends Base $this->assertNotFalse($g->parsePayload( 'issue:updated', - json_decode(file_get_contents(__DIR__.'/fixtures/bitbucket_issue_reopened.json'), true) + json_decode(file_get_contents(__DIR__.'/../fixtures/bitbucket_issue_reopened.json'), true) )); } @@ -194,7 +194,7 @@ class BitbucketWebhookTest extends Base $this->assertFalse($g->parsePayload( 'issue:updated', - json_decode(file_get_contents(__DIR__.'/fixtures/bitbucket_issue_reopened.json'), true) + json_decode(file_get_contents(__DIR__.'/../fixtures/bitbucket_issue_reopened.json'), true) )); $this->assertEmpty($this->container['dispatcher']->getCalledListeners()); @@ -215,7 +215,7 @@ class BitbucketWebhookTest extends Base $this->assertNotFalse($g->parsePayload( 'issue:updated', - json_decode(file_get_contents(__DIR__.'/fixtures/bitbucket_issue_unassigned.json'), true) + json_decode(file_get_contents(__DIR__.'/../fixtures/bitbucket_issue_unassigned.json'), true) )); } @@ -240,7 +240,7 @@ class BitbucketWebhookTest extends Base $this->assertNotFalse($g->parsePayload( 'issue:updated', - json_decode(file_get_contents(__DIR__.'/fixtures/bitbucket_issue_assigned.json'), true) + json_decode(file_get_contents(__DIR__.'/../fixtures/bitbucket_issue_assigned.json'), true) )); $this->assertNotEmpty($this->container['dispatcher']->getCalledListeners()); @@ -264,7 +264,7 @@ class BitbucketWebhookTest extends Base $this->assertFalse($g->parsePayload( 'issue:updated', - json_decode(file_get_contents(__DIR__.'/fixtures/bitbucket_issue_assigned.json'), true) + json_decode(file_get_contents(__DIR__.'/../fixtures/bitbucket_issue_assigned.json'), true) )); $this->assertEmpty($this->container['dispatcher']->getCalledListeners()); @@ -285,7 +285,7 @@ class BitbucketWebhookTest extends Base $this->assertFalse($g->parsePayload( 'issue:updated', - json_decode(file_get_contents(__DIR__.'/fixtures/bitbucket_issue_assigned.json'), true) + json_decode(file_get_contents(__DIR__.'/../fixtures/bitbucket_issue_assigned.json'), true) )); $this->assertEmpty($this->container['dispatcher']->getCalledListeners()); @@ -306,7 +306,7 @@ class BitbucketWebhookTest extends Base $this->assertFalse($g->parsePayload( 'issue:updated', - json_decode(file_get_contents(__DIR__.'/fixtures/bitbucket_issue_assigned.json'), true) + json_decode(file_get_contents(__DIR__.'/../fixtures/bitbucket_issue_assigned.json'), true) )); $this->assertEmpty($this->container['dispatcher']->getCalledListeners()); diff --git a/tests/units/GithubWebhookTest.php b/tests/units/Integration/GithubWebhookTest.php index e143cc1d..3b67ad1c 100644 --- a/tests/units/GithubWebhookTest.php +++ b/tests/units/Integration/GithubWebhookTest.php @@ -1,6 +1,6 @@ <?php -require_once __DIR__.'/Base.php'; +require_once __DIR__.'/../Base.php'; use Integration\GithubWebhook; use Model\TaskCreation; @@ -23,7 +23,7 @@ class GithubWebhookTest extends Base $this->assertNotFalse($g->parsePayload( 'issues', - json_decode(file_get_contents(__DIR__.'/fixtures/github_issue_opened.json'), true) + json_decode(file_get_contents(__DIR__.'/../fixtures/github_issue_opened.json'), true) )); } @@ -48,7 +48,7 @@ class GithubWebhookTest extends Base $this->assertNotFalse($g->parsePayload( 'issues', - json_decode(file_get_contents(__DIR__.'/fixtures/github_issue_assigned.json'), true) + json_decode(file_get_contents(__DIR__.'/../fixtures/github_issue_assigned.json'), true) )); } @@ -60,7 +60,7 @@ class GithubWebhookTest extends Base $g = new GithubWebhook($this->container); $g->setProjectId(1); - $payload = json_decode(file_get_contents(__DIR__.'/fixtures/github_issue_assigned.json'), true); + $payload = json_decode(file_get_contents(__DIR__.'/../fixtures/github_issue_assigned.json'), true); $this->assertFalse($g->handleIssueAssigned($payload['issue'])); } @@ -76,7 +76,7 @@ class GithubWebhookTest extends Base $g = new GithubWebhook($this->container); $g->setProjectId(1); - $payload = json_decode(file_get_contents(__DIR__.'/fixtures/github_issue_assigned.json'), true); + $payload = json_decode(file_get_contents(__DIR__.'/../fixtures/github_issue_assigned.json'), true); $this->assertFalse($g->handleIssueAssigned($payload['issue'])); } @@ -95,7 +95,7 @@ class GithubWebhookTest extends Base $g = new GithubWebhook($this->container); $g->setProjectId(1); - $payload = json_decode(file_get_contents(__DIR__.'/fixtures/github_issue_assigned.json'), true); + $payload = json_decode(file_get_contents(__DIR__.'/../fixtures/github_issue_assigned.json'), true); $this->assertFalse($g->handleIssueAssigned($payload['issue'])); } @@ -117,7 +117,7 @@ class GithubWebhookTest extends Base $g = new GithubWebhook($this->container); $g->setProjectId(1); - $payload = json_decode(file_get_contents(__DIR__.'/fixtures/github_issue_assigned.json'), true); + $payload = json_decode(file_get_contents(__DIR__.'/../fixtures/github_issue_assigned.json'), true); $this->assertTrue($g->handleIssueAssigned($payload['issue'])); } @@ -137,7 +137,7 @@ class GithubWebhookTest extends Base $this->assertNotFalse($g->parsePayload( 'issues', - json_decode(file_get_contents(__DIR__.'/fixtures/github_issue_unassigned.json'), true) + json_decode(file_get_contents(__DIR__.'/../fixtures/github_issue_unassigned.json'), true) )); } @@ -156,7 +156,7 @@ class GithubWebhookTest extends Base $this->assertNotFalse($g->parsePayload( 'issues', - json_decode(file_get_contents(__DIR__.'/fixtures/github_issue_closed.json'), true) + json_decode(file_get_contents(__DIR__.'/../fixtures/github_issue_closed.json'), true) )); } @@ -168,7 +168,7 @@ class GithubWebhookTest extends Base $g = new GithubWebhook($this->container); $g->setProjectId(1); - $payload = json_decode(file_get_contents(__DIR__.'/fixtures/github_issue_closed.json'), true); + $payload = json_decode(file_get_contents(__DIR__.'/../fixtures/github_issue_closed.json'), true); $this->assertFalse($g->handleIssueClosed($payload['issue'])); } @@ -188,7 +188,7 @@ class GithubWebhookTest extends Base $this->assertNotFalse($g->parsePayload( 'issues', - json_decode(file_get_contents(__DIR__.'/fixtures/github_issue_reopened.json'), true) + json_decode(file_get_contents(__DIR__.'/../fixtures/github_issue_reopened.json'), true) )); } @@ -200,7 +200,7 @@ class GithubWebhookTest extends Base $g = new GithubWebhook($this->container); $g->setProjectId(1); - $payload = json_decode(file_get_contents(__DIR__.'/fixtures/github_issue_reopened.json'), true); + $payload = json_decode(file_get_contents(__DIR__.'/../fixtures/github_issue_reopened.json'), true); $this->assertFalse($g->handleIssueReopened($payload['issue'])); } @@ -220,7 +220,7 @@ class GithubWebhookTest extends Base $this->assertNotFalse($g->parsePayload( 'issues', - json_decode(file_get_contents(__DIR__.'/fixtures/github_issue_labeled.json'), true) + json_decode(file_get_contents(__DIR__.'/../fixtures/github_issue_labeled.json'), true) )); } @@ -232,7 +232,7 @@ class GithubWebhookTest extends Base $g = new GithubWebhook($this->container); $g->setProjectId(1); - $payload = json_decode(file_get_contents(__DIR__.'/fixtures/github_issue_labeled.json'), true); + $payload = json_decode(file_get_contents(__DIR__.'/../fixtures/github_issue_labeled.json'), true); $this->assertFalse($g->handleIssueLabeled($payload['issue'], $payload['label'])); } @@ -252,7 +252,7 @@ class GithubWebhookTest extends Base $this->assertNotFalse($g->parsePayload( 'issues', - json_decode(file_get_contents(__DIR__.'/fixtures/github_issue_unlabeled.json'), true) + json_decode(file_get_contents(__DIR__.'/../fixtures/github_issue_unlabeled.json'), true) )); } @@ -264,7 +264,7 @@ class GithubWebhookTest extends Base $g = new GithubWebhook($this->container); $g->setProjectId(1); - $payload = json_decode(file_get_contents(__DIR__.'/fixtures/github_issue_unlabeled.json'), true); + $payload = json_decode(file_get_contents(__DIR__.'/../fixtures/github_issue_unlabeled.json'), true); $this->assertFalse($g->handleIssueUnlabeled($payload['issue'], $payload['label'])); } @@ -284,7 +284,7 @@ class GithubWebhookTest extends Base $this->assertNotFalse($g->parsePayload( 'issue_comment', - json_decode(file_get_contents(__DIR__.'/fixtures/github_comment_created.json'), true) + json_decode(file_get_contents(__DIR__.'/../fixtures/github_comment_created.json'), true) )); } @@ -306,7 +306,7 @@ class GithubWebhookTest extends Base $this->assertNotFalse($g->parsePayload( 'issue_comment', - json_decode(file_get_contents(__DIR__.'/fixtures/github_comment_created.json'), true) + json_decode(file_get_contents(__DIR__.'/../fixtures/github_comment_created.json'), true) )); } @@ -331,7 +331,7 @@ class GithubWebhookTest extends Base $this->assertNotFalse($g->parsePayload( 'issue_comment', - json_decode(file_get_contents(__DIR__.'/fixtures/github_comment_created.json'), true) + json_decode(file_get_contents(__DIR__.'/../fixtures/github_comment_created.json'), true) )); } @@ -350,7 +350,7 @@ class GithubWebhookTest extends Base $this->assertNotFalse($g->parsePayload( 'push', - json_decode(file_get_contents(__DIR__.'/fixtures/github_push.json'), true) + json_decode(file_get_contents(__DIR__.'/../fixtures/github_push.json'), true) )); } diff --git a/tests/units/GitlabWebhookTest.php b/tests/units/Integration/GitlabWebhookTest.php index a2dc0d3a..ec073fee 100644 --- a/tests/units/GitlabWebhookTest.php +++ b/tests/units/Integration/GitlabWebhookTest.php @@ -1,6 +1,6 @@ <?php -require_once __DIR__.'/Base.php'; +require_once __DIR__.'/../Base.php'; use Integration\GitlabWebhook; use Model\TaskCreation; @@ -15,9 +15,9 @@ class GitlabWebhookTest extends Base { $g = new GitlabWebhook($this->container); - $this->assertEquals(GitlabWebhook::TYPE_PUSH, $g->getType(json_decode(file_get_contents(__DIR__.'/fixtures/gitlab_push.json'), true))); - $this->assertEquals(GitlabWebhook::TYPE_ISSUE, $g->getType(json_decode(file_get_contents(__DIR__.'/fixtures/gitlab_issue_opened.json'), true))); - $this->assertEquals(GitlabWebhook::TYPE_COMMENT, $g->getType(json_decode(file_get_contents(__DIR__.'/fixtures/gitlab_comment_created.json'), true))); + $this->assertEquals(GitlabWebhook::TYPE_PUSH, $g->getType(json_decode(file_get_contents(__DIR__.'/../fixtures/gitlab_push.json'), true))); + $this->assertEquals(GitlabWebhook::TYPE_ISSUE, $g->getType(json_decode(file_get_contents(__DIR__.'/../fixtures/gitlab_issue_opened.json'), true))); + $this->assertEquals(GitlabWebhook::TYPE_COMMENT, $g->getType(json_decode(file_get_contents(__DIR__.'/../fixtures/gitlab_comment_created.json'), true))); $this->assertEquals('', $g->getType(array())); } @@ -33,7 +33,7 @@ class GitlabWebhookTest extends Base $this->container['dispatcher']->addListener(GitlabWebhook::EVENT_COMMIT, array($this, 'onCommit')); - $event = json_decode(file_get_contents(__DIR__.'/fixtures/gitlab_push.json'), true); + $event = json_decode(file_get_contents(__DIR__.'/../fixtures/gitlab_push.json'), true); // No task $this->assertFalse($g->handleCommit($event['commits'][0])); @@ -57,7 +57,7 @@ class GitlabWebhookTest extends Base $this->container['dispatcher']->addListener(GitlabWebhook::EVENT_ISSUE_OPENED, array($this, 'onOpen')); - $event = json_decode(file_get_contents(__DIR__.'/fixtures/gitlab_issue_opened.json'), true); + $event = json_decode(file_get_contents(__DIR__.'/../fixtures/gitlab_issue_opened.json'), true); $this->assertTrue($g->handleIssueOpened($event['object_attributes'])); $called = $this->container['dispatcher']->getCalledListeners(); @@ -76,7 +76,7 @@ class GitlabWebhookTest extends Base $this->container['dispatcher']->addListener(GitlabWebhook::EVENT_ISSUE_CLOSED, array($this, 'onClose')); - $event = json_decode(file_get_contents(__DIR__.'/fixtures/gitlab_issue_closed.json'), true); + $event = json_decode(file_get_contents(__DIR__.'/../fixtures/gitlab_issue_closed.json'), true); // Issue not there $this->assertFalse($g->handleIssueClosed($event['object_attributes'])); @@ -112,7 +112,7 @@ class GitlabWebhookTest extends Base $g->setProjectId(1); $this->assertNotFalse($g->parsePayload( - json_decode(file_get_contents(__DIR__.'/fixtures/gitlab_comment_created.json'), true) + json_decode(file_get_contents(__DIR__.'/../fixtures/gitlab_comment_created.json'), true) )); } @@ -133,7 +133,7 @@ class GitlabWebhookTest extends Base $g->setProjectId(1); $this->assertNotFalse($g->parsePayload( - json_decode(file_get_contents(__DIR__.'/fixtures/gitlab_comment_created.json'), true) + json_decode(file_get_contents(__DIR__.'/../fixtures/gitlab_comment_created.json'), true) )); } @@ -157,7 +157,7 @@ class GitlabWebhookTest extends Base $g->setProjectId(1); $this->assertNotFalse($g->parsePayload( - json_decode(file_get_contents(__DIR__.'/fixtures/gitlab_comment_created.json'), true) + json_decode(file_get_contents(__DIR__.'/../fixtures/gitlab_comment_created.json'), true) )); } diff --git a/tests/units/MailgunTest.php b/tests/units/Integration/MailgunTest.php index ce53228e..67914b0a 100644 --- a/tests/units/MailgunTest.php +++ b/tests/units/Integration/MailgunTest.php @@ -1,6 +1,6 @@ <?php -require_once __DIR__.'/Base.php'; +require_once __DIR__.'/../Base.php'; use Integration\Mailgun; use Model\TaskCreation; diff --git a/tests/units/PostmarkTest.php b/tests/units/Integration/PostmarkTest.php index f3d2e55b..9115e24a 100644 --- a/tests/units/PostmarkTest.php +++ b/tests/units/Integration/PostmarkTest.php @@ -1,6 +1,6 @@ <?php -require_once __DIR__.'/Base.php'; +require_once __DIR__.'/../Base.php'; use Integration\Postmark; use Model\TaskCreation; diff --git a/tests/units/SendgridTest.php b/tests/units/Integration/SendgridTest.php index 1fc5d0d5..b2352076 100644 --- a/tests/units/SendgridTest.php +++ b/tests/units/Integration/SendgridTest.php @@ -1,6 +1,6 @@ <?php -require_once __DIR__.'/Base.php'; +require_once __DIR__.'/../Base.php'; use Integration\Sendgrid; use Model\TaskCreation; diff --git a/tests/units/LocaleTest.php b/tests/units/Locale/LocaleTest.php index e00b8c83..6cace0d5 100644 --- a/tests/units/LocaleTest.php +++ b/tests/units/Locale/LocaleTest.php @@ -1,6 +1,6 @@ <?php -require_once __DIR__.'/Base.php'; +require_once __DIR__.'/../Base.php'; class LocaleTest extends Base { diff --git a/tests/units/AclTest.php b/tests/units/Model/AclTest.php index 4d735dfb..3cb28a77 100644 --- a/tests/units/AclTest.php +++ b/tests/units/Model/AclTest.php @@ -1,6 +1,6 @@ <?php -require_once __DIR__.'/Base.php'; +require_once __DIR__.'/../Base.php'; use Core\Session; use Model\Acl; @@ -290,4 +290,16 @@ class AclTest extends Base $this->assertFalse($acl->isAllowed('task', 'remove', 1)); $this->assertTrue($acl->isAllowed('app', 'index', 1)); } + + public function testExtend() + { + $acl = new Acl($this->container); + + $this->assertFalse($acl->isProjectManagerAction('plop', 'show')); + + $acl->extend('project_manager_acl', array('plop' => '*')); + + $this->assertTrue($acl->isProjectManagerAction('plop', 'show')); + $this->assertTrue($acl->isProjectManagerAction('swimlane', 'index')); + } } diff --git a/tests/units/ActionTest.php b/tests/units/Model/ActionTest.php index 7e0287a2..9034679b 100644 --- a/tests/units/ActionTest.php +++ b/tests/units/Model/ActionTest.php @@ -1,6 +1,6 @@ <?php -require_once __DIR__.'/Base.php'; +require_once __DIR__.'/../Base.php'; use Model\Action; use Model\Project; diff --git a/tests/units/AuthenticationTest.php b/tests/units/Model/AuthenticationTest.php index 75b55ece..7ce81d8b 100644 --- a/tests/units/AuthenticationTest.php +++ b/tests/units/Model/AuthenticationTest.php @@ -1,6 +1,6 @@ <?php -require_once __DIR__.'/Base.php'; +require_once __DIR__.'/../Base.php'; use Model\User; use Model\Authentication; diff --git a/tests/units/BoardTest.php b/tests/units/Model/BoardTest.php index ebd4f655..b527e983 100644 --- a/tests/units/BoardTest.php +++ b/tests/units/Model/BoardTest.php @@ -1,6 +1,6 @@ <?php -require_once __DIR__.'/Base.php'; +require_once __DIR__.'/../Base.php'; use Model\Project; use Model\Board; @@ -70,7 +70,7 @@ class BoardTest extends Base $s = new Swimlane($this->container); $this->assertEquals(1, $p->create(array('name' => 'Project #1'))); - $this->assertEquals(1, $s->create(1, 'test 1')); + $this->assertEquals(1, $s->create(array('project_id' => 1, 'name' => 'test 1'))); $this->assertEquals(1, $tc->create(array('title' => 'Task #1', 'project_id' => 1, 'column_id' => 1))); $this->assertEquals(2, $tc->create(array('title' => 'Task #2', 'project_id' => 1, 'column_id' => 3))); $this->assertEquals(3, $tc->create(array('title' => 'Task #3', 'project_id' => 1, 'column_id' => 2, 'swimlane_id' => 1))); diff --git a/tests/units/CategoryTest.php b/tests/units/Model/CategoryTest.php index 638f3fe4..0467dda4 100644 --- a/tests/units/CategoryTest.php +++ b/tests/units/Model/CategoryTest.php @@ -1,6 +1,6 @@ <?php -require_once __DIR__.'/Base.php'; +require_once __DIR__.'/../Base.php'; use Model\Task; use Model\TaskCreation; diff --git a/tests/units/CommentTest.php b/tests/units/Model/CommentTest.php index 295ac60e..5e532b8a 100644 --- a/tests/units/CommentTest.php +++ b/tests/units/Model/CommentTest.php @@ -1,6 +1,6 @@ <?php -require_once __DIR__.'/Base.php'; +require_once __DIR__.'/../Base.php'; use Model\Task; use Model\TaskCreation; diff --git a/tests/units/ConfigTest.php b/tests/units/Model/ConfigTest.php index f93619d6..c0ed0313 100644 --- a/tests/units/ConfigTest.php +++ b/tests/units/Model/ConfigTest.php @@ -1,6 +1,6 @@ <?php -require_once __DIR__.'/Base.php'; +require_once __DIR__.'/../Base.php'; use Model\Config; use Core\Session; diff --git a/tests/units/DateParserTest.php b/tests/units/Model/DateParserTest.php index 4b3e93c8..23c31f14 100644 --- a/tests/units/DateParserTest.php +++ b/tests/units/Model/DateParserTest.php @@ -1,6 +1,6 @@ <?php -require_once __DIR__.'/Base.php'; +require_once __DIR__.'/../Base.php'; use Model\DateParser; diff --git a/tests/units/FileTest.php b/tests/units/Model/FileTest.php index 4ea7f386..e7520c89 100644 --- a/tests/units/FileTest.php +++ b/tests/units/Model/FileTest.php @@ -1,6 +1,6 @@ <?php -require_once __DIR__.'/Base.php'; +require_once __DIR__.'/../Base.php'; use Model\Task; use Model\File; @@ -9,6 +9,17 @@ use Model\Project; class FileTest extends Base { + public function setUp() + { + parent::setUp(); + + $this->container['objectStorage'] = $this + ->getMockBuilder('\Core\ObjectStorage\FileStorage') + ->setConstructorArgs(array($this->container)) + ->setMethods(array('put', 'moveFile', 'remove')) + ->getMock(); + } + public function testCreation() { $p = new Project($this->container); @@ -85,13 +96,32 @@ class FileTest extends Base public function testUploadScreenshot() { $p = new Project($this->container); - $f = new File($this->container); $tc = new TaskCreation($this->container); $this->assertEquals(1, $p->create(array('name' => 'test'))); $this->assertEquals(1, $tc->create(array('project_id' => 1, 'title' => 'test'))); - $this->assertEquals(1, $f->uploadScreenshot(1, 1, base64_encode('image data'))); + $data = base64_encode('image data'); + + $f = $this + ->getMockBuilder('\Model\File') + ->setConstructorArgs(array($this->container)) + ->setMethods(array('generateThumbnailFromData')) + ->getMock(); + + $this->container['objectStorage'] + ->expects($this->once()) + ->method('put') + ->with( + $this->stringContains('1/1/'), + $this->equalTo(base64_decode($data)) + ) + ->will($this->returnValue(true)); + + $f->expects($this->once()) + ->method('generateThumbnailFromData'); + + $this->assertEquals(1, $f->uploadScreenshot(1, 1, $data)); $file = $f->getById(1); $this->assertNotEmpty($file); @@ -113,7 +143,18 @@ class FileTest extends Base $this->assertEquals(1, $p->create(array('name' => 'test'))); $this->assertEquals(1, $tc->create(array('project_id' => 1, 'title' => 'test'))); - $this->assertEquals(1, $f->uploadContent(1, 1, 'my file.pdf', base64_encode('file data'))); + $data = base64_encode('file data'); + + $this->container['objectStorage'] + ->expects($this->once()) + ->method('put') + ->with( + $this->stringContains('1/1/'), + $this->equalTo(base64_decode($data)) + ) + ->will($this->returnValue(true)); + + $this->assertEquals(1, $f->uploadContent(1, 1, 'my file.pdf', $data)); $file = $f->getById(1); $this->assertNotEmpty($file); @@ -170,9 +211,33 @@ class FileTest extends Base $this->assertEquals(1, $p->create(array('name' => 'test'))); $this->assertEquals(1, $tc->create(array('project_id' => 1, 'title' => 'test'))); - $this->assertEquals(1, $f->create(1, 'B.pdf', '/tmp/foo', 10)); - $this->assertEquals(2, $f->create(1, 'A.png', '/tmp/foo', 10)); - $this->assertEquals(3, $f->create(1, 'D.doc', '/tmp/foo', 10)); + $this->assertEquals(1, $f->create(1, 'B.pdf', '/tmp/foo1', 10)); + $this->assertEquals(2, $f->create(1, 'A.png', '/tmp/foo2', 10)); + $this->assertEquals(3, $f->create(1, 'D.doc', '/tmp/foo3', 10)); + + $this->container['objectStorage'] + ->expects($this->at(0)) + ->method('remove') + ->with( + $this->equalTo('/tmp/foo2') + ) + ->will($this->returnValue(true)); + + $this->container['objectStorage'] + ->expects($this->at(1)) + ->method('remove') + ->with( + $this->equalTo('/tmp/foo1') + ) + ->will($this->returnValue(true)); + + $this->container['objectStorage'] + ->expects($this->at(2)) + ->method('remove') + ->with( + $this->equalTo('/tmp/foo3') + ) + ->will($this->returnValue(true)); $this->assertTrue($f->remove(2)); diff --git a/tests/units/LinkTest.php b/tests/units/Model/LinkTest.php index 45e9796c..0399f13e 100644 --- a/tests/units/LinkTest.php +++ b/tests/units/Model/LinkTest.php @@ -1,6 +1,6 @@ <?php -require_once __DIR__.'/Base.php'; +require_once __DIR__.'/../Base.php'; use Model\Link; diff --git a/tests/units/NotificationTest.php b/tests/units/Model/NotificationTest.php index 4ae46ee3..b0eafc83 100644 --- a/tests/units/NotificationTest.php +++ b/tests/units/Model/NotificationTest.php @@ -1,6 +1,6 @@ <?php -require_once __DIR__.'/Base.php'; +require_once __DIR__.'/../Base.php'; use Model\TaskFinder; use Model\TaskCreation; diff --git a/tests/units/ProjectActivityTest.php b/tests/units/Model/ProjectActivityTest.php index f0b27649..fa45d740 100644 --- a/tests/units/ProjectActivityTest.php +++ b/tests/units/Model/ProjectActivityTest.php @@ -1,6 +1,6 @@ <?php -require_once __DIR__.'/Base.php'; +require_once __DIR__.'/../Base.php'; use Model\Task; use Model\TaskFinder; diff --git a/tests/units/ProjectDailyColumnStatsTest.php b/tests/units/Model/ProjectDailyColumnStatsTest.php index d314ac93..e01bdcc4 100644 --- a/tests/units/ProjectDailyColumnStatsTest.php +++ b/tests/units/Model/ProjectDailyColumnStatsTest.php @@ -1,6 +1,6 @@ <?php -require_once __DIR__.'/Base.php'; +require_once __DIR__.'/../Base.php'; use Model\Project; use Model\ProjectDailyColumnStats; diff --git a/tests/units/ProjectDuplicationTest.php b/tests/units/Model/ProjectDuplicationTest.php index 311ecc4a..0388d4a2 100644 --- a/tests/units/ProjectDuplicationTest.php +++ b/tests/units/Model/ProjectDuplicationTest.php @@ -1,6 +1,6 @@ <?php -require_once __DIR__.'/Base.php'; +require_once __DIR__.'/../Base.php'; use Model\Action; use Model\Project; @@ -20,7 +20,7 @@ class ProjectDuplicationTest extends Base $pd = new ProjectDuplication($this->container); $this->assertEquals('test (Clone)', $pd->getClonedProjectName('test')); - + $this->assertEquals(50, strlen($pd->getClonedProjectName(str_repeat('a', 50)))); $this->assertEquals(str_repeat('a', 42).' (Clone)', $pd->getClonedProjectName(str_repeat('a', 50))); @@ -155,7 +155,7 @@ class ProjectDuplicationTest extends Base $pd = new ProjectDuplication($this->container); $this->assertEquals(1, $p->create(array('name' => 'P1'))); - + $this->assertEquals(1, $a->create(array( 'project_id' => 1, 'event_name' => Task::EVENT_MOVE_COLUMN, @@ -185,7 +185,7 @@ class ProjectDuplicationTest extends Base $this->assertEquals(1, $c->create(array('name' => 'C1', 'project_id' => 1))); $this->assertEquals(2, $c->create(array('name' => 'C2', 'project_id' => 1))); $this->assertEquals(3, $c->create(array('name' => 'C3', 'project_id' => 1))); - + $this->assertEquals(1, $a->create(array( 'project_id' => 1, 'event_name' => Task::EVENT_CREATE_UPDATE, @@ -215,9 +215,9 @@ class ProjectDuplicationTest extends Base $this->assertEquals(1, $p->create(array('name' => 'P1'))); // create initial swimlanes - $this->assertEquals(1, $s->create(1, 'S1')); - $this->assertEquals(2, $s->create(1, 'S2')); - $this->assertEquals(3, $s->create(1, 'S3')); + $this->assertEquals(1, $s->create(array('project_id' => 1, 'name' => 'S1'))); + $this->assertEquals(2, $s->create(array('project_id' => 1, 'name' => 'S2'))); + $this->assertEquals(3, $s->create(array('project_id' => 1, 'name' => 'S3'))); $default_swimlane1 = $s->getDefault(1); $default_swimlane1['default_swimlane'] = 'New Default'; @@ -277,9 +277,9 @@ class ProjectDuplicationTest extends Base $this->assertEquals(1, $p->create(array('name' => 'P1'))); // create initial swimlanes - $this->assertEquals(1, $s->create(1, 'S1')); - $this->assertEquals(2, $s->create(1, 'S2')); - $this->assertEquals(3, $s->create(1, 'S3')); + $this->assertEquals(1, $s->create(array('project_id' => 1, 'name' => 'S1'))); + $this->assertEquals(2, $s->create(array('project_id' => 1, 'name' => 'S2'))); + $this->assertEquals(3, $s->create(array('project_id' => 1, 'name' => 'S3'))); $default_swimlane1 = $s->getDefault(1); $default_swimlane1['default_swimlane'] = 'New Default'; @@ -323,9 +323,9 @@ class ProjectDuplicationTest extends Base $this->assertEquals(1, $p->create(array('name' => 'P1'))); // create initial swimlanes - $this->assertEquals(1, $s->create(1, 'S1')); - $this->assertEquals(2, $s->create(1, 'S2')); - $this->assertEquals(3, $s->create(1, 'S3')); + $this->assertEquals(1, $s->create(array('project_id' => 1, 'name' => 'S1'))); + $this->assertEquals(2, $s->create(array('project_id' => 1, 'name' => 'S2'))); + $this->assertEquals(3, $s->create(array('project_id' => 1, 'name' => 'S3'))); $default_swimlane1 = $s->getDefault(1); $default_swimlane1['default_swimlane'] = 'New Default'; diff --git a/tests/units/ProjectPermissionTest.php b/tests/units/Model/ProjectPermissionTest.php index 9f6d6a52..475dd013 100644 --- a/tests/units/ProjectPermissionTest.php +++ b/tests/units/Model/ProjectPermissionTest.php @@ -1,6 +1,6 @@ <?php -require_once __DIR__.'/Base.php'; +require_once __DIR__.'/../Base.php'; use Model\Project; use Model\ProjectPermission; diff --git a/tests/units/ProjectTest.php b/tests/units/Model/ProjectTest.php index b7f168d7..9d7b6c0d 100644 --- a/tests/units/ProjectTest.php +++ b/tests/units/Model/ProjectTest.php @@ -1,6 +1,6 @@ <?php -require_once __DIR__.'/Base.php'; +require_once __DIR__.'/../Base.php'; use Core\Translator; use Subscriber\ProjectModificationDateSubscriber; @@ -26,7 +26,7 @@ class ProjectTest extends Base $this->assertNotFalse($p->create(array('name' => 'UnitTest '.$locale)), 'Unable to create project with '.$locale.':'.$language); } - Translator::load('en_US'); + Translator::unload(); } public function testCreation() diff --git a/tests/units/SubtaskTest.php b/tests/units/Model/SubtaskTest.php index 3c8cab49..5773893c 100644 --- a/tests/units/SubtaskTest.php +++ b/tests/units/Model/SubtaskTest.php @@ -1,6 +1,6 @@ <?php -require_once __DIR__.'/Base.php'; +require_once __DIR__.'/../Base.php'; use Model\Task; use Model\TaskCreation; @@ -13,6 +13,136 @@ use Model\UserSession; class SubTaskTest extends Base { + public function onSubtaskCreated($event) + { + $this->assertInstanceOf('Event\SubtaskEvent', $event); + $data = $event->getAll(); + + $this->assertArrayHasKey('id', $data); + $this->assertArrayHasKey('title', $data); + $this->assertArrayHasKey('status', $data); + $this->assertArrayHasKey('time_estimated', $data); + $this->assertArrayHasKey('time_spent', $data); + $this->assertArrayHasKey('status', $data); + $this->assertArrayHasKey('task_id', $data); + $this->assertArrayHasKey('user_id', $data); + $this->assertArrayHasKey('position', $data); + $this->assertNotEmpty($data['task_id']); + $this->assertNotEmpty($data['id']); + } + + public function onSubtaskUpdated($event) + { + $this->assertInstanceOf('Event\SubtaskEvent', $event); + $data = $event->getAll(); + + $this->assertArrayHasKey('id', $data); + $this->assertArrayHasKey('title', $data); + $this->assertArrayHasKey('status', $data); + $this->assertArrayHasKey('time_estimated', $data); + $this->assertArrayHasKey('time_spent', $data); + $this->assertArrayHasKey('status', $data); + $this->assertArrayHasKey('task_id', $data); + $this->assertArrayHasKey('user_id', $data); + $this->assertArrayHasKey('position', $data); + $this->assertArrayHasKey('changes', $data); + $this->assertArrayHasKey('user_id', $data['changes']); + $this->assertArrayHasKey('status', $data['changes']); + + $this->assertEquals(Subtask::STATUS_INPROGRESS, $data['changes']['status']); + $this->assertEquals(1, $data['changes']['user_id']); + } + + public function onSubtaskDeleted($event) + { + $this->assertInstanceOf('Event\SubtaskEvent', $event); + $data = $event->getAll(); + + $this->assertArrayHasKey('id', $data); + $this->assertArrayHasKey('title', $data); + $this->assertArrayHasKey('status', $data); + $this->assertArrayHasKey('time_estimated', $data); + $this->assertArrayHasKey('time_spent', $data); + $this->assertArrayHasKey('status', $data); + $this->assertArrayHasKey('task_id', $data); + $this->assertArrayHasKey('user_id', $data); + $this->assertArrayHasKey('position', $data); + $this->assertNotEmpty($data['task_id']); + $this->assertNotEmpty($data['id']); + } + + public function testCreation() + { + $tc = new TaskCreation($this->container); + $s = new Subtask($this->container); + $p = new Project($this->container); + + $this->assertEquals(1, $p->create(array('name' => 'test'))); + $this->assertEquals(1, $tc->create(array('title' => 'test 1', 'project_id' => 1))); + + $this->container['dispatcher']->addListener(Subtask::EVENT_CREATE, array($this, 'onSubtaskCreated')); + + $this->assertEquals(1, $s->create(array('title' => 'subtask #1', 'task_id' => 1))); + + $subtask = $s->getById(1); + $this->assertNotEmpty($subtask); + $this->assertEquals(1, $subtask['id']); + $this->assertEquals(1, $subtask['task_id']); + $this->assertEquals('subtask #1', $subtask['title']); + $this->assertEquals(Subtask::STATUS_TODO, $subtask['status']); + $this->assertEquals(0, $subtask['time_estimated']); + $this->assertEquals(0, $subtask['time_spent']); + $this->assertEquals(0, $subtask['user_id']); + $this->assertEquals(1, $subtask['position']); + } + + public function testModification() + { + $tc = new TaskCreation($this->container); + $s = new Subtask($this->container); + $p = new Project($this->container); + + $this->assertEquals(1, $p->create(array('name' => 'test'))); + $this->assertEquals(1, $tc->create(array('title' => 'test 1', 'project_id' => 1))); + + $this->container['dispatcher']->addListener(Subtask::EVENT_UPDATE, array($this, 'onSubtaskUpdated')); + + $this->assertEquals(1, $s->create(array('title' => 'subtask #1', 'task_id' => 1))); + $this->assertTrue($s->update(array('id' => 1, 'user_id' => 1, 'status' => Subtask::STATUS_INPROGRESS))); + + $subtask = $s->getById(1); + $this->assertNotEmpty($subtask); + $this->assertEquals(1, $subtask['id']); + $this->assertEquals(1, $subtask['task_id']); + $this->assertEquals('subtask #1', $subtask['title']); + $this->assertEquals(Subtask::STATUS_INPROGRESS, $subtask['status']); + $this->assertEquals(0, $subtask['time_estimated']); + $this->assertEquals(0, $subtask['time_spent']); + $this->assertEquals(1, $subtask['user_id']); + $this->assertEquals(1, $subtask['position']); + } + + public function testRemove() + { + $tc = new TaskCreation($this->container); + $s = new Subtask($this->container); + $p = new Project($this->container); + + $this->assertEquals(1, $p->create(array('name' => 'test'))); + $this->assertEquals(1, $tc->create(array('title' => 'test 1', 'project_id' => 1))); + $this->assertEquals(1, $s->create(array('title' => 'subtask #1', 'task_id' => 1))); + + $this->container['dispatcher']->addListener(Subtask::EVENT_DELETE, array($this, 'onSubtaskDeleted')); + + $subtask = $s->getById(1); + $this->assertNotEmpty($subtask); + + $this->assertTrue($s->remove(1)); + + $subtask = $s->getById(1); + $this->assertEmpty($subtask); + } + public function testToggleStatusWithoutSession() { $tc = new TaskCreation($this->container); diff --git a/tests/units/SubtaskTimeTrackingTest.php b/tests/units/Model/SubtaskTimeTrackingTest.php index 94f2ce54..f68f283d 100644 --- a/tests/units/SubtaskTimeTrackingTest.php +++ b/tests/units/Model/SubtaskTimeTrackingTest.php @@ -1,6 +1,6 @@ <?php -require_once __DIR__.'/Base.php'; +require_once __DIR__.'/../Base.php'; use Model\TaskFinder; use Model\TaskCreation; @@ -151,8 +151,8 @@ class SubtaskTimeTrackingTest extends Base $time = $st->calculateSubtaskTime(1); $this->assertNotempty($time); $this->assertCount(2, $time); - $this->assertEquals(3.3, $time['total_spent'], 'Total spent', 0.01); - $this->assertEquals(7.7, $time['total_estimated'], 'Total estimated', 0.01); + $this->assertEquals(3.3, $time['time_spent'], 'Total spent', 0.01); + $this->assertEquals(7.7, $time['time_estimated'], 'Total estimated', 0.01); } public function testUpdateSubtaskTimeSpent() @@ -184,13 +184,13 @@ class SubtaskTimeTrackingTest extends Base $time = $st->calculateSubtaskTime(1); $this->assertNotempty($time); - $this->assertEquals(4.2, $time['total_spent'], 'Total spent', 0.01); - $this->assertEquals(0, $time['total_estimated'], 'Total estimated', 0.01); + $this->assertEquals(4.2, $time['time_spent'], 'Total spent', 0.01); + $this->assertEquals(0, $time['time_estimated'], 'Total estimated', 0.01); $time = $st->calculateSubtaskTime(2); $this->assertNotempty($time); - $this->assertEquals(0, $time['total_spent'], 'Total spent', 0.01); - $this->assertEquals(0, $time['total_estimated'], 'Total estimated', 0.01); + $this->assertEquals(0, $time['time_spent'], 'Total spent', 0.01); + $this->assertEquals(0, $time['time_estimated'], 'Total estimated', 0.01); } public function testUpdateTaskTimeTracking() @@ -205,7 +205,7 @@ class SubtaskTimeTrackingTest extends Base $this->assertEquals(1, $tc->create(array('title' => 'test 1', 'project_id' => 1))); $this->assertEquals(2, $tc->create(array('title' => 'test 2', 'project_id' => 1, 'time_estimated' => 1.5, 'time_spent' => 0.5))); - $this->assertEquals(3, $tc->create(array('title' => 'test 2', 'project_id' => 1, 'time_estimated' => 4, 'time_spent' => 2))); + $this->assertEquals(3, $tc->create(array('title' => 'test 3', 'project_id' => 1, 'time_estimated' => 4, 'time_spent' => 2))); $this->assertEquals(1, $s->create(array('title' => 'subtask #1', 'task_id' => 1, 'time_spent' => 2.2))); $this->assertEquals(2, $s->create(array('title' => 'subtask #2', 'task_id' => 1, 'time_estimated' => 1))); @@ -231,8 +231,18 @@ class SubtaskTimeTrackingTest extends Base $task = $tf->getById(3); $this->assertNotEmpty($task); - $this->assertEquals(4, $task['time_estimated']); + $this->assertEquals(0, $task['time_estimated']); $this->assertEquals(8, $task['time_spent']); + + $this->assertTrue($s->remove(3)); + $this->assertTrue($s->remove(4)); + + $st->updateTaskTimeTracking(2); + + $task = $tf->getById(2); + $this->assertNotEmpty($task); + $this->assertEquals(0, $task['time_estimated']); + $this->assertEquals(0, $task['time_spent']); } public function testGetCalendarEvents() diff --git a/tests/units/SwimlaneTest.php b/tests/units/Model/SwimlaneTest.php index 37226613..7e1adb8e 100644 --- a/tests/units/SwimlaneTest.php +++ b/tests/units/Model/SwimlaneTest.php @@ -1,6 +1,6 @@ <?php -require_once __DIR__.'/Base.php'; +require_once __DIR__.'/../Base.php'; use Model\Project; use Model\Task; @@ -16,7 +16,7 @@ class SwimlaneTest extends Base $s = new Swimlane($this->container); $this->assertEquals(1, $p->create(array('name' => 'UnitTest'))); - $this->assertEquals(1, $s->create(1, 'Swimlane #1')); + $this->assertEquals(1, $s->create(array('project_id' => 1, 'name' => 'Swimlane #1'))); $swimlanes = $s->getSwimlanes(1); $this->assertNotEmpty($swimlanes); @@ -37,8 +37,8 @@ class SwimlaneTest extends Base $s = new Swimlane($this->container); $this->assertEquals(1, $p->create(array('name' => 'UnitTest'))); - $this->assertEquals(1, $s->create(1, 'Swimlane #1')); - $this->assertEquals(2, $s->create(1, 'Swimlane #2')); + $this->assertEquals(1, $s->create(array('project_id' => 1, 'name' => 'Swimlane #1'))); + $this->assertEquals(2, $s->create(array('project_id' => 1, 'name' => 'Swimlane #2'))); $swimlanes = $s->getList(1); $expected = array('Default swimlane', 'Swimlane #1', 'Swimlane #2'); @@ -46,26 +46,26 @@ class SwimlaneTest extends Base $this->assertEquals($expected, $swimlanes); } - public function testRename() + public function testUpdate() { $p = new Project($this->container); $s = new Swimlane($this->container); $this->assertEquals(1, $p->create(array('name' => 'UnitTest'))); - $this->assertEquals(1, $s->create(1, 'Swimlane #1')); + $this->assertEquals(1, $s->create(array('project_id' => 1, 'name' => 'Swimlane #1'))); $swimlane = $s->getById(1); $this->assertNotEmpty($swimlane); $this->assertEquals('Swimlane #1', $swimlane['name']); - $this->assertTrue($s->rename(1, 'foobar')); + $this->assertTrue($s->update(array('id' => 1, 'name' => 'foobar'))); $swimlane = $s->getById(1); $this->assertNotEmpty($swimlane); $this->assertEquals('foobar', $swimlane['name']); } - public function testRenameDefaultSwimlane() + public function testUpdateDefaultSwimlane() { $p = new Project($this->container); $s = new Swimlane($this->container); @@ -92,7 +92,7 @@ class SwimlaneTest extends Base $s = new Swimlane($this->container); $this->assertEquals(1, $p->create(array('name' => 'UnitTest'))); - $this->assertEquals(1, $s->create(1, 'Swimlane #1')); + $this->assertEquals(1, $s->create(array('project_id' => 1, 'name' => 'Swimlane #1'))); $swimlane = $s->getById(1); $this->assertNotEmpty($swimlane); @@ -110,7 +110,7 @@ class SwimlaneTest extends Base $this->assertEquals(1, $s->getLastPosition(1)); // Create a new swimlane - $this->assertEquals(2, $s->create(1, 'Swimlane #2')); + $this->assertEquals(2, $s->create(array('project_id' => 1, 'name' => 'Swimlane #2'))); $swimlane = $s->getById(2); $this->assertNotEmpty($swimlane); @@ -134,7 +134,7 @@ class SwimlaneTest extends Base $tf = new TaskFinder($this->container); $this->assertEquals(1, $p->create(array('name' => 'UnitTest'))); - $this->assertEquals(1, $s->create(1, 'Swimlane #1')); + $this->assertEquals(1, $s->create(array('project_id' => 1, 'name' => 'Swimlane #1'))); $this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1, 'swimlane_id' => 1))); $task = $tf->getbyId(1); @@ -156,9 +156,9 @@ class SwimlaneTest extends Base $s = new Swimlane($this->container); $this->assertEquals(1, $p->create(array('name' => 'UnitTest'))); - $this->assertEquals(1, $s->create(1, 'Swimlane #1')); - $this->assertEquals(2, $s->create(1, 'Swimlane #2')); - $this->assertEquals(3, $s->create(1, 'Swimlane #3')); + $this->assertEquals(1, $s->create(array('project_id' => 1, 'name' => 'Swimlane #1'))); + $this->assertEquals(2, $s->create(array('project_id' => 1, 'name' => 'Swimlane #2'))); + $this->assertEquals(3, $s->create(array('project_id' => 1, 'name' => 'Swimlane #3'))); $swimlane = $s->getById(1); $this->assertNotEmpty($swimlane); @@ -216,9 +216,9 @@ class SwimlaneTest extends Base $s = new Swimlane($this->container); $this->assertEquals(1, $p->create(array('name' => 'UnitTest'))); - $this->assertEquals(1, $s->create(1, 'Swimlane #1')); - $this->assertEquals(2, $s->create(1, 'Swimlane #2')); - $this->assertEquals(3, $s->create(1, 'Swimlane #3')); + $this->assertEquals(1, $s->create(array('project_id' => 1, 'name' => 'Swimlane #1'))); + $this->assertEquals(2, $s->create(array('project_id' => 1, 'name' => 'Swimlane #2'))); + $this->assertEquals(3, $s->create(array('project_id' => 1, 'name' => 'Swimlane #3'))); $swimlane = $s->getById(1); $this->assertNotEmpty($swimlane); @@ -299,9 +299,9 @@ class SwimlaneTest extends Base $s = new Swimlane($this->container); $this->assertEquals(1, $p->create(array('name' => 'UnitTest'))); - $this->assertEquals(1, $s->create(1, 'Swimlane #1')); - $this->assertEquals(2, $s->create(1, 'Swimlane #2')); - $this->assertEquals(3, $s->create(1, 'Swimlane #3')); + $this->assertEquals(1, $s->create(array('project_id' => 1, 'name' => 'Swimlane #1'))); + $this->assertEquals(2, $s->create(array('project_id' => 1, 'name' => 'Swimlane #2'))); + $this->assertEquals(3, $s->create(array('project_id' => 1, 'name' => 'Swimlane #3'))); $swimlane = $s->getById(1); $this->assertNotEmpty($swimlane); @@ -383,9 +383,9 @@ class SwimlaneTest extends Base $this->assertEquals(1, $p->create(array('name' => 'P1'))); $this->assertEquals(2, $p->create(array('name' => 'P2'))); - $this->assertEquals(1, $s->create(1, 'S1')); - $this->assertEquals(2, $s->create(1, 'S2')); - $this->assertEquals(3, $s->create(1, 'S3')); + $this->assertEquals(1, $s->create(array('project_id' => 1, 'name' => 'S1'))); + $this->assertEquals(2, $s->create(array('project_id' => 1, 'name' => 'S2'))); + $this->assertEquals(3, $s->create(array('project_id' => 1, 'name' => 'S3'))); $default_swimlane1 = $s->getDefault(1); $default_swimlane1['default_swimlane'] = 'New Default'; diff --git a/tests/units/TaskCreationTest.php b/tests/units/Model/TaskCreationTest.php index a77778d6..f292c7f1 100644 --- a/tests/units/TaskCreationTest.php +++ b/tests/units/Model/TaskCreationTest.php @@ -1,6 +1,6 @@ <?php -require_once __DIR__.'/Base.php'; +require_once __DIR__.'/../Base.php'; use Model\Config; use Model\Task; diff --git a/tests/units/TaskDuplicationTest.php b/tests/units/Model/TaskDuplicationTest.php index e87fe9cc..56718841 100644 --- a/tests/units/TaskDuplicationTest.php +++ b/tests/units/Model/TaskDuplicationTest.php @@ -1,6 +1,6 @@ <?php -require_once __DIR__.'/Base.php'; +require_once __DIR__.'/../Base.php'; use Model\Task; use Model\TaskCreation; @@ -225,8 +225,8 @@ class TaskDuplicationTest extends Base $this->assertEquals(1, $p->create(array('name' => 'test1'))); $this->assertEquals(2, $p->create(array('name' => 'test2'))); - $this->assertNotFalse($s->create(1, 'Swimlane #1')); - $this->assertNotFalse($s->create(2, 'Swimlane #1')); + $this->assertNotFalse($s->create(array('project_id' => 1, 'name' => 'Swimlane #1'))); + $this->assertNotFalse($s->create(array('project_id' => 2, 'name' => 'Swimlane #1'))); // We create a task $this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 2, 'swimlane_id' => 1))); @@ -258,8 +258,8 @@ class TaskDuplicationTest extends Base $this->assertEquals(1, $p->create(array('name' => 'test1'))); $this->assertEquals(2, $p->create(array('name' => 'test2'))); - $this->assertNotFalse($s->create(1, 'Swimlane #1')); - $this->assertNotFalse($s->create(2, 'Swimlane #2')); + $this->assertNotFalse($s->create(array('project_id' => 1, 'name' => 'Swimlane #1'))); + $this->assertNotFalse($s->create(array('project_id' => 2, 'name' => 'Swimlane #2'))); // We create a task $this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 2, 'swimlane_id' => 1))); @@ -291,9 +291,9 @@ class TaskDuplicationTest extends Base $this->assertEquals(1, $p->create(array('name' => 'test1'))); $this->assertEquals(2, $p->create(array('name' => 'test2'))); - $this->assertNotFalse($s->create(1, 'Swimlane #1')); - $this->assertNotFalse($s->create(2, 'Swimlane #1')); - $this->assertNotFalse($s->create(2, 'Swimlane #2')); + $this->assertNotFalse($s->create(array('project_id' => 1, 'name' => 'Swimlane #1'))); + $this->assertNotFalse($s->create(array('project_id' => 2, 'name' => 'Swimlane #1'))); + $this->assertNotFalse($s->create(array('project_id' => 2, 'name' => 'Swimlane #2'))); // We create a task $this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 2, 'swimlane_id' => 1))); @@ -574,8 +574,8 @@ class TaskDuplicationTest extends Base $this->assertEquals(1, $p->create(array('name' => 'test1'))); $this->assertEquals(2, $p->create(array('name' => 'test2'))); - $this->assertNotFalse($s->create(1, 'Swimlane #1')); - $this->assertNotFalse($s->create(2, 'Swimlane #1')); + $this->assertNotFalse($s->create(array('project_id' => 1, 'name' => 'Swimlane #1'))); + $this->assertNotFalse($s->create(array('project_id' => 2, 'name' => 'Swimlane #1'))); // We create a task $this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 2, 'swimlane_id' => 1))); @@ -607,8 +607,8 @@ class TaskDuplicationTest extends Base $this->assertEquals(1, $p->create(array('name' => 'test1'))); $this->assertEquals(2, $p->create(array('name' => 'test2'))); - $this->assertNotFalse($s->create(1, 'Swimlane #1')); - $this->assertNotFalse($s->create(2, 'Swimlane #2')); + $this->assertNotFalse($s->create(array('project_id' => 1, 'name' => 'Swimlane #1'))); + $this->assertNotFalse($s->create(array('project_id' => 2, 'name' => 'Swimlane #2'))); // We create a task $this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 2, 'swimlane_id' => 1))); diff --git a/tests/units/TaskExportTest.php b/tests/units/Model/TaskExportTest.php index 3892f2bd..52996369 100644 --- a/tests/units/TaskExportTest.php +++ b/tests/units/Model/TaskExportTest.php @@ -1,6 +1,6 @@ <?php -require_once __DIR__.'/Base.php'; +require_once __DIR__.'/../Base.php'; use Model\Task; use Model\TaskCreation; @@ -22,8 +22,8 @@ class TaskExportTest extends Base $this->assertEquals(1, $p->create(array('name' => 'Export Project'))); - $this->assertEquals(1, $s->create(1, 'S1')); - $this->assertEquals(2, $s->create(1, 'S2')); + $this->assertEquals(1, $s->create(array('project_id' => 1, 'name' => 'S1'))); + $this->assertEquals(2, $s->create(array('project_id' => 1, 'name' => 'S2'))); $this->assertNotFalse($c->create(array('name' => 'Category #1', 'project_id' => 1))); $this->assertNotFalse($c->create(array('name' => 'Category #2', 'project_id' => 1))); diff --git a/tests/units/TaskFilterTest.php b/tests/units/Model/TaskFilterTest.php index 1ae1e5b8..1987265d 100644 --- a/tests/units/TaskFilterTest.php +++ b/tests/units/Model/TaskFilterTest.php @@ -1,6 +1,6 @@ <?php -require_once __DIR__.'/Base.php'; +require_once __DIR__.'/../Base.php'; use Model\Project; use Model\User; @@ -335,8 +335,8 @@ class TaskFilterTest extends Base $s = new Swimlane($this->container); $this->assertEquals(1, $p->create(array('name' => 'My project A'))); - $this->assertEquals(1, $s->create(1, 'Version 1.1')); - $this->assertEquals(2, $s->create(1, 'Version 1.2')); + $this->assertEquals(1, $s->create(array('project_id' => 1, 'name' => 'Version 1.1'))); + $this->assertEquals(2, $s->create(array('project_id' => 1, 'name' => 'Version 1.2'))); $this->assertNotFalse($tc->create(array('project_id' => 1, 'title' => 'task1', 'swimlane_id' => 1))); $this->assertNotFalse($tc->create(array('project_id' => 1, 'title' => 'task2', 'swimlane_id' => 2))); $this->assertNotFalse($tc->create(array('project_id' => 1, 'title' => 'task3', 'swimlane_id' => 0))); diff --git a/tests/units/TaskFinderTest.php b/tests/units/Model/TaskFinderTest.php index 96a3809b..da0db7a7 100644 --- a/tests/units/TaskFinderTest.php +++ b/tests/units/Model/TaskFinderTest.php @@ -1,6 +1,6 @@ <?php -require_once __DIR__.'/Base.php'; +require_once __DIR__.'/../Base.php'; use Model\Task; use Model\TaskCreation; diff --git a/tests/units/TaskLinkTest.php b/tests/units/Model/TaskLinkTest.php index e213e25a..1e79ea74 100644 --- a/tests/units/TaskLinkTest.php +++ b/tests/units/Model/TaskLinkTest.php @@ -1,6 +1,6 @@ <?php -require_once __DIR__.'/Base.php'; +require_once __DIR__.'/../Base.php'; use Model\Link; use Model\TaskLink; diff --git a/tests/units/TaskModificationTest.php b/tests/units/Model/TaskModificationTest.php index 4dd89c5e..f85f1c10 100644 --- a/tests/units/TaskModificationTest.php +++ b/tests/units/Model/TaskModificationTest.php @@ -1,6 +1,6 @@ <?php -require_once __DIR__.'/Base.php'; +require_once __DIR__.'/../Base.php'; use Model\Task; use Model\TaskCreation; diff --git a/tests/units/TaskMovedDateSubscriberTest.php b/tests/units/Model/TaskMovedDateSubscriberTest.php index e0364918..6e3fb3bd 100644 --- a/tests/units/TaskMovedDateSubscriberTest.php +++ b/tests/units/Model/TaskMovedDateSubscriberTest.php @@ -1,6 +1,6 @@ <?php -require_once __DIR__.'/Base.php'; +require_once __DIR__.'/../Base.php'; use Model\TaskPosition; use Model\TaskCreation; @@ -54,8 +54,8 @@ class TaskMovedDateSubscriberTest extends Base $now = time(); $this->assertEquals(1, $p->create(array('name' => 'Project #1'))); - $this->assertEquals(1, $s->create(1, 'S1')); - $this->assertEquals(2, $s->create(1, 'S2')); + $this->assertEquals(1, $s->create(array('project_id' => 1, 'name' => 'S1'))); + $this->assertEquals(2, $s->create(array('project_id' => 1, 'name' => 'S2'))); $this->assertEquals(1, $tc->create(array('title' => 'Task #1', 'project_id' => 1))); $task = $tf->getById(1); diff --git a/tests/units/TaskPermissionTest.php b/tests/units/Model/TaskPermissionTest.php index 0bf68ce3..af413a76 100644 --- a/tests/units/TaskPermissionTest.php +++ b/tests/units/Model/TaskPermissionTest.php @@ -1,6 +1,6 @@ <?php -require_once __DIR__.'/Base.php'; +require_once __DIR__.'/../Base.php'; use Model\Task; use Model\TaskCreation; diff --git a/tests/units/TaskPositionTest.php b/tests/units/Model/TaskPositionTest.php index 83436683..86814c03 100644 --- a/tests/units/TaskPositionTest.php +++ b/tests/units/Model/TaskPositionTest.php @@ -1,6 +1,6 @@ <?php -require_once __DIR__.'/Base.php'; +require_once __DIR__.'/../Base.php'; use Model\Task; use Model\Board; @@ -425,7 +425,7 @@ class TaskPositionTest extends Base $s = new Swimlane($this->container); $this->assertEquals(1, $p->create(array('name' => 'Project #1'))); - $this->assertEquals(1, $s->create(1, 'test 1')); + $this->assertEquals(1, $s->create(array('project_id' => 1, 'name' => 'test 1'))); $this->assertEquals(1, $tc->create(array('title' => 'Task #1', 'project_id' => 1, 'column_id' => 1))); $this->assertEquals(2, $tc->create(array('title' => 'Task #2', 'project_id' => 1, 'column_id' => 1))); $this->assertEquals(3, $tc->create(array('title' => 'Task #3', 'project_id' => 1, 'column_id' => 1))); @@ -532,7 +532,7 @@ class TaskPositionTest extends Base $s = new Swimlane($this->container); $this->assertEquals(1, $p->create(array('name' => 'Project #1'))); - $this->assertEquals(1, $s->create(1, 'test 1')); + $this->assertEquals(1, $s->create(array('project_id' => 1, 'name' => 'test 1'))); $this->assertEquals(1, $tc->create(array('title' => 'Task #1', 'project_id' => 1, 'column_id' => 1))); $this->assertEquals(2, $tc->create(array('title' => 'Task #2', 'project_id' => 1, 'column_id' => 2))); diff --git a/tests/units/TaskStatusTest.php b/tests/units/Model/TaskStatusTest.php index c1f79142..e5172c4d 100644 --- a/tests/units/TaskStatusTest.php +++ b/tests/units/Model/TaskStatusTest.php @@ -1,6 +1,6 @@ <?php -require_once __DIR__.'/Base.php'; +require_once __DIR__.'/../Base.php'; use Model\Subtask; use Model\Task; diff --git a/tests/units/TaskTest.php b/tests/units/Model/TaskTest.php index d9c0fa4f..ebafa612 100644 --- a/tests/units/TaskTest.php +++ b/tests/units/Model/TaskTest.php @@ -1,6 +1,6 @@ <?php -require_once __DIR__.'/Base.php'; +require_once __DIR__.'/../Base.php'; use Model\Task; use Model\TaskCreation; diff --git a/tests/units/TimetableTest.php b/tests/units/Model/TimetableTest.php index 9c40dce1..887e1787 100644 --- a/tests/units/TimetableTest.php +++ b/tests/units/Model/TimetableTest.php @@ -1,6 +1,6 @@ <?php -require_once __DIR__.'/Base.php'; +require_once __DIR__.'/../Base.php'; use Model\User; use Model\Timetable; diff --git a/tests/units/UserSessionTest.php b/tests/units/Model/UserSessionTest.php index 6a831183..31072e6a 100644 --- a/tests/units/UserSessionTest.php +++ b/tests/units/Model/UserSessionTest.php @@ -1,6 +1,6 @@ <?php -require_once __DIR__.'/Base.php'; +require_once __DIR__.'/../Base.php'; use Core\Session; use Model\UserSession; diff --git a/tests/units/UserTest.php b/tests/units/Model/UserTest.php index f63ed3de..5b7edfb9 100644 --- a/tests/units/UserTest.php +++ b/tests/units/Model/UserTest.php @@ -1,6 +1,6 @@ <?php -require_once __DIR__.'/Base.php'; +require_once __DIR__.'/../Base.php'; use Model\User; use Model\Subtask; diff --git a/tests/units/WebhookTest.php b/tests/units/Model/WebhookTest.php index 946d744c..8ed630e4 100644 --- a/tests/units/WebhookTest.php +++ b/tests/units/Model/WebhookTest.php @@ -1,6 +1,6 @@ <?php -require_once __DIR__.'/Base.php'; +require_once __DIR__.'/../Base.php'; use Model\Config; use Model\Task; |