<?php

// This unit test tests, if the Registration and Activation process provided 
// by Yum works

Yii::import('application.modules.usuario.models.*');
Yii::import('application.modules.usuario.models.formularios.*');
Yii::import('application.modules.usuario.controllers.*');

class RegistrationTest extends CDbTestCase {

    public $fixtures = array();

    public function testRegistration() {
        Yii::app()->controller = new RegistroController('registro');

        $user = new FormularioRegistroUsuario;

        $user->username = 'no whitespaces allowed';
        $this->assertFalse($user->validate());

        $user->username = 'allowed';
        $user->password = 'notthesame';
        $user->password = 'emasehtton';
        $this->assertFalse($user->validate());

        $user->setAttributes(array(
            'username' => 'A_Testuser',
            'password' => 'hiddenpassword1',
            'confirmacion_password' => 'hiddenpassword1',
        ));
        $this->assertTrue($user->validate());

        /*$profile = new YumRegistrationForm;
        $profile->setAttributes(array(
            'firstname' => 'My first Name !"§$%&/()=',
            'lastname' => 'My last Name !"§$%&/()=<?php die() ?>',
            'password' => 'hiddenpassword1',
            'confirmacion_password' => 'hiddenpassword1',
        ));
        $profile->setAttributes($user->getAttributes());
        $this->assertTrue($profile->validate());*/

        // it is good that $_POST is bloated here because we want to test if
        // only safe Attributes are being assigned:
        $_POST['FormularioRegistroUsuario'] = $user->getAttributes();
        //$_POST['YumProfile'] = $profile->getAttributes();
    }

}
