Skip to content

Commit

Permalink
Merge pull request #68 from jasonvarga/master
Browse files Browse the repository at this point in the history
Get tests running
  • Loading branch information
jackmcdade authored Jul 23, 2017
2 parents cb402d3 + b6d86ff commit 576c42e
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 24 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
vendor
.DS_Store
composer.lock
.DS_Store
8 changes: 8 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit colors="true" bootstrap="vendor/autoload.php">
<testsuites>
<testsuite name="all">
<directory suffix="Test.php">tests/</directory>
</testsuite>
</testsuites>
</phpunit>
4 changes: 1 addition & 3 deletions tests/DumpTest.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
<?php

require_once ("../Spyc.php");

class DumpTest extends PHPUnit_Framework_TestCase {

private $files_to_test = array();

public function setUp() {
$this->files_to_test = array ('../spyc.yaml', 'failing1.yaml', 'indent_1.yaml', 'quotes.yaml');
$this->files_to_test = array (__DIR__.'/../spyc.yaml', 'failing1.yaml', 'indent_1.yaml', 'quotes.yaml');
}

public function testShortSyntax() {
Expand Down
4 changes: 1 addition & 3 deletions tests/IndentTest.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
<?php

require_once ("../Spyc.php");

class IndentTest extends PHPUnit_Framework_TestCase {

protected $Y;

protected function setUp() {
$this->Y = Spyc::YAMLLoad("indent_1.yaml");
$this->Y = Spyc::YAMLLoad(__DIR__."/indent_1.yaml");
}

public function testIndent_1() {
Expand Down
2 changes: 0 additions & 2 deletions tests/LoadTest.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<?php

require_once ("../Spyc.php");

class LoadTest extends PHPUnit_Framework_TestCase {
public function testQuotes() {
$test_values = array(
Expand Down
24 changes: 11 additions & 13 deletions tests/ParseTest.php
Original file line number Diff line number Diff line change
@@ -1,33 +1,31 @@
<?php

require_once ("../Spyc.php");

class ParseTest extends PHPUnit_Framework_TestCase {

protected $yaml;

protected function setUp() {
$this->yaml = spyc_load_file('../spyc.yaml');
$this->yaml = spyc_load_file(__DIR__.'/../spyc.yaml');
}

public function testMergeHashKeys() {
$Expected = array (
array ('step' => array('instrument' => 'Lasik 2000', 'pulseEnergy' => 5.4, 'pulseDuration' => 12, 'repetition' => 1000, 'spotSize' => '1mm')),
array ('step' => array('instrument' => 'Lasik 2000', 'pulseEnergy' => 5.4, 'pulseDuration' => 12, 'repetition' => 1000, 'spotSize' => '2mm')),
);
$Actual = spyc_load_file ('indent_1.yaml');
$Actual = spyc_load_file (__DIR__.'/indent_1.yaml');
$this->assertEquals ($Expected, $Actual['steps']);
}

public function testDeathMasks() {
$Expected = array ('sad' => 2, 'magnificent' => 4);
$Actual = spyc_load_file ('indent_1.yaml');
$Actual = spyc_load_file (__DIR__.'/indent_1.yaml');
$this->assertEquals ($Expected, $Actual['death masks are']);
}

public function testDevDb() {
$Expected = array ('adapter' => 'mysql', 'host' => 'localhost', 'database' => 'rails_dev');
$Actual = spyc_load_file ('indent_1.yaml');
$Actual = spyc_load_file (__DIR__.'/indent_1.yaml');
$this->assertEquals ($Expected, $Actual['development']);
}

Expand Down Expand Up @@ -341,45 +339,45 @@ public function testSpecialCharacters() {
}

public function testAngleQuotes() {
$Quotes = Spyc::YAMLLoad('quotes.yaml');
$Quotes = Spyc::YAMLLoad(__DIR__.'/quotes.yaml');
$this->assertEquals (array ('html_tags' => array ('<br>', '<p>'), 'html_content' => array ('<p>hello world</p>', 'hello<br>world'), 'text_content' => array ('hello world')),
$Quotes);
}

public function testFailingColons() {
$Failing = Spyc::YAMLLoad('failing1.yaml');
$Failing = Spyc::YAMLLoad(__DIR__.'/failing1.yaml');
$this->assertSame (array ('MyObject' => array ('Prop1' => array ('key1:val1'))),
$Failing);
}

public function testQuotesWithComments() {
$Expected = 'bar';
$Actual = spyc_load_file ('comments.yaml');
$Actual = spyc_load_file (__DIR__.'/comments.yaml');
$this->assertEquals ($Expected, $Actual['foo']);
}

public function testArrayWithComments() {
$Expected = array ('x', 'y', 'z');
$Actual = spyc_load_file ('comments.yaml');
$Actual = spyc_load_file (__DIR__.'/comments.yaml');
$this->assertEquals ($Expected, $Actual['arr']);
}

public function testAfterArrayWithKittens() {
$Expected = 'kittens';
$Actual = spyc_load_file ('comments.yaml');
$Actual = spyc_load_file (__DIR__.'/comments.yaml');
$this->assertEquals ($Expected, $Actual['bar']);
}

// Plain characters http://www.yaml.org/spec/1.2/spec.html#id2789510
public function testKai() {
$Expected = array('-example' => 'value');
$Actual = spyc_load_file ('indent_1.yaml');
$Actual = spyc_load_file (__DIR__.'/indent_1.yaml');
$this->assertEquals ($Expected, $Actual['kai']);
}

public function testKaiList() {
$Expected = array ('-item', '-item', '-item');
$Actual = spyc_load_file ('indent_1.yaml');
$Actual = spyc_load_file (__DIR__.'/indent_1.yaml');
$this->assertEquals ($Expected, $Actual['kai_list_of_items']);
}

Expand Down
2 changes: 0 additions & 2 deletions tests/RoundTripTest.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<?php

require_once ("../Spyc.php");

function roundTrip($a) { return Spyc::YAMLLoad(Spyc::YAMLDump(array('x' => $a))); }


Expand Down

0 comments on commit 576c42e

Please sign in to comment.