/**
  * @covers Intacct\Functions\Common\GetList\ExpressionFilter::writeXml
  * @expectedException InvalidArgumentException
  * @expectedExceptionMessage Operator is required for an expression filter
  */
 public function testNoOperator()
 {
     $xml = new XMLWriter();
     $xml->openMemory();
     $xml->setIndent(true);
     $xml->setIndentString('    ');
     $xml->startDocument();
     $exp = new ExpressionFilter();
     $exp->setFieldName('recordno');
     //$exp->setOperator(ExpressionFilter::OPERATOR_GREATER_THAN_OR_EQUAL_TO);
     $exp->setValue(1234);
     $exp->writeXml($xml);
 }
Exemplo n.º 2
0
    /**
     * @covers Intacct\Functions\Common\GetList\LogicalFilter::writeXml
     */
    public function testDefaultConstruct()
    {
        $expected = <<<EOF
<?xml version="1.0" encoding="UTF-8"?>
<logical logical_operator="and">
    <expression>
        <field>recordno</field>
        <operator>&gt;=</operator>
        <value>1234</value>
    </expression>
    <logical logical_operator="or">
        <expression>
            <field>ownerobject</field>
            <operator>=</operator>
            <value>PROJECT</value>
        </expression>
        <expression>
            <field>ownerobject</field>
            <operator>=</operator>
            <value>CUSTOMER</value>
        </expression>
    </logical>
</logical>
EOF;
        $xml = new XMLWriter();
        $xml->openMemory();
        $xml->setIndent(true);
        $xml->setIndentString('    ');
        $xml->startDocument();
        $exp1 = new ExpressionFilter();
        $exp1->setFieldName('recordno');
        $exp1->setOperator(ExpressionFilter::OPERATOR_GREATER_THAN_OR_EQUAL_TO);
        $exp1->setValue(1234);
        $exp2 = new ExpressionFilter();
        $exp2->setFieldName('ownerobject');
        $exp2->setOperator(ExpressionFilter::OPERATOR_EQUAL_TO);
        $exp2->setValue('PROJECT');
        $exp3 = new ExpressionFilter();
        $exp3->setFieldName('ownerobject');
        $exp3->setOperator(ExpressionFilter::OPERATOR_EQUAL_TO);
        $exp3->setValue('CUSTOMER');
        $logical2 = new LogicalFilter();
        $logical2->setOperator(LogicalFilter::OPERATOR_OR);
        $logical2->setFilters([$exp2, $exp3]);
        $logical1 = new LogicalFilter();
        $logical1->setOperator(LogicalFilter::OPERATOR_AND);
        $logical1->setFilters([$exp1, $logical2]);
        $logical1->writeXml($xml);
        $this->assertXmlStringEqualsXmlString($expected, $xml->flush());
    }