File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -58,6 +58,39 @@ public function testRegisteringASiteWithUrlAndKeyCreatesRow(): void
5858 Queue::assertPushed (CheckSiteHealth::class);
5959 }
6060
61+ public function testRegisteringASiteTwiceCreatesOnlyOneRow (): void
62+ {
63+ Queue::fake ();
64+
65+ $ mock = $ this ->getMockBuilder (Connection::class)
66+ ->disableOriginalConstructor ()
67+ ->getMock ();
68+
69+ $ mock ->method ('__call ' )->willReturn (HealthCheck::from ([
70+ "php_version " => "1.0.0 " ,
71+ "db_type " => "mysqli " ,
72+ "db_version " => "1.0.0 " ,
73+ "cms_version " => "1.0.0 " ,
74+ "server_os " => "Joomla OS 1.0.0 " ,
75+ "update_requirement_state " => true
76+ ]));
77+
78+ $ this ->app ->bind (Connection::class, fn () => $ mock );
79+
80+ $ this ->postJson (
81+ '/api/v1/register ' ,
82+ ["url " => "https://www.joomla.org " , "key " => "foobar123foobar123foobar123foobar123 " ]
83+ );
84+
85+ $ this ->postJson (
86+ '/api/v1/register ' ,
87+ ["url " => "https://www.joomla.org " , "key " => "foobar123foobar123foobar123foobar123 " ]
88+ );
89+
90+ $ count = Site::where ('url ' , 'https://www.joomla.org ' )->count ();
91+ $ this ->assertEquals (1 , $ count );
92+ }
93+
6194 public function testRegisteringASiteFailsWhenHealthCheckFails (): void
6295 {
6396 $ mock = $ this ->getMockBuilder (Connection::class)
You can’t perform that action at this time.
0 commit comments