diff --git a/src/Gnugat/Redaktilo/Service/EditorBuilder.php b/src/Gnugat/Redaktilo/Service/EditorBuilder.php index ded97e1..e131bfa 100644 --- a/src/Gnugat/Redaktilo/Service/EditorBuilder.php +++ b/src/Gnugat/Redaktilo/Service/EditorBuilder.php @@ -83,10 +83,10 @@ protected function getSearchEngine() $engine = new SearchEngine(); $phpConverter = $this->getPhpConverter(); - $engine->registerStrategy(new PhpSearchStrategy($phpConverter)); $engine->registerStrategy(new LineRegexSearchStrategy(), 20); $engine->registerStrategy(new SameSearchStrategy(), 10); $engine->registerStrategy(new LineNumberSearchStrategy()); + $engine->registerStrategy(new PhpSearchStrategy($phpConverter)); foreach ($this->searchStrategies as $priority => $strategies) { foreach ($strategies as $strategy) { diff --git a/tests/example/BundleRegistrationTest.php b/tests/example/BundleRegistrationTest.php index 6e6291d..e5fe7b1 100644 --- a/tests/example/BundleRegistrationTest.php +++ b/tests/example/BundleRegistrationTest.php @@ -12,7 +12,6 @@ namespace example\Gnugat\Redaktilo; use Gnugat\Redaktilo\EditorFactory; -use Gnugat\Redaktilo\Search\Php\TokenBuilder; use Symfony\Component\Filesystem\Filesystem as SymfonyFilesystem; class BundleRegistrationTest extends \PHPUnit_Framework_TestCase diff --git a/tests/example/DocumentationReformattingTest.php b/tests/example/DocumentationReformattingTest.php index c4a07ee..733862a 100644 --- a/tests/example/DocumentationReformattingTest.php +++ b/tests/example/DocumentationReformattingTest.php @@ -12,8 +12,6 @@ namespace example\Gnugat\Redaktilo; use Gnugat\Redaktilo\EditorFactory; -use Gnugat\Redaktilo\Editor; -use Gnugat\Redaktilo\File; use Symfony\Component\Filesystem\Filesystem as SymfonyFilesystem; class DocumentationReformattingTest extends \PHPUnit_Framework_TestCase diff --git a/tests/example/LineJumpingTest.php b/tests/example/LineJumpingTest.php new file mode 100644 index 0000000..6c06f02 --- /dev/null +++ b/tests/example/LineJumpingTest.php @@ -0,0 +1,43 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace example\Gnugat\Redaktilo; + +use Gnugat\Redaktilo\EditorFactory; +use Gnugat\Redaktilo\Text; + +class LineJumpingTest extends \PHPUnit_Framework_TestCase +{ + private $editor; + + protected function setUp() + { + $this->editor = EditorFactory::createEditor(); + set_error_handler(function($errno, $errstr, $errfile, $errline) { + throw new \RuntimeException($errstr . " on line " . $errline . " in file " . $errfile); + }); + } + + /** + * @expectedException \RuntimeException + * @expectedExceptionMessage Gnugat\Redaktilo\Search\LineNumberSearchStrategy has been replaced by Text#setCurrentLineNumber on line 50 in file /home/gnucat/Projects/gnugat/redaktilo/src/Gnugat/Redaktilo/Search/LineNumberSearchStrategy.php + */ + public function testItCannotFindNonExistingLine() + { + $text = Text::fromArray(array('')); + $this->editor->jumpBelow($text, 0); + } + + protected function tearDown() + { + restore_error_handler(); + } +} diff --git a/tests/spec/Gnugat/Redaktilo/Service/EditorBuilderSpec.php b/tests/spec/Gnugat/Redaktilo/Service/EditorBuilderSpec.php index ac6dc97..7b748ce 100644 --- a/tests/spec/Gnugat/Redaktilo/Service/EditorBuilderSpec.php +++ b/tests/spec/Gnugat/Redaktilo/Service/EditorBuilderSpec.php @@ -26,10 +26,10 @@ function it_can_build_the_default_editor() $editor->shouldBeAnInstanceOf('Gnugat\Redaktilo\Editor'); $editor->shouldHaveSearchStrategies(array( - 'Gnugat\Redaktilo\Search\PhpSearchStrategy', - 'Gnugat\Redaktilo\Search\LineNumberSearchStrategy', 'Gnugat\Redaktilo\Search\LineRegexSearchStrategy', 'Gnugat\Redaktilo\Search\SameSearchStrategy', + 'Gnugat\Redaktilo\Search\LineNumberSearchStrategy', + 'Gnugat\Redaktilo\Search\PhpSearchStrategy', )); $editor->shouldHaveCommands(array(