Example #1
0
 /**
  * Writes the class to a file.
  */
 public function write()
 {
     try {
         $dir = $this->path->isDir() ? $this->path->getPathname() : $this->path->getPath();
         $path = $dir . '/' . $this->baseClass->getClassName() . $this->baseClass->getExtension();
         if (!file_exists($dir)) {
             $this->fileSystem->mkdir($dir, 0777, true);
         }
         //if (!file_exists($path)) {
         file_put_contents($path, $this->baseClass->generate());
         //}
     } catch (IOExceptionInterface $e) {
     }
 }
    /**
     * @covers ::generate
     */
    public function testGenerate()
    {
        $class = $this->baseClass->generate();
        $expectedClass = '<?php

namespace App\\Classes\\;


/**
 * Class BaseClass
 *
 * @package App\\Classes\\
 */
class BaseClass {

}
';
        $this->assertEquals($class, $expectedClass);
        $this->assertRegexp('/namespace/', $class);
        $this->assertRegexp('/\\* Class BaseClass/', $class);
    }