Skip to content

Commit

Permalink
Fix failing Appveyor builds (fixes #261)
Browse files Browse the repository at this point in the history
  • Loading branch information
colinodell committed Nov 22, 2016
1 parent b9b9240 commit 26fc47b
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 49 deletions.
34 changes: 34 additions & 0 deletions tests/functional/AbstractBinTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

namespace League\CommonMark\Tests\Functional;

use mikehaertl\shellcommand\Command;

abstract class AbstractBinTest extends \PHPUnit_Framework_TestCase
{
/**
* @return string
*/
protected function getPathToCommonmark()
{
return realpath(__DIR__ . '/../../bin/commonmark');
}

/**
* @return Command
*/
protected function createCommand()
{
$path = $this->getPathToCommonmark();

$command = new Command();
if ($command->getIsWindows()) {
$command->setCommand('php');
$command->addArg($path);
} else {
$command->setCommand($path);
}

return $command;
}
}
32 changes: 8 additions & 24 deletions tests/functional/BinTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

use mikehaertl\shellcommand\Command;

class BinTest extends \PHPUnit_Framework_TestCase
class BinTest extends AbstractBinTest
{
/**
* Tests the behavior of not providing any Markdown input
*/
public function testNoArgsOrStdin()
{
$cmd = new Command($this->getPathToCommonmark());
$cmd = $this->createCommand();
$cmd->execute();

$this->assertEquals(1, $cmd->getExitCode());
Expand All @@ -27,7 +27,7 @@ public function testNoArgsOrStdin()
*/
public function testHelpShortFlag()
{
$cmd = new Command($this->getPathToCommonmark());
$cmd = $this->createCommand();
$cmd->addArg('-h');
$cmd->execute();

Expand All @@ -40,7 +40,7 @@ public function testHelpShortFlag()
*/
public function testHelpOption()
{
$cmd = new Command($this->getPathToCommonmark());
$cmd = $this->createCommand();
$cmd->addArg('--help');
$cmd->execute();

Expand All @@ -53,7 +53,7 @@ public function testHelpOption()
*/
public function testUnknownOption()
{
$cmd = new Command($this->getPathToCommonmark());
$cmd = $this->createCommand();
$cmd->addArg('--foo');
$cmd->execute();

Expand All @@ -69,7 +69,7 @@ public function testUnknownOption()
*/
public function testFileArgument()
{
$cmd = new Command($this->getPathToCommonmark());
$cmd = $this->createCommand();
$cmd->addArg($this->getPathToData('atx_heading.md'));
$cmd->execute();

Expand Down Expand Up @@ -100,7 +100,7 @@ public function testStdin()
*/
public function testUnsafe()
{
$cmd = new Command($this->getPathToCommonmark());
$cmd = $this->createCommand();
$cmd->addArg($this->getPathToData('safe/input.md'));
$cmd->execute();

Expand All @@ -114,7 +114,7 @@ public function testUnsafe()
*/
public function testSafe()
{
$cmd = new Command($this->getPathToCommonmark());
$cmd = $this->createCommand();
$cmd->addArg($this->getPathToData('safe/input.md'));
$cmd->addArg('--safe');
$cmd->execute();
Expand All @@ -124,22 +124,6 @@ public function testSafe()
$this->assertEquals($expectedContents, $cmd->getOutput());
}

/**
* Returns the full path the commonmark "binary"
*
* @return string
*/
protected function getPathToCommonmark()
{
$path = realpath(__DIR__ . '/../../bin/commonmark');

if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
$path = 'php ' . $path;
}

return $path;
}

/**
* Returns the full path to the test data file
*
Expand Down
32 changes: 7 additions & 25 deletions tests/functional/EmphasisTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,8 @@

namespace League\CommonMark\Tests\Functional;

use mikehaertl\shellcommand\Command;

class EmphasisTest extends \PHPUnit_Framework_TestCase
class EmphasisTest extends AbstractBinTest
{
/**
* Returns the full path the commonmark "binary"
*
* @return string
*/
protected function getPathToCommonmark()
{
$path = realpath(__DIR__ . '/../../bin/commonmark');

if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
$path = 'php ' . $path;
}

return $path;
}

/**
* Returns the full path to the test data file
*
Expand All @@ -39,7 +21,7 @@ protected function getPathToData($file)
*/
public function testEmStrong()
{
$cmd = new Command($this->getPathToCommonmark());
$cmd = $this->createCommand();
$cmd->addArg($this->getPathToData('input.md'));
$cmd->execute();

Expand All @@ -53,7 +35,7 @@ public function testEmStrong()
*/
public function testEm()
{
$cmd = new Command($this->getPathToCommonmark());
$cmd = $this->createCommand();
$cmd->addArg('--enable-strong=', 0);
$cmd->addArg($this->getPathToData('input.md'));
$cmd->execute();
Expand All @@ -68,7 +50,7 @@ public function testEm()
*/
public function testStrong()
{
$cmd = new Command($this->getPathToCommonmark());
$cmd = $this->createCommand();
$cmd->addArg('--enable-em=', 0);
$cmd->addArg($this->getPathToData('input.md'));
$cmd->execute();
Expand All @@ -83,7 +65,7 @@ public function testStrong()
*/
public function testNone()
{
$cmd = new Command($this->getPathToCommonmark());
$cmd = $this->createCommand();
$cmd->addArg('--enable-strong=', 0);
$cmd->addArg('--enable-em=', 0);
$cmd->addArg($this->getPathToData('input.md'));
Expand All @@ -99,7 +81,7 @@ public function testNone()
*/
public function testAsterisks()
{
$cmd = new Command($this->getPathToCommonmark());
$cmd = $this->createCommand();
$cmd->addArg('--use-underscore=', 0);
$cmd->addArg($this->getPathToData('input.md'));
$cmd->execute();
Expand All @@ -114,7 +96,7 @@ public function testAsterisks()
*/
public function testUnderscores()
{
$cmd = new Command($this->getPathToCommonmark());
$cmd = $this->createCommand();
$cmd->addArg('--use-asterisk=', 0);
$cmd->addArg($this->getPathToData('input.md'));
$cmd->execute();
Expand Down

0 comments on commit 26fc47b

Please sign in to comment.