-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Intialize Util Composer, Git and Metadata tests
- Loading branch information
Showing
5 changed files
with
206 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the PHINT package. | ||
* | ||
* (c) Jitendra Adhikari <[email protected]> | ||
* <https://github.com/adhocore> | ||
* | ||
* Licensed under MIT license. | ||
*/ | ||
|
||
namespace Ahc\Phint\Test; | ||
|
||
use Ahc\Phint\Util\Composer; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class ComposerTest extends TestCase | ||
{ | ||
public function testCreateProjectOnWithoutComposerBinary() | ||
{ | ||
$composer = new Composer; | ||
$composer->withWorkDir(sys_get_temp_dir()); | ||
$result = $composer->createProject('project-name', 'app-name'); | ||
|
||
$this->assertInstanceOf(Composer::class, $result); | ||
$this->assertFalse($result->successful()); | ||
} | ||
|
||
public function testInstallOnWithoutComposerBinary() | ||
{ | ||
$composer = new Composer; | ||
$composer->withWorkDir(sys_get_temp_dir()); | ||
$result = $composer->install(); | ||
|
||
$this->assertInstanceOf(Composer::class, $result); | ||
$this->assertFalse($result->successful()); | ||
} | ||
|
||
public function testUpdateOnWithoutComposerBinary() | ||
{ | ||
$composer = new Composer; | ||
$composer->withWorkDir(sys_get_temp_dir()); | ||
$result = $composer->update(); | ||
|
||
$this->assertInstanceOf(Composer::class, $result); | ||
$this->assertFalse($result->successful()); | ||
} | ||
|
||
public function testDumpAutoloadOnWithoutComposerBinary() | ||
{ | ||
$composer = new Composer; | ||
$composer->withWorkDir(sys_get_temp_dir()); | ||
$result = $composer->dumpAutoload(); | ||
|
||
$this->assertInstanceOf(Composer::class, $result); | ||
$this->assertFalse($result->successful()); | ||
} | ||
|
||
public function testConfigOnNullDefaultValue() | ||
{ | ||
$composer = new Composer; | ||
$composer->withWorkDir(sys_get_temp_dir()); | ||
|
||
$this->assertNull($composer->config('name')); | ||
} | ||
|
||
public function testConfigOnDefaultValue() | ||
{ | ||
copy(__DIR__ . '/../../composer.json', sys_get_temp_dir() . '/composer.json'); | ||
$composer = new Composer; | ||
$composer->withWorkDir(sys_get_temp_dir()); | ||
|
||
$this->assertSame('app/name', $composer->config('name.license', 'app/name')); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the PHINT package. | ||
* | ||
* (c) Jitendra Adhikari <[email protected]> | ||
* <https://github.com/adhocore> | ||
* | ||
* Licensed under MIT license. | ||
*/ | ||
|
||
namespace Ahc\Phint\Test; | ||
|
||
use Ahc\Phint\Util\Git; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class GitTest extends TestCase | ||
{ | ||
public function testGetConfig() | ||
{ | ||
$git = new Git; | ||
|
||
$this->assertArraySubset([ | ||
'core.repositoryformatversion' => '0', | ||
'core.filemode' => 'true', | ||
'core.bare' => 'false', | ||
'core.logallrefupdates' => 'true', | ||
'remote.origin.url' => 'https://github.com/adhocore/phint.git', | ||
'remote.origin.fetch' => '+refs/heads/master:refs/remotes/origin/master', | ||
'' => '', | ||
], $git->getConfig()); | ||
} | ||
|
||
public function testGetConfigOnSpecificKey() | ||
{ | ||
$git = new Git; | ||
|
||
$this->assertSame('false', $git->getConfig('core.bare')); | ||
} | ||
|
||
public function testInit() | ||
{ | ||
$git = new Git(); | ||
|
||
$this->assertInstanceOf(Git::class, $git->init()); | ||
$this->assertTrue($git->successful()); | ||
} | ||
|
||
public function testAddRemote() | ||
{ | ||
$git = new Git(); | ||
|
||
$this->assertInstanceOf(Git::class, $git->addRemote('adhocore', 'phint')); | ||
$this->assertFalse($git->successful()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the PHINT package. | ||
* | ||
* (c) Jitendra Adhikari <[email protected]> | ||
* <https://github.com/adhocore> | ||
* | ||
* Licensed under MIT license. | ||
*/ | ||
|
||
namespace Ahc\Phint\Test; | ||
|
||
use Ahc\Phint\Util\Metadata; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class MetadataTest extends TestCase | ||
{ | ||
public function testForClass() | ||
{ | ||
$metaData = new Metadata; | ||
$result = $metaData->forClass(Metadata::class); | ||
|
||
$this->assertArraySubset([ | ||
'namespace' => 'Ahc\Phint\Util', | ||
'classFqcn' => 'Ahc\Phint\Util\Metadata', | ||
'name' => 'Metadata', | ||
'className' => 'Metadata', | ||
'isTrait' => false, | ||
'isAbstract' => false, | ||
'isInterface' => false, | ||
'newable' => true, | ||
'title' => null, | ||
'texts' => [], | ||
'methods' => [], | ||
'name' => 'Metadata', | ||
], $result); | ||
} | ||
|
||
public function testForMethod() | ||
{ | ||
$metaData = new Metadata; | ||
$result = $metaData->forMethod(Metadata::class, 'forClass'); | ||
|
||
$this->assertSame([ | ||
'name' => 'forClass', | ||
'inClass' => 'Ahc\Phint\Util\Metadata', | ||
'isStatic' => false, | ||
'isFinal' => false, | ||
'isPublic' => true, | ||
'isAbstract' => false, | ||
'maybeMagic' => false, | ||
'title' => null, | ||
'texts' => [], | ||
'params' => [ | ||
'string $classFqcn', | ||
], | ||
'return' => 'array', | ||
], $result); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters