Smalot\PdfParser\Tests\Units\Header::testParse PHP Method

testParse() public method

public testParse ( )
    public function testParse()
    {
        $document = new \Smalot\PdfParser\Document();
        $content = '<</Type/Page/SubType/Text>>foo';
        $position = 0;
        $header = \Smalot\PdfParser\Header::parse($content, $document, $position);
        $this->assert->object($header)->isInstanceOf('\\Smalot\\PdfParser\\Header');
        $this->assert->integer($position)->isEqualTo(27);
        $this->assert->array($header->getElements())->hasSize(2);
        // No header to parse
        $this->assert->castToString($header->get('Type'))->isEqualTo('Page');
        $content = 'foo';
        $position = 0;
        $header = \Smalot\PdfParser\Header::parse($content, $document, $position);
        $this->assert->object($header)->isInstanceOf('\\Smalot\\PdfParser\\Header');
        $this->assert->integer($position)->isEqualTo(0);
        $this->assert->array($header->getElements())->hasSize(0);
        $position = 0;
        $content = "<</CreationDate(D:20100309184803+01'00')/Author(Utilisateur)/Creator(PScript5.dll Version 5.2.2)/Producer(Acrobat Distiller 7.0.5 \\(Windows\\))/ModDate(D:20100310104810+01'00')/Title(Microsoft Word - CLEMI.docx)>>";
        $header = \Smalot\PdfParser\Header::parse($content, $document, $position);
        $this->assert->integer($position)->isEqualTo(212);
        $position = 0;
        $content = '[5 0 R ] foo';
        $header = \Smalot\PdfParser\Header::parse($content, $document, $position);
        $this->assert->integer($position)->isEqualTo(8);
        $this->assert->array($header->getElements())->hasSize(1);
    }