OptionTest.php 1.11 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
<?php

namespace Doctrine\Tests\Common\Cli;

use Doctrine\Common\Cli\Option;

require_once __DIR__ . '/../../TestInit.php';

class OptionTest extends \Doctrine\Tests\DoctrineTestCase
{
    public function testGetMethods()
    {
        $option = new Option('name', 'value', 'Description');
        
        $this->assertEquals('name', $option->getName());
        $this->assertEquals('value', $option->getDefaultValue());
        $this->assertEquals('Description', $option->getDescription());
    }
    
    public function testStringCastWithDefaultValue()
    {
        $option = new Option('name', 'value', 'Description');
        
        $this->assertEquals('--name=value', (string) $option);
    }
    
    public function testStringCastWithoutDefaultValue()
    {
        $option = new Option('name', null, 'Description');
        
        $this->assertEquals('--name', (string) $option);
    }
    
    public function testStringCastWithArrayDefaultValue()
    {
        $option = new Option('name', array('value1', 'value2'), 'Description');
        
        $this->assertEquals('--name=value1,value2', (string) $option);
    }
}