arrow-left

All pages
gitbookPowered by GitBook
1 of 6

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

week11-project05-DOTNET-testing

schedule


layout: schedule schedule: monday: # - name: Build # start: 10:00 # end: 13:00 # type: project # - name: Thought of the Week # url: https://www.notion.so/foundersandcoders/Personal-Development-91fe75c7e2cc4f989954108729a2c834 # type: personal-development # start: 14:00 # end: 14:45 # - name: Build # start: 14:45 # end: 17:45 # type: project # - name: Check out # start: 17:45 # end: 18:00 tuesday: # - name: Build # start: 10:00 # end: 12:45 # type: project # - name: Role circles # start: 12:45 # end: 13:00 # url: https://foundersandcoders.notion.site/Role-circles-a2371aab24f34955a69904b87ffc1f05 # - name: Build # start: 14:00 # end: 16:00 # type: project # - name: Update READMEs # start: 16:00 # end: 16:15 # - name: Team code review # start: 16:15 # end: 17:45 # url: https://foundersandcoders.notion.site/Code-Reviews-5c3b987ed1204e46b4c738da538a758c wednesday: # - name: Web Science # start: 10:00 # end: 11:00 # type: presentation # - name: Build # start: 11:00 # end: 13:00 # type: project # - name: Build # start: 14:00 # end: 17:45 # type: project - name: Thought of the week. Healthy Working Relationships and Conflict Resolution type: thought url: https://docs.google.com/presentation/d/1phpxhz6laAZcph84D04u02QaBEeKJ_U_1VLqDNV3hjo/edit#slide=id.g25ece6437ef_0_0 start: 10:30 end: 10:45 thursday: # - name: Update READMEs # start: 10:00 # end: 10:15 # - name: Sprint Review # start: 10:15 # end: 11:45 # - start: 11:45 # end: 13:00 # name: Presentation prep # url: https://foundersandcoders.notion.site/In-House-Project-Presentation-e1936ce95a8041b9b8a93e5d4f638ff6 # - name: Project documentation # start: 15:30 # end: 16:00 friday:

hashtag
- name: Progress Log Review

hashtag
start: 10:00

hashtag
end: 11:30

hashtag
type: expert-feedback

hashtag
- name: Consolidation day

hashtag
start: 11:30

hashtag
end: 18:00

hashtag
---

Testing and deployment

hashtag
.NET

hashtag
Testing

Week of November 18th

.NET Path

This week focuses on improving code quality and testability of the library management system through dependency injection and comprehensive testing strategies.

hashtag
Core Topics

  • Dependency Injection principles in .NET

  • Unit testing with .NET testing frameworks

  • Test-driven development practices

  • Code organization and solution architecture

  • Mock databases for testing

  • Code refactoring techniques

hashtag
Project Development Focus

  • Implementing dependency injection

  • Writing comprehensive API tests

  • Refactoring code for better maintainability

hashtag
Learning Objectives

  • Understanding dependency injection concepts

  • Writing effective unit tests

  • Mocking dependencies for testing

PHP Path

This week focuses on advanced WordPress development, including custom plugin creation, theme integration, and implementing dynamic features using AJAX and APIs.

hashtag
Core Topics

  • Custom plugin development

  • WordPress hooks and filters

  • AJAX implementation in WordPress

  • External API integration

hashtag
Project Development Focus

  • Planning plugin functionality

  • Creating custom post types and taxonomies

  • Building admin interfaces

hashtag
Learning Objectives

  • Building custom WordPress plugins

  • Working with WordPress APIs

  • Implementing dynamic features with AJAX

project

hashtag
.NET

Your task this week is to continue building the project from last week but to try and add some .NET tests and more broadly to use dependency injection.

hashtag
Spike

Before you start think what are your dependencies. Which of these are tightly tied to other classes in a way that will slow development or make testing hard. If you want to replace this with dependency injection think what will the interface look like.

hashtag
Questions to consider

  • What do you want the structure of your project to look like and how should the solution file be configured to allow that?

  • Where do you want to use dependency injections in my code?

  • How will you test the functionality of the API?

hashtag
Acceptance Criteria

hashtag
Stretch criteria


hashtag
PHP

hashtag
Building the Custom Plugin and Theme Integration

Monday: Planning the Plugin Functionality

  • Objectives:

    • Define the plugin's purpose, features, and data requirements.

    • Design the database schema if needed.


Tuesday: Developing the Plugin Backend

  • Objectives:

    • Start coding the core functionality of the plugin.

    • Create custom post types and taxonomies.


