public function testTruncateCategoryAnalytics()
 {
     Factory::create('Giftertipster\\Entity\\Eloquent\\Analytic\\CategoryAnalytic');
     assertThat(CategoryAnalytic::get()->toArray(), not(emptyArray()));
     $this->repo->truncateCategoryAnalytics();
     assertThat(CategoryAnalytic::get()->toArray(), emptyArray());
 }
Ejemplo n.º 2
0
 public function testCallChunkedWithNoValues()
 {
     $values = array();
     assertThat(ArrayOperation::callChunked(function ($values) {
         return array(count($values));
     }, $values, 2), is(emptyArray()));
 }
 public function testDeleteWhenIdIsProvided()
 {
     $product = Factory::create('Giftertipster\\Entity\\Eloquent\\Product');
     $keyword_profile = Factory::make('Giftertipster\\Entity\\Eloquent\\KeywordProfile');
     $product->keywordProfile()->save($keyword_profile);
     $this->repo->delete(1);
     assertThat(KeywordProfile::get()->toArray(), emptyArray());
 }
 public function testArraySeparateWithUndefinedIndexes()
 {
     $array = [1 => 'January', 2 => 'February', 3 => 'March', 4 => 'April'];
     $keys = [5, 6];
     $result = array_separate($array, $keys);
     assertThat($result, is(emptyArray()));
     assertThat(count($array), is(equalTo(4)));
 }
Ejemplo n.º 5
0
 public function testDelete()
 {
     $this->client->delete();
     $msgs = [];
     $this->client->receive(function ($msg) use(&$msgs) {
         $msgs[] = $msg;
     }, null);
     assertThat($msgs, is(emptyArray()));
 }
Ejemplo n.º 6
0
 public function testGetNonArtifactDescendantsWithoutMaterialize()
 {
     $uploadTreeProxy = new UploadTreeProxy($uploadId = 1, $options = array(), $uploadTreeTableName = 'uploadtree_a');
     $artifact = new ItemTreeBounds(2, 'uploadtree_a', $uploadId, 2, 3);
     $artifactDescendants = $uploadTreeProxy->getNonArtifactDescendants($artifact);
     assertThat($artifactDescendants, emptyArray());
     $zip = new ItemTreeBounds(1, 'uploadtree_a', $uploadId, 1, 24);
     $zipDescendants = $uploadTreeProxy->getNonArtifactDescendants($zip);
     assertThat(array_keys($zipDescendants), arrayContainingInAnyOrder(array(6, 7, 8, 10, 11, 12)));
 }
 public function testDelete()
 {
     $seed_product1 = Factory::create('Giftertipster\\Entity\\Eloquent\\Product');
     $seed_product2 = Factory::create('Giftertipster\\Entity\\Eloquent\\Product');
     $update_attributes = ['binding' => 'binding update test'];
     $product_repo = $this->app->make('Giftertipster\\Repository\\Product\\EloquentProductRepository');
     $product_repo->delete(2);
     $product = $this->eloquent_product->all()->toArray();
     assertThat($product, not(emptyArray()));
     assertThat($product[0], hasKeyValuePair('id', 1));
     assertThat($product[0], not(hasKeyValuePair('id', 2)));
 }
Ejemplo n.º 8
0
 public function testAddVariableWithRegexRoute()
 {
     $patternBuilder = \Mockery::mock('Rootr\\PatternBuilder');
     $patternBuilder->shouldReceive('build')->andReturn(['/products/(\\d+)', ['id']]);
     $router = new Router($patternBuilder);
     $router->add('GET', '/products/{id}', function ($id) {
         return "/products/{$id}";
     });
     assertThat($router->getStaticRoutes(), emptyArray());
     assertThat($router->getVariableRoutes(), arrayWithSize(1));
     assertThat($router->getVariableRoutes(), hasKeyInArray('/products/(\\d+)'));
 }
 public function testGetUnfulfilledRequests()
 {
     Factory::create('Giftertipster\\Entity\\Eloquent\\User', ['permissions' => []]);
     Factory::create('Giftertipster\\Entity\\Eloquent\\Product');
     Factory::create('Giftertipster\\Entity\\Eloquent\\Product');
     $seed_request1 = Factory::create('Giftertipster\\Entity\\Eloquent\\ProductDeleteRequest', ['user_id' => 1, 'product_id' => 1, 'is_fulfilled' => 1, 'delete_type' => 'delete']);
     $seed_request2 = Factory::create('Giftertipster\\Entity\\Eloquent\\ProductDeleteRequest', ['user_id' => 1, 'product_id' => 2, 'is_fulfilled' => 0, 'delete_type' => 'delete']);
     $repo = $this->app->make('Giftertipster\\Repository\\ProductDeleteRequest\\EloquentProductDeleteRequestRepository');
     $requests = $repo->getUnfulfilledRequests();
     assertThat($requests, not(emptyArray()));
     assertThat($requests[0], hasKeyValuePair('id', 2));
     assertThat($requests[0], hasKeyValuePair('is_fulfilled', 0));
 }
 public function testSubProductForCartAddWorks()
 {
     $sub_product = Factory::create('Giftertipster\\Entity\\Eloquent\\SubProduct', ['id' => 1, 'vendor_id' => 'asin stub', 'offer_listing_id' => 'offer listing id stub']);
     $image = Factory::make('Giftertipster\\Entity\\Eloquent\\Image', ['category' => 'variation']);
     $image2 = Factory::make('Giftertipster\\Entity\\Eloquent\\Image', ['category' => 'primary']);
     $sub_product->images()->save($image);
     $sub_product->images()->save($image2);
     $sub_product2 = Factory::create('Giftertipster\\Entity\\Eloquent\\SubProduct');
     $sub_product_repo = $this->app->make('Giftertipster\\Repository\\SubProduct\\EloquentSubProductRepository');
     $result_sub_product = $sub_product_repo->subProductDataForCartAdd(1);
     assertThat($result_sub_product, hasKeyValuePair('id', 1));
     assertThat($result_sub_product, hasKey('images'));
     assertThat($result_sub_product['images'], not(emptyArray()));
 }
