You are here

public function GroupSequenceTest::testArrayAccess in Plug 7

File

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

Class

GroupSequenceTest
@author Bernhard Schussek <bschussek@gmail.com>

Namespace

Symfony\Component\Validator\Tests\Constraints

Code

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]);
}