Example #1
0
 public function testEdit()
 {
     $this->mock->shouldReceive('with')->with('role')->andReturn($this->mock);
     $this->mock->shouldReceive('findOrFail')->with(3)->once()->andReturn(Factory::make($this->factory, array('id' => 3)));
     $this->get($this->url . '/3/edit', 3);
     $this->assertViewHas(substr($this->var, 0, -1));
 }
 public function testGetAnalytics()
 {
     //load analytics into DB
     Factory::create('Giftertipster\\Entity\\Eloquent\\User', ['permissions' => []]);
     Factory::create('Giftertipster\\Entity\\Eloquent\\User', ['permissions' => []]);
     Factory::create('Giftertipster\\Entity\\Eloquent\\User', ['permissions' => []]);
     $occasion1 = Factory::create('Giftertipster\\Entity\\Eloquent\\Category\\OccasionCategory', ['label' => 'foobar1', 'icon_name' => 'icon1', 'priority' => 1]);
     $occasion2 = Factory::create('Giftertipster\\Entity\\Eloquent\\Category\\OccasionCategory', ['label' => 'foobar2', 'icon_name' => 'icon2', 'priority' => 1]);
     //$occasion3 = Factory::create('Giftertipster\Entity\Eloquent\Category\OccasionCategory', ['label' => 'foobar5', 'icon_name' => 'icon5', 'priority' => 1]);
     //$occasion4 = Factory::create('Giftertipster\Entity\Eloquent\Category\OccasionCategory', ['label' => 'foobar6', 'icon_name' => 'icon6', 'priority' => 1]);
     Factory::create('Giftertipster\\Entity\\Eloquent\\Analytic\\UserAnalytic', ['user_id' => 1, 'quantity' => 2]);
     Factory::create('Giftertipster\\Entity\\Eloquent\\Analytic\\UserAnalytic', ['user_id' => 2, 'quantity' => 8]);
     Factory::create('Giftertipster\\Entity\\Eloquent\\Analytic\\UserAnalytic', ['user_id' => 3, 'quantity' => 0]);
     $cat_analytic1 = Factory::make('Giftertipster\\Entity\\Eloquent\\Analytic\\CategoryAnalytic', ['user_id' => 1, 'category_type' => null, 'category_id' => null, 'quantity' => 1]);
     $cat_analytic2 = Factory::make('Giftertipster\\Entity\\Eloquent\\Analytic\\CategoryAnalytic', ['user_id' => 1, 'category_type' => null, 'category_id' => null, 'quantity' => 2]);
     $cat_analytic3 = Factory::make('Giftertipster\\Entity\\Eloquent\\Analytic\\CategoryAnalytic', ['user_id' => 2, 'category_type' => null, 'category_id' => null, 'quantity' => 5]);
     $cat_analytic4 = Factory::make('Giftertipster\\Entity\\Eloquent\\Analytic\\CategoryAnalytic', ['user_id' => 2, 'category_type' => null, 'category_id' => null, 'quantity' => 6]);
     $cat_analytic5 = Factory::make('Giftertipster\\Entity\\Eloquent\\Analytic\\CategoryAnalytic', ['user_id' => 3, 'category_type' => null, 'category_id' => null, 'quantity' => 0]);
     $cat_analytic6 = Factory::make('Giftertipster\\Entity\\Eloquent\\Analytic\\CategoryAnalytic', ['user_id' => 3, 'category_type' => null, 'category_id' => null, 'quantity' => 0]);
     $occasion1->categoryAnalytics()->save($cat_analytic1);
     $occasion2->categoryAnalytics()->save($cat_analytic2);
     $occasion1->categoryAnalytics()->save($cat_analytic3);
     $occasion2->categoryAnalytics()->save($cat_analytic4);
     $occasion1->categoryAnalytics()->save($cat_analytic5);
     $occasion2->categoryAnalytics()->save($cat_analytic6);
     //expected results
     $expected_analytics = ['_users' => [1 => ['occasion_categories' => [1 => ['quantity' => 1, 'total_quantity' => 2, 'percentage_of_total' => 50.0], 2 => ['quantity' => 2, 'total_quantity' => 2, 'percentage_of_total' => 100.0]]], 2 => ['occasion_categories' => [1 => ['quantity' => 5, 'total_quantity' => 8, 'percentage_of_total' => 62.0], 2 => ['quantity' => 6, 'total_quantity' => 8, 'percentage_of_total' => 75.0]]], 3 => ['occasion_categories' => [1 => ['quantity' => 0, 'total_quantity' => 0, 'percentage_of_total' => 0], 2 => ['quantity' => 0, 'total_quantity' => 0, 'percentage_of_total' => 0]]]], '_all' => ['occasion_categories' => [1 => ['quantity' => 6, 'total_quantity' => 10, 'percentage_of_total' => 60.0], 2 => ['quantity' => 8, 'total_quantity' => 10, 'percentage_of_total' => 80.0]]]];
     assertThat($this->repo->getCategoryAnalytics(), identicalTo($expected_analytics));
 }
 public function testIsInvalidWhenAddTypeIdDoesntExist()
 {
     Factory::create('Giftertipster\\Entity\\Eloquent\\AddType');
     Factory::create('Giftertipster\\Entity\\Eloquent\\Product');
     $add = Factory::make('Giftertipster\\Entity\\Eloquent\\Add', ['product_id' => 1, 'add_type_id' => 5]);
     $this->assertNotValid($add);
 }
 public function test_edit_devuelve_tipotorneo()
 {
     $tipo_torneo = Factory::make('App\\TipoTorneo', ['ttr_nombre' => 'Ecuador']);
     $this->modelMock->shouldReceive('findOrFail')->once()->andReturn($tipo_torneo);
     $this->app->instance('App\\TipoTorneo', $this->modelMock);
     $response = $this->call('GET', '/tipo_torneo/1/edit');
     $this->assertViewHas('tipo_torneo', $tipo_torneo);
 }
 public function testUpdateForProduct()
 {
     $product = Factory::create('Giftertipster\\Entity\\Eloquent\\Product');
     $keyword_profile = Factory::make('Giftertipster\\Entity\\Eloquent\\KeywordProfile');
     $product->keywordProfile()->save($keyword_profile);
     $this->repo->updateForProduct(1, ['profile' => ['updated', 'profile']]);
     assertThat(KeywordProfile::find(1)->profile, identicalTo(['updated', 'profile']));
 }
 public function testFillableAndGuardedAttributes()
 {
     $product = Factory::make('Giftertipster\\Entity\\Eloquent\\RangeCronJob');
     assertThat($product['guarded'], hasItemInArray('id'));
     assertThat($product['guarded'], hasItemInArray('created_at'));
     assertThat($product['guarded'], hasItemInArray('updated_at'));
     assertThat($product['fillable'], hasItemInArray('job_name'));
     assertThat($product['fillable'], hasItemInArray('last_id_processed'));
     assertThat($product['fillable'], hasItemInArray('last_status'));
 }