Ejemplo n.º 11
0
 public function testUploads2Jobs()
 {
     $jobs = array(3 => 2, 4 => 3, 5 => 5, 6 => 8 % 6, 7 => 13 % 6, 8 => 21 % 6);
     foreach ($jobs as $jobId => $jobUpload) {
         $this->dbManager->insertTableRow('job', array('job_pk' => $jobId, 'job_upload_fk' => $jobUpload));
     }
     $uploadDao = M::mock('Fossology\\Lib\\Dao\\UploadDao');
     $showJobDao = new ShowJobsDao($this->dbManager, $uploadDao);
     $jobsWithoutUpload = $showJobDao->uploads2Jobs(array());
     assertThat($jobsWithoutUpload, is(emptyArray()));
     $jobsWithUploadIdOne = $showJobDao->uploads2Jobs(array(1));
     assertThat($jobsWithUploadIdOne, equalTo(array(1, 7)));
     $jobsAtAll = $showJobDao->uploads2Jobs(array(1, 2, 3, 4, 5));
     assertThat($jobsAtAll, equalTo(array(1, 7, 2, 3, 6, 4, 8, 5)));
     $jobsWithUploadFour = $showJobDao->uploads2Jobs(array(4));
     assertThat($jobsWithUploadFour, is(emptyArray()));
 }
 public function testGetIncompleteProductLoadsWhenIdHasProduct()
 {
     $user = Factory::create('Giftertipster\\Entity\\Eloquent\\User', ['permissions' => ['test']]);
     $prod_req = Factory::create('Giftertipster\\Entity\\Eloquent\\ProductRequest', ['created_at' => Carbon::tomorrow(), 'user_id' => 1, 'product_id' => 1, 'vendor' => 'foo', 'vendor_id' => 'bar']);
     $idea = Factory::create('Giftertipster\\Entity\\Eloquent\\Idea', ['created_at' => Carbon::today(), 'user_id' => 1, 'description' => 'foobar idea', 'is_fulfilled' => 0]);
     $repo_result = $this->repo()->getIncompleteProductLoads(1);
     //since keys aren't adjusted after sorting, re apply keys:
     foreach ($repo_result as $item) {
         $result[] = $item;
     }
     assertThat($result, not(emptyArray()));
     assertThat($result[0], hasKeyValuePair('type', 'idea load'));
     assertThat($result[0], hasKey('created_at'));
     assertThat($result[0], hasKey('updated_at'));
     assertThat($result[0], hasKey('description'));
     assertThat($result[0], hasKeyValuePair('query', ['idea_description' => 'foobar idea']));
     assertThat($result[0], hasKey('human_time_diff'));
     assertThat($result, not(hasKey(1)));
 }
