You are here

public function OgResolvedGroupCollectionTest::testGetSetVoteWeight in Organic groups 8

Tests if it is possible to retrieve and set the default vote weight.

@covers ::getVoteWeight @covers ::setVoteWeight

File

tests/src/Unit/OgResolvedGroupCollectionTest.php, line 225

Class

OgResolvedGroupCollectionTest
Tests the collecting of resolved groups to pass as a route context.

Namespace

Drupal\Tests\og\Unit

Code

public function testGetSetVoteWeight() {
  $collection = new OgResolvedGroupCollection();

  // Test that the vote weight is initially 0.
  $this
    ->assertEquals(0, $collection
    ->getVoteWeight());

  // Test setting and getting a range of weights.
  for ($weight = -100; $weight <= 100; $weight++) {
    $collection
      ->setVoteWeight($weight);
    $this
      ->assertEquals($weight, $collection
      ->getVoteWeight());
  }
}