aboutsummaryrefslogtreecommitdiff
path: root/tests/functional
diff options
context:
space:
mode:
authorJan-Hendrik Willms <tleilax+studip@gmail.com>2022-07-14 08:21:04 +0000
committerDavid Siegfried <david.siegfried@uni-vechta.de>2022-07-14 08:21:04 +0000
commit24377df5463c10696077822a81a8fa20790a4749 (patch)
tree98db3b55da25cf32d5ea3af46314077cc071e920 /tests/functional
parentb7dcb67da285cd25122a59dd342ca78400450ff2 (diff)
fix errors in tests, fixes #1309
Closes #1309 Merge request studip/studip!805
Diffstat (limited to 'tests/functional')
-rw-r--r--tests/functional/lib/models/resources/BuildingTest.php9
-rw-r--r--tests/functional/lib/models/resources/LocationTest.php7
-rw-r--r--tests/functional/lib/models/resources/ResourceAssignmentTest.php42
-rw-r--r--tests/functional/lib/models/resources/ResourceTest.php202
-rw-r--r--tests/functional/lib/models/resources/RoomTest.php77
-rw-r--r--tests/functional/lib/resources/ResourceManagerTest.php77
-rw-r--r--tests/functional/lib/resources/RoomManagerTest.php94
7 files changed, 207 insertions, 301 deletions
diff --git a/tests/functional/lib/models/resources/BuildingTest.php b/tests/functional/lib/models/resources/BuildingTest.php
index 109cccb..6576196 100644
--- a/tests/functional/lib/models/resources/BuildingTest.php
+++ b/tests/functional/lib/models/resources/BuildingTest.php
@@ -23,10 +23,15 @@ class BuildingTest extends \Codeception\Test\Unit
protected $db_handle;
protected $oldUser;
+ private $location_cat;
+ private $building_cat;
+ private $location;
+ private $building;
+
/**
* @SuppressWarnings(PHPMD.Superglobals)
*/
- protected function _before()
+ protected function setUp(): void
{
//First we must initialise the StudipPDO database connection:
$this->db_handle = new \StudipPDO(
@@ -61,7 +66,7 @@ class BuildingTest extends \Codeception\Test\Unit
//Everything is set up for the test cases.
}
- protected function _after()
+ protected function tearDown(): void
{
//We must roll back the changes we made in this test
//so that the live database remains unchanged after
diff --git a/tests/functional/lib/models/resources/LocationTest.php b/tests/functional/lib/models/resources/LocationTest.php
index 97b139c..a8c4261 100644
--- a/tests/functional/lib/models/resources/LocationTest.php
+++ b/tests/functional/lib/models/resources/LocationTest.php
@@ -26,7 +26,10 @@ class LocationTest extends \Codeception\Test\Unit
protected $db_handle;
protected $oldUser;
- protected function _before()
+ private $location_cat;
+ private $location;
+
+ protected function setUp(): void
{
//First we must initialise the StudipPDO database connection:
$this->db_handle = new \StudipPDO(
@@ -65,7 +68,7 @@ class LocationTest extends \Codeception\Test\Unit
//Everything is set up for the test cases.
}
- protected function _after()
+ protected function tearDown(): void
{
//We must roll back the changes we made in this test
//so that the live database remains unchanged after
diff --git a/tests/functional/lib/models/resources/ResourceAssignmentTest.php b/tests/functional/lib/models/resources/ResourceAssignmentTest.php
index f1a6a6c..f2c2fcd 100644
--- a/tests/functional/lib/models/resources/ResourceAssignmentTest.php
+++ b/tests/functional/lib/models/resources/ResourceAssignmentTest.php
@@ -20,9 +20,16 @@
class ResourceAssignmentTest extends \Codeception\Test\Unit
{
protected $db_handle;
- protected $oldPerm, $oldUser;
+ protected $oldPerm;
+ protected $oldUser;
- protected function _before()
+ private $test_user_username;
+ private $test_user;
+ private $resource_category;
+ private $resource;
+ private $booking;
+
+ protected function setUp(): void
{
//First we must initialise the StudipPDO database connection:
$this->db_handle = new \StudipPDO(
@@ -55,12 +62,12 @@ class ResourceAssignmentTest extends \Codeception\Test\Unit
//As a final step we create the SORM objects for our test cases:
$this->test_user_username = 'test_user_' . date('YmdHis');
- $this->test_user = new User();
- $this->test_user->username = $this->test_user_username;
- $this->test_user->vorname = 'Test';
- $this->test_user->nachname = 'User';
- $this->test_user->perms = 'admin';
- $this->test_user->store();
+ $this->test_user = User::create([
+ 'username' => $this->test_user_username,
+ 'vorname' => 'Test',
+ 'nachname' => 'User',
+ 'perms' => 'admin',
+ ]);
$perm = new ResourcePermission();
$perm->user_id = $this->test_user->id;
@@ -88,21 +95,9 @@ class ResourceAssignmentTest extends \Codeception\Test\Unit
0,
new DateTime('2017-12-04 15:00:00+0000')
);
-
- $this->another_booking = $this->resource->createBooking(
- $this->test_user,
- $this->test_user->id,
- [
- [
- 'begin' => new DateTime('2017-12-06 0:00:00+0000'),
- 'end' => new DateTime('2017-12-06 12:00:00+0000')
- ]
- ]
- );
- //Everything is set up for the test cases.
}
- protected function _after()
+ protected function tearDown(): void
{
//We must roll back the changes we made in this test
//so that the live database remains unchanged after
@@ -175,9 +170,6 @@ class ResourceAssignmentTest extends \Codeception\Test\Unit
{
$time_intervals = $this->booking->getTimeIntervals();
- $this->assertEquals(
- 4,
- count($time_intervals)
- );
+ $this->assertCount(4, $time_intervals);
}
}
diff --git a/tests/functional/lib/models/resources/ResourceTest.php b/tests/functional/lib/models/resources/ResourceTest.php
index 86c46f9..66eae55 100644
--- a/tests/functional/lib/models/resources/ResourceTest.php
+++ b/tests/functional/lib/models/resources/ResourceTest.php
@@ -3,9 +3,29 @@
class ResourceTest extends \Codeception\Test\Unit
{
protected $db_handle;
- protected $oldPerm, $oldUser;
-
- protected function _before()
+ protected $oldPerm;
+ protected $oldUser;
+
+ private $test_user_username;
+ private $test_user;
+ private $test_property_name;
+ private $test_property2_name;
+ private $resource_cat;
+ private $test_resource_name;
+ private $resource;
+ private $booking_start_time;
+ private $booking_end_time;
+ private $booking_repeat_end;
+ private $booking;
+ private $lock_start_time;
+ private $lock_end_time;
+ private $lock;
+ private $course;
+ private $course_date;
+ private $user2;
+
+
+ protected function setUp(): void
{
//First we must initialise the StudipPDO database connection:
$this->db_handle = new \StudipPDO(
@@ -36,44 +56,44 @@ class ResourceTest extends \Codeception\Test\Unit
//As a final step we create the SORM objects for our test cases:
$this->test_user_username = 'test_user_' . date('YmdHis');
- $this->test_user = new User();
- $this->test_user->username = $this->test_user_username;
- $this->test_user->vorname = 'Test';
- $this->test_user->nachname = 'User';
- $this->test_user->perms = 'admin';
- $this->test_user->store();
+ $this->test_user = User::create([
+ 'username' => $this->test_user_username,
+ 'vorname' => 'Test',
+ 'nachname' => 'User',
+ 'perms' => 'admin',
+ ]);
$this->test_property_name = 'test_' . date('YmdHis');
$this->test_property2_name = 'some_test_user_' . date('YmdHis');
- $this->resource_cat = new ResourceCategory();
- $this->resource_cat->name = 'Test Category';
- $this->resource_cat->class_name = 'Resource';
- $this->resource_cat->iconnr = '1';
- $this->resource_cat->store();
-
- $def = new ResourcePropertyDefinition();
- $def->name = $this->test_property_name;
- $def->type = 'text';
- $def->searchable = '0';
- $def->range_search = '0';
- $def->store();
-
- $def2 = new ResourcePropertyDefinition();
- $def2->name = $this->test_property2_name;
- $def2->type = 'user';
- $def2->searchable = '0';
- $def2->range_search = '0';
- $def2->store();
-
- $this->test_property = $this->resource_cat->addProperty(
+ $this->resource_cat = ResourceCategory::create([
+ 'name' => 'Test Category',
+ 'class_name' => Resource::class,
+ 'iconnr' => 1,
+ ]);
+
+ ResourcePropertyDefinition::create([
+ 'name' => $this->test_property_name,
+ 'type' => 'text',
+ 'searchable' => false,
+ 'range_search' => false,
+ ]);
+
+ ResourcePropertyDefinition::create([
+ 'name' => $this->test_property2_name,
+ 'type' => 'user',
+ 'searchable' => false,
+ 'range_search' => false,
+ ]);
+
+ $this->resource_cat->addProperty(
$this->test_property_name,
'text',
true,
true
);
- $this->test_property2 = $this->resource_cat->addProperty(
+ $this->resource_cat->addProperty(
$this->test_property2_name,
'user',
false,
@@ -86,7 +106,7 @@ class ResourceTest extends \Codeception\Test\Unit
$this->test_resource_name,
'Resource Description 20171013'
);
- $this->resource->requestable = '1';
+ $this->resource->requestable = true;
$this->resource->store();
$this->resource->setProperty(
@@ -99,11 +119,11 @@ class ResourceTest extends \Codeception\Test\Unit
$this->test_user
);
- $permission = new ResourcePermission();
- $permission->user_id = $this->test_user->id;
- $permission->resource_id = $this->resource->id;
- $permission->perms = 'admin';
- $permission->store();
+ ResourcePermission::create([
+ 'user_id' => $this->test_user->id,
+ 'resource_id' => $this->resource->id,
+ 'perms' => 'admin',
+ ]);
$this->booking_start_time = new DateTime('2017-10-02 8:00:00 +0000');
$this->booking_end_time = new DateTime('2017-10-02 10:00:00 +0000');
@@ -132,18 +152,18 @@ class ResourceTest extends \Codeception\Test\Unit
$this->lock_end_time
);
- $this->course = new Course();
- $this->course->name = 'Test Resource Course ' . date('YmdHis');
- $this->course->store();
+ $this->course = Course::create([
+ 'name' => 'Test Resource Course ' . date('YmdHis'),
+ ]);
- $this->course_date = new CourseDate();
- $this->course_date->range_id = $this->course->id;
- $this->course_date->autor_id = $this->test_user->id;
- $this->course_date->date = strtotime('2017-10-02 11:00:00 +0000');
- $this->course_date->end_time = strtotime('2017-10-02 12:00:00 +0000');
- $this->course_date->store();
+ CourseDate::create([
+ 'range_id' => $this->course->id,
+ 'autor_id' => $this->test_user->id,
+ 'date' => strtotime('2017-10-02 11:00:00 +0000'),
+ 'end_time' => strtotime('2017-10-02 12:00:00 +0000'),
+ ]);
- $this->request = $this->resource->createRequest(
+ $this->resource->createRequest(
$this->test_user,
$this->course->id,
'test createRequest',
@@ -152,12 +172,12 @@ class ResourceTest extends \Codeception\Test\Unit
]
);
- $this->user2 = new User();
- $this->user2->username = 'test_user2_' . date('YmdHis');
- $this->user2->perms = 'tutor';
- $this->user2->vorname = 'Test';
- $this->user2->nachname = 'User 2';
- $this->user2->store();
+ $this->user2 = User::create([
+ 'username' => 'test_user2_' . date('YmdHis'),
+ 'perms' => 'tutor',
+ 'vorname' => 'Test',
+ 'nachname' => 'User 2',
+ ]);
$this->resource->setUserPermission(
$this->user2,
@@ -167,7 +187,7 @@ class ResourceTest extends \Codeception\Test\Unit
//Everything is set up for the test cases.
}
- protected function _after()
+ protected function tearDown(): void
{
//We must roll back the changes we made in this test
//so that the live database remains unchanged after
@@ -185,14 +205,14 @@ class ResourceTest extends \Codeception\Test\Unit
InvalidResourceException::class
);
- $r = new Resource();
- $r->name = 'Invalid Resource';
- $r->store();
+ Resource::create([
+ 'name' => 'Invalid Resource',
+ ]);
}
public function testCreateResource()
{
- //$this->resource has been created in the _before() method
+ //$this->resource has been created in the setUp() method
$this->assertEquals(
$this->test_resource_name,
$this->resource->name
@@ -206,7 +226,7 @@ class ResourceTest extends \Codeception\Test\Unit
public function testCreateBooking()
{
- //The booking has been created in the _before() method.
+ //The booking has been created in the setUp() method.
$this->assertEquals(
$this->resource->id,
@@ -246,7 +266,7 @@ class ResourceTest extends \Codeception\Test\Unit
public function testCreateLock()
{
- //The resource lock has been created in the _before() method.
+ //The resource lock has been created in the setUp() method.
$this->assertEquals(
$this->resource->id,
@@ -266,7 +286,7 @@ class ResourceTest extends \Codeception\Test\Unit
public function testPropertyExists()
{
- //The property has been created in the _before() method.
+ //The property has been created in the setUp() method.
$this->assertTrue(
$this->resource->propertyExists(
@@ -277,7 +297,7 @@ class ResourceTest extends \Codeception\Test\Unit
public function testGetPropertyObject()
{
- //The property has been created in the _before() method.
+ //The property has been created in the setUp() method.
$property = $this->resource->getPropertyObject(
$this->test_property_name
@@ -296,7 +316,7 @@ class ResourceTest extends \Codeception\Test\Unit
public function testGetProperty()
{
- //The property has been created in the _before() method.
+ //The property has been created in the setUp() method.
$state = $this->resource->getProperty(
$this->test_property_name
@@ -310,7 +330,7 @@ class ResourceTest extends \Codeception\Test\Unit
public function testNonexistingProperty()
{
- //The resource has been created in the _before() method.
+ //The resource has been created in the setUp() method.
$this->assertFalse(
$this->resource->propertyExists(
@@ -321,7 +341,7 @@ class ResourceTest extends \Codeception\Test\Unit
public function testGetNonexistingPropertyObject()
{
- //The resource has been created in the _before() method.
+ //The resource has been created in the setUp() method.
$no_object = $this->resource->getPropertyObject(
'nonexistant_property_' . date('YmdHis')
@@ -334,7 +354,7 @@ class ResourceTest extends \Codeception\Test\Unit
public function testGetNonexistingProperty()
{
- //The resource has been created in the _before() method.
+ //The resource has been created in the setUp() method.
$no_object = $this->resource->getProperty(
'nonexistant_property_' . date('YmdHis')
@@ -349,7 +369,7 @@ class ResourceTest extends \Codeception\Test\Unit
{
$this->expectException(TypeError::class);
- //The resource has been created in the _before() method.
+ //The resource has been created in the setUp() method.
$no_object = $this->resource->getPropertyObject();
@@ -362,7 +382,7 @@ class ResourceTest extends \Codeception\Test\Unit
public function testGetPropertyWithoutName()
{
$this->expectException(TypeError::class);
- //The resource has been created in the _before() method.
+ //The resource has been created in the setUp() method.
$this->assertEquals(
null,
@@ -376,10 +396,7 @@ class ResourceTest extends \Codeception\Test\Unit
$this->test_property2_name
);
- $this->assertEquals(
- true,
- ($user instanceof User)
- );
+ $this->assertInstanceOf(User::class, $user);
$this->assertEquals(
$this->test_user_username,
@@ -393,13 +410,11 @@ class ResourceTest extends \Codeception\Test\Unit
'nonexistant_property' . date('YmdHis')
);
- $this->assertNull(
- $no_object
- );
+ $this->assertNull($no_object);
}
//Resource::setProperty and Resource::setPropertyRelatedObject
- //don't need to be tested since they are called in the _before() method.
+ //don't need to be tested since they are called in the setUp() method.
//If those set methods wouldn't work then the tests where
//properties or property objects are retrieved would fail.
@@ -407,20 +422,14 @@ class ResourceTest extends \Codeception\Test\Unit
{
$properties = $this->resource->getPropertyArray();
- $this->assertEquals(
- 2,
- count($properties)
- );
+ $this->assertCount(2, $properties);
}
public function testGetOnlyRequestablePropertyArray()
{
$properties = $this->resource->getPropertyArray(true);
- $this->assertEquals(
- 1,
- count($properties)
- );
+ $this->assertCount(1, $properties);
$this->assertEquals(
$this->test_property_name,
@@ -444,35 +453,35 @@ class ResourceTest extends \Codeception\Test\Unit
public function testResourceAddChild()
{
- //$this->resource has been created in the _before() method.
+ //$this->resource has been created in the setUp() method.
- $this->child = $this->resource_cat->createResource(
+ $child = $this->resource_cat->createResource(
'Test Resource Child 20171013',
'Resource Child Description 20171013'
);
- $this->resource->addChild($this->child);
+ $this->resource->addChild($child);
$this->assertEquals(
$this->resource->children[0]->id,
- $this->child->id
+ $child->id
);
$this->assertEquals(
- $this->child->parent_id,
+ $child->parent_id,
$this->resource->id
);
$this->assertEquals(
- $this->child->level,
- ($this->resource->level+1)
+ $child->level,
+ $this->resource->level + 1
);
}
public function testResourceIsAssigned()
{
//$this->resource has been created
- //in the _before()-Method.
+ //in the setUp()-Method.
$this->assertTrue(
$this->resource->isAssigned(
@@ -506,17 +515,14 @@ class ResourceTest extends \Codeception\Test\Unit
public function testGetResourceBookings()
{
- //$this->resource has been created in the _before() method.
+ //$this->resource has been created in the setUp() method.
$bookings = $this->resource->getResourceBookings(
new DateTime('2017-01-01 0:00:00 +0000'),
new DateTime('2017-12-31 23:59:59 +0000')
);
- $this->assertEquals(
- count($bookings),
- 1
- );
+ $this->assertCount(1, $bookings);
$this->assertEquals(
$bookings[0]->id,
@@ -592,7 +598,7 @@ class ResourceTest extends \Codeception\Test\Unit
)
);
- //user2 is set up in the _before() method and user2's
+ //user2 is set up in the setUp() method and user2's
//permission level on $this->resource is set to admin.
$user2_perms = $this->resource->getUserPermission($this->user2);
diff --git a/tests/functional/lib/models/resources/RoomTest.php b/tests/functional/lib/models/resources/RoomTest.php
index baf6573..82611f2 100644
--- a/tests/functional/lib/models/resources/RoomTest.php
+++ b/tests/functional/lib/models/resources/RoomTest.php
@@ -24,9 +24,23 @@ require_once __DIR__ . '/../../../_bootstrap.php';
class RoomTest extends \Codeception\Test\Unit
{
protected $db_handle;
- protected $oldPerm, $oldUser;
-
- protected function _before()
+ protected $oldPerm;
+ protected $oldUser;
+
+ private $test_user_username;
+ private $test_user;
+ private $location_cat;
+ private $building_cat;
+ private $room_cat;
+ private $location;
+ private $building;
+ private $room;
+ private $request_begin_date;
+ private $request_end_date;
+ private $course_date;
+ private $room_request;
+
+ protected function setUp(): void
{
//First we must initialise the StudipPDO database connection:
$this->db_handle = new \StudipPDO(
@@ -57,32 +71,24 @@ class RoomTest extends \Codeception\Test\Unit
//As a final step we create the SORM objects for our test cases:
$this->test_user_username = 'test_user_' . date('YmdHis');
- $this->test_user = new User();
- $this->test_user->username = $this->test_user_username;
- $this->test_user->vorname = 'Test';
- $this->test_user->nachname = 'User';
- $this->test_user->perms = 'admin';
- $this->test_user->store();
-
- $perms = new ResourcePermission();
- $perms->user_id = $this->test_user->id;
- $perms->resource_id = 'global';
- $perms->perms = 'tutor';
- $perms->store();
-
- $this->location_cat = ResourceManager::createLocationCategory(
- 'TestLocation'
- );
- $this->building_cat = ResourceManager::createBuildingCategory(
- 'TestBuilding'
- );
- $this->room_cat = ResourceManager::createRoomCategory(
- 'TestRoom'
- );
+ $this->test_user = User::create([
+ 'username' => $this->test_user_username,
+ 'vorname' => 'Test',
+ 'nachname' => 'User',
+ 'perms' => 'admin',
+ ]);
- $this->location = $this->location_cat->createResource(
- 'Test location object'
- );
+ ResourcePermission::create([
+ 'user_id' => $this->test_user->id,
+ 'resource_id' => 'global',
+ 'perms' => 'tutor',
+ ]);
+
+ $this->location_cat = ResourceManager::createLocationCategory('TestLocation');
+ $this->building_cat = ResourceManager::createBuildingCategory('TestBuilding');
+ $this->room_cat = ResourceManager::createRoomCategory('TestRoom');
+
+ $this->location = $this->location_cat->createResource('Test location object');
$this->building = $this->building_cat->createResource(
'Test building object',
@@ -100,19 +106,18 @@ class RoomTest extends \Codeception\Test\Unit
//it when we're testing finding rooms by a room request.
//The request we create is for a room with at least 22 seats.
$this->room->seats = 25;
-
- $this->room->requestable = '1';
-
+ $this->room->requestable = true;
$this->room->store();
$this->request_begin_date = new DateTime();
$this->request_begin_date->setTime(12,0,0);
$this->request_end_date = clone $this->request_begin_date;
$this->request_end_date->setTime(14,0,0);
- $this->course_date = new CourseDate();
- $this->course_date->date = $this->request_begin_date->getTimestamp();
- $this->course_date->end_time = $this->request_end_date->getTimestamp();
- $this->course_date->store();
+
+ $this->course_date = CourseDate::create([
+ 'date' => $this->request_begin_date->getTimestamp(),
+ 'end_time' => $this->request_end_date->getTimestamp(),
+ ]);
$this->room_request = $this->room->createRequest(
$this->test_user,
@@ -126,7 +131,7 @@ class RoomTest extends \Codeception\Test\Unit
//Everything is set up for the test cases.
}
- protected function _after()
+ protected function tearDown(): void
{
//We must roll back the changes we made in this test
//so that the live database remains unchanged after
diff --git a/tests/functional/lib/resources/ResourceManagerTest.php b/tests/functional/lib/resources/ResourceManagerTest.php
index 5b65c3b..f858e90 100644
--- a/tests/functional/lib/resources/ResourceManagerTest.php
+++ b/tests/functional/lib/resources/ResourceManagerTest.php
@@ -6,7 +6,11 @@ class ResourceManagerTest extends \Codeception\Test\Unit
protected $db_handle;
protected $oldUser;
- protected function _before()
+ private $test_cat;
+ private $position_def;
+ private $perm_resource;
+
+ protected function setUp(): void
{
//First we must initialise the StudipPDO database connection:
$this->db_handle = new \StudipPDO(
@@ -34,34 +38,32 @@ class ResourceManagerTest extends \Codeception\Test\Unit
//As a final step we create the SORM objects for our test cases:
- $this->test_cat = new ResourceCategory();
- $this->test_cat->class_name = 'Resource';
- $this->test_cat->store();
+ $this->test_cat = ResourceCategory::create([
+ 'class_name' => Resource::class,
+ ]);
- $this->position_def = new ResourcePropertyDefinition();
- $this->position_def->name = 'test_pos';
- $this->position_def->type = 'position';
- $this->position_def->store();
+ $this->position_def = ResourcePropertyDefinition::create([
+ 'name' => 'test_pos',
+ 'type' => 'position',
+ ]);
- $this->perm_user = new User();
- $this->perm_user->username = 'test_resource_perm';
- $this->perm_user->perms = 'autor';
- $this->perm_user->store();
+ User::create([
+ 'username' => 'test_resource_perm',
+ 'perms' => 'autor',
+ ]);
$this->perm_resource = $this->test_cat->createResource(
'Permission Test Resource'
);
$this->perm_resource->store();
- $this->test_def = new ResourcePropertyDefinition();
- $this->test_def->name = 'test_is_test';
- $this->test_def->type = 'bool';
- $this->test_def->store();
-
- //Everything is set up for the test cases.
+ ResourcePropertyDefinition::create([
+ 'name' => 'test_is_test',
+ 'type' => 'bool',
+ ]);
}
- protected function _after()
+ protected function tearDown(): void
{
//We must roll back the changes we made in this test
//so that the live database remains unchanged after
@@ -115,8 +117,7 @@ class ResourceManagerTest extends \Codeception\Test\Unit
$category->iconnr
);
- $this->assertEquals(
- true,
+ $this->assertTrue(
$category->hasProperty('test_is_test', 'bool')
);
}
@@ -137,14 +138,12 @@ class ResourceManagerTest extends \Codeception\Test\Unit
);
//Test default properties:
- $this->assertEquals(
- true,
+ $this->assertTrue(
$location_cat->hasProperty('geo_coordinates', 'position')
);
//Test optional properties:
- $this->assertEquals(
- true,
+ $this->assertTrue(
$location_cat->hasProperty('test_is_test', 'bool')
);
}
@@ -165,29 +164,24 @@ class ResourceManagerTest extends \Codeception\Test\Unit
);
//Test default properties:
- $this->assertEquals(
- true,
+ $this->assertTrue(
$building_cat->hasProperty('address', 'text')
);
- $this->assertEquals(
- true,
+ $this->assertTrue(
$building_cat->hasProperty('accessible', 'bool')
);
- $this->assertEquals(
- true,
+ $this->assertTrue(
$building_cat->hasProperty('geo_coordinates', 'position')
);
- $this->assertEquals(
- true,
+ $this->assertTrue(
$building_cat->hasProperty('number', 'text')
);
//Test optional properties:
- $this->assertEquals(
- true,
+ $this->assertTrue(
$building_cat->hasProperty('test_is_test', 'bool')
);
}
@@ -208,24 +202,20 @@ class ResourceManagerTest extends \Codeception\Test\Unit
);
//Test default properties:
- $this->assertEquals(
- true,
+ $this->assertTrue(
$room_cat->hasProperty('room_type', 'select')
);
- $this->assertEquals(
- true,
+ $this->assertTrue(
$room_cat->hasProperty('seats', 'num')
);
- $this->assertEquals(
- true,
+ $this->assertTrue(
$room_cat->hasProperty('booking_plan_is_public', 'bool')
);
//Test optional properties:
- $this->assertEquals(
- true,
+ $this->assertTrue(
$room_cat->hasProperty('test_is_test', 'bool')
);
}
@@ -309,7 +299,6 @@ class ResourceManagerTest extends \Codeception\Test\Unit
public static function coordinateProvider(): array
{
-
return [
'empty' => [''],
diff --git a/tests/functional/lib/resources/RoomManagerTest.php b/tests/functional/lib/resources/RoomManagerTest.php
deleted file mode 100644
index 910a576..0000000
--- a/tests/functional/lib/resources/RoomManagerTest.php
+++ /dev/null
@@ -1,94 +0,0 @@
-<?php
-
-
-require_once __DIR__ . '/../../_bootstrap.php';
-require_once 'lib/resources/RoomManager.class.php';
-require_once 'lib/resources/ResourceManager.class.php';
-
-
-class RoomManagerTest extends \Codeception\Test\Unit
-{
- protected $db_handle;
-
-
- protected function _before()
- {
- //First we must initialise the StudipPDO database connection:
- $this->db_handle = new \StudipPDO(
- 'mysql:host='
- . $GLOBALS['DB_STUDIP_HOST']
- . ';dbname='
- . $GLOBALS['DB_STUDIP_DATABASE'],
- $GLOBALS['DB_STUDIP_USER'],
- $GLOBALS['DB_STUDIP_PASSWORD']
- );
-
- //Then we must start a transaction before we access the database,
- //otherwise we would spam the live database with test data!
- $this->db_handle->beginTransaction();
-
- //Now we tell the DBManager about the connection
- //we have established to the Stud.IP database:
- \DBManager::getInstance()->setConnection('studip', $this->db_handle);
-
- $this->user = new User();
- $this->user->username = 'test_user_' . date('YmdHis');
- $this->user->vorname = 'Test';
- $this->user->nachname = 'User';
- $this->user->perms = 'admin';
- $this->user->store();
-
- ResourceManager::setGlobalResourcePermission($this->user, 'admin');
-
- $this->location_cat = ResourceManager::createLocationCategory(
- 'TestLocation'
- );
- $this->building_cat = ResourceManager::createBuildingCategory(
- 'TestBuilding'
- );
- $this->room_cat = ResourceManager::createRoomCategory(
- 'TestRoom'
- );
-
- $this->location = $this->location_cat->createResource(
- 'Test location object'
- );
- $this->building = $this->building_cat->createResource(
- 'Test building object',
- '',
- $this->location->id
- );
- $this->room = $this->room_cat->createResource(
- 'Test room object',
- '',
- $this->building->id
- );
-
- $this->room->seats = 25;
-
- $this->room->createLock(
- $this->user,
- new DateTime('2017-10-02 8:00:00 +0000'),
- new DateTime('2017-10-02 18:00:00 +0000')
- );
-
- $this->course = new Course();
- $this->course->name = 'test_course_' . date('YmdHis');
- $this->course->store();
-
- $this->course_date = new CourseDate();
- $this->course_date->range_id = $this->course->id;
- $this->course_date->autor_id = $this->user->id;
- $this->course_date->date = strtotime('2017-10-01 8:00:00 +0000');
- $this->course_date->end_time = strtotime('2017-10-01 10:00:00 +0000');
- $this->course_date->store();
- }
-
- protected function _after()
- {
- //We must roll back the changes we made in this test
- //so that the live database remains unchanged after
- //all the test cases of this test have been finished:
- $this->db_handle->rollBack();
- }
-}