Ejemplo n.º 13
0
 public function testGetCopyrightHighlights()
 {
     $this->testDb->createPlainTables(array(), true);
     $this->testDb->createInheritedTables();
     $uploadDao = M::mock('Fossology\\Lib\\Dao\\UploadDao');
     $uploadDao->shouldReceive('getUploadEntry')->with(1)->andReturn(array('pfile_fk' => 8));
     $uploadDao->shouldReceive('getUploadEntry')->with(2)->andReturn(array('pfile_fk' => 9));
     $copyrightDao = new CopyrightDao($this->dbManager, $uploadDao);
     $noHighlights = $copyrightDao->getHighlights($uploadTreeId = 1);
     assertThat($noHighlights, emptyArray());
     $this->testDb->insertData(array('copyright'));
     $highlights = $copyrightDao->getHighlights($uploadTreeId = 1);
     assertThat($highlights, arrayWithSize(1));
     $highlight0 = $highlights[0];
     assertThat($highlight0, anInstanceOf(Highlight::classname()));
     $this->assertInstanceOf('Fossology\\Lib\\Data\\Highlight', $highlight0);
     assertThat($highlight0->getEnd(), equalTo(201));
     $hilights = $copyrightDao->getHighlights($uploadTreeId = 2);
     assertThat($hilights, arrayWithSize(1));
     $hilight0 = $hilights[0];
     assertThat($hilight0->getStart(), equalTo(0));
 }
Ejemplo n.º 14
0
 /**
  * Authorize filter should be attached to every route
  * Calls the gate:check method with the appropriate user and resource
  * @param Route the route
  * @param $request the request object
  * @param String $action the action mapping of the action performed for a complete list
  * @see AuthServiceProvider
  * @throws ClassNotFoundException if the $action parameter is malformed therefore there is no known Resource to
  * be retrieved
  *
  * TODO: add an after plugin action to allow plugin owners add and authorize their own resources
  */
 private function authorize(Request $request, string $action)
 {
     $user = Auth::user();
     if ($user !== NULL && $action !== '') {
         $resource = explode('-', $action);
         //echo '$resource == ';var_dump($user);
         if (FALSE !== $resource && !emptyArray($resource)) {
             $resource = $resource[1];
         }
         if (!isset($request->id)) {
             $request->id = $user->id;
         }
         if ($request->user()->can($action, $resource)) {
         }
         //            var_dump($resource);
     } elseif ($user === NULL && $action === '') {
         Log::info("Non logged in user tried to access no-action(allowed by default)");
         //   redirect('/login');
     } else {
         Log::info("Non-logged in user tried to perform {$action}");
         abort(401, "Unauthorized action");
     }
 }
Ejemplo n.º 15
0
 protected function handleRequestParameters(array $requestParameters)
 {
     $queryParameters = array();
     if (isset($requestParameters['paginate'])) {
         $paginateValue = $requestParameters['paginate'];
         $pageValue = isset($requestParameters['page']) ? $requestParameters['page'] : ($requestParameters['page'] = 1);
         $paginateIntValue = $this->validateInteger($paginateValue);
         $pageIntValue = $this->validateInteger($pageValue);
         if (!is_null($paginateIntValue) && !is_null($pageIntValue)) {
             $queryParameters['pagination'] = ['paginate' => $paginateIntValue, 'page' => $pageIntValue];
         }
         unset($requestParameters['paginate']);
         unset($requestParameters['page']);
     }
     if (isset($requestParameters['take'])) {
         $takeIntValue = $this->validateInteger($requestParameters['take']);
         if (!is_null($takeIntValue)) {
             $queryParameters['take'] = $takeIntValue;
             if (isset($queryParameters['pagination'])) {
                 unset($queryParameters['pagination']);
             }
         }
         unset($requestParameters['take']);
     }
     $requestParameters = $this->validateQueryColumnExistence($requestParameters);
     $queries = array();
     foreach ($requestParameters as $key => $value) {
         $validatedQueryParameter = $this->getQueryParameters($key, $value);
         if (is_array($validatedQueryParameter)) {
             array_push($queries, $validatedQueryParameter);
         }
     }
     if (emptyArray($queries)) {
         $queryParameters['queries'] = $queries;
     }
     return $queryParameters;
 }
 public function testGetScannedLicensesWithEmptyDetails()
 {
     assertThat($this->agentLicenseEventProcessor->getScannedLicenses(array()), is(emptyArray()));
 }
 public function testAddPopularitySearchReturnsResultOnSuccess()
 {
     //product
     $this->client->index(['index' => $this->product_index, 'type' => $this->product_type, 'id' => 100, 'body' => ['title' => 'test product', 'min_price' => 20000, 'max_price' => 20000, 'datetime' => '2014-02-14 00:01:01', 'group' => 'testgroup1', 'soft_delete_status' => 0], 'refresh' => true]);
     //product
     $this->client->index(['index' => $this->product_index, 'type' => $this->product_type, 'id' => 200, 'body' => ['title' => 'test product2', 'min_price' => 30000, 'max_price' => 20000, 'datetime' => '2014-02-14 00:01:01', 'group' => 'testgroup2', 'soft_delete_status' => 0], 'refresh' => true]);
     //add
     $this->client->index(['index' => $this->add_index, 'type' => $this->add_type, 'id' => 1, 'parent' => 100, 'body' => ['gender_ids' => 1, 'interest_ids' => [1, 2], 'datetime' => '2014-02-14 00:01:01'], 'refresh' => true]);
     //add
     $this->client->index(['index' => $this->add_index, 'type' => $this->add_type, 'id' => 2, 'parent' => 100, 'body' => ['gender_ids' => 2, 'interest_ids' => [2], 'datetime' => '2014-02-14 00:01:01'], 'refresh' => true]);
     //add
     $this->client->index(['index' => $this->add_index, 'type' => $this->add_type, 'id' => 3, 'parent' => 200, 'body' => ['gender_ids' => 1, 'interests\\_ids' => [2], 'datetime' => '2014-02-14 00:01:01'], 'refresh' => true]);
     $result = $this->repo->AddPopularitySearch(0, 100);
     assertThat($result, hasKey('results'));
     assertThat($result['results'], not(emptyArray()));
     assertThat($result['results'][0], not(hasKey('_source')));
     assertThat($result['meta']['total_hits'], atLeast(1));
     assertThat($result, hasKey('facets'));
     assertThat($result['facets'], hasKey('price'));
     assertThat($result['facets']['price'], not(emptyArray()));
     assertThat($result['facets'], hasKey('group'));
 }
