Skip to content
This repository was archived by the owner on Jan 29, 2020. It is now read-only.

Fix generateShortOrCompleteClassname #75

Merged
merged 4 commits into from
Jun 30, 2016
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
1 change: 1 addition & 0 deletions src/Generator/ClassGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -1018,6 +1018,7 @@ private function validateConstantValue($value)
*/
private function generateShortOrCompleteClassname($fqnClassName)
{
$fqnClassName = ltrim($fqnClassName, '\\');
$parts = explode('\\', $fqnClassName);
$className = array_pop($parts);
$classNamespace = implode('\\', $parts);
Expand Down
17 changes: 17 additions & 0 deletions test/Generator/ClassGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1107,6 +1107,23 @@ public function testCorrectExtendNames()
$this->assertContains('class ClassName extends DateTime', $classGenerator->generate());
}

/**
* @group 75
*/
public function testCorrectExtendNamesFromGlobalNamespace()
{
$classGenerator = new ClassGenerator();
$classGenerator->setName('ClassName');
$classGenerator->setNamespaceName('SomeNamespace');
$classGenerator->setExtendedClass('\DateTime');
$this->assertContains('class ClassName extends \DateTime', $classGenerator->generate());

$classGenerator = new ClassGenerator();
$classGenerator->setName('ClassName');
$classGenerator->setExtendedClass('\DateTime');
$this->assertContains('class ClassName extends DateTime', $classGenerator->generate());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please create new test methods for these two new cases, using a name descriptive of the behavior being tested, and annotate them with @group 75.

Thanks!

}

public function testCorrectImplementNames()
{
$classGenerator = new ClassGenerator();
Expand Down