List of commits:
Subject Hash Author Date (UTC)
test import service 09491f15db36a84ef6187017ce9db2130f4571ac Ivaylo Iliev 2017-08-28 22:03:41
use buzz aab347ba51a0b85668f2e85de4023b70e6ef778f Ivaylo Iliev 2017-08-28 21:54:25
neo entity fix setApproachAtAsString time and test 2b3a3fbf854192f55445a1e391b6cc422a7c54d7 Ivaylo Iliev 2017-08-28 20:59:35
fix controller tests 5501c12260f3a914dd8d10f01173da4fc2dece12 Ivaylo Iliev 2017-08-28 20:44:10
update readme d8e9d69d2a47397220c53a39f521cb29472a41d0 Ivaylo Iliev 2017-08-28 20:22:46
add license 995fe65147bc8a4b4de219adc8017fcfb78cac09 Ivaylo Iliev 2017-08-28 16:19:54
install phpunit e7a7933c696cf51fef8339875c0bedadc09f23d8 Ivaylo Iliev 2017-08-27 23:07:28
error checks 8b899df6bfc00397ddd8b874f8d603f5e5fc813d Ivaylo Iliev 2017-08-27 23:07:18
add some docblocks a8a8b7ca6436d8be7eae177e163f5f3846a3850e Ivaylo Iliev 2017-08-27 22:34:55
update readme 0526d98854866a43c3f72c2a28f2e7a3693d11c7 Ivaylo Iliev 2017-08-27 22:27:47
import variable days b9719a68e4a21fbf418b7e82353e48d77e5f0247 Ivaylo Iliev 2017-08-27 22:27:38
update readme e3951190baa0e679f87cf878f1ebfee910be6da2 Ivaylo Iliev 2017-08-27 22:04:18
best month 049d1757e5bab195dbd4374c0f3cba19a263e0e2 Ivaylo Iliev 2017-08-27 22:01:20
best year 9c830895cacc9ae9206901d3eabdc6b21488d718 Ivaylo Iliev 2017-08-27 21:57:46
fix docblock 20f563de5a256acde8c4a2335bf5779c670c61a0 Ivaylo Iliev 2017-08-27 21:22:50
strong typing c5314f47704760d3720f0c92bd3da9e3c7299eea Ivaylo Iliev 2017-08-27 21:15:11
change boolean to bool and add /neo/fastest?hazardous=(true|false) aa0b6fc0d2ab78404e4677863aafae1dd27bead0 Ivaylo Iliev 2017-08-27 21:07:44
fix cases 7fd7024355b538de353f032f69f8e4a1ee5f0b6b Ivaylo Iliev 2017-08-27 20:56:14
/neo/hazardous 61f9c4506a8ddf037f6cd670afdaa4f38f44829c Ivaylo Iliev 2017-08-27 20:54:40
cleanup 98f98692a290d3cd6e76b36e48be6610754640db Ivaylo Iliev 2017-08-27 20:54:24
Commit 09491f15db36a84ef6187017ce9db2130f4571ac - test import service
Author: Ivaylo Iliev
Author date (UTC): 2017-08-28 22:03
Committer name: Ivaylo Iliev
Committer date (UTC): 2017-08-28 22:03
Parent(s): aab347ba51a0b85668f2e85de4023b70e6ef778f
Signing key:
Tree: 69a02b9a6e6d1e19d0fd197fe302f26aa7581adb
File Lines added Lines deleted
src/nasa/tests/NeoBundle/Service/ImportTest.php 127 0
File src/nasa/tests/NeoBundle/Service/ImportTest.php added (mode: 100644) (index 0000000..9ca8845)
1 <?php
2
3 namespace NeoBundle\Tests\Service;
4
5 use PHPUnit\Framework\TestCase;
6
7 use Doctrine\ORM\EntityManager;
8
9 use Buzz\Browser;
10
11 use NeoBundle\Repository\NeoRepository;
12 use NeoBundle\Entity\Neo;
13 use NeoBundle\Service\Import;
14 use NeoBundle\Exception\NeoImportStructureInvalidException;
15
16 class ImportTest extends TestCase
17 {
18 public function testImportUrlGeneration()
19 {
20 $entityManagerMock = $this->createMock(EntityManager::class);
21 $browserMock = $this->createMock(Browser::class);
22 $getMock = $this->createMock(MockClass::class);
23 $neoRepositoryMock = $this->createMock(NeoRepository::class);
24 $key = 'key';
25 $url = 'key=##key##&start=##start##&end=##end##';
26 $days = 3;
27
28 $browserMock
29 ->expects($this->once())
30 ->method('get')
31 ->with($this->equalTo('key=key&start=2017-08-26&end=2017-08-28'))
32 ->willReturn($getMock);
33 $getMock->method('getContent')->willReturn('{ "near_earth_objects": [] }');
34
35 $import = new Import(
36 $entityManagerMock,
37 $browserMock,
38 $neoRepositoryMock,
39 $key, $url, $days
40 );
41
42 $import->import();
43
44 $this->assertTrue(true);
45 }
46
47 /**
48 * @expectedException NeoBundle\Exception\NeoImportStructureInvalidException
49 */
50 public function testImportResponseException()
51 {
52 $entityManagerMock = $this->createMock(EntityManager::class);
53 $browserMock = $this->createMock(Browser::class);
54 $getMock = $this->createMock(MockClass::class);
55 $neoRepositoryMock = $this->createMock(NeoRepository::class);
56 $key = 'key';
57 $url = 'key=##key##&start=##start##&end=##end##';
58 $days = 3;
59
60 $browserMock
61 ->method('get')
62 ->willReturn($getMock);
63 $getMock->method('getContent')->willReturn('{}');
64
65 $import = new Import(
66 $entityManagerMock,
67 $browserMock,
68 $neoRepositoryMock,
69 $key, $url, $days
70 );
71
72 $import->import();
73 }
74
75 public function testImportPersistance()
76 {
77 $entityManagerMock = $this->createMock(EntityManager::class);
78 $browserMock = $this->createMock(Browser::class);
79 $getMock = $this->createMock(MockClass::class);
80 $neoRepositoryMock = $this->createMock(NeoRepository::class);
81 $key = 'key';
82 $url = 'key=##key##&start=##start##&end=##end##';
83 $days = 3;
84
85 $neo = new Neo();
86 $neo
87 ->setName('name')
88 ->setReference(123456)
89 ->setSpeed(123.456)
90 ->setIsHazardous(false)
91 ->setApproachAtAsString('2017-08-27');
92
93 $browserMock
94 ->method('get')
95 ->willReturn($getMock);
96 $getMock
97 ->method('getContent')
98 ->willReturn('{ "near_earth_objects": { "2017-08-27": [ { "name": "name", "neo_reference_id": 123456, "is_potentially_hazardous_asteroid": false, "close_approach_data": [ { "close_approach_date": "2017-08-27", "relative_velocity": { "kilometers_per_hour": 123.456 } } ] } ] } }');
99 $neoRepositoryMock
100 ->expects($this->exactly(1))
101 ->method('referenceExists')
102 ->with($this->equalTo(123456))
103 ->willReturn(true);
104 $entityManagerMock
105 ->expects($this->exactly(1))
106 ->method('persist')
107 ->with($this->equalTo($neo));
108 $entityManagerMock
109 ->expects($this->exactly(1))
110 ->method('flush');
111
112 $import = new Import(
113 $entityManagerMock,
114 $browserMock,
115 $neoRepositoryMock,
116 $key, $url, $days
117 );
118
119 $import->import();
120
121 $this->assertTrue(true);
122 }
123 }
124
125 class MockClass {
126 public function getContent() {}
127 }
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/ranapat/nasa

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/ranapat/nasa

Clone this repository using git:
git clone git://git.rocketgit.com/user/ranapat/nasa

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main