Пример #1
0
 /**
  * Test remove from relation
  */
 public function testRemove()
 {
     $this->createUsers(5);
     $users_in_afiveone = $this->accounts->usersBelongingTo(1);
     $users_in_afiveone->add(1, 2, 3, 5);
     $this->assertEquals([1, 2, 3, 5], $users_in_afiveone->get());
     $users_in_afiveone->remove(2);
     $users_in_afiveone->remove(3);
     $this->assertEquals([1, 5], $users_in_afiveone->get());
     $users_in_afiveone->clear();
     $this->assertEquals([], $users_in_afiveone->get());
 }
Пример #2
0
 /**
  * Test default values
  */
 public function testDefaults()
 {
     $id = $this->accounts->insert(['license_key' => '123', 'subdomain' => 'afiveone', 'url' => 'https://afiveone.manageprojects.com'])[0];
     $this->assertEquals(1, $id);
     $record = $this->accounts->get($id);
     $this->assertTrue(is_array($record));
     $this->assertEquals(1, $record['_id']);
     $this->assertEquals('123', $record['license_key']);
     $this->assertEquals('afiveone', $record['subdomain']);
     $this->assertEquals('https://afiveone.manageprojects.com', $record['url']);
     $this->assertEquals('UTC', $record['timezone']);
     $this->assertEquals(false, $record['is_paid']);
 }
Пример #3
0
 /**
  * Test if unique value is released when item is removed (case insensitive)
  */
 public function testInsensitiveUniquenessReleaseOnRecordRemove()
 {
     $this->assertTrue($this->accounts->isUnique('subdomain'));
     $id = $this->accounts->insert(['license_key' => '123', 'subdomain' => 'aFiveOne', 'url' => 'https://www.activecollab.com'])[0];
     $this->accounts->delete($id);
     $this->accounts->insert(['license_key' => '123', 'subdomain' => 'AFIVEONE', 'url' => 'https://www.activecollab.com']);
 }
Пример #4
0
 /**
  * Test remove IDs
  */
 public function testRemove()
 {
     $this->assertEquals(1, $this->accounts->getNextId());
     $this->assertEquals(0, $this->accounts->count());
     $this->accounts->insert(['license_key' => '123', 'subdomain' => 'afiveone', 'url' => 'https://www.activecollab.com'], ['license_key' => '456', 'subdomain' => 'feather', 'url' => 'https://www.activecollab.com'], ['license_key' => '789', 'subdomain' => 'supportyard', 'url' => 'https://www.activecollab.com']);
     $this->assertEquals(3, $this->accounts->count());
     $this->assertEquals([1, 2, 3], $this->accounts->getIds());
     $this->accounts->delete(2);
     $this->assertEquals(2, $this->accounts->count());
     $this->assertEquals([1, 3], $this->accounts->getIds());
 }
Пример #5
0
 /**
  * Test if member and client counts are properly refreshed as users are added and removed from the list
  */
 public function testMembersAndClientsCount()
 {
     $afiveone_id = $this->accounts->insert(['subdomain' => 'afiveone', 'url' => 'https://afiveone.activecollab.com', 'license_key' => '123'])[0];
     $this->assertEquals(1, $this->accounts->count());
     $this->assertEquals(1, $afiveone_id);
     list($owner_id, $member_id, $subcontractor_id, $client1_id, $client2_id) = $this->users->insert(['acid' => 1001, 'email' => '*****@*****.**', 'role' => 'Owner'], ['acid' => 1002, 'email' => '*****@*****.**', 'role' => 'Member'], ['acid' => 1003, 'email' => '*****@*****.**', 'role' => 'Subcontractor'], ['acid' => 1004, 'email' => '*****@*****.**', 'role' => 'Client'], ['acid' => 1005, 'email' => '*****@*****.**', 'role' => 'Client']);
     $this->assertEquals(1, $owner_id);
     $this->assertEquals(2, $member_id);
     $this->assertEquals(3, $subcontractor_id);
     $this->assertEquals(4, $client1_id);
     $this->assertEquals(5, $client2_id);
     $afiveone_users = $this->accounts->usersBelongingTo(1);
     $this->assertInstanceOf('ActiveCollab\\Resistance\\Storage\\Relationship\\BelongingTo', $afiveone_users);
     $this->assertEquals(0, $this->accounts->getFieldValue(1, 'members_count'));
     $this->assertEquals(0, $this->accounts->getFieldValue(1, 'clients_count'));
     // ---------------------------------------------------
     //  Add members
     // ---------------------------------------------------
     $afiveone_users->add($owner_id, $member_id, $subcontractor_id);
     $this->assertEquals(3, $this->accounts->getFieldValue(1, 'members_count'));
     $this->assertEquals(0, $this->accounts->getFieldValue(1, 'clients_count'));
     // ---------------------------------------------------
     //  Add clients
     // ---------------------------------------------------
     $afiveone_users->add($client1_id, $client2_id);
     $this->assertEquals(3, $this->accounts->getFieldValue(1, 'members_count'));
     $this->assertEquals(2, $this->accounts->getFieldValue(1, 'clients_count'));
     // ---------------------------------------------------
     //  Remove one member and one client
     // ---------------------------------------------------
     $afiveone_users->remove($subcontractor_id);
     $afiveone_users->remove($client1_id);
     $this->assertEquals(2, $this->accounts->getFieldValue(1, 'members_count'));
     $this->assertEquals(1, $this->accounts->getFieldValue(1, 'clients_count'));
     // ---------------------------------------------------
     //  Clear
     // ---------------------------------------------------
     $afiveone_users->clear();
     $this->assertEquals(0, $this->accounts->getFieldValue(1, 'members_count'));
     $this->assertEquals(0, $this->accounts->getFieldValue(1, 'clients_count'));
 }