public function testGenerator() { /** @var OpsWay\Test2\Solid\S $generator */ $generator = OpsWay\Test2\Solid\Factory::create('s'); for ($i = 0; $i < 20; $i++) { $generator->generate(); $this->checkIfMethodsAreUnique($generator->getGodMethodNames()); $this->checkIfTwoClassesExist($generator->getGodMethodNames()); $this->checkIfFileWithGodClassCreated($generator->getGodClassFileName()); } }
public function testChecker() { /** @var OpsWay\Test2\Solid\S $checker */ $checker = OpsWay\Test2\Solid\Factory::create('s'); $this->assertFileNotExists($checker->getGodClassFileName()); include_once $checker->getGodClassFileTmpName(); $allPhpFileNames = glob(dirname($checker->getGodClassFileName()) . '/*.php'); $this->assertEquals(2, count($allPhpFileNames), 'Incorrect file names in folder'); $actualFileNames = []; foreach ($allPhpFileNames as $fileName) { include_once $fileName; $actualFileNames[] = basename($fileName); } sort($actualFileNames); $godTmpClass = new ReflectionClass('GodTmp'); $this->checkExpectedClasses($godTmpClass->getMethods()); $this->checkMethodsInNewClasses($godTmpClass->getMethods()); }
public function testQuestion() { /** @var OpsWay\Test2\Solid\I $generator */ $generator = OpsWay\Test2\Solid\Factory::create('i'); $this->assertGreaterThan(100, strlen($generator->printQuestion())); }
<?php include 'vendor/autoload.php'; if (php_sapi_name() != 'cli') { die('This script works only in CLI mode' . PHP_EOL); } if (!isset($argv[1]) || isset($argv[2])) { die('Need one argument for running' . PHP_EOL); } try { $generator = OpsWay\Test2\Solid\Factory::create($argv[1]); $generator->generate(); echo $generator->printQuestion(); } catch (OpsWay\Test2\Solid\Exception $e) { echo $e->getMessage() . "\n"; }