Exemplo n.º 1
0
 public function testSameBaseType()
 {
     // If any of the values is null, false.
     $operands = new OperandsCollection(array(null, null, null));
     $this->assertFalse($operands->sameBaseType());
     // If any of the values is null, false.
     $operands = new OperandsCollection(array(new MultipleContainer(BaseType::INTEGER), null, null));
     $this->assertFalse($operands->sameBaseType());
     // If any of the values is null, false.
     $operands = new OperandsCollection(array(new MultipleContainer(BaseType::INTEGER), null, new QtiInteger(15)));
     $this->assertFalse($operands->sameBaseType());
     // If any of the values is null (an empty container is considered null), false.
     $operands = new OperandsCollection(array(new MultipleContainer(BaseType::INTEGER), new QtiInteger(1), new QtiInteger(15)));
     $this->assertFalse($operands->sameBaseType());
     // Non-null values, all integers.
     $operands = new OperandsCollection(array(new MultipleContainer(BaseType::INTEGER, array(new QtiInteger(15))), new QtiInteger(1), new QtiInteger(15)));
     $this->assertTrue($operands->sameBaseType());
     // Non-null, exclusively records.
     $operands = new OperandsCollection(array(new RecordContainer(array('a' => new QtiInteger(15))), new RecordContainer(array('b' => new QtiInteger(22)))));
     $this->assertTrue($operands->sameBaseType());
     // Exclusively records but considered to be null because they are empty.
     $operands = new OperandsCollection(array(new RecordContainer(), new RecordContainer()));
     $this->assertFalse($operands->sameBaseType());
     // Test Exclusively boolean
     $operands = new OperandsCollection(array(new QtiBoolean(true), new QtiBoolean(false)));
     $this->assertTrue($operands->sameBaseType());
     $operands = new Operandscollection(array(new QtiBoolean(false)));
     $this->assertTrue($operands->sameBaseType());
     // Test Exclusively int
     $operands = new OperandsCollection(array(new QtiInteger(10), new QtiInteger(0)));
     $this->assertTrue($operands->sameBaseType());
     $operands = new OperandsCollection(array(new QtiInteger(0)));
     $this->assertTrue($operands->sameBaseType());
     $operands = new OperandsCollection(array(new QtiInteger(10), new OrderedContainer(BaseType::INTEGER, array(new QtiInteger(10), new QtiInteger(-1), new QtiInteger(20))), new QtiInteger(5)));
     $this->assertTrue($operands->sameBaseType());
     // - Misc
     $operands = new Operandscollection(array(new QtiInteger(0), new QtiInteger(10), new QtiFloat(10.0)));
     $this->assertFalse($operands->sameBaseType());
 }