Wednesday: Enhancing the Plugin with AJAX and APIs

  • Objectives:

    • Implement dynamic features using AJAX.

    • Integrate external APIs if applicable.


Thursday: Presentation Preparation and Delivery

  • Objectives:

    • Prepare and deliver a 20-minute presentation showcasing the plugin progress.

    • Continue normal development activities.


Friday: Front-End Integration and Shortcodes

  • Objectives:

    • Connect the plugin with the theme.

    • Provide user-facing features using shortcodes and widgets.

Resources

  • hashtag
    Detailed tutorial of building a project and adding DI

Creating mock objects for testing
  • Improving project structure

  • Implementing verification systems

  • Refactoring code for better testability
  • Implementing verification systems

  • Shortcode creation and usage

  • Front-end integration techniques

  • Testing and documentation

  • Implementing AJAX features
  • Integrating with external APIs

  • Creating shortcodes

  • Writing documentation

  • Creating responsive and accessible interfaces
  • Testing WordPress applications

  • Writing technical documentation

  • hashtag
    Official Microsoft Documentationarrow-up-right Microsoft's explanation of dependency injections
  • hashtag
    A Guide to NET Testingarrow-up-right Basic intro to xUnit

  • hashtag
    A Guide to ASP.NET Testingarrow-up-right Testing with a ASP.NET project although the project and set up might be a bit different from yours

  • hashtag
    Official Microsoft xUnit Guidearrow-up-right The official xUnit documentation

  • Tutorial for Dependency Injections arrow-up-right
    Where you are using interfaces what keys and methods will the interface need to look for?
    Set up version control.
  • Activities:

    1. Brainstorm Plugin Ideas:

      • Possible Ideas:

        • Event Manager with custom event posts.

        • Testimonials plugin with submission form.

        • Simple CRM for managing contacts.

    2. Outline Main Features:

      • User Interactions:

        • Front-end forms for data submission.

    3. Design Database Schema:

      • Identify Data Entities:

        • Determine what data needs to be stored.

    4. Set Up Version Control:

      • Initialize Git Repository:

        • Run git init in your plugin directory.

  • Resources:

    • Guide to Custom Post Types (Official Docs)arrow-up-right

    • Git Basics (Git-SCM)arrow-up-right

  • Build admin menus and settings pages.
  • Activities:

    1. Register Custom Post Types (CPT):

      • Add Code in Plugin File:

    2. Add Custom Taxonomies:

      • Register Taxonomy:

    3. Build Admin Menus and Settings Pages:

      • Add Menu Page:

      • Create Settings Page Content:

    4. Use the WordPress Settings API:

      • Register Settings:

      • Create Settings Form:

  • Resources:

    • How to Register Custom Taxonomies (Official Docs)arrow-up-right

    • Admin Menus and Settings API (Official Docs)arrow-up-right

  • Activities:
    1. Implement AJAX in the Plugin:

      • Enqueue Scripts:

      • Create JavaScript File plugin-ajax.js:

      • Handle AJAX Request in PHP:

    2. Integrate External APIs (Optional):

      • Choose an API:

        • For example, fetch event data from a public API like Eventbrite.

    3. Continue Integrating TypeScript:

      • Use TypeScript for AJAX Calls:

        • Convert plugin-ajax.js to TypeScript and place it in src/.

  • Resources:

    • Using AJAX in Plugins (Official Docs)arrow-up-right

    • Fetch API Basics (MDN Web Docs)arrow-up-right

  • Activities:
    1. Morning Development:

      • Integrate Plugin with Theme:

        • Connect plugin functionalities to the custom theme.

      • Enhance Plugin Features:

        • Add new features or refine existing ones.

      • Debug and Test:

        • Ensure the plugin works seamlessly within the theme.

    2. Presentation Preparation (1 hour):

      • Summarize Plugin Progress:

        • Outline key functionalities developed.

    3. Deliver the Presentation (20 minutes):

      • Presentation Content:

        • Introduce your plugin and its purpose.

    4. Afternoon Development:

      • Implement Feedback:

        • Incorporate any useful suggestions received during the presentation.

  • Resources:

    • Presentation Skills for Developersarrow-up-right

    • Demo Preparation Checklistarrow-up-right

  • Activities:
    1. Create Shortcodes to Display Plugin Data:

      • Display Events List:

      • Use Shortcode in a Page:

        • Add [events_list] to display the list of events.

    2. Design Front-End Templates for CPT:

      • Create Template Files:

        • single-event.php for individual events.

    3. Ensure Responsive Design and Accessibility:

      • Use Responsive CSS Frameworks (Optional):

        • Integrate Bootstrap or Tailwind CSS.

    4. Optimize Assets with TypeScript and CSS Preprocessors:

      • Set Up SASS (Optional):

        • Install node-sass:

  • Resources:

    • Building Shortcodes (Official Docs)arrow-up-right

    • Creating Widgets for Plugins (Official Docs)arrow-up-right

  • function create_custom_post_type() {
      $labels = array(
        'name' => __( 'Events' ),
        'singular_name' => __( 'Event' ),
        'add_new' => __( 'Add New Event' ),
        'add_new_item' => __( 'Add New Event' ),
        'edit_item' => __( 'Edit Event' ),
        'new_item' => __( 'New Event' ),
        'all_items' => __( 'All Events' ),
        'view_item' => __( 'View Event' ),
        'search_items' => __( 'Search Events' ),
        'not_found' => __( 'No events found' ),
        'not_found_in_trash' => __( 'No events found in Trash' ),
        'menu_name' => __( 'Events' )
      );
      $args = array(
        'labels' => $labels,
        'public' => true,
        'has_archive' => true,
        'supports' => array( 'title', 'editor', 'custom-fields', 'thumbnail' ),
        'rewrite' => array( 'slug' => 'events' ),
      );
      register_post_type( 'event', $args );
    }
    add_action( 'init', 'create_custom_post_type' );
    function enqueue_plugin_scripts() {
      wp_enqueue_script( 'my-plugin-ajax', plugin_dir_url( __FILE__ ) . 'js/plugin-ajax.js', array('jquery'), null, true );
      wp_localize_script( 'my-plugin-ajax', 'ajax_object', array( 'ajax_url' => admin_url( 'admin-ajax.php' ) ) );
    }
    add_action( 'wp_enqueue_scripts', 'enqueue_plugin_scripts' );
    jQuery(document).ready(function ($) {
      $("#my-button").on("click", function () {
        $.ajax({
          url: ajax_object.ajax_url,
          type: "POST",
          data: {
            action: "my_ajax_action",
            data: "test",
          },
          success: function (response) {
            alert("Response: " + response);
          },
        });
      });
    });
    function display_events_shortcode() {
      $args = array(
        'post_type' => 'event',
        'posts_per_page' => -1,
      );
      $events = new WP_Query( $args );
      $output = '<ul>';
      if ( $events->have_posts() ) {
        while ( $events->have_posts() ) {
          $events->the_post();
          $output .= '<li>' . get_the_title() . ' - ' . get_the_date() . '</li>';
        }
      } else {
        $output .= '<li>No events found.</li>';
      }
      $output .= '</ul>';
      wp_reset_postdata();
      return $output;
    }
    add_shortcode( 'events_list', 'display_events_shortcode' );
    Admin pages for data management.
  • Functionality:

    • CRUD operations (Create, Read, Update, Delete).

    • Notifications or email integration.

  • Sketch Tables and Relationships:
    • Use diagrams or tools like Draw.ioarrow-up-right.

    Create a Remote Repository:

    • Use GitHubarrow-up-right, GitLabarrow-up-right, or Bitbucketarrow-up-right.

  • Commit and Push Changes:

    • Stage files with git add ., commit with git commit -m "Initial commit", and push to remote.

  • Make API Requests:
    • Use wp_remote_get() to fetch data.

  • Display Data on Front-End:

    • Process and output the data within templates or via shortcodes.

  • Update Build Process:

    • Ensure Webpack compiles the TypeScript file into JavaScript.

  • Enqueue the Compiled Script:

    • Update the script handle and path in your plugin.

  • Prepare Presentation Materials:
    • Create slides or notes.

    • Set up a live demo.

  • Rehearse:

    • Practice delivering the presentation within the time limit.

  • Demonstrate key features and integrations.
  • Discuss challenges faced and solutions implemented.

  • Engage with the Audience:

    • Encourage questions and feedback.

  • Continue Development:
    • Proceed with pending tasks.

    archive-event.php for event archives.

  • Customize Templates:

    • Use HTML and WordPress functions to display event details.

    • Example for single-event.php:

  • Accessibility Best Practices:
    • Use semantic HTML.

    • Ensure proper contrast and font sizes.

    • Add alt attributes to images.

    Update Build Process:

    • Configure Webpack to process SCSS files.

    • Example webpack.config.js update:

  • Organize Styles:

    • Create SCSS files in src/styles/.

  • Import Styles in TypeScript:

  • Database Schema Best Practices (DigitalOcean)arrow-up-right
    Plugin Settings with the WordPress Settings API (Smashing Magazine)arrow-up-right
    Integrating APIs into WordPress (WPBeginner)arrow-up-right
    Responsive Design Basics (MDN Web Docs)arrow-up-right
    <?php get_header(); ?>
    <div class="event-content">
      <?php
      if ( have_posts() ) :
        while ( have_posts() ) : the_post();
          ?>
          <h1><?php the_title(); ?></h1>
          <div class="event-meta">
            <p>Date: <?php echo get_post_meta( get_the_ID(), 'event_date', true ); ?></p>
            <p>Location: <?php echo get_post_meta( get_the_ID(), 'event_location', true ); ?></p>
          </div>
          <div class="event-description">
            <?php the_content(); ?>
          </div>
          <?php
        endwhile;
      endif;
      ?>
    </div>
    <?php get_footer(); ?>
    module: {
      rules: [
        // ...existing rules
        {
          test: /\.scss$/,
          use: [
            'style-loader',
            'css-loader',
            'sass-loader'
          ],
        },
      ],
    },
    import "./styles/main.scss";
    function create_event_taxonomies() {
      $labels = array(
        'name' => __( 'Event Types' ),
        'singular_name' => __( 'Event Type' ),
        'search_items' =>  __( 'Search Event Types' ),
        'all_items' => __( 'All Event Types' ),
        'parent_item' => __( 'Parent Event Type' ),
        'parent_item_colon' => __( 'Parent Event Type:' ),
        'edit_item' => __( 'Edit Event Type' ),
        'update_item' => __( 'Update Event Type' ),
        'add_new_item' => __( 'Add New Event Type' ),
        'new_item_name' => __( 'New Event Type Name' ),
        'menu_name' => __( 'Event Types' ),
      );
      $args = array(
        'hierarchical' => true,
        'labels' => $labels,
        'show_ui' => true,
        'show_admin_column' => true,
        'query_var' => true,
        'rewrite' => array( 'slug' => 'event-type' ),
      );
      register_taxonomy( 'event_type', array( 'event' ), $args );
    }
    add_action( 'init', 'create_event_taxonomies', 0 );
    function my_plugin_menu() {
      add_menu_page( 'Events Management', 'Events', 'manage_options', 'events', 'events_page', 'dashicons-calendar', 6 );
    }
    add_action( 'admin_menu', 'my_plugin_menu' );
    function events_page() {
      echo '<div class="wrap"><h1>Events Management</h1>';
      // Add settings forms or data display here.
      echo '</div>';
    }
    function my_plugin_settings() {
      register_setting( 'my-plugin-settings-group', 'my_option_name' );
    }
    add_action( 'admin_init', 'my_plugin_settings' );
    function events_page() {
      ?>
      <div class="wrap">
        <h1>Events Management</h1>
        <form method="post" action="options.php">
          <?php settings_fields( 'my-plugin-settings-group' ); ?>
          <?php do_settings_sections( 'my-plugin-settings-group' ); ?>
          <table class="form-table">
            <tr valign="top">
              <th scope="row">Option Name</th>
              <td><input type="text" name="my_option_name" value="<?php echo esc_attr( get_option('my_option_name') ); ?>" /></td>
            </tr>
          </table>
          <?php submit_button(); ?>
        </form>
      </div>
      <?php
    }
    function my_ajax_action() {
      $data = $_POST['data'];
      // Process data here.
      echo 'Received: ' . $data;
      wp_die(); // All AJAX handlers should die when finished.
    }
    add_action( 'wp_ajax_my_ajax_action', 'my_ajax_action' );
    add_action( 'wp_ajax_nopriv_my_ajax_action', 'my_ajax_action' );
    import $ from "jquery";
    
    $(document).ready(function () {
      $("#my-button").on("click", function () {
        $.ajax({
          url: ajax_object.ajax_url,
          type: "POST",
          data: {
            action: "my_ajax_action",
            data: "test",
          },
          success: function (response) {
            alert("Response: " + response);
          },
        });
      });
    });
    npm install --save-dev node-sass
    $response = wp_remote_get( 'https://api.eventbriteapi.com/v3/events/search/?token=YOUR_API_TOKEN' );
    if ( is_array( $response ) && ! is_wp_error( $response ) ) {
      $body = $response['body']; // use the content
      $data = json_decode( $body );
    }