diff --git a/tests/bootstrap.php b/tests/bootstrap.php deleted file mode 100644 index e78cc0c..0000000 --- a/tests/bootstrap.php +++ /dev/null @@ -1,9 +0,0 @@ - diff --git a/tests/modules/zvps_zpanelx_htpasswd/code/module_controllerTest.php b/tests/modules/zvps_zpanelx_htpasswd/code/module_controllerTest.php deleted file mode 100644 index b16451b..0000000 --- a/tests/modules/zvps_zpanelx_htpasswd/code/module_controllerTest.php +++ /dev/null @@ -1,313 +0,0 @@ -assertNotEmpty( $return ); - $this->assertTrue( is_array( $return ) ); - - $this->assertEquals( '1', $return[ 'x_zvps_htpasswd_file_id' ] ); - $this->assertEquals( 'domain_com/', $return[ 'x_zvps_htpasswd_file_target' ] ); - $this->assertEquals( 'Go Away', $return[ 'x_zvps_htpasswd_file_message' ] ); - $this->assertEquals( '123456789', $return[ 'x_zvps_htpasswd_file_created' ] ); - $this->assertEquals( null, $return[ 'x_zvps_htpasswd_file_deleted' ] ); - $this->assertEquals( '1', $return[ 'x_zvps_htpasswd_zpanel_user_id' ] ); - } - - /** - * @covers module_controller::fetchFileList - * @todo Implement testFetchFileList(). - */ - public function testFetchFileList() - { - $return = module_controller::fetchFileList(); - $this->assertNotEmpty( $return ); - $this->assertTrue( is_array( $return ) ); - - /** assert our two test rows have come back */ - $result1 = $return[ 0 ]; - $result2 = $return[ 1 ]; - $this->assertEquals( '1', $result1[ 'x_zvps_htpasswd_file_id' ] ); - $this->assertEquals( 'domain_com/', $result1[ 'x_zvps_htpasswd_file_target' ] ); - $this->assertEquals( 'Go Away', $result1[ 'x_zvps_htpasswd_file_message' ] ); - $this->assertEquals( '123456789', $result1[ 'x_zvps_htpasswd_file_created' ] ); - $this->assertEquals( null, $result1[ 'x_zvps_htpasswd_file_deleted' ] ); - $this->assertEquals( '1', $result1[ 'x_zvps_htpasswd_zpanel_user_id' ] ); - - $this->assertEquals( '2', $result2[ 'x_zvps_htpasswd_file_id' ] ); - $this->assertEquals( 'test_domain_com/', $result2[ 'x_zvps_htpasswd_file_target' ] ); - $this->assertEquals( 'Test', $result2[ 'x_zvps_htpasswd_file_message' ] ); - $this->assertEquals( '987654321', $result2[ 'x_zvps_htpasswd_file_created' ] ); - $this->assertEquals( null, $result2[ 'x_zvps_htpasswd_file_deleted' ] ); - $this->assertEquals( '1', $result2[ 'x_zvps_htpasswd_zpanel_user_id' ] ); - - /** assert other file row hasn't been returned */ - $this->assertArrayNotHasKey( 2, $return ); - } - - /** - * @covers module_controller::fetchUser - */ - public function testFetchUser() - { - $return = module_controller::fetchUser( '1' ); - $this->assertNotEmpty( $return ); - $this->assertTrue( is_array( $return ) ); - - /** assert correct user row has been returned */ - $this->assertEquals( '1', $return[ 'x_zvps_htpasswd_user_id' ] ); - $this->assertEquals( 'phpunit', $return[ 'x_zvps_htpasswd_user_username' ] ); - $this->assertEquals( 'cGPzE1TTrUaLU', $return[ 'x_zvps_htpasswd_user_password' ] ); - $this->assertEquals( '123456789', $return[ 'x_zvps_htpasswd_user_created' ] ); - $this->assertEquals( null, $return[ 'x_zvps_htpasswd_user_deleted' ] ); - - /** assert other user row hasn't been returned */ - $this->assertArrayNotHasKey( 1, $return ); - } - - /** - * @covers module_controller::fetchUserList - */ - public function testFetchUserList() - { - $return = module_controller::fetchUserList(); - $this->assertNotEmpty( $return ); - $this->assertTrue( is_array( $return ) ); - - /** assert our two test rows have come back */ - $result1 = $return[ 0 ]; - $result2 = $return[ 1 ]; - - $this->assertEquals( '1', $result1[ 'x_zvps_htpasswd_user_id' ] ); - $this->assertEquals( 'phpunit', $result1[ 'x_zvps_htpasswd_user_username' ] ); - $this->assertEquals( 'cGPzE1TTrUaLU', $result1[ 'x_zvps_htpasswd_user_password' ] ); - $this->assertEquals( '123456789', $result1[ 'x_zvps_htpasswd_user_created' ] ); - $this->assertEquals( null, $result1[ 'x_zvps_htpasswd_user_deleted' ] ); - - $this->assertEquals( '2', $result2[ 'x_zvps_htpasswd_user_id' ] ); - $this->assertEquals( 'phpunit1', $result2[ 'x_zvps_htpasswd_user_username' ] ); - $this->assertEquals( 'cG.CpakizS7M.', $result2[ 'x_zvps_htpasswd_user_password' ] ); - $this->assertEquals( '987654321', $result2[ 'x_zvps_htpasswd_user_created' ] ); - $this->assertEquals( null, $result2[ 'x_zvps_htpasswd_user_deleted' ] ); - - - /** assert other user row hasn't been returned */ - $this->assertArrayNotHasKey( 3, $return ); - } - - /** - * @covers module_controller::fetchFileUserList - */ - public function testFetchFileUserList() - { - $return = module_controller::fetchFileUserList( 1, 1 ); - $this->assertNotEmpty( $return ); - $this->assertTrue( is_array( $return ) ); - - /** assert file 1 has two users returned */ - $result0 = $return[ 0 ]; - $result1 = $return[ 1 ]; - - $this->assertEquals( '1', $result0[ 'x_zvps_htpasswd_file_id' ] ); - $this->assertEquals( 'domain_com/', $result0[ 'x_zvps_htpasswd_file_target' ] ); - $this->assertEquals( 'Go Away', $result0[ 'x_zvps_htpasswd_file_message' ] ); - $this->assertEquals( '123456789', $result0[ 'x_zvps_htpasswd_file_created' ] ); - $this->assertEquals( null, $result0[ 'x_zvps_htpasswd_file_deleted' ] ); - $this->assertEquals( '1', $result0[ 'x_zvps_htpasswd_zpanel_user_id' ] ); - $this->assertEquals( '1', $result0[ 'x_zvps_htpasswd_user_id' ] ); - $this->assertEquals( 'phpunit', $result0[ 'x_zvps_htpasswd_user_username' ] ); - $this->assertEquals( 'cGPzE1TTrUaLU', $result0[ 'x_zvps_htpasswd_user_password' ] ); - $this->assertEquals( '123456789', $result0[ 'x_zvps_htpasswd_user_created' ] ); - $this->assertEquals( null, $result0[ 'x_zvps_htpasswd_user_deleted' ] ); - - $this->assertEquals( '1', $result1[ 'x_zvps_htpasswd_file_id' ] ); - $this->assertEquals( 'domain_com/', $result1[ 'x_zvps_htpasswd_file_target' ] ); - $this->assertEquals( 'Go Away', $result1[ 'x_zvps_htpasswd_file_message' ] ); - $this->assertEquals( '123456789', $result1[ 'x_zvps_htpasswd_file_created' ] ); - $this->assertEquals( null, $result1[ 'x_zvps_htpasswd_file_deleted' ] ); - $this->assertEquals( '1', $result1[ 'x_zvps_htpasswd_zpanel_user_id' ] ); - $this->assertEquals( '2', $result1[ 'x_zvps_htpasswd_user_id' ] ); - $this->assertEquals( 'phpunit1', $result1[ 'x_zvps_htpasswd_user_username' ] ); - $this->assertEquals( 'cG.CpakizS7M.', $result1[ 'x_zvps_htpasswd_user_password' ] ); - $this->assertEquals( '987654321', $result1[ 'x_zvps_htpasswd_user_created' ] ); - $this->assertEquals( null, $result1[ 'x_zvps_htpasswd_user_deleted' ] ); - - /** assert file 2 has one user returned */ - $return1 = module_controller::fetchFileUserList( 2, 1 ); - $result3 = $return1[ 0 ]; - $this->assertEquals( '2', $result3[ 'x_zvps_htpasswd_file_id' ] ); - $this->assertEquals( 'test_domain_com/', $result3[ 'x_zvps_htpasswd_file_target' ] ); - $this->assertEquals( 'Test', $result3[ 'x_zvps_htpasswd_file_message' ] ); - $this->assertEquals( '987654321', $result3[ 'x_zvps_htpasswd_file_created' ] ); - $this->assertEquals( null, $result3[ 'x_zvps_htpasswd_file_deleted' ] ); - $this->assertEquals( '1', $result3[ 'x_zvps_htpasswd_zpanel_user_id' ] ); - $this->assertEquals( '1', $result3[ 'x_zvps_htpasswd_user_id' ] ); - $this->assertEquals( 'phpunit', $result3[ 'x_zvps_htpasswd_user_username' ] ); - $this->assertEquals( 'cGPzE1TTrUaLU', $result3[ 'x_zvps_htpasswd_user_password' ] ); - $this->assertEquals( '123456789', $result3[ 'x_zvps_htpasswd_user_created' ] ); - $this->assertEquals( null, $result3[ 'x_zvps_htpasswd_user_deleted' ] ); - } - - /** - * @covers module_controller::createFile - */ - public function testCreateFile( ) - { - $fileArray = array( - 'x_zvps_htpasswd_file_target' => 'another_domain_com/', - 'x_zvps_htpasswd_file_message' => 'Another', - 'x_zvps_htpasswd_file_created' => '678954321', - 'x_zvps_htpasswd_zpanel_user_id' => '2', - ); - $return = module_controller::createFile( $fileArray ); - $this->assertNotEmpty( $return ); - $this->assertGreaterThan( 3, $return ); - } - - /** - * @covers module_controller::createUser - */ - public function testCreateUser() - { - $userArray = array( - 'x_zvps_htpasswd_user_username' => 'phpunit2', - 'x_zvps_htpasswd_user_password' => 'cGCg3S01tTKxg', - 'x_zvps_htpasswd_user_created' => '678954321', - ); - $return = module_controller::createUser( $userArray ); - $this->assertNotEmpty( $return ); - $this->assertGreaterThan( 2, $return ); - } - - /** - * @covers module_controller::createMapper - */ - public function testCreateMapper() - { - $x_zvps_htpasswd_file_id = 3; - $x_zvps_htpasswd_user_id = 2; - - $return = module_controller::createMapper( $x_zvps_htpasswd_file_id, $x_zvps_htpasswd_user_id ); - $this->assertNotEmpty( $return ); - $this->assertGreaterThan( 3, $return ); - } - - /** - * @covers module_controller::updateFile - */ - public function testUpdateFile() - { - $fileArrayCreate = array( - 'x_zvps_htpasswd_file_target' => 'another_domain_com1/', - 'x_zvps_htpasswd_file_message' => 'Another1', - 'x_zvps_htpasswd_file_created' => '6789543212', - 'x_zvps_htpasswd_zpanel_user_id' => '2', - ); - $returnCreate = module_controller::createFile( $fileArrayCreate ); - $this->assertNotEmpty( $returnCreate ); - $this->assertTrue( false !== $returnCreate ); - - $fileArrayUpdate = array( - 'x_zvps_htpasswd_file_id' => $returnCreate, - 'x_zvps_htpasswd_file_target' => 'another_domain_com2/', - 'x_zvps_htpasswd_file_message' => 'Another2', - ); - - $return = module_controller::updateFile( $fileArrayUpdate ); - $this->assertNotEmpty( $return ); - $this->assertEquals( 1, $return ); - } - - /** - * @covers module_controller::updateUser - * @todo Implement testUpdateUser(). - */ - public function testUpdateUser() - { - $userCreateArray = array( - 'x_zvps_htpasswd_user_username' => 'phpunit3', - 'x_zvps_htpasswd_user_password' => 'cGCg3S01tTKxg', - 'x_zvps_htpasswd_user_created' => '678954321', - ); - $returnCreate = module_controller::createUser( $userCreateArray ); - $this->assertNotEmpty( $userCreateArray ); - $this->assertTrue( false !== $userCreateArray ); - - $userArray = array( - 'x_zvps_htpasswd_user_id' => $returnCreate, - 'x_zvps_htpasswd_user_username' => 'newuser', - 'x_zvps_htpasswd_user_password' => 'newpassword', - ); - - $return = module_controller::updateUser( $userArray ); - $this->assertNotEmpty( $return ); - $this->assertEquals( 1, $return ); - } - - /** - * @covers module_controller::deleteFile - * @todo Implement testDeleteFile(). - */ - public function testDeleteFile() - { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); - } - - /** - * @covers module_controller::deleteUser - * @todo Implement testDeleteUser(). - */ - public function testDeleteUser() - { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); - } - - /** - * @covers module_controller::deleteMapper - * @todo Implement testDeleteMapper(). - */ - public function testDeleteMapper() - { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); - } - -}