protected function assertNoUsersExists() { $userBusiness = new UserBusiness('User'); $users = $userBusiness->getAll(); $this->assertInternalType('array', $users); $this->assertEquals(0, count($users)); }
/** * @param \Seitenbau\Logger\SegmentIoStats $sio * @param $tracking_id * * @return array * @throws \Exception */ protected function addCalculatedStats($sio, $tracking_id) { $allUsers = $this->userBusiness->getAll(); $allWebsites = $this->websiteBusiness->getAll(); $numOfWebsites = count($allWebsites); list($numPublishData, $numWebsitesOnceSuccessfullyPublished, $publishedWebsitesUrl) = $this->collectPublishStats($allWebsites); $usedModuleIds = $this->getUsedModuleIds($allWebsites); $calculated_stats = array('diskUsage' => round(DiskUsageHelper::getDiskUsage() / 1024, 2), 'usedWebsites' => $numOfWebsites, 'publishingEnabledWebsites' => $numPublishData, 'publishedWebsites' => $numWebsitesOnceSuccessfullyPublished, 'publishedWebsitesInternalUrl' => $publishedWebsitesUrl['internal'], 'publishedWebsitesExternalUrl' => $publishedWebsitesUrl['external'], 'totalUsers' => count($allUsers), 'usedModuleIds' => $usedModuleIds); $sio->addProperties($tracking_id, $calculated_stats); return $calculated_stats; }
/** * @test * @group library */ public function businessShouldEditUserAsExpected() { // ARRANGE $userId = 'USER-ba67e2cf-1175-45e9-bcbd-a25cee8a74c1-USER'; $editValues = array('email' => '*****@*****.**', 'lastname' => 'rewind_business_edited', 'firstname' => 'jonny_business_edited', 'gender' => 'm', 'password' => 'EditTest01', 'isSuperuser' => true, 'isDeletable' => false, 'isOwner' => false); // ACT $testUser = $this->business->edit($userId, $editValues); // ASSERT $this->assertTrue($this->business->validatePassword($editValues['password'], $testUser->getPassword())); foreach ($editValues as $field => $value) { if ($field == 'password') { continue; } if (in_array($field, array('isSuperuser', 'isDeletable', 'isOwner'))) { $getter = $field; } else { $getter = 'get' . $field; } $this->assertSame($editValues[$field], $testUser->{$getter}()); } }
/** * @param string $identity - email address * @param mixed $credentials - e.g. password string * * @return \Cms\Access\Auth\Result */ public function checkLogin($identity, $credentials) { if (is_null($identity) || is_null($credentials) || !is_string($credentials)) { return null; } try { // get user object $userBusiness = new User('User'); $user = $userBusiness->getByEmail($identity); // check credentials $ph = new PasswordHasher(); if (!$ph->validate($credentials, $user->getPassword())) { return null; } // create auth result and return it return $this->createSuccessAuthResult($user); } catch (\Exception $e) { Registry::getLogger()->logException(__METHOD__, __LINE__, $e, \Seitenbau\Log::DEBUG); return null; } }
protected function asserUserExists($userId, $userCreateValues) { $userBusiness = new UserBusiness('User'); $user = $userBusiness->getById($userId); $this->assertUserCreatedSuccessfully($userCreateValues, $user); }