Example #7
0
 public function testUsesRoleReturnsPermissionsArray()
 {
     $mock = Mockery::mock('Sorora\\Aurp\\Models\\Role');
     $mock->shouldReceive('load')->with('permissions')->once();
     $permissions = array(Factory::make('Sorora\\Aurp\\Models\\' . $this->model, array('id' => 1, 'task' => 'Foo')), Factory::make('Sorora\\Aurp\\Models\\' . $this->model, array('id' => 5, 'task' => 'Bar')));
     $mock->shouldReceive('getAttribute')->once()->andReturn((object) $permissions);
     $item = new Permission();
     $permissions = $item->usesRole($mock);
     $this->assertEquals($permissions, array(1 => 'Foo', 5 => 'Bar'));
 }
 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()));
 }
 public function testIsInvalidIfIsRefreshedIsNot1Or0()
 {
     $invalid_value = 3;
     $product = Factory::make('Giftertipster\\Entity\\Eloquent\\Product', ['is_refreshed' => $invalid_value]);
     $this->assertNotValid($product);
 }
 public function testFilterProductsReturnsProductsSortedPerIndexResponse()
 {
     $index_response_stub = ['meta' => ['total_hits' => 2], 'results' => [['_id' => 2], ['_id' => 1]], 'facets' => ['foobar']];
     $find_many_params_stub = [2, 1];
     $product_suite_response = new \Illuminate\Database\Eloquent\Collection();
     $product_suite_response->add(Factory::make('Giftertipster\\Entity\\Eloquent\\Product', ['id' => 2, 'title' => 'foobar title']));
     $product_suite_response->add(Factory::make('Giftertipster\\Entity\\Eloquent\\Product', ['id' => 1, 'title' => 'foobar title']));
     $expected_response = ['meta' => ['total_hits' => 2], 'results' => [['is_refreshed' => 1, 'id' => 2, 'title' => 'foobar title'], ['is_refreshed' => 1, 'id' => 1, 'title' => 'foobar title']], 'facets' => ['foobar']];
     $index_repo_mock = Mockery::mock('Giftertipster\\Repository\\ProductsIndex\\Product\\ProductsIndexProductRepositoryInterface');
     $index_repo_mock->shouldReceive('filterProducts')->with(0, 2, ['FilterName' => ['filter params' => 'foobar']])->once()->andReturn($index_response_stub);
     $this->app->instance('Giftertipster\\Repository\\ProductsIndex\\Product\\ProductsIndexProductRepositoryInterface', $index_repo_mock);
     $product_suite_mock = Mockery::mock('Giftertipster\\Repository\\ProductSuite\\ProductSuiteRepositoryInterface');
     $product_suite_mock->shouldReceive('findMany')->with($find_many_params_stub, true)->andReturn($product_suite_response);
     $this->app->instance('Giftertipster\\Repository\\ProductSuite\\ProductSuiteRepositoryInterface', $product_suite_mock);
     $this->service = $this->app->make('Giftertipster\\Service\\ProductSuite\\ProductSuiteFromIndexFetcher');
     //offset, limit, array of filters
     $response = $this->service->filterProducts(0, 2, ['FilterName' => ['filter params' => 'foobar']]);
     assertThat($response, identicalTo($expected_response));
 }
 /**
  * @expectedException RuntimeException
  */
 public function testProductMatchingAsinThrowsRunTimeExceptionWhenMoreThanOneSubProductMatches()
 {
     $product = Factory::create('Giftertipster\\Entity\\Eloquent\\Product');
     $product2 = Factory::create('Giftertipster\\Entity\\Eloquent\\Product');
     $sub_product = Factory::make('Giftertipster\\Entity\\Eloquent\\SubProduct', ['vendor_id' => 'asin stub']);
     $sub_product2 = Factory::make('Giftertipster\\Entity\\Eloquent\\SubProduct', ['vendor_id' => 'asin stub']);
     $product->subProducts()->save($sub_product);
     $product2->subProducts()->save($sub_product2);
     $calib_count = $product->has('subProducts')->get()->count();
     assertThat($calib_count, equalTo(2));
     $product_repo = $this->app->make('Giftertipster\\Repository\\Product\\EloquentProductRepository');
     $result_product = $product_repo->productMatchingAsin('asin stub');
 }
 public function testUpdatedAtIsGuarded()
 {
     $product = Factory::make('Giftertipster\\Entity\\Eloquent\\Category\\AgeCategory');
     assertThat($product['guarded'], either(hasItemInArray('updated_at'))->orElse(hasItemInArray('*')));
 }