Ejemplo n.º 18
0
 public function testPurge()
 {
     $url = $this->stubCreateQueue();
     $timeout = $this->stubQueueVisibilityTimeout($url);
     $receiveModel = m::mock('Aws\\ResultInterface');
     $receiveModel->shouldReceive('get')->once()->with('Messages')->andReturn([]);
     $this->sqsClient->shouldReceive('receiveMessage')->once()->with(['QueueUrl' => $url, 'AttributeNames' => ['All'], 'MaxNumberOfMessages' => 1, 'VisibilityTimeout' => $timeout])->andReturn($receiveModel);
     $purgeModel = m::mock('Aws\\ResultInterface');
     $this->sqsClient->shouldReceive('purgeQueue')->once()->with(['QueueUrl' => $url])->andReturn($purgeModel);
     $this->client->purge();
     $msgs = [];
     $this->client->receive(function ($msg) use(&$msgs) {
         $msgs[] = $msg;
     });
     assertThat($msgs, is(emptyArray()));
 }
Ejemplo n.º 19
0
 private function runnerDeciderScanWithForceDecision($runner)
 {
     $this->setUpTables();
     $this->setUpRepo();
     $jobId = 42;
     $licenseRef1 = $this->licenseDao->getLicenseByShortName("GPL-3.0")->getRef();
     $licenseRef2 = $this->licenseDao->getLicenseByShortName("3DFX")->getRef();
     $agentLicId = $this->licenseDao->getLicenseByShortName("Adaptec")->getRef()->getId();
     $addedLicenses = array($licenseRef1, $licenseRef2);
     assertThat($addedLicenses, not(arrayContaining(null)));
     $agentId = 5;
     $pfile = 4;
     $this->dbManager->queryOnce("INSERT INTO license_file (fl_pk,rf_fk,pfile_fk,agent_fk) VALUES(12222,{$agentLicId},{$pfile},{$agentId})");
     $itemTreeBounds = $this->uploadDao->getItemTreeBounds($itemId = 23);
     assertThat($this->agentLicenseEventProcessor->getScannerEvents($itemTreeBounds), is(not(emptyArray())));
     $eventId1 = $this->clearingDao->insertClearingEvent($itemId, $userId = 2, $groupId = 3, $licenseRef1->getId(), false);
     $eventId2 = $this->clearingDao->insertClearingEvent($itemId, 5, $groupId, $licenseRef2->getId(), true);
     $this->dbManager->queryOnce("UPDATE clearing_event SET job_fk={$jobId}");
     $addedEventIds = array($eventId1, $eventId2);
     list($success, $output, $retCode) = $runner->run($uploadId = 2, $userId, $groupId, $jobId, $args = "-k1");
     $this->assertTrue($success, 'cannot run runner');
     $this->assertEquals($retCode, 0, 'decider failed: ' . $output);
     assertThat($this->getHeartCount($output), equalTo(1));
     $uploadBounds = $this->uploadDao->getParentItemBounds($uploadId);
     $decisions = $this->clearingDao->getFileClearingsFolder($uploadBounds, $groupId);
     assertThat($decisions, is(arrayWithSize(1)));
     /** @var ClearingDecision $deciderMadeDecision */
     $deciderMadeDecision = $decisions[0];
     $eventIds = array();
     foreach ($deciderMadeDecision->getClearingEvents() as $event) {
         $eventIds[] = $event->getEventId();
     }
     assertThat($eventIds, arrayValue($addedEventIds[0]));
     assertThat($eventIds, arrayValue($addedEventIds[1]));
     assertThat($eventIds, arrayWithSize(1 + count($addedEventIds)));
     $this->rmRepo();
 }
