Foros del Web » Programando para Internet » PHP »

Doble herencia de clases

Estas en el tema de Doble herencia de clases en el foro de PHP en Foros del Web. Hola tengo el siguiente problema, tengo una clase"IWT_ValidateIP" que hereda de otra clase "PHPUnit_Framework_TestCase". Esta funciona perfectamente el problema es cuando quiero hacer otra clase ...
  #1 (permalink)  
Antiguo 08/04/2010, 12:14
 
Fecha de Ingreso: octubre-2008
Mensajes: 151
Antigüedad: 15 años, 6 meses
Puntos: 1
Doble herencia de clases

Hola tengo el siguiente problema, tengo una clase"IWT_ValidateIP" que hereda de otra clase "PHPUnit_Framework_TestCase". Esta funciona perfectamente el problema es cuando quiero hacer otra clase "IWT_ValidateLocalhostIPAddress" que herede de "IWT_ValidateIP". Ahi cuando abro la clase "IWT_ValidateLocalhostIPAddress" me tira el siguiente error "Fatal error: Class 'IWT_ValidateIP' not found in..".

Les dejo el codgio de las dos clases.

Código PHP:
<?php
include ('IWT_ValidateIP.php');
class 
IWT_ValidateLocalhostIPAddress extends IWT_ValidateIP
{
   public function 
testValidateLocalHostIP()
    {
        
$ip $this->validate->localhostIpAddress('192.15.178.10');
        
$this->assertFalse($ip->isValid"Not Localhost IP [$ip->value] must be invalid");
        
$this->assertEquals($ip->errorCode'IPADDRESS_NOT_LOCALHOST'"Not complete  IP [$ip->value] must be invalid");

        
$ip $this->validate->localhostIpAddress('127.0.0.1');
        
$this->assertTrue($ip->isValid"Localhost IP [$ip->value] must be valid");

        
$ip $this->validate->localhostIpAddress('::1');
        
$this->assertTrue($ip->isValid"Localhost IP [$ip->value] must be valid");
        
        
$ip $this->validate->localhostIpAddress('0:0:0:0:0:0:0:1');
        
$this->assertTrue($ip->isValid"Localhost IP [$ip->value] must be valid");
    }

}
?>
Código PHP:
<?php
class IWT_ValidateIP extends PHPUnit_Framework_TestCase
{
    protected 
$validate;

    protected function 
setUp()
    {
        
iwt_init(iwt_test_config());
        
$find iwt_finder();
        
$this->validate $find->any('IWT_Validate');
    }

    public function 
testValidateEmptyIP()
    {
        
$ip $this->validate->localhostIpAddress('');
        
$this->assertFalse($ip->isValid"Empty IP [$ip->value] must be invalid");
        
$this->assertEquals($ip->errorCode'INVALID_IPADDRESS'"Empty IP [$ipt->value] must be invalid");
    }

    public function 
testValidateInvalidCharactersIP()
    {
        
$ip $this->validate->localhostIpAddress('19a.168.152.134');
        
$this->assertFalse($ip->isValid"Invalid Character IP [$ip->value] must be invalid");
        
$this->assertEquals($ip->errorCode'INVALID_IPADDRESS'"Invalid Character IP [$ip->value] must be invalid");

        
$ip $this->validate->localhostIpAddress('192.1»8.152.134');
        
$this->assertFalse($ip->isValid"Invalid Character IP [$ip->value] must be invalid");
        
$this->assertEquals($ip->errorCode'INVALID_IPADDRESS'"Invalid Character IP [$ip->value] must be invalid");

        
$ip $this->validate->localhostIpAddress('192.138.15♫.134');
        
$this->assertFalse($ip->isValid"Invalid Character IP [$ip->value] must be invalid");
        
$this->assertEquals($ip->errorCode'INVALID_IPADDRESS'"Invalid Character IP [$ip->value] must be invalid");

        
$ip $this->validate->localhostIpAddress('192.128.152.13¾');
        
$this->assertFalse($ip->isValid"Invalid Character IP [$ip->value] must be invalid");
        
$this->assertEquals($ip->errorCode'INVALID_IPADDRESS'"Invalid Character IP [$ip->value] must be invalid");
    }

    public function 
testValidateTwoPointsIP()
    {
        
$ip $this->validate->localhostIpAddress('192.15..131.120');
        
$this->assertFalse($ip->isValid"Two Points IP [$ip->value] must be invalid");
        
$this->assertEquals($ip->errorCode'INVALID_IPADDRESS'"Two Points IP [$ip->value] must be invalid");
    }
    public function 
testValidateOutOfRangeIP()
    {
        
$ip $this->validate->localhostIpAddress('192.15.256.120');
        
$this->assertFalse($ip->isValid"Out of range IP [$ip->value] must be invalid");
        
$this->assertEquals($ip->errorCode'INVALID_IPADDRESS'"Out of range IP [$ip->value] must be invalid");

        
$ip $this->validate->localhostIpAddress('-1.255.255.300');
        
$this->assertFalse($ip->isValid"Out of range IP [$ip->value] must be invalid");
        
$this->assertEquals($ip->errorCode'INVALID_IPADDRESS'"Out of range IP [$ip->value] must be invalid");
    }

        public function 
testValidateIPNotComplete()
    {
        
$ip $this->validate->localhostIpAddress('192.15.178');
        
$this->assertFalse($ip->isValid"Not complete IP [$ip->value] must be invalid");
        
$this->assertEquals($ip->errorCode'INVALID_IPADDRESS'"Not complete  IP [$ip->value] must be invalid");

        
$ip $this->validate->localhostIpAddress('192.15.178.1.145');
        
$this->assertFalse($ip->isValid"Not complete IP [$ip->value] must be invalid");
        
$this->assertEquals($ip->errorCode'INVALID_IPADDRESS'"Not complete  IP [$ip->value] must be invalid");
    }
}

?>
  #2 (permalink)  
Antiguo 08/04/2010, 12:27
Avatar de santris  
Fecha de Ingreso: agosto-2009
Ubicación: Sant Feliu de Llobregat
Mensajes: 955
Antigüedad: 14 años, 8 meses
Puntos: 66
Respuesta: Doble herencia de clases

No estoy seguro, pero creo que ese tipo de anidación no es posible porque lo que pretendes es que un hijo herede de otro hijo.

Mi pregunta es:
porqué no heredan las dos subclases del mismo padre PHPUnit_Framework_TestCase

Saludos
__________________
Tu álbum de cromos online!!
  #3 (permalink)  
Antiguo 08/04/2010, 13:45
Avatar de maturano  
Fecha de Ingreso: enero-2010
Ubicación: /home/
Mensajes: 537
Antigüedad: 14 años, 3 meses
Puntos: 36
Respuesta: Doble herencia de clases

Cambia el include() por un require().
__________________
I ♥ The Music!

Etiquetas: clases, doble, herencia
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 11:27.