Exemplo n.º 1
0
 /**
  * @param FunctionalTester $I
  */
 public function testCreate(FunctionalTester $I)
 {
     $I->wantTo('ensure that create post-type works');
     $createPage = CreatePage::openBy($I);
     $I->see('Add New Post Type', 'h1');
     // Test empty data
     $I->amGoingTo('submit form post-type with no data');
     $createPage->submitPostType([]);
     $I->expectTo('see validation errors');
     $I->see('Name cannot be blank.', '.help-block');
     $I->see('Singular Name cannot be blank.', '.help-block');
     $I->see('Plural Name cannot be blank.', '.help-block');
     // Test same data
     $I->amGoingTo('submit form post-type with existing data');
     $createPage->submitPostType(['post_type_name' => 'post', 'post_type_slug' => 'post', 'post_type_pn' => 'Post', 'post_type_sn' => 'Posts']);
     $I->expectTo('see validation errors');
     $I->see('Name "post" has already been taken.', '.help-block');
     $I->see('Slug "post" has already been taken.', '.help-block');
     // Test correct data
     $I->amGoingTo('submit form post-type with correct data');
     $I->selectOption('#posttype-post_type_permission', 'author');
     $createPage->submitPostType(['post_type_name' => 'test-post-type', 'post_type_slug' => 'test-post-type', 'post_type_sn' => 'Test Post Type', 'post_type_pn' => 'Test Post Types']);
     $I->expect('new post-type created');
     // $I->see('View Post Type: Test Post Type', 'h1');
     $I->see('View Post Type: Test Post Type');
     PostType::deleteAll(['post_type_name' => 'test-post-type']);
     Taxonomy::deleteAll(['taxonomy_name' => 'test-taxonomy']);
 }
Exemplo n.º 2
0
 /**
  * @param AcceptanceTester $I
  */
 public function testCreate(AcceptanceTester $I)
 {
     $I->wantTo('ensure that create post-type works');
     $createPage = CreatePage::openBy($I);
     $I->see('Add New Post Type', 'h1');
     // Only run for selenium
     if (method_exists($I, 'executeJS')) {
         $I->amGoingTo('submit taxonomy with no data');
         $createPage->submitTaxonomy([]);
         $I->expectTo('see validation errors');
         $I->see('Name cannot be blank.', '.help-block');
         $I->see('Singular Name cannot be blank.', '.help-block');
         $I->see('Plural Name cannot be blank.', '.help-block');
         $I->amGoingTo('submit taxonomy with correct data');
         $createPage->submitTaxonomy(['name' => 'test-taxonomy', 'singular_name' => 'Test Taxonomy', 'plural_name' => 'Test Taxonomies']);
         $I->expect('new taxonomy saved');
         $I->see('test-taxonomy', '#taxonomy_list');
         $I->dontSee('Name cannot be blank.', '.help-block');
         $I->dontSee('Singular Name cannot be blank.', '.help-block');
         $I->dontSee('Plural Name cannot be blank.', '.help-block');
     }
     // Test empty data
     $I->amGoingTo('submit form post-type with no data');
     $createPage->submitPostType([]);
     $I->expectTo('see validation errors');
     $I->see('Name cannot be blank.', '.help-block');
     $I->see('Singular Name cannot be blank.', '.help-block');
     $I->see('Plural Name cannot be blank.', '.help-block');
     // Test same data
     $I->amGoingTo('submit form post-type with existing data');
     $createPage->submitPostType(['name' => 'post', 'slug' => 'post', 'singular_name' => 'Post', 'plural_name' => 'Posts']);
     $I->expectTo('see validation errors');
     $I->see('Name "post" has already been taken.', '.help-block');
     $I->see('Slug "post" has already been taken.', '.help-block');
     // Test correct data
     $I->amGoingTo('submit form post-type with correct data');
     $I->selectOption('#posttype-permission', 'author');
     $createPage->submitPostType(['name' => 'test-post-type', 'slug' => 'test-post-type', 'singular_name' => 'Test Post Type', 'plural_name' => 'Test Post Types']);
     $I->expect('new post-type created');
     $I->see('View Post Type: Test Post Type', 'h1');
     PostType::deleteAll(['name' => 'test-post-type']);
     Taxonomy::deleteAll(['name' => 'test-taxonomy']);
 }