Ejemplo n.º 20
0
 public function testGetCommitsOfLastDays()
 {
     $result = $this->repositoryApi->getCommitsOfLastDays(60);
     assertThat($result, is(not(emptyArray())));
     assertThat($result[0], hasKey('sha'));
 }
 public function testFilterEffectiveEventsWithEmptyArray()
 {
     assertThat($this->clearingEventProcessor->filterEffectiveEvents(array()), is(emptyArray()));
 }
Ejemplo n.º 22
0
 public function testMainLicenseIds()
 {
     $this->testDb->createPlainTables(array('upload_clearing_license'));
     $uploadId = 101;
     $mainLicIdsInitially = $this->clearingDao->getMainLicenseIds($uploadId, $this->groupId);
     assertThat($mainLicIdsInitially, is(emptyArray()));
     $this->clearingDao->makeMainLicense($uploadId, $this->groupId, $licenseId = 402);
     $mainLicIdsAfterAddingOne = $this->clearingDao->getMainLicenseIds($uploadId, $this->groupId);
     assertThat($mainLicIdsAfterAddingOne, arrayContaining(array($licenseId)));
     $this->clearingDao->makeMainLicense($uploadId, $this->groupId, $licenseId);
     $mainLicIdsAfterAddingOneTwice = $this->clearingDao->getMainLicenseIds($uploadId, $this->groupId);
     assertThat($mainLicIdsAfterAddingOneTwice, is(arrayWithSize(1)));
     $this->clearingDao->makeMainLicense($uploadId, $this->groupId, $licenseId2 = 403);
     $mainLicIdsAfterAddingOther = $this->clearingDao->getMainLicenseIds($uploadId, $this->groupId);
     assertThat($mainLicIdsAfterAddingOther, arrayContainingInAnyOrder(array($licenseId, $licenseId2)));
     $this->clearingDao->removeMainLicense($uploadId, $this->groupId, $licenseId2);
     $mainLicIdsAfterRemovingOne = $this->clearingDao->getMainLicenseIds($uploadId, $this->groupId);
     assertThat($mainLicIdsAfterRemovingOne, is(arrayWithSize(1)));
     $this->clearingDao->removeMainLicense($uploadId, $this->groupId, $licenseId2);
     $mainLicIdAfterRemovingSomethingNotInSet = $this->clearingDao->getMainLicenseIds($uploadId, $this->groupId);
     assertThat($mainLicIdAfterRemovingSomethingNotInSet, is(arrayWithSize(1)));
     $this->clearingDao->removeMainLicense($uploadId, $this->groupId + 1, $licenseId);
     $mainLicIdAfterInsertToOtherGroup = $this->clearingDao->getMainLicenseIds($uploadId, $this->groupId);
     assertThat($mainLicIdAfterInsertToOtherGroup, is(arrayWithSize(1)));
     $this->clearingDao->removeMainLicense($uploadId + 1, $this->groupId, $licenseId);
     $mainLicIdAfterInsertToOtherUpload = $this->clearingDao->getMainLicenseIds($uploadId, $this->groupId);
     assertThat($mainLicIdAfterInsertToOtherUpload, is(arrayWithSize(1)));
 }
 public function testDeletePermDeletesProductAndProductRequestAndReturnsTrue()
 {
     $index_repo = Mockery::mock('Giftertipster\\Repository\\ProductsIndex\\Product\\ProductsIndexProductRepositoryInterface');
     $index_repo->shouldReceive('deleteProductAndAdds')->with(1, true)->once()->andReturn(true);
     $this->app->instance('Giftertipster\\Repository\\ProductsIndex\\Product\\ProductsIndexProductRepositoryInterface', $index_repo);
     $data_repo = $this->dataRepoSetup();
     $this->getDataRepoData();
     //connect product to product request
     Factory::create('Giftertipster\\Entity\\Eloquent\\User', ['permissions' => []]);
     $prod_request = $this->app->make('Giftertipster\\Entity\\Eloquent\\ProductRequest');
     $prod_request->fill(['user_id' => 1, 'vendor' => 'test', 'vendor_id' => 100]);
     $this->product->productRequest()->save($prod_request);
     $prod_request_check = $prod_request->where('product_id', '=', 1)->get();
     assertThat($prod_request_check, not(nullValue()));
     $response = $data_repo->deletePerm(1);
     assertThat($response, identicalTo(true));
     $product = $this->app->make('Giftertipster\\Entity\\Eloquent\\Product');
     $product_check = $product->find(1);
     $prod_request_check = $prod_request->where('product_id', '=', 1)->get()->toArray();
     assertThat($product_check, nullValue());
     assertThat($prod_request_check, emptyArray());
 }
