public function testSerializeWithExclusions()
 {
     $a = new A();
     $a->setRid(1);
     $a->setName('name');
     $a->setStatus(true);
     $a->setHiddenStatus(true);
     $this->unitUnderTest->addExclusionSpecification(new GroupsSpecification(array('get')));
     $result = $this->unitUnderTest->serialize($a);
     $expectedString = '{"status":true}';
     $this->assertEquals($expectedString, $result);
     $this->unitUnderTest->addExclusionSpecification(new VersionSpecification('1.5'));
     $result = $this->unitUnderTest->serialize($a);
     $expectedString = '{"status":true}';
     $this->assertEquals($expectedString, $result);
     $this->unitUnderTest->addExclusionSpecification(new VersionSpecification('2.5'));
     $result = $this->unitUnderTest->serialize($a);
     $expectedString = '[]';
     $this->assertEquals($expectedString, $result);
     $this->unitUnderTest->cleanUpExclusionSpecifications();
     $result = $this->unitUnderTest->serialize($a);
     $expectedString = '{"id":1,"name":"name","status":true}';
     $this->assertEquals($expectedString, $result);
 }
 public function testNormalizationWithVersionExclusion()
 {
     $object = new A();
     $object->setRid(2)->setName('testName')->setStatus(true)->setHiddenStatus(false);
     $this->unitUnderTest->cleanUpExclusionSpecifications();
     $this->unitUnderTest->addExclusionSpecification(new VersionSpecification('0.5'));
     $result = $this->unitUnderTest->normalize($object);
     $this->assertCount(2, $result);
     $this->assertArrayHasKey('id', $result);
     $this->assertArrayHasKey('name', $result);
     $this->assertEquals(2, $result['id']);
     $this->assertEquals('testName', $result['name']);
     $this->unitUnderTest->cleanUpExclusionSpecifications();
     $this->unitUnderTest->addExclusionSpecification(new VersionSpecification('2.5'));
     $result = $this->unitUnderTest->normalize($object);
     $this->assertCount(2, $result);
     $this->assertArrayHasKey('id', $result);
     $this->assertArrayHasKey('name', $result);
     $this->assertEquals(2, $result['id']);
     $this->assertEquals('testName', $result['name']);
     $this->unitUnderTest->cleanUpExclusionSpecifications();
     $this->unitUnderTest->addExclusionSpecification(new VersionSpecification('1.5'));
     $result = $this->unitUnderTest->normalize($object);
     $this->assertCount(3, $result);
     $this->assertArrayHasKey('id', $result);
     $this->assertArrayHasKey('name', $result);
     $this->assertEquals(2, $result['id']);
     $this->assertEquals('testName', $result['name']);
     $this->unitUnderTest->cleanUpExclusionSpecifications();
     $result = $this->unitUnderTest->normalize($object);
     $this->assertCount(3, $result);
     $this->assertArrayHasKey('id', $result);
     $this->assertArrayHasKey('name', $result);
     $this->assertArrayHasKey('status', $result);
     $this->assertEquals(2, $result['id']);
     $this->assertEquals('testName', $result['name']);
     $this->assertTrue($result['status']);
 }
 public function testToArrayVersion()
 {
     $object = new A();
     $object->setRid(2)->setName('testName')->setStatus(true)->setHiddenStatus(false);
     $this->unitUnderTest->setExclusionStrategy(new VersionExclusionStrategy('0.5'));
     $result = $this->unitUnderTest->toArray($object);
     $this->assertCount(2, $result);
     $this->assertArrayHasKey('id', $result);
     $this->assertArrayHasKey('name', $result);
     $this->assertEquals(2, $result['id']);
     $this->assertEquals('testName', $result['name']);
     $this->unitUnderTest->setExclusionStrategy(new VersionExclusionStrategy('2.5'));
     $result = $this->unitUnderTest->toArray($object);
     $this->assertCount(2, $result);
     $this->assertArrayHasKey('id', $result);
     $this->assertArrayHasKey('name', $result);
     $this->assertEquals(2, $result['id']);
     $this->assertEquals('testName', $result['name']);
     $this->unitUnderTest->setExclusionStrategy(new VersionExclusionStrategy('1.5'));
     $result = $this->unitUnderTest->toArray($object);
     $this->assertCount(3, $result);
     $this->assertArrayHasKey('id', $result);
     $this->assertArrayHasKey('name', $result);
     $this->assertEquals(2, $result['id']);
     $this->assertEquals('testName', $result['name']);
     $this->unitUnderTest->setExclusionStrategy(null);
     $result = $this->unitUnderTest->toArray($object);
     $this->assertCount(3, $result);
     $this->assertArrayHasKey('id', $result);
     $this->assertArrayHasKey('name', $result);
     $this->assertArrayHasKey('status', $result);
     $this->assertEquals(2, $result['id']);
     $this->assertEquals('testName', $result['name']);
     $this->assertTrue($result['status']);
 }