Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mariancalinro’s picture

m1r1k’s picture

Assigned: Unassigned » m1r1k

I will take care

jibran’s picture

Issue tags: +Needs tests
stefan.r’s picture

Assigned: m1r1k » stefan.r
stefan.r’s picture

Status: Active » Needs review
FileSize
3.07 KB

fago’s picture

Status: Needs review » Needs work
  1. +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/ValidReferenceConstraintValidatorTest.php
    @@ -0,0 +1,73 @@
    +  public static function getInfo() {
    ...
    +  public function setUp() {
    +    parent::setUp();
    

    miss @inheritdoc

  2. +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/ValidReferenceConstraintValidatorTest.php
    @@ -0,0 +1,73 @@
    +    ->setSettings(array('target_type' => 'user'));
    

    indentation missing.

Else test looks good!

stefan.r’s picture

Status: Needs work » Needs review
FileSize
2.73 KB

This patch was green but it was not running the tests in the patch any more :)

Re-roll attached

stefan.r’s picture

Typo ("refence" -> reference)

pfrenssen’s picture

Status: Needs review » Needs work
  1. +++ b/core/modules/system/src/Tests/Entity/ValidReferenceConstraintValidatorTest.php
    @@ -0,0 +1,69 @@
    +/**
    + * @file
    + * Contains \Drupal\system\Tests\Entity\EntityTypeConstraintValidatorTest.
    + */
    

    This refers to EntityTypeConstraintValidatorTest, but this is in fact ValidReferenceConstraintValidatorTest.

  2. +++ b/core/modules/system/src/Tests/Entity/ValidReferenceConstraintValidatorTest.php
    @@ -0,0 +1,69 @@
    +use Drupal\system\Tests\Entity\EntityUnitTestBase;
    +use Drupal\system\Tests\TypedData;
    +use Drupal\Core\Field\BaseFieldDefinition;
    

    EntityUnitTestBase resides in the same namespace so this use statement is unnecessary.
    Change the order of the other two so they are in alphabetical order.

  3. +++ b/core/modules/system/src/Tests/Entity/ValidReferenceConstraintValidatorTest.php
    @@ -0,0 +1,69 @@
    +  public static $modules = array('field', 'user');
    

    Missing {@inheritdoc}.

  4. +++ b/core/modules/system/src/Tests/Entity/ValidReferenceConstraintValidatorTest.php
    @@ -0,0 +1,69 @@
    +    $this->assertEqual($violations->count(), 0, 'Validation passed for correct value.');
    

    Tip: you can use $this->assertFalse() to check for values that are 0.

  5. +++ b/core/modules/system/src/Tests/Entity/ValidReferenceConstraintValidatorTest.php
    @@ -0,0 +1,69 @@
    +    // Delete the referenced entity.
    +    $entity->delete();
    +    $violations = $typed_data->validate();
    +    $this->assertEqual($violations->count(), 1, 'Validation failed for incorrect value.');
    

    I like this approach!

  6. +++ b/core/modules/system/src/Tests/Entity/ValidReferenceConstraintValidatorTest.php
    @@ -0,0 +1,69 @@
    +    $this->assertEqual($violation->getMessage(), t('The referenced entity (%type: %id) does not exist.', array('%type' => 'user', '%id' => $entity->id())), 'The message for invalid value is correct.');
    

    Strictly speaking according to coding standards the array should be split on a new line because it exceeds 80 characters. I do not feel very strongly about this ;)

stefan.r’s picture

Status: Needs work » Needs review
Issue tags: -Needs tests
FileSize
2.74 KB
2.05 KB
pfrenssen’s picture

Status: Needs review » Needs work

The assertEqual() -> assertFalse() pattern occurred multiple times in the test, sorry I didn't point this out in my previous review. For the rest this is looking very good.

pfrenssen’s picture

Issue tags: +SprintWeekend2015
stefan.r’s picture

Status: Needs work » Needs review
FileSize
2.73 KB
1.18 KB
pfrenssen’s picture

Status: Needs review » Reviewed & tested by the community

Thanks! Looking great now.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs issue summary update

This issue is a normal task so we need to outline how it fits within the allowable Drupal 8 beta criteria. Can someone add Drupal 8 beta phase evaluation template to the issue summary.

stefan.r’s picture

Issue summary: View changes

stefan.r’s picture

Status: Needs work » Needs review
Issue tags: -Needs issue summary update
stefan.r’s picture

Assigned: stefan.r » Unassigned
YesCT’s picture

Issue summary: View changes

html.

stefan.r’s picture

Issue summary: View changes
stefan.r’s picture

Issue summary: View changes
YesCT’s picture

Status: Needs review » Reviewed & tested by the community

that beta evaluation looks good.
and the interdiff in #26 should be fine and come back green.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed e6e359b and pushed to 8.0.x. Thanks!

Thanks for adding the beta evaluation to the issue summary.

  • alexpott committed e6e359b on 8.0.x
    Issue #2142997 by stefan.r: Test for ValidReferenceConstraintValidator
    

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.