public function testSetDefault() { $a = new AttributesResolver(); $a->setDefault('name', 'Yo! Symfony')->setDefault('title', 'Hi', 'string')->setDefault('host', 'localhost', 'string', false, true)->setDefault('port', 4000, 'int', false, false)->setDefault('path', '', 'string', true)->setValidator('port', function ($value) { return $value > 0 && $value <= 65535; }); $result = $a->resolve(['name' => 'Yo! Symfony 2', 'path' => '/var/www']); $this->assertEquals(5, $a->count()); $this->assertTrue(is_array($result)); $this->assertEquals('Yo! Symfony 2', $result['name']); $this->assertEquals('Hi', $result['title']); $this->assertEquals('localhost', $result['host']); $this->assertEquals(4000, $result['port']); $this->assertEquals('/var/www', $result['path']); $a->remove('port'); $this->assertEquals(4, $a->count()); $this->assertFalse($a->hasdefault('port')); $a->remove(['path', 'host']); $this->assertEquals(2, $a->count()); $this->assertFalse($a->hasdefault('path')); $this->assertFalse($a->hasdefault('host')); $a->clear(); $this->assertEquals(0, $a->count()); }