Skip to content

Commit

Permalink
Merge pull request #62 from neighborhoods/BUPH-92-single-line-annotat…
Browse files Browse the repository at this point in the history
…ions-2

BUPH-92 | Multiple single line annotations
  • Loading branch information
jpmarcotte authored Jul 12, 2022
2 parents 465218d + c510e6b commit e3cd0df
Show file tree
Hide file tree
Showing 16 changed files with 207 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/V2/Actor/Template/AnnotationTokenizerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
interface AnnotationTokenizerInterface
{
public const ANNOTATION_TAG = '@neighborhoods-buphalo:annotation-processor';
public const ANNOTATION_REGEX = '/(?<=\/\*\*)(\s+' . self::ANNOTATION_TAG . ')(.*)([\s\S]*?)(?=\*\/)/';
public const ANNOTATION_REGEX = '/(?<=\/\*\*)\s+(' . self::ANNOTATION_TAG . ')\s+(\S*)([\s\S]*?)(?=\*\/)/';

public function setFabricationFile(FabricationFileInterface $FabricationFile);

Expand Down
1 change: 1 addition & 0 deletions tests/v1/DefaultAnnotationContents/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fab/*
12 changes: 12 additions & 0 deletions tests/v1/DefaultAnnotationContents/control/DefaultContents.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php
declare(strict_types=1);

namespace Neighborhoods\BuphaloTest;

class DefaultContents
{
public const TEST_STRING =<<<EOC
This is a default string
EOC;
}
37 changes: 37 additions & 0 deletions tests/v1/DefaultAnnotationContents/run_test
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/env php
<?php
declare(strict_types=1);
error_reporting(E_ALL);

$PWD = __DIR__;

// Must load autoloader before including any Annotation Processors
if (file_exists($autoloaderFilePath = dirname($PWD, 5) . '/autoload.php')) {
/** @noinspection PhpIncludeInspection */
require_once $autoloaderFilePath;
} elseif (file_exists($autoloaderFilePath = dirname($PWD, 3) . '/vendor/autoload.php')) {
/** @noinspection PhpIncludeInspection */
require_once $autoloaderFilePath;
} else {
throw new RuntimeException('Unable to find the Composer autoloader.');
}

// Include Annotation Processors for Buphalo
// None for this test

// Add exec envs
putenv("Neighborhoods_Buphalo_V1_TargetApplication_BuilderInterface__SourceDirectoryPath=$PWD/src");
putenv("Neighborhoods_Buphalo_V1_TargetApplication_BuilderInterface__FabricationDirectoryPath=$PWD/fab");
putenv("Neighborhoods_Buphalo_V1_TargetApplication_BuilderInterface__NamespacePrefix=Neighborhoods\\BuphaloTest");
putenv("Neighborhoods_Buphalo_V1_TemplateTree_Map_Builder_FactoryInterface__TemplateTreeDirectoryPaths=$PWD/templates");

// Include Buphalo
require_once($PWD . '/../../../bin/v1/buphalo.php');

// Diff the two directories
exec("diff -r $PWD/control/ $PWD/fab/", $output, $return);

if ($return) {
echo(implode(PHP_EOL, $output) . PHP_EOL);
die(1);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
actors:
<PrimaryActorName>.php:
template: PrimaryActorName.php
13 changes: 13 additions & 0 deletions tests/v1/DefaultAnnotationContents/templates/PrimaryActorName.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php
declare(strict_types=1);

namespace Neighborhoods\BuphaloTemplateTree;

class PrimaryActorName
{
public const TEST_STRING =<<<EOC
/** @neighborhoods-buphalo:annotation-processor Test Default Annotation Processor with white space in name
This is a default string
*/
EOC;
}
1 change: 1 addition & 0 deletions tests/v2/DefaultAnnotationContents/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fab/*
12 changes: 12 additions & 0 deletions tests/v2/DefaultAnnotationContents/control/DefaultContents.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php
declare(strict_types=1);

namespace Neighborhoods\BuphaloTest;

class DefaultContents
{
public const TEST_STRING =<<<EOC
This is a default string
EOC;
}
37 changes: 37 additions & 0 deletions tests/v2/DefaultAnnotationContents/run_test
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/env php
<?php
declare(strict_types=1);
error_reporting(E_ALL);

$PWD = __DIR__;

// Must load autoloader before including any Annotation Processors
if (file_exists($autoloaderFilePath = dirname($PWD, 5) . '/autoload.php')) {
/** @noinspection PhpIncludeInspection */
require_once $autoloaderFilePath;
} elseif (file_exists($autoloaderFilePath = dirname($PWD, 3) . '/vendor/autoload.php')) {
/** @noinspection PhpIncludeInspection */
require_once $autoloaderFilePath;
} else {
throw new RuntimeException('Unable to find the Composer autoloader.');
}

