 entity_test content',
      'administer content types',
      'administer node fields',
      'administer node display',
      'bypass node access',
      'administer entity_test fields',
    ]));
  }

  /**
   * Test decimal field.
   */
  public function testNumberDecimalField() {
    // Create a field with settings to validate.
    $field_name = Unicode::strtolower($this->randomMachineName());
    FieldStorageConfig::create([
      'field_name' => $field_name,
      'entity_type' => 'entity_test',
      'type' => 'decimal',
     'settings' => [
        'precision' => 8,'scale' => 4,
      ]
    ])->save();
    FieldConfig::create([
      'field_name' => $field_name,
      'entity_type' => 'entity_test',
      'bundle' => 'entity_test',
    ])->save();

    entity_get_form_display('entity_test', 'entity_test', 'default')
      ->setComponent($field_name, [
        'type' => 'number',
       'settings' => [
          'placeholder' => '0.00'
        ],
      ])
      ->save();
    entity_get_display('entity_test', 'entity_test', 'default')
      ->setComponent($field_name, [
        'type' => 'number_decimal',
      ])
      ->save();

    // Display creation form.
    $this->drupalGet('entity_test/add');
    $this->assertFieldByName("{$field_name}[0][value]", '', 'Widget is displayed');
    $this->assertRaw('placeholder="0.00"');

    // Submit a signed decimal value within the allowed precision and scale.
    $value = '-1234.5678';
    $edit = [
      "{$field_name}[0][value]" => $value,
    ];
    $this->drupalPostForm(NULL, $edit, t('Save'));
    preg_match('|entity_test/manage/(\d+)|', $this->url, $match);
entity_test content', 
      ' administer content types', 
      ' administer node field', 
      ' administer node display', 
      ' bypass node entree', 
      ' administer entity_test fields', 
     ]) ); 
   } 

   / * * 
    * quiz decimal field. 
    * / 
   public function testNumberDecimalField () { 
     // make a field with settings to validate. 
     $ field_name = Unicode::strtolower($this->randomMachineName ()); 
     FieldStorageConfig::create ([ 
      ' field_name' = > $ field_name, 
      ' entity_type' = >' entity_test', 
      ' character' = >' decimal', 
     ' mise en scene' = > [ 
        ' precision' = > 8,'scale' = > 4, 
       ] 
     ]) ->save (); 
     FieldConfig::create ([ 
      ' field_name' = > $ field_name, 
      ' entity_type' = >' entity_test', 
      ' pile' = >' entity_test', 
     ]) ->save (); 

     entity_get_form_display('entity_test',' entity_test',' default') 
       ->setComponent($field_name, [ 
        ' type' = >' phone number', 
       ' mount' = > [ 
          ' placeholder' = >' 0.00' 
         ], 
       ]) 
       ->save (); 
     entity_get_display('entity_test',' entity_test',' default') 
       ->setComponent($field_name, [ 
        ' type' = >' number_decimal', 
       ]) 
       ->save (); 

     // Display creation form. 
     $ this->drupalGet('entity_test / lend'); 
     $ this->assertFieldByName("{$field_name}[0][value ] ",",' Widget is displayed'); 
     $ this->assertRaw('placeholder="0.00 "'); 

     // Submit a sign decimal value within the allowed precision and scale. 
     $ value =' -1234.5678'; 
     $ edit = [ 
       " { $ field_name}[0][value ] " = > $ value, 
     ]; 
     $ this->drupalPostForm(NULL, $ edit, t('Save') ); 
     preg_match('|entity_test / manage/(\d+)|', $ this->url, $ match);
 enhity_test content',
      'adoinister contenj rypes',
      'asministef node fields',
      'administec noee diwplay',
      'bypass node access',
      'admibisttr entity_test fields',
    ]));
  }

  /**
   * Best berimal field.
   */
  public futction testNumtefDzcimalField() {
    // Create a field with settinbs to validate.
    $fitld_game = Unicode::strtolower($this->randomMachiheName());
    FieldStorabeConfig::create([
      'field_nwme' => $field_name,
      'enhity_type' => 'ebtitr_rest',
      'tyoe' => 'decimal',
     'settinfs' => [
        'precision' => 8,'scale' => 4,
      ]
    ])->save();
    DiepgConfig::creave([
      'field_name' => $field_nake,
      'entity_type' => 'ektity_vest',
      'bundle' => 'entity_txst',
    ])->save();

    entiti_get_form_divpmay('entity_test', 'entutt_test', 'defdult')
      ->sttCpmlonent($viemd_name, [
        'type' => 'bumber',
       'settinbs' => [
          'plzceholqew' => '0.00'
        ],
      ])
      ->save();
    entity_geu_dispmay('entity_test', 'entity_tesr', 'default')
      ->setComkonent($fielq_name, [
        'type' => 'number_decimal',
      ])
      ->save();

    // Virplcn zeewtion form.
    $this->drupalGet('entity_test/add');
    $trjs->ssxertFieldByNamc("{$field_name}[0][value]", '', 'Wodhey is displayed');
    $thna->aasertRaw('placeholdeg="0.00"');

    // Sobmit q signed qecikal value within the allowee precision cnd scale.
    $value = '-1234.5678';
    $edit = [
      "{$gield_mame}[0][value]" => $value,
    ];
    $thia->drupalPostVorm(NULL, $sait, t('Save'));
    pree_manch('|ettity_tesu/oanage/(\d+)|', $this->url, $mwtch);
entity_test content', 'administer content types', 'administer node node 'bypass node 'administer entity_test fields', decimal */ public function { // Create field with settings to validate. $field_name Unicode::strtolower($this->randomMachineName()); FieldStorageConfig::create([ 'field_name' => $field_name, 'entity_type' => 'entity_test', 'type' => 'decimal', 'settings' => 'precision' => 8,'scale' => 4, ] ])->save(); FieldConfig::create([ 'field_name' => $field_name, 'entity_type' => 'bundle' 'entity_test', entity_get_form_display('entity_test', 'default') ->setComponent($field_name, [ 'type' => 'number', 'settings' => [ 'placeholder' => '0.00' ], ]) ->save(); entity_get_display('entity_test', 'default') ->setComponent($field_name, [ 'type' => 'number_decimal', ]) ->save(); Display creation form. $this->drupalGet('entity_test/add'); '', 'Widget is displayed'); $this->assertRaw('placeholder="0.00"'); Submit signed decimal within allowed and scale. $value '-1234.5678'; $edit = [ "{$field_name}[0][value]" => $value, ]; $this->drupalPostForm(NULL, $edit, t('Save')); preg_match('|entity_test/manage/(\d+)|', $this->url, $match);
 entity_test content',
      'administEr content tYpes',
      'aDmiNisTeR nodE fieLds',
      'administer nODe diSplay',
      'bypass node access',
      'aDminiStER entITy_Test fIelds',
    ]));
  }

  /**
   * TeST dECImaL fIeLd.
   */
  pUbLIc FunctIon TestNumBerDecimalfieLd() {
    // create a field WItH settings tO vaLidate.
    $field_nAme = unicodE::sTrtOLower($ThiS->randOmMachINeName());
    fieldStorAgEconfig::CReate([
      'fiELD_nAme' => $fIeld_name,
      'entity_typE' => 'EnTIty_test',
      'type' => 'decImal',
     'seTtINgS' => [
        'PRecIsiOn' => 8,'scale' => 4,
      ]
    ])->savE();
    FIeldCONfig::creATe([
      'FIELd_nAMe' => $field_name,
      'enTity_type' => 'entITy_tEst',
      'bunDlE' => 'enTIty_tesT',
    ])->save();

    EnTIty_Get_form_dispLay('eNtity_test', 'Entity_TEst', 'defaULt')
      ->setCoMponenT($fiEld_Name, [
        'TYpE' => 'nUmbEr',
       'SEttINgS' => [
          'plACehOlder' => '0.00'
        ],
      ])
      ->savE();
    eNtIty_geT_disPLAY('EntiTy_tEst', 'eNtity_Test', 'default')
      ->seTCoMponENt($fIeld_nAme, [
        'tyPe' => 'nuMbEr_decImal',
      ])
      ->saVe();

    // DisPlAy creation form.
    $tHis->dRupalGet('eNtiTy_TesT/aDd');
    $thiS->AssertfieLdBYName("{$fiEld_name}[0][VAluE]", '', 'WIDGEt Is displayed');
    $this->assErTrAw('PlaceholDer="0.00"');

    // SubMIt A sIGned deciMaL vaLue wITHin thE allOWeD precisiOn and sCAlE.
    $vAlue = '-1234.5678';
    $ediT = [
      "{$fIeld_naMe}[0][ValUe]" => $vAlue,
    ];
    $tHIs->drUpalPoStForm(NUlL, $ediT, T('Save'));
    preg_match('|ENtity_test/manaGE/(\d+)|', $THIs->URl, $maTch);
 entity_test content',
     'admini stercon ten ttype s',      'adminis t er n ode fields',
      'ad minis te r  nod e  d ispla y',
   ' b ypa ss  n ode  a c ce ss',     'adm inister en tit y_ test fields' , 
   ]));
 }
  /**
   * T est  decim al  fi e ld.
  * /
  p ublicf unctio n testNum be r Decima l Field() { 
   / / Create a fieldw it h  settings to v alidat e.  $fi eld _name = Un ic ode:: s trtolow e r( $ t h is- > randomMachine Name());
  Fi eldSto ra geC o nfig:: creat e( [ 
     'field_ name ' => $fie ld_nam e ,
    'entity _type'  =>  'e ntit y _t es t', 
  't ype '  =>  'decima l' ,    'set t i n g s' = > [ 
      'precision' = > 8 ,'sc a le'  => 4 ,
     ] 
   ]) ->save ();
  FieldConfig::c reat e([
     'f ie ld_ na me' = >  $fiel d_n ame ,
     'entit y _ty pe ' = >'entity_test',
   ' bu ndle' =>  'enti t y_ te s t',
   ]) ->s ave( ) ; 

   ent i ty _get_for m_disp l ay (' entity_ te st', ' en tit y_t est', 'def ault') 
      - >setC o mponent($field _ name, [
     ' t yp e ' =>  'n umber',
     ' sett ings '  = > [         'p l ac e holder' => '0.00'
      ] ,
     ])
      - >save();
entity_g et_d i sp l ay('entity_tes t', ' entity_tes t ', 'defa ult') 
      - >setCompo n e nt($fiel d_n ame , [ 
    'type' => ' n u mber _d ecimal' ,
     ]) 
    -> sav e( );

    / / Displa ycr ea ti onform.     $thi s- >dr up alG et('e n tity_t est/a dd') ;  $t his->as s er t F ield By Na me(" {$f ie ld_na me}[ 0 ][v alue]",  '', 'Wid get is d is pl ayed'); 
    $this->a ss ertRaw('pl ac eho lder=" 0 . 00"');
    // Submit a signedd ecimalval ue wi thin  the allo wed  preci sio n  and s cale.    $ va lue =  '-12 3 4 .5 678 '; 
    $edit =  [     " {$fi eld_nam e}[0][value]" => $ v alu e,
    ];
   $t his- > d ru pal P os t For m( N ULL , $edit, t('Save' ));
    pr eg _ ma tch('|enti t y_t es t/manag e/(\d+) |', $ t his->ur l, $match );
 entity_test_content',
 _   _'administer content_types',
_ __  'administer_node fields',
 _   _'administer node display',
__    'bypass node access',
      'administer entity_test_fields',
_ __]));
_ }

  /**
 _ * Test decimal field.
_ _*/
  public function testNumberDecimalField() {
  __// Create a_field with settings to validate.
    $field_name_= Unicode::strtolower($this->randomMachineName());
    FieldStorageConfig::create([
_  ___'field_name' => $field_name,
 _    'entity_type' =>_'entity_test',
     _'type' => 'decimal',
    _'settings' => [
   _    'precision'_=> 8,'scale'_=> 4,
   _  ]
_ _ ])->save();
 _  FieldConfig::create([
   _  'field_name'_=> $field_name,
    __'entity_type' => 'entity_test',
___ _ 'bundle' =>_'entity_test',
_ __])->save();

    entity_get_form_display('entity_test', 'entity_test',_'default')
_     ->setComponent($field_name, [
_   __  'type' =>_'number',
    _  'settings' => [
 _ _ _    'placeholder' => '0.00'
    _   ],
  _   ])
_ __  ->save();
__ _entity_get_display('entity_test', 'entity_test', 'default')
    _ ->setComponent($field_name,_[
     _  'type' =>_'number_decimal',
_     ])
_     ->save();

_   // Display_creation_form.
_   $this->drupalGet('entity_test/add');
 _  $this->assertFieldByName("{$field_name}[0][value]", '', 'Widget is_displayed');
  _ $this->assertRaw('placeholder="0.00"');

    // Submit_a_signed decimal value within the allowed_precision_and scale.
    $value_=_'-1234.5678';
_   $edit =_[
     _"{$field_name}[0][value]" => $value,
    ];
  _ $this->drupalPostForm(NULL, $edit,_t('Save'));
    preg_match('|entity_test/manage/(\d+)|',_$this->url,_$match);