PHP Classes

File: tests/ParserTest.php

Recommend this page to a friend!
  Classes of Maik Greubel   Caribu Console   tests/ParserTest.php   Download  
File: tests/ParserTest.php
Role: Unit test script
Content type: text/plain
Description: Class source
Class: Caribu Console
Read and process console shell commands
Author: By
Last change:
Date: 6 years ago
Size: 1,145 bytes
 

Contents

Class file image Download
<?php
namespace Nkey\Caribu\Console\Test;

use
Nkey\Caribu\Console\DefaultParser;

class
ParserTest extends \PHPUnit\Framework\TestCase
{

    public function
testSimple()
    {
       
$command = "printf";
       
       
$parser = new DefaultParser();
       
       
$parsedCommand = $parser->parse($command);
       
       
$this->assertEquals('printf', $parsedCommand->getCommand());
       
$this->assertEquals(0, count($parsedCommand->getArguments()));
    }

    public function
testParser()
    {
       
$command = 'printf "Hello World" "Master Windoo" fump';
       
$parser = new DefaultParser();
       
       
$parsedCommand = $parser->parse($command);
       
       
$this->assertEquals('printf', $parsedCommand->getCommand());
       
$this->assertEquals(3, count($parsedCommand->getArguments()));
       
$this->assertEquals('Hello World', $parsedCommand->getArguments()[0]);
    }
   
   
/**
     * @expectedException \Nkey\Caribu\Console\ParserException
     */
   
public function testParserException()
    {
       
$parser = new DefaultParser();
       
$parsedCommand = $parser->parse('"printf "Hello World');
    }
}