// Include Annotation Processors for Buphalo
// None for this test

// Add exec envs
putenv("Neighborhoods_Buphalo_V2_TargetApplication_BuilderInterface__SourceDirectoryPath=$PWD/src");
putenv("Neighborhoods_Buphalo_V2_TargetApplication_BuilderInterface__FabricationDirectoryPath=$PWD/fab");
putenv("Neighborhoods_Buphalo_V2_TargetApplication_BuilderInterface__NamespacePrefix=Neighborhoods\\BuphaloTest");
putenv("Neighborhoods_Buphalo_V2_TemplateTree_Map_Builder_FactoryInterface__TemplateTreeDirectoryPaths=$PWD/templates");

// Include Buphalo
require_once($PWD . '/../../../bin/v2/buphalo.php');

// Diff the two directories
exec("diff -r $PWD/control/ $PWD/fab/", $output, $return);

if ($return) {
echo(implode(PHP_EOL, $output) . PHP_EOL);
die(1);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
actors:
<PrimaryActorName>.php:
template: PrimaryActorName.php
13 changes: 13 additions & 0 deletions tests/v2/DefaultAnnotationContents/templates/PrimaryActorName.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php
declare(strict_types=1);

namespace Neighborhoods\BuphaloTemplateTree;

class PrimaryActorName
{
public const TEST_STRING =<<<EOC
/** @neighborhoods-buphalo:annotation-processor TestDefaultAnnotationProcessorNoWhitespaceAllowed
This is a default string
*/
EOC;
}
1 change: 1 addition & 0 deletions tests/v2/MultipleSingleLineAPs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fab/*
13 changes: 13 additions & 0 deletions tests/v2/MultipleSingleLineAPs/control/MultipleSingleLine.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php
declare(strict_types=1);

namespace Neighborhoods\BuphaloTest;

class MultipleSingleLine
{
public const TEST_STRING = '';

public const IN_BETWEEN = 'in_between';

public const SECOND = 'second';
}
37 changes: 37 additions & 0 deletions tests/v2/MultipleSingleLineAPs/run_test
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/env php
<?php
declare(strict_types=1);
error_reporting(E_ALL);

$PWD = __DIR__;

// Must load autoloader before including any Annotation Processors
if (file_exists($autoloaderFilePath = dirname($PWD, 5) . '/autoload.php')) {
/** @noinspection PhpIncludeInspection */
require_once $autoloaderFilePath;
} else if (file_exists($autoloaderFilePath = dirname($PWD, 3) . '/vendor/autoload.php')) {
/** @noinspection PhpIncludeInspection */
require_once $autoloaderFilePath;
} else {
throw new RuntimeException('Unable to find the Composer autoloader.');
}

// Include Annotation Processors for Buphalo
// None for this test

// Add exec envs
putenv("Neighborhoods_Buphalo_V2_TargetApplication_BuilderInterface__SourceDirectoryPath=$PWD/src");
putenv("Neighborhoods_Buphalo_V2_TargetApplication_BuilderInterface__FabricationDirectoryPath=$PWD/fab");
putenv("Neighborhoods_Buphalo_V2_TargetApplication_BuilderInterface__NamespacePrefix=Neighborhoods\\BuphaloTest");
putenv("Neighborhoods_Buphalo_V2_TemplateTree_Map_Builder_FactoryInterface__TemplateTreeDirectoryPaths=$PWD/templates");

// Include Buphalo
require_once($PWD . '/../../../bin/v2/buphalo.php');

// Diff the two directories
exec("diff -r $PWD/control/ $PWD/fab/", $output, $return);

if ($return) {
echo(implode(PHP_EOL, $output) . PHP_EOL);
die(1);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
actors:
<PrimaryActorName>.php:
template: PrimaryActorName.php
annotation_processors:
FirstAnnotation:
processor_fqcn: \Neighborhoods\Buphalo\V2\AnnotationProcessors\EmptyString
SecondAnnotation:
processor_fqcn: \Neighborhoods\Buphalo\V2\AnnotationProcessors\SimpleString
static_context_record:
string: "public const SECOND = 'second';"
13 changes: 13 additions & 0 deletions tests/v2/MultipleSingleLineAPs/templates/PrimaryActorName.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php
declare(strict_types=1);

namespace Neighborhoods\BuphaloTemplateTree;

class PrimaryActorName
{
public const TEST_STRING = '/** @neighborhoods-buphalo:annotation-processor FirstAnnotation */';

public const IN_BETWEEN = 'in_between';

/** @neighborhoods-buphalo:annotation-processor SecondAnnotation */
}

0 comments on commit e3cd0df

Please sign in to comment.