raphael 3 years ago
parent
commit
8c5caf917c

+ 13
- 0
Services/PhoenixServices.php View File

@@ -22,6 +22,19 @@ class PhoenixServices extends Services
22 22
 	private $apiService;
23 23
 	private $layoutPath = '@LogiproPhoenixJupyter/back-office/';
24 24
 
25
+	public function __construct(FormFactoryInterface $formFactory,EntityManagerInterface $manager,RouterInterface $router)
26
+	{
27
+        $this->layer = ApiLayer::getInstanceIfAvalaible();
28
+        $this->manager = $manager;
29
+        $this->router = $router;
30
+	}
31
+	
32
+
33
+	public function setLayer()
34
+	{
35
+
36
+	}
37
+
25 38
     /**
26 39
      * dit si le service jupyter est entièrement accessible
27 40
      * @return bool

+ 36
- 0
Tests/Services/ApiLayer/ApiLayerMock.php View File

@@ -0,0 +1,36 @@
1
+<?php
2
+class ApiLayerMock {
3
+	/**
4
+	 * Generates a mock object on the singleton Someclass util object.
5
+	 *
6
+	 * @param array $name
7
+	 * @return void
8
+	 */
9
+	public static function expects($name, $replace) {
10
+		// Mock the object
11
+		$mock = \PHPUnit_Framework_MockObject_Generator::getMock(
12
+			'ApiLayer',
13
+			array('getInstanceIfAvalaible'),
14
+			array(),
15
+			'',
16
+			false
17
+		);
18
+		// Replace protected self reference with mock object
19
+		$ref = new \ReflectionProperty('ApiLayer', 'self');
20
+		$ref->setAccessible(true);
21
+		$ref->setValue(null, $mock);
22
+		// Set expectations and return values
23
+		$mock
24
+			->expects(new \PHPUnit_Framework_MockObject_Matcher_InvokedCount(1))
25
+			->method('getInstanceIfAvalaible')
26
+			->with(
27
+				\PHPUnit_Framework_Assert::equalTo($name)
28
+			)
29
+			->will(new \PHPUnit_Framework_MockObject_Stub_Return($replace));
30
+	}
31
+	public static function cleanup() {
32
+		$ref = new \ReflectionProperty('ApiLayer', 'self');
33
+		$ref->setAccessible(true);
34
+		$ref->setValue(null, null);
35
+	}
36
+}

+ 58
- 0
Tests/Services/PhoenixServicesTest.php View File

@@ -0,0 +1,58 @@
1
+<?php
2
+namespace Logipro\Bundle\PhoenixJupyterBundle\Tests\Services;
3
+
4
+use Logipro\Bundle\PhoenixJupyterBundle\Entity\JupyterVirtualClassroom;
5
+use PHPUnit\Framework\TestCase;
6
+use Symfony\Component\Form\FormFactoryInterface;
7
+use Doctrine\ORM\EntityManagerInterface;
8
+use Symfony\Component\Routing\RouterInterface;
9
+use Logipro\Bundle\PhoenixJupyterBundle\Components\ApiLayer\ApiLayer;
10
+use Logipro\Bundle\PhoenixJupyterBundle\Services\PhoenixServices;
11
+
12
+class PhoenixServicesTest extends TestCase
13
+{
14
+	/**
15
+     * @expectedException Exception
16
+     */
17
+	private function mockPhoenixServices($serviceIsAvalaible = true)
18
+	{
19
+		// mock FormFactoryInterface
20
+		$formFactory = $this->getMockBuilder(FormFactoryInterface::class);
21
+
22
+		// mock EntityManagerInterface
23
+		$entityManager = $this->getMockBuilder(EntityManagerInterface::class);
24
+
25
+		// mock RouterInterface
26
+		$router = $this->getMockBuilder(RouterInterface::class);
27
+
28
+		// mock layer
29
+		$layerMock = $this->getMockBuilder(ApiLayer::class)
30
+            ->disableOriginalConstructor()
31
+            ->setMethods(['getInstanceIfAvalaible'])
32
+			->getMock();
33
+			
34
+		if ($serviceIsAvalaible)
35
+		{
36
+			$layerMock
37
+            	->method('getInstanceIfAvalaible');
38
+		}
39
+		else
40
+		{
41
+			$layerMock
42
+				->method('getInstanceIfAvalaible')
43
+				->willReturn($layerMock);
44
+		}
45
+		
46
+		return new PhoenixServices($formFactory,$entityManager,$router,$layerMock);
47
+	}
48
+
49
+	public function testStartTrainerServerWhitoutApi()
50
+	{
51
+		$service = $this->mockPhoenixServices(false);
52
+
53
+		$classRoom = new JupyterVirtualClassRoom();
54
+		$service->startTrainerServer($classRoom);
55
+
56
+	}
57
+
58
+}

+ 10
- 2
composer.json View File

@@ -5,8 +5,8 @@
5 5
     "type": "symfony-bundle",
6 6
     "authors": [
7 7
         {
8
-            "name": "Phoenix team",
9
-            "email": "infinity@tree-learning.fr"
8
+            "name": "Logipro",
9
+            "email": "contact@logipro.com"
10 10
         }
11 11
     ],
12 12
     "require": {
@@ -44,5 +44,13 @@
44 44
         "psr-4": {
45 45
             "Logipro\\Bundle\\PhoenixJupyterBundle\\": ""
46 46
         }
47
+    },
48
+    "minimum-stability": "dev",
49
+    "prefer-stable": true,
50
+    "extra": {
51
+        "branch-alias": {
52
+            "dev-master": "*"
53
+        },
54
+        "class": "Logipro\\Bundle\\PhoenixJupyterBundle\\LogiproPhoenixJupyterBundle"
47 55
     }
48 56
 }

+ 1
- 1
phpunit.xml.dist View File

@@ -11,7 +11,7 @@
11 11
          bootstrap="Tests/bootstrap.php"
12 12
 >
13 13
     <testsuites>
14
-        <testsuite name="Logipro Example Bundle Test Suite">
14
+        <testsuite name="PhoenixJupyterBundle Test Suite">
15 15
             <directory suffix="Test.php">./Tests/</directory>
16 16
         </testsuite>
17 17
     </testsuites>

Loading…
Cancel
Save