You are here

class GroupSequenceTest in Plug 7

@author Bernhard Schussek <bschussek@gmail.com>

Hierarchy

  • class \Symfony\Component\Validator\Tests\Constraints\GroupSequenceTest extends \Symfony\Component\Validator\Tests\Constraints\PHPUnit_Framework_TestCase

Expanded class hierarchy of GroupSequenceTest

File

lib/Symfony/validator/Symfony/Component/Validator/Tests/Constraints/GroupSequenceTest.php, line 19

Namespace

Symfony\Component\Validator\Tests\Constraints
View source
class GroupSequenceTest extends \PHPUnit_Framework_TestCase {
  public function testCreate() {
    $sequence = new GroupSequence(array(
      'Group 1',
      'Group 2',
    ));
    $this
      ->assertSame(array(
      'Group 1',
      'Group 2',
    ), $sequence->groups);
  }
  public function testCreateDoctrineStyle() {
    $sequence = new GroupSequence(array(
      'value' => array(
        'Group 1',
        'Group 2',
      ),
    ));
    $this
      ->assertSame(array(
      'Group 1',
      'Group 2',
    ), $sequence->groups);
  }
  public function testIterate() {
    $sequence = new GroupSequence(array(
      'Group 1',
      'Group 2',
    ));
    $this
      ->assertSame(array(
      'Group 1',
      'Group 2',
    ), iterator_to_array($sequence));
  }
  public function testCount() {
    $sequence = new GroupSequence(array(
      'Group 1',
      'Group 2',
    ));
    $this
      ->assertCount(2, $sequence);
  }
  public function testArrayAccess() {
    $sequence = new GroupSequence(array(
      'Group 1',
      'Group 2',
    ));
    $this
      ->assertSame('Group 1', $sequence[0]);
    $this
      ->assertSame('Group 2', $sequence[1]);
    $this
      ->assertTrue(isset($sequence[0]));
    $this
      ->assertFalse(isset($sequence[2]));
    unset($sequence[0]);
    $this
      ->assertFalse(isset($sequence[0]));
    $sequence[] = 'Group 3';
    $this
      ->assertTrue(isset($sequence[2]));
    $this
      ->assertSame('Group 3', $sequence[2]);
    $sequence[0] = 'Group 1';
    $this
      ->assertTrue(isset($sequence[0]));
    $this
      ->assertSame('Group 1', $sequence[0]);
  }

  /**
   * @expectedException \Symfony\Component\Validator\Exception\OutOfBoundsException
   */
  public function testGetExpectsExistingKey() {
    $sequence = new GroupSequence(array(
      'Group 1',
      'Group 2',
    ));
    $sequence[2];
  }
  public function testUnsetIgnoresNonExistingKeys() {
    $sequence = new GroupSequence(array(
      'Group 1',
      'Group 2',
    ));

    // should not fail
    unset($sequence[2]);
  }

}

Members