Skip to content

Commit

Permalink
Add e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
reimic committed Mar 22, 2024
1 parent e613c47 commit a4c2f61
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 54 deletions.
12 changes: 7 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{
"prefer-stable": true,
"require": {
"ext-json": "*",
"php": ">=7.0"
"ext-json": "*"
},
"require-dev": {
"yoast/phpunit-polyfills": "2.0.0"
Expand All @@ -20,9 +19,9 @@
"Pimple\\": "src/pimple/pimple/src/Pimple",
"Psr\\Container\\": "src/psr/container",
"Psr\\SimpleCache\\": "src/psr/simple-cache",
"Symfony\\Component\\Process\\": "src/Symfony/process",
"Symfony\\Component\\EventDispatcher\\": "src/Symfony/event-dispatcher",
"Symfony\\Component\\filesystem\\": "src/Symfony/filesystem",
"Symfony\\Component\\Process\\": "src/symfony/process",
"Symfony\\Component\\EventDispatcher\\": "src/symfony/event-dispatcher",
"Symfony\\Component\\filesystem\\": "src/symfony/filesystem",
"Opis\\JsonSchema\\": "src/opis/json-schema/src",
"Opis\\String\\": "src/opis/string/src",
"Opis\\Uri\\": "src/opis/uri/src"
Expand All @@ -38,5 +37,8 @@
"classmap": [
"tests/"
]
},
"scripts": {
"test": [ "Composer\\Config::disableProcessTimeout", "@php ./vendor/phpunit/phpunit/phpunit --testdox" ]
}
}
6 changes: 3 additions & 3 deletions dev/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
"Pimple\\": "../src/pimple/pimple/src/Pimple",
"Psr\\Container\\": "../src/psr/container",
"Psr\\SimpleCache\\": "../src/psr/simple-cache",
"Symfony\\Component\\Process\\": "../src/Symfony/process",
"Symfony\\Component\\EventDispatcher\\": "../src/Symfony/event-dispatcher",
"Symfony\\Component\\Filesystem\\": "../src/Symfony/filesystem",
"Symfony\\Component\\Process\\": "../src/symfony/process",
"Symfony\\Component\\EventDispatcher\\": "../src/symfony/event-dispatcher",
"Symfony\\Component\\Filesystem\\": "../src/symfony/filesystem",
"Opis\\JsonSchema\\": "../src/opis/json-schema/src",
"Opis\\String\\": "../src/opis/string/src",
"Opis\\Uri\\": "../src/opis/uri/src"
Expand Down
36 changes: 10 additions & 26 deletions tests/e2e/JsonBlueprintTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@
namespace e2e;

use E2ETestCase;
use Symfony\Component\Console\Helper\ProgressBar;
use Symfony\Component\Console\Input\StringInput;
use Symfony\Component\Console\Output\ConsoleOutput;
use Symfony\Component\Console\Style\SymfonyStyle;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Filesystem\Path;
Expand All @@ -29,39 +25,27 @@ class JsonBlueprintTest extends E2ETestCase {
/**
* @before
*/
public function before() {
$this->document_root = Path::makeAbsolute( 'test', sys_get_temp_dir() );
public function before()
{
$this->document_root = Path::makeAbsolute('test', sys_get_temp_dir());

$this->subscriber = new class() implements EventSubscriberInterface {
$this->subscriber = new class implements EventSubscriberInterface {
public static function getSubscribedEvents() {
return array(
return [
ProgressEvent::class => 'onProgress',
DoneEvent::class => 'onDone',
);
DoneEvent::class => 'onDone',
];
}

protected $progress_bar;

public function __construct() {
ProgressBar::setFormatDefinition( 'custom', ' [%bar%] %current%/%max% -- %message%' );

$this->progress_bar = ( new SymfonyStyle(
new StringInput( '' ),
new ConsoleOutput()
) )->createProgressBar( 100 );
$this->progress_bar->setFormat( 'custom' );
$this->progress_bar->setMessage( 'Start' );
$this->progress_bar->start();
}
public function __construct() {}

public function onProgress( ProgressEvent $event ) {
$this->progress_bar->setMessage( $event->caption );
$this->progress_bar->setProgress( (int) $event->progress );
echo $event->caption . "" . $event->progress . "%\n";
}

public function onDone( DoneEvent $event ) {
$this->progress_bar->finish();
}
public function onDone( DoneEvent $event ) {}
};
}

Expand Down
27 changes: 7 additions & 20 deletions tests/e2e/PhpBlueprintTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,36 +36,23 @@ class PhpBlueprintTest extends E2ETestCase {
public function before() {
$this->document_root = Path::makeAbsolute( 'test', sys_get_temp_dir() );

$this->subscriber = new class() implements EventSubscriberInterface {
$this->subscriber = new class implements EventSubscriberInterface {
public static function getSubscribedEvents() {
return array(
return [
ProgressEvent::class => 'onProgress',
DoneEvent::class => 'onDone',
);
DoneEvent::class => 'onDone',
];
}

protected $progress_bar;

public function __construct() {
ProgressBar::setFormatDefinition( 'custom', ' [%bar%] %current%/%max% -- %message%' );

$this->progress_bar = ( new SymfonyStyle(
new StringInput( '' ),
new ConsoleOutput()
) )->createProgressBar( 100 );
$this->progress_bar->setFormat( 'custom' );
$this->progress_bar->setMessage( 'Start' );
$this->progress_bar->start();
}
public function __construct() {}

public function onProgress( ProgressEvent $event ) {
$this->progress_bar->setMessage( $event->caption );
$this->progress_bar->setProgress( (int) $event->progress );
echo $event->caption . "" . $event->progress . "%\n";
}

public function onDone( DoneEvent $event ) {
$this->progress_bar->finish();
}
public function onDone( DoneEvent $event ) {}
};
}

Expand Down

0 comments on commit a4c2f61

Please sign in to comment.