Page MenuHomeDevCentral

D318.diff
No OneTemporary

D318.diff

diff --git a/app/Console/Commands/PhabricatorGetProjectsMap.php b/app/Console/Commands/PhabricatorGetProjectsMap.php
--- a/app/Console/Commands/PhabricatorGetProjectsMap.php
+++ b/app/Console/Commands/PhabricatorGetProjectsMap.php
@@ -4,8 +4,7 @@
use Illuminate\Console\Command;
-use Nasqueron\Notifications\Phabricator\ProjectsMap;
-
+use ProjectsMap;
use Services;
class PhabricatorGetProjectsMap extends Command {
diff --git a/tests/Console/Commands/ConfigShowTest.php b/tests/Console/Commands/ConfigShowTest.php
--- a/tests/Console/Commands/ConfigShowTest.php
+++ b/tests/Console/Commands/ConfigShowTest.php
@@ -22,21 +22,7 @@
public function setUp () {
parent::setUp();
- $this->mockServices();
- }
-
- protected function mockServices () {
- // Inject into our container a mock of Services
- $this->servicesMock = Mockery::mock('Nasqueron\Notifications\Services\Services');
- $this->app->instance('services', $this->servicesMock);
- }
-
- protected function mockService ($gate = 'Storm') {
- $service = new Service;
- $service->gate = $gate;
- $service->door = 'Acme';
- $service->instance = "http://www.perdu.com";
- return $service;
+ $this->servicesMock = $this->mockServices();
}
public function testRegularExecute () {
diff --git a/tests/Console/Commands/PhabricatorGetProjectsMapTest.php b/tests/Console/Commands/PhabricatorGetProjectsMapTest.php
new file mode 100644
--- /dev/null
+++ b/tests/Console/Commands/PhabricatorGetProjectsMapTest.php
@@ -0,0 +1,31 @@
+<?php
+
+namespace Nasqueron\Notifications\Tests\Console\Commands;
+
+use Nasqueron\Notifications\Services\Service;
+
+class PhabricatorGetProjectsMapTest extends TestCase {
+
+ /**
+ * @var string
+ */
+ protected $class = 'Nasqueron\Notifications\Console\Commands\PhabricatorGetProjectsMap';
+
+ public function setUp () {
+ parent::setUp();
+
+ $service = $this->mockService('Phabricator');
+ $this->mockServices()
+ ->shouldReceive('getForGate')
+ ->once()
+ ->andReturn([$service]);
+
+ $this->mockPhabricatorAPIForProjectsMap();
+ }
+
+ public function testRegularExecute () {
+ $this->tester->execute(['command' => $this->command->getName()]);
+ $this->assertRegexp('/PHID.*Project name/', $this->tester->getDisplay());
+ $this->assertRegexp('/PHID-PROJ-cztcgpvqr6smnnekotq7.*Agora/', $this->tester->getDisplay());
+ }
+}
diff --git a/tests/Console/Commands/TestCase.php b/tests/Console/Commands/TestCase.php
--- a/tests/Console/Commands/TestCase.php
+++ b/tests/Console/Commands/TestCase.php
@@ -4,9 +4,11 @@
use Symfony\Component\Console\Tester\CommandTester;
+use Nasqueron\Notifications\Services\Service;
use Nasqueron\Notifications\Tests\TestCase as BaseTestCase;
use Artisan;
+use Mockery;
class TestCase extends BaseTestCase {
@@ -56,4 +58,25 @@
return self::findInstanceOf($expectedType, Artisan::all());
}
+ ///
+ /// Helper methods to mock services
+ ///
+
+ protected function mockServices () {
+ // Inject into our container a mock of Services
+ $mock = Mockery::mock('Nasqueron\Notifications\Services\Services');
+ $this->app->instance('services', $mock);
+
+ return $mock;
+ }
+
+ protected function mockService ($gate = 'Storm') {
+ $service = new Service;
+ $service->gate = $gate;
+ $service->door = 'Acme';
+ $service->instance = "http://www.perdu.com";
+
+ return $service;
+ }
+
}

File Metadata

Mime Type
text/plain
Expires
Sat, Dec 21, 04:31 (18 h, 18 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2308952
Default Alt Text
D318.diff (3 KB)

Event Timeline