Ejemplo n.º 24
0
 /**
  * @covers Jazzee\JazzeePageController::getMessages
  */
 public function testGetMessages()
 {
     assertThat(is(emptyArray($this->object->getMessages())));
 }
 public function testGetAdminAddWhenAdminAddTypeIsAdminIdea()
 {
     $this->makeRelatedModels();
     $add = $this->add_repo->create(['product_id' => 1, 'add_type_id' => 1, 'occasion_ids' => [1], 'relation_ids' => [1], 'gender_ids' => [1], 'age_ids' => [1], 'interest_ids' => [1], 'sub_interest_ids' => [1]]);
     $admin_add = $this->add_repo->getAdminAdd(1);
     assertThat($admin_add, hasKeyValuePair('id', 1));
     assertThat($admin_add['occasion_categories'], not(emptyArray()));
     assertThat($admin_add['relation_categories'], not(emptyArray()));
     assertThat($admin_add['gender_categories'], not(emptyArray()));
     assertThat($admin_add['age_categories'], not(emptyArray()));
     assertThat($admin_add['interest_categories'], not(emptyArray()));
     assertThat($admin_add['sub_interest_categories'], not(emptyArray()));
 }
Ejemplo n.º 26
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $existe = false;
     //inicializo $existe en false
     $docUsuario = DB::table('personas')->join('categoria_persona', 'personas.id', '=', 'categoria_persona.persona_id')->join('categorias', 'categoria_persona.categoria_id', '=', 'categorias.id')->join('eventos', 'categoria_persona.evento_id', '=', 'eventos.id')->select('documento')->where('eventos.id', '=', 2)->get();
     foreach ($docUsuario as $doc) {
         $documentos[] = $doc->documento;
     }
     if (!empty($documentos)) {
         $existe = array_search($request->documento, $documentos, false);
     }
     $urlparse = parse_url($_SERVER['HTTP_REFERER']);
     //Guardo en urlparse de donde viene para poder hacer el return donde corresponda
     //si viene del congreso la mando a la url del congreso.
     $options = Config::get('categorias.types');
     //traigo los valores del archivo categorias.php dentro de la carpeta config
     $tipoDoc = Config::get('tipoDoc.types');
     //traigo los valores del archivo tipoDoc.php dentro de la carpeta config
     $pais = Config::get('pais.types');
     //traigo los valores del archivo pais.php dentro de la carpeta config
     $evento_id = $request->evento_id;
     if ($existe === false) {
         $persona = new Persona();
         /* LLAMAR FUNCION GENERAR CLAVE*/
         $data = Input::all();
         $data['clave'] = $this->generaclave();
         $persona->fill($data);
         $persona['nombre'] = Persona::getNombreNormalizado($data['nombre']);
         $persona['apellidos'] = Persona::getNombreNormalizado($data['apellidos']);
         $persona->save();
         //Guardo las categorias
         $array = $request->options;
         //en caso de que las categorias esten en null, le seteo por defecto el 4 (Otros)
         if (emptyArray($array)) {
             $array[] = 4;
         }
         foreach ($array as $key => $value) {
             $resultado[] = $value;
         }
         foreach ($resultado as $idC) {
             DB::table('categoria_persona')->insert(['categoria_id' => $idC, 'evento_id' => $request->evento_id, 'persona_id' => $persona->id]);
         }
         //guardo evento_persona
         DB::table('evento_persona')->insert(['evento_id' => $request->evento_id, 'persona_id' => $persona->id]);
         $this->enviar_correo($request->apellidos, $request->nombre, $request->email, $request->documento, $data['clave']);
         //TODO : Hay que programar esto para que tome la url desde la BD para que no este harcodeado
         // Como esta hecho ahora, si se necesita agregar una nueva jornada o congreso, hay que hacerlo mediante el codigo
         if ($urlparse['path'] == '/persona') {
             //si es persona va al home de jornadas.app
             return redirect()->route("home");
         }
         Session::flash('mensaje_correo_ok', 'Su consulta fue enviada correctamente');
         Session::flash('mensaje_correo_ok1', 'Si no recibe el correo de confirmación, revise su casilla de correo no deseado.');
         return redirect()->route("congresoOk");
         //return view('congreso', compact('evento_id','tipoDoc','options','pais'));
     } else {
         Session::flash('message_congreso', 'Ya existe una persona inscripta con el documento ingresado Congreso ');
         Session::flash('alert-class', 'alert-danger');
         if ($urlparse['path'] == '/persona') {
             //si es persona va al home de jornadas.app
             return redirect()->back();
         } else {
             //return redirect('congreso')->with('message', 'Profile updated!');
             //return view('congreso', compact('evento_id','tipoDoc','options','pais'));
             return redirect()->back();
         }
     }
 }
 public function testAddPopularitySearchReturnsResultOnSuccess()
 {
     //product
     $this->es_client->index(['index' => $this->product_index, 'type' => $this->product_type, 'id' => 100, 'body' => ['title' => 'test product', 'min_price' => 20000, 'max_price' => 20000, 'datetime' => '2014-02-14 00:01:01', 'group' => 'testgroup1', 'soft_delete_status' => 0], 'refresh' => true]);
     //product
     $this->es_client->index(['index' => $this->product_index, 'type' => $this->product_type, 'id' => 200, 'body' => ['title' => 'test product2', 'min_price' => 30000, 'max_price' => 20000, 'datetime' => '2014-02-14 00:01:01', 'group' => 'testgroup2', 'soft_delete_status' => 0], 'refresh' => true]);
     //add
     $this->es_client->index(['index' => $this->add_index, 'type' => $this->add_type, 'id' => 1, 'parent' => 100, 'body' => ['gender_ids' => 1, 'interest_ids' => [1, 2], 'datetime' => '2014-02-14 00:01:01'], 'refresh' => true]);
     //add
     $this->es_client->index(['index' => $this->add_index, 'type' => $this->add_type, 'id' => 2, 'parent' => 100, 'body' => ['gender_ids' => 2, 'interest_ids' => [2], 'datetime' => '2014-02-14 00:01:01'], 'refresh' => true]);
     //add
     $this->es_client->index(['index' => $this->add_index, 'type' => $this->add_type, 'id' => 3, 'parent' => 200, 'body' => ['gender_ids' => 1, 'interests\\_ids' => [2], 'datetime' => '2014-02-14 00:01:01'], 'refresh' => true]);
     \Config::shouldReceive('get')->with('laravel-elasticsearch-repository::index.index_models.product_add.setup.type')->andReturn('add');
     $result = $this->repo->model('product')->search('add_count', null, 0, 100);
     assertThat($result, hasKey('results'));
     assertThat($result['results'], not(emptyArray()));
     assertThat($result['results'][0], not(hasKey('_source')));
     assertThat($result['meta']['total_hits'], atLeast(1));
     assertThat($result, hasKey('facets'));
     assertThat($result['facets'], hasKey('price'));
     assertThat($result['facets']['price'], not(emptyArray()));
     assertThat($result['facets'], hasKey('group'));
 }
 public function testDelete()
 {
     $occasion = Factory::create('Giftertipster\\Entity\\Eloquent\\Category\\OccasionCategory', ['label' => 'foobar', 'priority' => 5]);
     $relation = Factory::create('Giftertipster\\Entity\\Eloquent\\Category\\RelationCategory', ['priority' => 5]);
     $gender = Factory::create('Giftertipster\\Entity\\Eloquent\\Category\\GenderCategory', ['priority' => 5]);
     $dependency_profile = Factory::make('Giftertipster\\Entity\\Eloquent\\Category\\CategoryDependencyProfile');
     $occasion->categoryDependencyProfile()->save($dependency_profile);
     $dependency_profile->relationCategories()->attach($relation);
     $exclusion_profile = Factory::make('Giftertipster\\Entity\\Eloquent\\Category\\CategoryExclusionProfile');
     $occasion->categoryExclusionProfile()->save($exclusion_profile);
     $exclusion_profile->relationCategories()->attach($gender);
     $product = Factory::create('Giftertipster\\Entity\\Eloquent\\Product');
     $add_type = Factory::create('Giftertipster\\Entity\\Eloquent\\AddType');
     $add = Factory::create('Giftertipster\\Entity\\Eloquent\\Add', ['product_id' => 1, 'add_type_id' => 1]);
     $add->occasionCategories()->attach($add);
     Factory::create('Giftertipster\\Entity\\Eloquent\\User', ['permissions' => []]);
     $category_analytic = Factory::make('Giftertipster\\Entity\\Eloquent\\Analytic\\CategoryAnalytic', ['user_id' => 1]);
     $occasion->categoryAnalytics()->save($category_analytic);
     //delete pre chck
     assertThat($category_analytic->exists, identicalTo(true));
     $add_categories_pivot = DB::select(DB::raw("SELECT * FROM add_categories"));
     assertThat($add_categories_pivot, not(emptyArray()));
     /** DELETE **/
     $response = $this->repo->delete(1, 'occasion');
     //delete post check
     $occasions = $occasion->newInstance()->get()->toArray();
     $relations = $relation->newInstance()->get()->toArray();
     $dependency_profiles = $dependency_profile->newInstance()->get()->toArray();
     $exclusion_profiles = $exclusion_profile->newInstance()->get()->toArray();
     $category_analytics = $category_analytic->newInstance()->get()->toArray();
     $category_depedencies_pivot = DB::select(DB::raw("SELECT * FROM category_dependencies"));
     $category_exclusions_pivot = DB::select(DB::raw("SELECT * FROM category_exclusions"));
     $add_categories_pivot = DB::select(DB::raw("SELECT * FROM add_categories"));
     assertThat($response, identicalTo(true));
     assertThat($occasions, emptyArray());
     assertThat($relations, not(emptyArray()));
     assertThat($dependency_profiles, emptyArray());
     assertThat($exclusion_profiles, emptyArray());
     assertThat($category_analytics, emptyArray());
     assertThat($category_depedencies_pivot, emptyArray());
     assertThat($category_exclusions_pivot, emptyArray());
     assertThat($add_categories_pivot, emptyArray());
 }
