Skip to content

Commit

Permalink
Reorganize tests. Add basic console commands. Add parsed flad on Lime…
Browse files Browse the repository at this point in the history
…lightWord object.
  • Loading branch information
zachleigh committed Jan 30, 2016
1 parent a541221 commit cfea270
Show file tree
Hide file tree
Showing 34 changed files with 140 additions and 551 deletions.
18 changes: 14 additions & 4 deletions limelight_console
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,20 @@ use Limelight\Limelight;

require __DIR__ . '/vendor/autoload.php';

$limelight = new Limelight();
$input = $argv[1];

$method = (isset($argv[2]) ? $argv[2] : null);

$results = $limelight->parse('ロマンティック');
$flag = (isset($argv[3]) ? $argv[3] : null);

$limelight = new Limelight();

$result = $results->all()[0];
$results = $limelight->parse($input);

var_dump($result->romanji());
if ($method && $flag) {
echo $results->$flag()->$method() . "\n";
} else if ($method) {
echo $results->$method() . "\n";
} else {
var_dump($results);
}
21 changes: 21 additions & 0 deletions src/Classes/LimelightWord.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,13 @@ class LimelightWord
*/
private $grammar;

/**
* True if word was successfully parsed.
*
* @var boolean
*/
private $parsed = false;

/**
* Results from plugins.
*
Expand Down Expand Up @@ -229,6 +236,16 @@ public function grammar()
return $this->grammar;
}

/**
* Return true if word was successfully parsed.
*
* @return bool
*/
public function parsed()
{
return $this->parsed;
}

/**
* Set $this->conversionFlag to hiragana.
*
Expand Down Expand Up @@ -348,6 +365,10 @@ private function setProperties($token, $properties)
$this->partOfSpeech = $properties['partOfSpeech'];

$this->grammar = $properties['grammar'];

if (!is_null($this->reading)) {
$this->parsed = true;
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Limelight\Tests\Classes;
namespace Limelight\tests\Acceptance;

use Limelight\Limelight;
use Limelight\Tests\TestCase;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php

namespace Limelight\Tests\Functional;
namespace Limelight\tests\Acceptance;

use Limelight\Limelight;
use Limelight\Tests\TestCase;

class FunctionalTest extends TestCase
class ParseTest extends TestCase
{
/**
* @var Limelight\Limelight
Expand All @@ -28,8 +28,6 @@ public static function setUpBeforeClass()
}

/**
* It correctly parses a simple sentence.
*
* @test
*/
public function it_parses_a_simple_sentence()
Expand Down Expand Up @@ -60,8 +58,6 @@ public function it_parses_a_simple_sentence()
}

/**
* It parses a slightly more complicated sentence.
*
* @test
*/
public function it_parses_a_slightly_more_complicated_sentence()
Expand Down Expand Up @@ -108,8 +104,6 @@ public function it_parses_a_slightly_more_complicated_sentence()
}

/**
* It parses multiple sentences.
*
* @test
*/
public function it_parses_multiple_sentences()
Expand All @@ -124,8 +118,6 @@ public function it_parses_multiple_sentences()
}

/**
* Random character input does not break it.
*
* @test
*/
public function it_handles_random_characters()
Expand All @@ -138,11 +130,9 @@ public function it_handles_random_characters()
}

/**
* It parses text.
*
* @test
*/
public function it_parses_text_1()
public function it_parses_text()
{
$results = self::$limelight->parse(self::$lib['textOne']);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Limelight\Tests\Plugins;
namespace Limelight\tests\Acceptance;

use Limelight\Limelight;
use Limelight\Tests\TestCase;
Expand All @@ -21,8 +21,6 @@ public static function setUpBeforeClass()
}

/**
* It runs plugins by default.
*
* @test
*/
public function it_runs_plugins_by_default()
Expand All @@ -39,11 +37,9 @@ public function it_runs_plugins_by_default()
}

/**
* Passing false to parse() turns plugins off.
*
* @test
*/
public function it_turns_plugins_off()
public function it_turns_plugins_off_if_false_is_passed_as_second_parameter()
{
$results = self::$limelight->parse('燃える', false);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?php

namespace Limelight\Tests\Functional;
namespace Limelight\tests\Acceptance;

use Limelight\Limelight;
use Limelight\Config\Config;
use Limelight\Tests\TestCase;

class RomanjiFunctionalTest extends TestCase
class RomanjiTest extends TestCase
{
/**
* @var Limelight\Limelight
Expand All @@ -32,8 +32,6 @@ public static function tearDownAfterClass()
}

/**
* It makes Hepburn Modified Romanji.
*
* @test
*/
public function it_makes_hepburn_modified_romanji()
Expand All @@ -46,8 +44,6 @@ public function it_makes_hepburn_modified_romanji()
}

/**
* It makes Hepburn Traditional Romanji.
*
* @test
*/
public function it_makes_hepburn_traditional_romanji()
Expand All @@ -60,8 +56,6 @@ public function it_makes_hepburn_traditional_romanji()
}

/**
* It makes Kunrei Shiki Romanji.
*
* @test
*/
public function it_makes_kunrei_shiki_romanji()
Expand All @@ -74,8 +68,6 @@ public function it_makes_kunrei_shiki_romanji()
}

/**
* It makes Nihon Shiki Romanji.
*
* @test
*/
public function it_makes_nihon_shiki_romanji()
Expand Down
Loading

0 comments on commit cfea270

Please sign in to comment.