assertSame(1, $user->getId()); $this->assertSame('John', $user->getNom()); $this->assertSame('Doe', $user->getPrenom()); $this->assertSame('john@example.com', $user->getEmail()); $this->assertSame('hashed_password', $user->getMotDePasse()); $this->assertSame('M', $user->getSexe()); $this->assertSame(1.80, $user->getTaille()); $this->assertSame(75.0, $user->getPoids()); $this->assertInstanceOf(\DateTime::class, $user->getDateNaissance()); $this->assertSame($role, $user->getRole()); // Test setters $user->setId(2); $this->assertSame(2, $user->getId()); $user->setNom('Jane'); $this->assertSame('Jane', $user->getNom()); $user->setPrenom('Doe'); $this->assertSame('Doe', $user->getPrenom()); $user->setEmail('jane@example.com'); $this->assertSame('jane@example.com', $user->getEmail()); $user->setMotDePasse('new_hashed_password'); $this->assertSame('new_hashed_password', $user->getMotDePasse()); $user->setSexe('F'); $this->assertSame('F', $user->getSexe()); $user->setTaille(1.60); $this->assertSame(1.60, $user->getTaille()); $user->setPoids(60.0); $this->assertSame(60.0, $user->getPoids()); $newDateNaissance = new \DateTime('1995-01-01'); $user->setDateNaissance($newDateNaissance); $this->assertSame($newDateNaissance, $user->getDateNaissance()); $newRole = new Athlete(); $user->setRole($newRole); $this->assertSame($newRole, $user->getRole()); } public function testIsValidPassword() { $role = new Coach(); $user = new User( 1, 'John', 'Doe', 'john@example.com', 'test123', 'H', 1.80, 75.0, new \DateTime('1990-01-01'), $role ); // Assuming the hashed password is 'hashed_password' $this->assertTrue($user->isValidPassword('test123')); $this->assertFalse($user->isValidPassword('test1234')); } public function testToString() { $role = new Coach(); $user = new User( 1, 'John', 'Doe', 'john@example.com', 'hashed_password', 'M', 1.80, 75.0, new \DateTime('1990-01-01'), $role ); $expectedString = "Athlete [ID: 1, Nom: John, Prénom: Doe, Email: john@example.com]"; $this->assertSame($expectedString, (string)$user); } }