setUsername() public method

public setUsername ( string $username )
$username string
Exemplo n.º 1
0
    public function testSystemConfigDb()
    {
        $xml = '<config>
  <database>
    <connections>
      <connection>
        <name>testdb</name>
        <username>peter</username>
      </connection>
    </connections>
  </database>
</config>';
        $config = new SystemConfig();
        $connection = new Connection();
        $connection->setUsername('peter');
        $connection->setType('mysql');
        $connection->setName('testdb');
        $database = new Database();
        $config->setDatabase($database);
        $config->getDatabase()->addConnection($connection);
        $output = $config->toXml();
        $this->assertEquals($xml, $output);
        $reverse = new SystemConfig($xml);
        $this->assertInternalType('array', $reverse->getDatabase()->getConnections());
        $this->assertInstanceOf('\\Jarves\\Configuration\\Connection', $reverse->getDatabase()->getConnections()[0]);
        $this->assertEquals('mysql', $reverse->getDatabase()->getConnections()[0]->getType());
        $this->assertEquals('peter', $reverse->getDatabase()->getConnections()[0]->getUsername());
        $this->assertEquals('testdb', $reverse->getDatabase()->getConnections()[0]->getName());
        $this->assertEquals($xml, $reverse->toXml());
    }