public function testMergeComplexTypes()
 {
     $elements = array('r_type' => new slSchemaElement('root', $rType = new slSchemaType('r_type')), 'ra_type' => new slSchemaElement('a', $raType = new slSchemaType('ra_type')), 'rb_type' => new slSchemaElement('b', $rbType = new slSchemaType('rb_type')), 'rba_type' => new slSchemaElement('a', $rbaType = new slSchemaType('rba_type')), 'rbc_type' => new slSchemaElement('c', $rbcType = new slSchemaType('rbc_type')), 'rbcd_type' => new slSchemaElement('d', $rbcdType = new slSchemaType('rbcd_type')), 'rc_type' => new slSchemaElement('c', $rcType = new slSchemaType('g_type')), 'rca_type' => new slSchemaElement('a', $rcaType = new slSchemaType('rca_type')));
     $rType->automaton->learn(array(0, new slSchemaAutomatonNode('a', 'ra_type'), new slSchemaAutomatonNode('b', 'rb_type'), new slSchemaAutomatonNode('c', 'rc_type'), 1));
     $rType->learnAttributes(array());
     $raType->automaton->learn(array(0, 1));
     $raType->learnAttributes(array());
     $rbType->automaton->learn(array(0, new slSchemaAutomatonNode('a', 'rba_type'), new slSchemaAutomatonNode('c', 'rbc_type'), 1));
     $rbType->learnAttributes(array());
     $rbaType->automaton->learn(array(0, 1));
     $rbaType->learnAttributes(array());
     $rbcType->automaton->learn(array(0, new slSchemaAutomatonNode('d', 'rbcd_type'), 1));
     $rbcType->learnAttributes(array());
     $rbcdType->automaton->learn(array(0, 1));
     $rbcdType->learnAttributes(array());
     $rcType->automaton->learn(array(0, new slSchemaAutomatonNode('a', 'rca_type'), 1));
     $rcType->learnAttributes(array());
     $rcaType->automaton->learn(array(0, 1));
     $rcaType->learnAttributes(array());
     $merger = new slConfigurableTypeMerger(new slSchemaTypeSubsumingPatternComparator(), new slSchemaTypeEqualAttributeComparator());
     $this->assertEquals(array('r_type' => new slSchemaElement('root', $rType), 'ra_type' => new slSchemaElement('a', $raType), 'rb_type' => new slSchemaElement('b', $rbType), 'rbc_type' => new slSchemaElement('c', $rbcType), 'rc_type' => new slSchemaElement('c', $rcType)), $elements = $merger->groupTypes($elements));
     foreach ($elements as $element) {
         foreach ($element->type->automaton->getNodes() as $node) {
             $this->assertTrue($node === 0 || $node === 1 || $node instanceof slSchemaAutomatonNode);
         }
     }
     $this->assertEquals(array('rba_type' => 'ra_type', 'rbcd_type' => 'ra_type', 'rca_type' => 'ra_type'), $merger->getTypeMapping());
 }
 public function testTypeAttributesOptionalDifferent()
 {
     $t1 = new slSchemaType('t1');
     $t1->learnAttributes(array());
     $t1->learnAttributes(array('att1' => '23'));
     $t2 = new slSchemaType('t2');
     $t2->learnAttributes(array());
     $t2->learnAttributes(array('att2' => '42'));
     $comparator = $this->getComparator();
     $this->assertSame($this->results[__FUNCTION__], $comparator->compare($t1, $t2));
 }
 public function testMergeTypeAttributes6()
 {
     $t1 = new slSchemaType('t1');
     $t1->learnAttributes(array('att1' => '23', 'att2' => '23'));
     $t2 = new slSchemaType('t2');
     $t2->learnAttributes(array('att1' => '23', 'att2' => '23'));
     $t2->learnAttributes(array());
     $t1->merge($t2);
     $this->assertSame(array('att1', 'att2'), array_keys($t1->attributes));
     $this->assertTrue($t1->attributes['att1']->optional);
     $this->assertTrue($t1->attributes['att2']->optional);
 }