1515use App \Audit \AuditRecordType ;
1616use App \Entity \AuditRecord ;
1717use App \Entity \Package ;
18+ use App \Entity \RequireLink ;
1819use App \Entity \Version ;
1920use Doctrine \DBAL \Connection ;
2021use Doctrine \Persistence \ManagerRegistry ;
@@ -50,15 +51,14 @@ public function testVersionCreationGetsRecorded(): void
5051 ]);
5152
5253 self ::assertNotNull ($ log , 'No audit record created for new version ' );
53- self ::assertSame ('automation ' , $ log ->attributes ['actor ' ]);
5454 self ::assertSame ('composer ' , $ log ->vendor );
55- self :: assertEqualsCanonicalizing ([
56- ' name ' => ' composer/composer ' ,
57- ' actor ' => ' automation ' ,
58- ' version ' => ' 1.0.0 ' ,
59- ' source ' => ' source -ref ' ,
60- ' dist ' => ' dist -ref ' ,
61- ] , $ log -> attributes );
55+ $ attributes = $ log -> attributes ;
56+ self :: assertSame ( ' composer/composer ' , $ attributes [ ' name ' ]);
57+ self :: assertSame ( ' automation ' , $ attributes [ ' actor ' ]);
58+ self :: assertSame ( ' 1.0.0 ' , $ attributes [ ' version ' ]);
59+ self :: assertSame ( ' dist -ref ' , $ attributes [ ' metadata ' ][ ' dist ' ][ ' reference ' ]);
60+ self :: assertSame ( ' source -ref ' , $ attributes [ ' metadata ' ][ ' source ' ][ ' reference ' ]);
61+ self :: assertSame ( ' ^1.5.0 ' , $ attributes[ ' metadata ' ][ ' require ' ][ ' composer/ca-bundle ' ] );
6262 }
6363
6464 public function testVersionChangesGetRecorded (): void
@@ -103,7 +103,7 @@ public function testVersionChangesGetRecorded(): void
103103 $ logs = $ container ->get (Connection::class)->fetchAllAssociative ('SELECT * FROM audit_log ORDER BY id DESC ' );
104104 self ::assertCount (3 , $ logs );
105105
106- $ em ->remove ($ version );
106+ $ em ->getRepository (Version::class)-> remove ($ version );
107107 $ em ->flush ();
108108
109109 $ logs = $ container ->get (Connection::class)->fetchAllAssociative ('SELECT * FROM audit_log ORDER BY id DESC ' );
@@ -117,6 +117,7 @@ private function createPackageAndVersion(): Version
117117 $ em = $ container ->get (ManagerRegistry::class)->getManager ();
118118
119119 $ package = new Package ();
120+ $ package ->setName ('composer/composer ' );
120121 $ package ->setRepository ('https://github.com/composer/composer ' );
121122
122123 $ version = new Version ();
@@ -130,6 +131,13 @@ private function createPackageAndVersion(): Version
130131 $ version ->setDist (['reference ' => 'dist-ref ' , 'type ' => 'zip ' , 'url ' => 'https://example.org/dist.zip ' ]);
131132 $ version ->setSource (['reference ' => 'source-ref ' , 'type ' => 'git ' , 'url ' => 'https://example.org/dist.git ' ]);
132133
134+ $ link = new RequireLink ();
135+ $ link ->setVersion ($ version );
136+ $ link ->setPackageVersion ('^1.5.0 ' );
137+ $ link ->setPackageName ('composer/ca-bundle ' );
138+ $ version ->addRequireLink ($ link );
139+
140+ $ em ->persist ($ link );
133141 $ em ->persist ($ package );
134142 $ em ->persist ($ version );
135143 $ em ->flush ();
0 commit comments