Ejemplo n.º 29
0
 public function testHasAReadableDescription()
 {
     $this->assertDescription('an array with size <3>', arrayWithSize(equalTo(3)));
     $this->assertDescription('an empty array', emptyArray());
 }
Ejemplo n.º 30
0
 public function listNavigator($option)
 {
     $cate = array();
     $cate_root_name = array();
     $cate_lv1_name = array();
     $cate_lv2_name = array();
     $cate_lv3_name = array();
     $cate_root = array();
     $cate_lv1 = array();
     $cate_lv2 = array();
     $cate_lv3 = array();
     //check optional and get all Navigator
     if ($option == 'BE') {
         $listCategory = Navigator::where('status', 1)->where('in_page', 1)->orderBy('position', 'asc')->get(['id', 'uri', 'name', 'parent_id', 'level'])->toArray();
     } elseif ($option == 'FE') {
         $listCategory = Navigator::where('status', 1)->where('in_page', 0)->orderBy('position', 'asc')->get(['id', 'uri', 'name', 'parent_id', 'level'])->toArray();
     }
     //end check optional and get all Navigator
     //put into array
     for ($i = 0; $i < sizeof($listCategory); $i++) {
         if ($listCategory[$i]['level'] == 0) {
             array_push($cate_root, $listCategory[$i]);
         } elseif ($listCategory[$i]['level'] == 1) {
             array_push($cate_lv1, $listCategory[$i]);
         } elseif ($listCategory[$i]['level'] == 2) {
             array_push($cate_lv2, $listCategory[$i]);
         } elseif ($listCategory[$i]['level'] == 3) {
             array_push($cate_lv3, $listCategory[$i]);
         }
     }
     //loop amount root tag time
     for ($i = 0; $i < sizeof($cate_root); $i++) {
         //declare template array
         $_tmp = array();
         //put a name into array name root
         array_push($cate_root_name, $cate_root[$i]['name']);
         for ($j = 0; $j < sizeof($cate_lv1); $j++) {
             //declare template array
             $__tmp = array();
             //put a name into array name Navigator level1
             array_push($cate_lv1_name, $cate_lv1[$j]['name']);
             //check parent id of Navigator level1 is current  id of root id
             if ($cate_lv1[$j]['parent_id'] == $cate_root[$i]['id']) {
                 for ($m = 0; $m < sizeof($cate_lv2); $m++) {
                     //declare template array
                     $___tmp = array();
                     //put a name into array name Navigator level2
                     array_push($cate_lv2_name, $cate_lv2[$m]['name']);
                     //check parent id of Navigator level2 is current  id of Navigator level1 id
                     if ($cate_lv2[$m]['parent_id'] == $cate_lv1[$j]['id']) {
                         for ($n = 0; $n < sizeof($cate_lv3); $n++) {
                             //put a name into array name Navigator level3
                             array_push($cate_lv3_name, $cate_lv3[$n]['name']);
                             //check parent id of Navigator level3 is current  id of Navigator level2 id
                             if ($cate_lv3[$n]['parent_id'] == $cate_lv2[$m]['id']) {
                                 $___tmp = array_add($___tmp, $n, $cate_lv3[$n]);
                             }
                             //end check parent id of Navigator level3 is current  id of Navigator level2 id
                         }
                         //check Navigator level1 has child
                         if (sizeof($___tmp) == 0) {
                             $__tmp = array_add($__tmp, $m, $cate_lv2[$m]);
                         } else {
                             $__tmp = array_add($__tmp, $m, $___tmp);
                         }
                         //end check Navigator level1 has child
                     }
                     //end check parent id of Navigator level2 is current  id of Navigator level1 id
                 }
                 //check root has child
                 if (emptyArray($__tmp)) {
                     $_tmp = array_add($_tmp, $cate_lv1_name[$j], $cate_lv1[$j]);
                 } else {
                     $_tmp = array_add($_tmp, $cate_lv1_name[$j], $__tmp);
                 }
                 //end check root has child
             }
             //check parent id of Navigator level1 is current  id of root id
         }
         //add each element
         $cate = array_add($cate, $cate_root_name[$i], $_tmp);
     }
     return $cate;
 }