Example #13
0
 public function testValidWithAllFields()
 {
     $item = Factory::make('Sorora\\Bms\\Models\\' . $this->model, array('user_id' => 1));
     $this->assertValid($item);
 }
 public function testIsInvalidWhenHeightAndWidthExceedMaxValue()
 {
     $invalid_input = 65536;
     $image = Factory::make('Giftertipster\\Entity\\Eloquent\\Image', ['swatch_height' => $invalid_input]);
     $this->assertNotValid($image);
     $image = Factory::make('Giftertipster\\Entity\\Eloquent\\Image', ['swatch_width' => $invalid_input]);
     $this->assertNotValid($image);
     $image = Factory::make('Giftertipster\\Entity\\Eloquent\\Image', ['small_height' => $invalid_input]);
     $this->assertNotValid($image);
     $image = Factory::make('Giftertipster\\Entity\\Eloquent\\Image', ['small_width' => $invalid_input]);
     $this->assertNotValid($image);
     $image = Factory::make('Giftertipster\\Entity\\Eloquent\\Image', ['tiny_height' => $invalid_input]);
     $this->assertNotValid($image);
     $image = Factory::make('Giftertipster\\Entity\\Eloquent\\Image', ['tiny_width' => $invalid_input]);
     $this->assertNotValid($image);
     $image = Factory::make('Giftertipster\\Entity\\Eloquent\\Image', ['thumb_height' => $invalid_input]);
     $this->assertNotValid($image);
     $image = Factory::make('Giftertipster\\Entity\\Eloquent\\Image', ['thumb_width' => $invalid_input]);
     $this->assertNotValid($image);
     $image = Factory::make('Giftertipster\\Entity\\Eloquent\\Image', ['medium_height' => $invalid_input]);
     $this->assertNotValid($image);
     $image = Factory::make('Giftertipster\\Entity\\Eloquent\\Image', ['medium_width' => $invalid_input]);
     $this->assertNotValid($image);
     $image = Factory::make('Giftertipster\\Entity\\Eloquent\\Image', ['large_height' => $invalid_input]);
     $this->assertNotValid($image);
     $image = Factory::make('Giftertipster\\Entity\\Eloquent\\Image', ['large_width' => $invalid_input]);
     $this->assertNotValid($image);
 }
 public function testIsInvalidWhenIconNameIsMoreThan100Chars()
 {
     Factory::make('Giftertipster\\Entity\\Eloquent\\Category\\SubInterestCategory', ['label' => 'foobar']);
     $invalid_input = str_pad('a', 101);
     $model = Factory::make('Giftertipster\\Entity\\Eloquent\\Category\\SubInterestCategory', ['icon_name' => $invalid_input, 'priority' => 5]);
     $this->assertNotValid($model);
 }
 public function test_Show_redirecciona_hacia_Editar()
 {
     $lugar = Factory::make('App\\Lugar', ['lug_id' => 1, 'lug_nombre' => 'foooooooooooo']);
     $jugador = Factory::make('App\\Jugador', ['jug_id' => 1, 'jug_foto' => 'http://lanacion.com.ec/wp-content/uploads/2015/09/onu.jpg', 'jug_nacionalidad' => 1, 'nacionalidad' => $lugar]);
     $this->modelMock->shouldReceive('findOrFail')->once()->andReturn($jugador);
     $this->modelMock->shouldReceive('with->findOrFail')->once()->andReturn($jugador);
     $this->app->instance('App\\Jugador', $this->modelMock);
     $response = $this->visit('/jugadores/1');
     $this->press('Editar');
     $this->seePageIs('/jugadores/1/edit');
     $this->see('foooooooooooo');
 }
 public function testIsInvalidWithoutUniqueDescription()
 {
     $idea = Factory::create('Giftertipster\\Entity\\Eloquent\\Idea', ['user_id' => 1, 'description' => 'foo']);
     $idea2 = Factory::make('Giftertipster\\Entity\\Eloquent\\Idea', ['user_id' => 1, 'description' => 'foo']);
     $this->assertNotValid($idea2);
 }
 public function testIsInvalidWhenListingExceedsMaxLength()
 {
     $invalid_input = str_pad('a', 41, '1');
     $model = Factory::make('Giftertipster\\Entity\\Eloquent\\FeaturedListing', ['listing' => $invalid_input]);
     $this->assertNotValid($model);
 }
 public function testIsInvalidWhenProductIdIsLessThan0()
 {
     $invalid_input = -1;
     $model = Factory::make('Giftertipster\\Entity\\Eloquent\\KeywordProfile', ['product_id' => $invalid_input]);
     $this->assertNotValid($model);
 }
 public function testIsInvalidWhenFeaturableTypeExceedsMaxLength()
 {
     $invalid_input = str_pad('a', 101, '1');
     $model = Factory::make('Giftertipster\\Entity\\Eloquent\\Feature', ['featurable_type' => $invalid_input]);
     $this->assertNotValid($model);
 }
 public function testIsInvalidIfOfferListingIdExceedMaxLengths()
 {
     $invalid_value = str_pad('1', 401, 'a');
     $product = Factory::make('Giftertipster\\Entity\\Eloquent\\SubProduct', ['offer_listing_id' => $invalid_value, 'availibility_ss_ship' => 1]);
     $this->assertNotValid($product);
 }
 public function test_Show_redirecciona_hacia_Editar()
 {
     $auspiciante = Factory::make('App\\Auspiciante', ['aus_id' => 1, 'aus_nombre' => 'asdf', 'aus_sitioweb' => '', 'aus_imagen' => 'http://lanacion.com.ec/wp-content/uploads/2015/09/onu.jpg']);
     $this->modelMock->shouldReceive('findOrFail')->twice()->andReturn($auspiciante);
     $this->app->instance('App\\Auspiciante', $this->modelMock);
     $response = $this->visit('/auspiciantes/1');
     $this->press('Editar');
     $this->seePageIs('/auspiciantes/1/edit');
     $this->see('asdf');
 }
 /**
  * @expectedException RuntimeException
  */
 public function testProcessLoadProductsRollsBackAndThrowsRuntimeExceptionWhenFlushIndexingFails()
 {
     $product_model_1 = Factory::make('Giftertipster\\Entity\\Eloquent\\Product', ['id' => 1000]);
     $product_model_2 = Factory::make('Giftertipster\\Entity\\Eloquent\\Product', ['id' => 2000]);
     DB::shouldReceive('beginTransaction')->once();
     DB::shouldReceive('commit')->never();
     DB::shouldReceive('rollback')->once();
     Session::start();
     Session::put('AdminProductController.op_id', 100);
     Session::put('AdminProductController.op_type', 'Idea');
     Session::put('AdminProductController.products', [['product suite stub 1'], ['product suite stub 2']]);
     AuthMgr::shouldReceive('getLoggedUserId')->once()->andReturn(2);
     $add_form_prepper_mock = Mockery::mock('Giftertipster\\Service\\Add\\AddFormPrepperInterface');
     $add_form_prepper_mock->shouldReceive('prep')->with(['admin add stub'])->once()->andReturn(['admin add stub']);
     $this->app->instance('Giftertipster\\Service\\Add\\AddFormPrepperInterface', $add_form_prepper_mock);
     $prod_suite_repo = Mockery::mock('Giftertipster\\Repository\\ProductSuite\\ProductSuiteRepositoryInterface');
     $prod_suite_repo->shouldReceive('finderCreate')->with(['product suite stub 1', 'keyword_profile' => [], 'category_keywords' => ['category keywords']], 'Idea', 100, 2, false)->andReturn($product_model_1);
     $prod_suite_repo->shouldReceive('finderCreate')->with(['product suite stub 2', 'keyword_profile' => [], 'category_keywords' => ['category keywords']], 'Idea', 100, 2, false)->andReturn($product_model_2);
     $prod_suite_repo->shouldReceive('flushIndexing')->andReturn(false);
     $this->app->instance('Giftertipster\\Repository\\ProductSuite\\ProductSuiteRepositoryInterface', $prod_suite_repo);
     $save_adds = Mockery::mock('Giftertipster\\Service\\Add\\SaveAdminMultiAddsInterface');
     $save_adds->shouldReceive('getFormattedAdd')->with(['admin add stub'])->andReturn(['formatted add']);
     $save_adds->shouldReceive('save')->with(1000, 1, ['admin add stub'])->andReturn(true);
     $save_adds->shouldReceive('save')->with(2000, 1, ['admin add stub'])->andReturn(true);
     $this->app->instance('Giftertipster\\Service\\Add\\SaveAdminMultiAddsInterface', $save_adds);
     $cat_keywords_gen = Mockery::mock('Giftertipster\\Service\\CategoryKeywords\\CategoryKeywordsGeneratorInterface');
     $cat_keywords_gen->shouldReceive('make')->with(['formatted add'])->once()->andReturn(['category keywords']);
     $this->app->instance('Giftertipster\\Service\\CategoryKeywords\\CategoryKeywordsGeneratorInterface', $cat_keywords_gen);
     $idea_repo = Mockery::mock('Giftertipster\\Repository\\Idea\\IdeaRepositoryInterface');
     $idea_repo->shouldReceive('update')->with(100, ['is_fulfilled' => 1])->andReturn(true);
     $this->app->instance('Giftertipster\\Repository\\Idea\\IdeaRepositoryInterface', $idea_repo);
     $keyword_profile_gen = Mockery::mock('Giftertipster\\Service\\KeywordProfile\\KeywordProfileGeneratorInterface');
     $keyword_profile_gen->shouldReceive('make')->with('keywords string')->andReturn([]);
     $this->app->instance('Giftertipster\\Service\\KeywordProfile\\KeywordProfileGeneratorInterface', $keyword_profile_gen);
     $blacklisted_product_repo = Mockery::mock('Giftertipster\\Repository\\BlacklistedProduct\\BlacklistedProductRepositoryInterface');
     $blacklisted_product_repo->shouldReceive('isProductSuiteBlacklisted')->with(['product suite stub 1'])->andReturn(false);
     $blacklisted_product_repo->shouldReceive('isProductSuiteBlacklisted')->with(['product suite stub 2'])->andReturn(false);
     $this->app->instance('Giftertipster\\Repository\\BlacklistedProduct\\BlacklistedProductRepositoryInterface', $blacklisted_product_repo);
     $this->call('POST', 'service-tools/load-products', ['query.keywords_profile' => 'keywords string', 'query.add_attributes' => ['admin add stub'], 'product_0-install' => 'on', 'product_1-install' => 'on']);
 }
 public function testIsInvalidWhenLabelLengthIsLongerThan50()
 {
     $invalid_value = str_pad('foo ', 19, 'b');
     $AddType = Factory::make('Giftertipster\\Entity\\Eloquent\\AddType', ['label' => $invalid_value]);
     $this->assertNotValid($AddType);
 }
 public function test_show_redirecciona_hacia_editar()
 {
     $clienteFake = factory(App\Cliente::class)->make();
     $cliente = Factory::make('App\\Cliente', ['clt_id' => 1, 'clt_nombre' => $clienteFake->clt_nombre, 'clt_descripcion' => $clienteFake->clt_descripcion, 'clt_dominio' => $clienteFake->clt_dominio]);
     $this->modelMock->shouldReceive('findOrFail')->twice()->andReturn($cliente);
     $this->app->instance('App\\Cliente', $this->modelMock);
     $response = $this->visit('/clientes/1');
     $this->press('Editar');
     $this->seePageIs('/clientes/1/edit');
     $this->see($clienteFake->clt_nombre);
 }
 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());
 }
 public function testIsInvalidWhenUseridDoesntExistInUsersTable()
 {
     $model = Factory::make('Giftertipster\\Entity\\Eloquent\\Analytic\\UserAnalytic', ['user_id' => 2]);
     $this->assertNotValid($model);
 }
 public function test_edit_devuelve_lugar()
 {
     $lugar = Factory::make('App\\Lugar', ['lug_nombre' => 'Ecuador']);
     $this->modelMock->shouldReceive('findOrFail')->once()->andReturn($lugar);
     $this->app->instance('App\\Lugar', $this->modelMock);
     $response = $this->call('GET', '/lugares/1/edit');
     $this->assertViewHas('lugar', $lugar);
 }
Example #29
0
 public function testValidWithAllFields()
 {
     $item = Factory::make('Sorora\\Aurp\\Models\\' . $this->model);
     $this->assertValid($item);
 }
 public function testIsInvalidWhenVendorVendorIdComboAlreadyExists()
 {
     Factory::create('Giftertipster\\Entity\\Eloquent\\Product');
     Factory::create('Giftertipster\\Entity\\Eloquent\\ProductRequest', ['user_id' => 1, 'product_id' => 1, 'vendor' => 'amazon.com', 'vendor_id' => 'b1']);
     $model = Factory::make('Giftertipster\\Entity\\Eloquent\\ProductRequest', ['user_id' => 1, 'product_id' => 1, 'vendor' => 'amazon.com', 'vendor_id' => 'b1']);
     $this->assertNotValid($model);
 }