Skip to content
This repository was archived by the owner on Apr 14, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -190,14 +190,22 @@ Run a specific chunk of functional tests:

phpchunkit --num-chunks=5 --chunk=1

Run tests that match a filter:
Run test paths that match a filter:

phpchunkit --filter=BuildSandbox

Run a specific file:

phpchunkit --file=tests/Command/BuildSandboxTest.php

Run tests that contain the given content:

phpchunkit --contains="SOME_CONSTANT_NAME"

Run tests that do not contain the given content:

phpchunkit --group=functional --not-contains="SOME_CONSTANT_NAME"

Run tests for changed files:

> Note: This relies on git to know which files have changed.
Expand Down
Binary file modified phpchunkit.phar
Binary file not shown.
56 changes: 9 additions & 47 deletions src/ChunkedTests.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types = 1);

namespace PHPChunkit;

/**
Expand All @@ -20,7 +22,7 @@ class ChunkedTests
/**
* @var int
*/
private $testsPerChunk;
private $testsPerChunk = 0;

/**
* @var array
Expand All @@ -32,100 +34,60 @@ class ChunkedTests
*/
private $totalTests = 0;

/**
* @return int
*/
public function getChunk()
{
return $this->chunk;
}

/**
* @param int $chunk
*
* @return self
*/
public function setChunk($chunk)
public function setChunk(int $chunk) : self
{
$this->chunk = $chunk;

return $this;
}

/**
* @return int
*/
public function getNumChunks() : int
{
return $this->numChunks;
}

/**
* @param int $numChunks
*
* @return self
*/
public function setNumChunks($numChunks)
public function setNumChunks(int $numChunks) : self
{
$this->numChunks = $numChunks;

return $this;
}

/**
* @return int
*/
public function getTestsPerChunk()
public function getTestsPerChunk() : int
{
return $this->testsPerChunk;
}

/**
* @param int $testsPerChunk
*
* @return self
*/
public function setTestsPerChunk($testsPerChunk)
public function setTestsPerChunk(int $testsPerChunk) : self
{
$this->testsPerChunk = $testsPerChunk;

return $this;
}

/**
* @return array
*/
public function getChunks() : array
{
return $this->chunks;
}

/**
* @param array $chunks
*
* @return self
*/
public function setChunks(array $chunks)
public function setChunks(array $chunks) : self
{
$this->chunks = $chunks;

return $this;
}

/**
* @return int
*/
public function getTotalTests() : int
{
return $this->totalTests;
}

/**
* @param int $totalTests
*
* @return self
*/
public function setTotalTests($totalTests)
public function setTotalTests(int $totalTests) : self
{
$this->totalTests = $totalTests;

Expand Down
27 changes: 19 additions & 8 deletions src/Command/BuildSandbox.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
<?php

declare(strict_types = 1);

namespace PHPChunkit\Command;

use PHPChunkit\Events;
use PHPChunkit\TestRunner;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\EventDispatcher\EventDispatcher;

Expand All @@ -13,6 +17,8 @@
*/
class BuildSandbox implements CommandInterface
{
const NAME = 'sandbox';

/**
* @var TestRunner
*/
Expand All @@ -23,20 +29,25 @@ class BuildSandbox implements CommandInterface
*/
private $eventDispatcher;

/**
* @param TestRunner $testRunner
* @param EventDispatcher $eventDispatcher
*/
public function __construct(TestRunner $testRunner, EventDispatcher $eventDispatcher)
{
$this->testRunner = $testRunner;
$this->eventDispatcher = $eventDispatcher;
}

/**
* @param InputInterface $input
* @param OutputInterface $output
*/
public function getName() : string
{
return self::NAME;
}

public function configure(Command $command)
{
$command
->setDescription('Build a sandbox for a test run.')
->addOption('create-dbs', null, InputOption::VALUE_NONE, 'Create the test databases after building the sandbox.')
;
}

public function execute(InputInterface $input, OutputInterface $output)
{
$this->eventDispatcher->dispatch(Events::SANDBOX_PREPARE);
Expand Down
5 changes: 5 additions & 0 deletions src/Command/CommandInterface.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
<?php

declare(strict_types = 1);

namespace PHPChunkit\Command;

use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

interface CommandInterface
{
public function getName() : string;
public function configure(Command $command);
public function execute(InputInterface $input, OutputInterface $output);
}
26 changes: 19 additions & 7 deletions src/Command/CreateDatabases.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
<?php

declare(strict_types = 1);

namespace PHPChunkit\Command;

use PHPChunkit\Events;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\EventDispatcher\EventDispatcher;

Expand All @@ -12,23 +16,31 @@
*/
class CreateDatabases implements CommandInterface
{
const NAME = 'create-dbs';

/**
* @var EventDispatcher
*/
private $eventDispatcher;

/**
* @param EventDispatcher $eventDispatcher
*/
public function __construct(EventDispatcher $eventDispatcher)
{
$this->eventDispatcher = $eventDispatcher;
}

/**
* @param InputInterface $input
* @param OutputInterface $output
*/
public function getName() : string
{
return self::NAME;
}

public function configure(Command $command)
{
$command
->setDescription('Create the test databases.')
->addOption('sandbox', null, InputOption::VALUE_NONE, 'Prepare sandbox before creating databases.')
;
}

public function execute(InputInterface $input, OutputInterface $output)
{
$this->eventDispatcher->dispatch(Events::DATABASES_CREATE);
Expand Down
28 changes: 21 additions & 7 deletions src/Command/Generate.php
Original file line number Diff line number Diff line change
@@ -1,32 +1,46 @@
<?php

declare(strict_types = 1);

namespace PHPChunkit\Command;

use PHPChunkit\Events;
use PHPChunkit\GenerateTestClass;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\EventDispatcher\EventDispatcher;

class Generate implements CommandInterface
{
const NAME = 'generate';

/**
* @var GenerateTestClass
*/
private $generateTestClass;

/**
* @param GenerateTestClass $generateTestClass
*/
public function __construct(GenerateTestClass $generateTestClass)
{
$this->generateTestClass = $generateTestClass;
}

/**
* @param InputInterface $input
* @param OutputInterface $output
*/
public function getName() : string
{
return self::NAME;
}

public function configure(Command $command)
{
$command
->setDescription('Generate a test skeleton from a class.')
->addArgument('class', InputArgument::REQUIRED, 'Class to generate test for.')
->addOption('file', null, InputOption::VALUE_REQUIRED, 'File path to write test to.')
;
}

public function execute(InputInterface $input, OutputInterface $output)
{
$class = $input->getArgument('class');
Expand Down
Loading