* @license http://www.apache.org/licenses/LICENSE-2.0 * @link http://phpsx.org */ class LengthTest extends FilterTestCase { public function testFilterIntegerLength() { $filter = new Length(3, 8); $this->assertEquals(false, $filter->apply(2)); $this->assertEquals(true, $filter->apply(3)); $this->assertEquals(true, $filter->apply(8)); $this->assertEquals(false, $filter->apply(9)); // test error message $this->assertErrorMessage($filter->getErrorMessage()); $filter = new Length(8); $this->assertEquals(true, $filter->apply(2)); $this->assertEquals(true, $filter->apply(3)); $this->assertEquals(true, $filter->apply(8)); $this->assertEquals(false, $filter->apply(9)); // test error message $this->assertErrorMessage($filter->getErrorMessage()); } public function testFilterFloatLength() { $filter = new Length(3.4, 8.4); $this->assertEquals(false, $filter->apply(3.3)); $this->assertEquals(true, $filter->apply(3.4)); $this->assertEquals(true, $filter->apply(8.4)); $this->assertEquals(false, $filter->apply(8.5)); // test error message $this->assertErrorMessage($filter->getErrorMessage()); $filter = new Length(8.4); $this->assertEquals(true, $filter->apply(3.3)); $this->assertEquals(true, $filter->apply(3.4)); $this->assertEquals(true, $filter->apply(8.4)); $this->assertEquals(false, $filter->apply(8.5)); // test error message $this->assertErrorMessage($filter->getErrorMessage()); } public function testFilterArrayLength() { $filter = new Length(3, 8); $this->assertEquals(false, $filter->apply(range(0, 1))); $this->assertEquals(true, $filter->apply(range(0, 2))); $this->assertEquals(true, $filter->apply(range(0, 7))); $this->assertEquals(false, $filter->apply(range(0, 8))); // test error message $this->assertErrorMessage($filter->getErrorMessage()); $filter = new Length(8); $this->assertEquals(true, $filter->apply(range(0, 1))); $this->assertEquals(true, $filter->apply(range(0, 2))); $this->assertEquals(true, $filter->apply(range(0, 7))); $this->assertEquals(false, $filter->apply(range(0, 8))); // test error message $this->assertErrorMessage($filter->getErrorMessage()); } public function testFilterStringLength() { $filter = new Length(3, 8); $this->assertEquals(false, $filter->apply('fo')); $this->assertEquals(true, $filter->apply('foo')); $this->assertEquals(true, $filter->apply('foobarte')); $this->assertEquals(false, $filter->apply('foobartes')); // test error message $this->assertErrorMessage($filter->getErrorMessage()); $filter = new Length(8); $this->assertEquals(true, $filter->apply('fo')); $this->assertEquals(true, $filter->apply('foo')); $this->assertEquals(true, $filter->apply('foobarte')); $this->assertEquals(false, $filter->apply('foobartes')); // test error message $this->assertErrorMessage($filter->getErrorMessage()); } } __halt_compiler();----SIGNATURE:----SI6qKPIv3hcVDCwQtPD5Kf3f1E2Vnu3y0t01sH3VpYj6lGe5hRjBm6oCu8PVyLzbdE9FtsD0CuFY2GOjHfE+uhg3E82WHd4w83nIS6v+azDi+/gFVwXmxQktqJEiuUusnSFcnOyzbopSsJZ85lXmA9UQiykgBhqrSR7sW1+Tmd3OWx3rNQjpds7W3/0cXkLvHfxUwsjYU3dhmVhfrn6Z9UQnWbMOnvMLfZTrDnhXD3yXC133FaY8L66sZTKZMfPONVXL5R+2S6oNTm5VFuCmS3Ewe+ZgMlbfQ94H6WZe3kRgz/N6VHILmCdp9iQMccsES4mOBivHiHq1jR0D+CJ5UpVVHxHMZuyHFtTQOdOlFGJR1oFnEbfQmtihGx3MpPKnIx7jovInzwOBHQFgl8W7ziqhUf4fKeAE3FZb0+aw+voPUbMldYi6BXWT7RwvND80UZtKm7IbyFFo8Qyn436nxGIvWQznsY9T72VubO27Ud2h/n56gMs/K6M598e9qKpjxtpmQ/f83KwvPFGSqcgQ4eFgBBXyqiUOGAX7LGg2Ea4LefTXbZr+Cx4m2oTRWOu52OGlRksCI7TXSvhdMEZbUTs73axnnOkLhbnUSwF07qDCYLHSQJzbaRjMwK1mBRw+8IRhGN3hTkor1SqCNHB08KLxK8xmvwdYRyX5+H0v9YI=----ATTACHMENT:----MzgwOTE0NjEyNzA3Mjc5MSA1NjU5NzQ2Nzc2ODI3MjY1IDU4MDM4MzQyMDU3MjkzNDk=