/** * @test */ public function findBySearchTermReturnsFilteredResult() { $tag1 = new Tag('foobar'); $tag2 = new Tag('foo bar'); $tag3 = new Tag('bar foo bar'); $this->tagRepository->add($tag1); $this->tagRepository->add($tag2); $this->tagRepository->add($tag3); $this->persistenceManager->persistAll(); $this->persistenceManager->clearState(); $this->assertCount(3, $this->tagRepository->findBySearchTerm('foo')); $this->assertCount(2, $this->tagRepository->findBySearchTerm('foo bar')); $this->assertCount(1, $this->tagRepository->findBySearchTerm(' foo ')); }
/** * Creates a user based on the given information * * The created user and account are automatically added to their respective repositories and thus be persisted. * * @param string $username The username of the user to be created. * @param string $password Password of the user to be created * @param string $firstName First name of the user to be created * @param string $lastName Last name of the user to be created * @param string $department department of the user to be created * @param string $photo photo of the user to be created * @param array $roleIdentifiers A list of role identifiers to assign * @param string $authenticationProviderName Name of the authentication provider to use. Example: "Typo3BackendProvider" * @return User The created user instance * @api */ public function createUserPhlu($username, $password, $firstName, $lastName, $department, $photo, array $roleIdentifiers = null, $authenticationProviderName = null) { $collection = $this->assetCollectionRepository->findByCollectionName('phluCollection2')->getFirst(); if (!$collection) { $collection = new \TYPO3\Media\Domain\Model\AssetCollection('phluCollection2'); $this->assetCollectionRepository->add($collection); $this->persistenceManager->persistAll(); } $user = new User(); $user->setDepartment($department); $name = new PersonName('', $firstName, '', $lastName, '', $username); $user->setName($name); $resource = $this->resourceManager->importResource($photo); $image = new Image($resource); $image->setTitle($name->getFullName()); $tag = $this->tagRepository->findBySearchTerm('Hauswart')->getFirst(); if (!$tag) { $tag = new Tag(); $tag->setLabel('Hauswart'); $this->tagRepository->add($tag); $collection->addTag($tag); } $image->addTag($tag); $user->setPhoto($image); $this->assetRepository->add($image); $collection->addAsset($image); $this->assetCollectionRepository->update($collection); return $this->addUserPhlu($username, $password, $user, $roleIdentifiers, $authenticationProviderName); }
/** * Shows a list of assets * * @param string $searchTerm An optional search term used for filtering the list of assets * @return string */ public function indexAction($searchTerm = '') { $assets = $this->assetRepository->findBySearchTermOrTags($searchTerm, $this->tagRepository->findBySearchTerm($searchTerm)->toArray()); $this->view->assign('assets', $assets); }